Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(960)

Unified Diff: content/browser/renderer_host/input/synthetic_gesture_target_base.cc

Issue 256593013: Fail if key synthesized events are off screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/input/synthetic_gesture_target_base.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..987dff4f7c84ff8a896ae5fa31aef858baf47064 100644
--- a/content/browser/renderer_host/input/synthetic_gesture_target_base.cc
+++ b/content/browser/renderer_host/input/synthetic_gesture_target_base.cc
@@ -14,6 +14,7 @@
using blink::WebInputEvent;
using blink::WebTouchEvent;
+using blink::WebTouchPoint;
using blink::WebMouseEvent;
using blink::WebMouseWheelEvent;
@@ -52,14 +53,29 @@ void SyntheticGestureTargetBase::DispatchInputEventToPlatform(
if (WebInputEvent::isTouchEventType(event.type)) {
const WebTouchEvent& web_touch =
static_cast<const WebTouchEvent&>(event);
+
+ // Check that all touch pointers are within the content bounds.
+ if (web_touch.type == WebInputEvent::TouchStart) {
+ for (unsigned i = 0; i < web_touch.touchesLength; i++)
+ CHECK(web_touch.touches[i].state != WebTouchPoint::StatePressed ||
+ PointIsWithinContents(web_touch.touches[i].position.x,
+ web_touch.touches[i].position.y))
+ << "Touch coordinates are not within content bounds on TouchStart.";
+ }
+
DispatchWebTouchEventToPlatform(web_touch, latency_info);
} else if (event.type == WebInputEvent::MouseWheel) {
const WebMouseWheelEvent& web_wheel =
static_cast<const WebMouseWheelEvent&>(event);
+ CHECK(PointIsWithinContents(web_wheel.x, web_wheel.y))
+ << "Mouse wheel position is not within content bounds.";
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 ||
+ PointIsWithinContents(web_mouse.x, web_mouse.y))
+ << "Mouse pointer is not within content bounds on MouseDown.";
DispatchWebMouseEventToPlatform(web_mouse, latency_info);
} else {
NOTREACHED();
@@ -72,7 +88,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 +121,10 @@ int SyntheticGestureTargetBase::GetTouchSlopInDips() const {
return kTouchSlopInDips;
}
+bool SyntheticGestureTargetBase::PointIsWithinContents(int x, int y) const {
+ gfx::Rect bounds = host_->GetView()->GetViewBounds();
+ bounds -= bounds.OffsetFromOrigin(); // Translate the bounds to (0,0).
+ return bounds.Contains(x, y);
+}
+
} // namespace content
« no previous file with comments | « content/browser/renderer_host/input/synthetic_gesture_target_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698