mirror of
https://github.com/servo/servo.git
synced 2025-07-30 18:50:36 +01:00
Auto merge of #15904 - sendilkumarn:image-area, r=jdm
making image element areas good at finding areas <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #15884 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15904) <!-- Reviewable:end -->
This commit is contained in:
commit
c12b17d276
5 changed files with 74 additions and 9 deletions
|
@ -429,16 +429,12 @@ impl HTMLImageElement {
|
|||
return None
|
||||
}
|
||||
|
||||
let map = self.upcast::<Node>()
|
||||
.following_siblings()
|
||||
.filter_map(Root::downcast::<HTMLMapElement>)
|
||||
.find(|n| n.upcast::<Element>().get_string_attribute(&LocalName::from("name")) == last);
|
||||
let useMapElements = document_from_node(self).upcast::<Node>()
|
||||
.traverse_preorder()
|
||||
.filter_map(Root::downcast::<HTMLMapElement>)
|
||||
.find(|n| n.upcast::<Element>().get_string_attribute(&LocalName::from("name")) == last);
|
||||
|
||||
let elements: Vec<Root<HTMLAreaElement>> = map.unwrap().upcast::<Node>()
|
||||
.children()
|
||||
.filter_map(Root::downcast::<HTMLAreaElement>)
|
||||
.collect();
|
||||
Some(elements)
|
||||
useMapElements.map(|mapElem| mapElem.get_area_elements())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::HTMLMapElementBinding;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::document::Document;
|
||||
use dom::htmlareaelement::HTMLAreaElement;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::node::Node;
|
||||
use dom_struct::dom_struct;
|
||||
|
@ -33,4 +35,11 @@ impl HTMLMapElement {
|
|||
document,
|
||||
HTMLMapElementBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn get_area_elements(&self) -> Vec<Root<HTMLAreaElement>> {
|
||||
self.upcast::<Node>()
|
||||
.traverse_preorder()
|
||||
.filter_map(Root::downcast::<HTMLAreaElement>).collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue