Auto merge of #15882 - ak1t0:clean-up-htmlimageelement, r=Ms2ger

Clean up HTMLImageElement::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 #15835 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because github issue says no tests needed.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/15882)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-03-13 07:47:56 -07:00 committed by GitHub
commit 94c344a014

View file

@ -413,25 +413,18 @@ impl HTMLImageElement {
} }
pub fn areas(&self) -> Option<Vec<Root<HTMLAreaElement>>> { pub fn areas(&self) -> Option<Vec<Root<HTMLAreaElement>>> {
let elem = self.upcast::<Element>(); let elem = self.upcast::<Element>();
let usemap_attr; let usemap_attr = match elem.get_attribute(&ns!(), &local_name!("usemap")) {
if elem.has_attribute(&LocalName::from("usemap")) { Some(attr) => attr,
usemap_attr = elem.get_string_attribute(&local_name!("usemap")); None => return None,
} else { };
return None;
let value = usemap_attr.value();
let (first, last) = value.split_at(1);
if first != "#" || last.len() == 0 {
return None
} }
let (first, last) = usemap_attr.split_at(1);
match first {
"#" => {},
_ => return None,
};
match last.len() {
0 => return None,
_ => {},
};
let map = self.upcast::<Node>() let map = self.upcast::<Node>()
.following_siblings() .following_siblings()
.filter_map(Root::downcast::<HTMLMapElement>) .filter_map(Root::downcast::<HTMLMapElement>)