Skip to content
Permalink
Browse files

Auto merge of #15892 - hgallagher1993:local_branch, r=emilio

Change while loop in HTMLImageElement::handle_event to for loop

<!-- 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 #15885

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because @Ms2ger said none were 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/15892)
<!-- Reviewable:end -->
  • Loading branch information...
bors-servo committed Mar 10, 2017
2 parents b97b0fd + 97e7c6b commit c584f3967c830a3925fbb849ab7df165a6ad0710
Showing with 9 additions and 8 deletions.
  1. +9 −8 components/script/dom/htmlimageelement.rs
@@ -658,7 +658,7 @@ impl VirtualMethods for HTMLImageElement {
}

fn handle_event(&self, event: &Event) {
if (event.type_() == atom!("click")) {
if event.type_() == atom!("click") {
let area_elements = self.areas();
let elements = if let Some(x) = area_elements {
x
@@ -673,23 +673,24 @@ impl VirtualMethods for HTMLImageElement {
return;
};

let point = Point2D::new(mouse_event.ClientX().to_f32().unwrap(), mouse_event.ClientY().to_f32().unwrap());
let point = Point2D::new(mouse_event.ClientX().to_f32().unwrap(),
mouse_event.ClientY().to_f32().unwrap());

// Walk HTMLAreaElements
let mut index = 0;
while index < elements.len() {
let shape = elements[index].get_shape_from_coords();
for element in elements {
let shape = element.get_shape_from_coords();
let p = Point2D::new(self.upcast::<Element>().GetBoundingClientRect().X() as f32,
self.upcast::<Element>().GetBoundingClientRect().Y() as f32);
self.upcast::<Element>().GetBoundingClientRect().Y() as f32);

let shp = if let Some(x) = shape {
x.absolute_coords(p)
} else {
return
};
if shp.hit_test(point) {
elements[index].activation_behavior(event, self.upcast());
element.activation_behavior(event, self.upcast());
return
}
index += 1;
}
}
}

0 comments on commit c584f39

Please sign in to comment.
You can’t perform that action at this time.