зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #15892 - Change while loop in HTMLImageElement::handle_event to for loop (from hgallagher1993:local_branch); r=emilio
<!-- 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. --> Source-Repo: https://github.com/servo/servo Source-Revision: c584f3967c830a3925fbb849ab7df165a6ad0710 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : e44a401e17bc8b15582862b686a0411debd9ef02
This commit is contained in:
Родитель
1fdf93a46a
Коммит
cb9fc26751
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче