aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-04-05 08:49:22 -0500
committerGitHub <noreply@github.com>2017-04-05 08:49:22 -0500
commitc12b17d276df5e6960358b33b9c9ff2fc414e083 (patch)
tree983a4c5ed2db38b5f6036e13b6282ec0b948fa71 /components/script/dom
parentc2f3cf020531f6fcf05b164ca699cd827114136c (diff)
parent31dafcc5f3e503655cc3e72ae10a815c47f55801 (diff)
downloadservo-c12b17d276df5e6960358b33b9c9ff2fc414e083.tar.gz
servo-c12b17d276df5e6960358b33b9c9ff2fc414e083.zip
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 -->
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/htmlimageelement.rs16
-rw-r--r--components/script/dom/htmlmapelement.rs9
2 files changed, 15 insertions, 10 deletions
diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs
index acf1d2ed9ce..7cebebade0a 100644
--- a/components/script/dom/htmlimageelement.rs
+++ b/components/script/dom/htmlimageelement.rs
@@ -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 elements: Vec<Root<HTMLAreaElement>> = map.unwrap().upcast::<Node>()
- .children()
- .filter_map(Root::downcast::<HTMLAreaElement>)
- .collect();
- Some(elements)
+ 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);
+
+ useMapElements.map(|mapElem| mapElem.get_area_elements())
}
}
diff --git a/components/script/dom/htmlmapelement.rs b/components/script/dom/htmlmapelement.rs
index c6bcb615431..9a2ae807619 100644
--- a/components/script/dom/htmlmapelement.rs
+++ b/components/script/dom/htmlmapelement.rs
@@ -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()
+ }
}
+