mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
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 -->
This commit is contained in:
commit
c584f3967c
1 changed files with 9 additions and 8 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue