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

Side by Side 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: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/input/synthetic_gesture_target_base.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" 5 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h"
6 6
7 #include "content/browser/renderer_host/render_widget_host_impl.h" 7 #include "content/browser/renderer_host/render_widget_host_impl.h"
8 #include "content/browser/renderer_host/render_widget_host_view_base.h" 8 #include "content/browser/renderer_host/render_widget_host_view_base.h"
9 #include "content/browser/renderer_host/ui_events_helper.h" 9 #include "content/browser/renderer_host/ui_events_helper.h"
10 #include "content/common/input_messages.h" 10 #include "content/common/input_messages.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 TRACE_EVENT1("input", 45 TRACE_EVENT1("input",
46 "SyntheticGestureTarget::DispatchInputEventToPlatform", 46 "SyntheticGestureTarget::DispatchInputEventToPlatform",
47 "type", WebInputEventTraits::GetName(event.type)); 47 "type", WebInputEventTraits::GetName(event.type));
48 48
49 ui::LatencyInfo latency_info; 49 ui::LatencyInfo latency_info;
50 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 50 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
51 51
52 if (WebInputEvent::isTouchEventType(event.type)) { 52 if (WebInputEvent::isTouchEventType(event.type)) {
53 const WebTouchEvent& web_touch = 53 const WebTouchEvent& web_touch =
54 static_cast<const WebTouchEvent&>(event); 54 static_cast<const WebTouchEvent&>(event);
55
56 // Check that all touch pointers are on the screen on TouchStart.
57 if (web_touch.type == WebInputEvent::TouchStart) {
58 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.
59 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.
60 web_touch.touches[i].screenPosition.y))
61 << "Touch coordinates are off screen on TouchStart.";
62 }
63
55 DispatchWebTouchEventToPlatform(web_touch, latency_info); 64 DispatchWebTouchEventToPlatform(web_touch, latency_info);
56 } else if (event.type == WebInputEvent::MouseWheel) { 65 } else if (event.type == WebInputEvent::MouseWheel) {
57 const WebMouseWheelEvent& web_wheel = 66 const WebMouseWheelEvent& web_wheel =
58 static_cast<const WebMouseWheelEvent&>(event); 67 static_cast<const WebMouseWheelEvent&>(event);
68 CHECK(PointIsOnScreen(web_wheel.x, web_wheel.y))
69 << "Mouse wheel position is off screen.";
59 DispatchWebMouseWheelEventToPlatform(web_wheel, latency_info); 70 DispatchWebMouseWheelEventToPlatform(web_wheel, latency_info);
60 } else if (WebInputEvent::isMouseEventType(event.type)) { 71 } else if (WebInputEvent::isMouseEventType(event.type)) {
61 const WebMouseEvent& web_mouse = 72 const WebMouseEvent& web_mouse =
62 static_cast<const WebMouseEvent&>(event); 73 static_cast<const WebMouseEvent&>(event);
74 CHECK(event.type != WebInputEvent::MouseDown ||
75 PointIsOnScreen(web_mouse.x, web_mouse.y))
76 << "Mouse pointer is off screen on MouseDown.";
63 DispatchWebMouseEventToPlatform(web_mouse, latency_info); 77 DispatchWebMouseEventToPlatform(web_mouse, latency_info);
64 } else { 78 } else {
65 NOTREACHED(); 79 NOTREACHED();
66 } 80 }
67 } 81 }
68 82
69 void SyntheticGestureTargetBase::DispatchWebTouchEventToPlatform( 83 void SyntheticGestureTargetBase::DispatchWebTouchEventToPlatform(
70 const blink::WebTouchEvent& web_touch, 84 const blink::WebTouchEvent& web_touch,
71 const ui::LatencyInfo& latency_info) { 85 const ui::LatencyInfo& latency_info) {
72 // We assume that platforms supporting touch have their own implementation of 86 // We assume that platforms supporting touch have their own implementation of
73 // SyntheticGestureTarget to route the events through their respective input 87 // SyntheticGestureTarget to route the events through their respective input
74 // stack. 88 // stack.
75 CHECK(false); 89 CHECK(false) << "Touch events not supported for this browser.";
76 } 90 }
77 91
78 void SyntheticGestureTargetBase::DispatchWebMouseWheelEventToPlatform( 92 void SyntheticGestureTargetBase::DispatchWebMouseWheelEventToPlatform(
79 const blink::WebMouseWheelEvent& web_wheel, 93 const blink::WebMouseWheelEvent& web_wheel,
80 const ui::LatencyInfo& latency_info) { 94 const ui::LatencyInfo& latency_info) {
81 host_->ForwardWheelEventWithLatencyInfo(web_wheel, latency_info); 95 host_->ForwardWheelEventWithLatencyInfo(web_wheel, latency_info);
82 } 96 }
83 97
84 void SyntheticGestureTargetBase::DispatchWebMouseEventToPlatform( 98 void SyntheticGestureTargetBase::DispatchWebMouseEventToPlatform(
85 const blink::WebMouseEvent& web_mouse, 99 const blink::WebMouseEvent& web_mouse,
(...skipping 12 matching lines...) Expand all
98 112
99 base::TimeDelta SyntheticGestureTargetBase::PointerAssumedStoppedTime() 113 base::TimeDelta SyntheticGestureTargetBase::PointerAssumedStoppedTime()
100 const { 114 const {
101 return base::TimeDelta::FromMilliseconds(kPointerAssumedStoppedTimeMs); 115 return base::TimeDelta::FromMilliseconds(kPointerAssumedStoppedTimeMs);
102 } 116 }
103 117
104 int SyntheticGestureTargetBase::GetTouchSlopInDips() const { 118 int SyntheticGestureTargetBase::GetTouchSlopInDips() const {
105 return kTouchSlopInDips; 119 return kTouchSlopInDips;
106 } 120 }
107 121
122 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.
123 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
124 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
125 return bounds.Contains(x, y);
126 }
127
108 } // namespace content 128 } // namespace content
OLDNEW
« 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