Adopt Rect::contains in compositor hit-testing

This does make hit-testing inclusive in the right/bottom edges, whereas it
was only inclusive in the top/left edges before.
This commit is contained in:
Cameron Zwarich 2014-07-07 10:45:48 -07:00
parent 797663c43e
commit 91c7acd4c4

View file

@ -230,12 +230,11 @@ impl CompositorData {
}
Some(rect) => {
let rect: TypedRect<PagePx, f32> = Rect::from_untyped(&rect);
if cursor.x >= rect.origin.x && cursor.x < rect.origin.x + rect.size.width
&& cursor.y >= rect.origin.y && cursor.y < rect.origin.y + rect.size.height
&& CompositorData::handle_scroll_event(child.clone(),
delta,
cursor - rect.origin,
rect.size) {
if rect.contains(&cursor) &&
CompositorData::handle_scroll_event(child.clone(),
delta,
cursor - rect.origin,
rect.size) {
return true
}
}
@ -312,8 +311,7 @@ impl CompositorData {
}
Some(rect) => {
let rect: TypedRect<PagePx, f32> = Rect::from_untyped(&rect);
if cursor.x >= rect.origin.x && cursor.x < rect.origin.x + rect.size.width
&& cursor.y >= rect.origin.y && cursor.y < rect.origin.y + rect.size.height {
if rect.contains(&cursor) {
CompositorData::send_mouse_event(child.clone(), event, cursor - rect.origin);
return;
}