Index: content/browser/renderer_host/input/synthetic_gesture_target_base.cc |
diff --git a/content/browser/renderer_host/input/synthetic_gesture_target_base.cc b/content/browser/renderer_host/input/synthetic_gesture_target_base.cc |
index 778afb0d4f5d044a178968648889739e55715342..b10660c33ca385d7ab33a795629700149704ef7d 100644 |
--- a/content/browser/renderer_host/input/synthetic_gesture_target_base.cc |
+++ b/content/browser/renderer_host/input/synthetic_gesture_target_base.cc |
@@ -52,14 +52,28 @@ void SyntheticGestureTargetBase::DispatchInputEventToPlatform( |
if (WebInputEvent::isTouchEventType(event.type)) { |
const WebTouchEvent& web_touch = |
static_cast<const WebTouchEvent&>(event); |
+ |
+ // Check that all touch pointers are on the screen on TouchStart. |
+ if (web_touch.type == WebInputEvent::TouchStart) { |
+ for (unsigned i = 0; i < web_touch.touchesLength; i++) |
jdduke (slow)
2014/04/28 16:30:23
It's probably only necessary to check touch positi
Dominik Grewe
2014/04/28 17:32:24
Done.
|
+ CHECK(PointIsOnScreen(web_touch.touches[i].screenPosition.x, |
Rick Byers
2014/04/28 17:01:22
The fact that you're using screenPosition (instead
Dominik Grewe
2014/04/28 17:32:24
Done.
|
+ web_touch.touches[i].screenPosition.y)) |
+ << "Touch coordinates are off screen on TouchStart."; |
+ } |
+ |
DispatchWebTouchEventToPlatform(web_touch, latency_info); |
} else if (event.type == WebInputEvent::MouseWheel) { |
const WebMouseWheelEvent& web_wheel = |
static_cast<const WebMouseWheelEvent&>(event); |
+ CHECK(PointIsOnScreen(web_wheel.x, web_wheel.y)) |
+ << "Mouse wheel position is off screen."; |
DispatchWebMouseWheelEventToPlatform(web_wheel, latency_info); |
} else if (WebInputEvent::isMouseEventType(event.type)) { |
const WebMouseEvent& web_mouse = |
static_cast<const WebMouseEvent&>(event); |
+ CHECK(event.type != WebInputEvent::MouseDown || |
+ PointIsOnScreen(web_mouse.x, web_mouse.y)) |
+ << "Mouse pointer is off screen on MouseDown."; |
DispatchWebMouseEventToPlatform(web_mouse, latency_info); |
} else { |
NOTREACHED(); |
@@ -72,7 +86,7 @@ void SyntheticGestureTargetBase::DispatchWebTouchEventToPlatform( |
// We assume that platforms supporting touch have their own implementation of |
// SyntheticGestureTarget to route the events through their respective input |
// stack. |
- CHECK(false); |
+ CHECK(false) << "Touch events not supported for this browser."; |
} |
void SyntheticGestureTargetBase::DispatchWebMouseWheelEventToPlatform( |
@@ -105,4 +119,10 @@ int SyntheticGestureTargetBase::GetTouchSlopInDips() const { |
return kTouchSlopInDips; |
} |
+bool SyntheticGestureTargetBase::PointIsOnScreen(int x, int y) const { |
Rick Byers
2014/04/28 17:01:22
You mean "within contents" not "on screen" I think
Dominik Grewe
2014/04/28 17:32:24
Done.
|
+ gfx::Rect bounds = host_->GetView()->GetViewBounds(); |
Rick Byers
2014/04/28 17:01:22
GetViewBounds says it's relative to the parent, I
jdduke (slow)
2014/04/28 17:16:09
Is GetViewBounds().size() equivalent to GetContain
|
+ bounds -= bounds.OffsetFromOrigin(); // Translate the bounds to (0,0). |
jdduke (slow)
2014/04/28 16:30:23
Are the bounds in device pixels or DIPs?
Dominik Grewe
2014/04/28 16:38:46
Good question... In the comments it says "screen c
|
+ return bounds.Contains(x, y); |
+} |
+ |
} // namespace content |