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

Side by Side Diff: content/renderer/render_widget_fullscreen_pepper.cc

Issue 12093110: pepper: Make sure gesture events are mapped to touch events correctly in fullscreen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 10 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 | « no previous file | 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/render_widget_fullscreen_pepper.h" 5 #include "content/renderer/render_widget_fullscreen_pepper.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 private: 58 private:
59 // MouseLockDispatcher implementation. 59 // MouseLockDispatcher implementation.
60 virtual void SendLockMouseRequest(bool unlocked_by_target) OVERRIDE; 60 virtual void SendLockMouseRequest(bool unlocked_by_target) OVERRIDE;
61 virtual void SendUnlockMouseRequest() OVERRIDE; 61 virtual void SendUnlockMouseRequest() OVERRIDE;
62 62
63 RenderWidgetFullscreenPepper* widget_; 63 RenderWidgetFullscreenPepper* widget_;
64 64
65 DISALLOW_COPY_AND_ASSIGN(FullscreenMouseLockDispatcher); 65 DISALLOW_COPY_AND_ASSIGN(FullscreenMouseLockDispatcher);
66 }; 66 };
67 67
68 WebMouseEvent WebMouseEventFromGestureEvent(const WebGestureEvent& gesture) {
69 WebMouseEvent mouse;
70
71 switch (gesture.type) {
72 case WebInputEvent::GestureScrollBegin:
73 mouse.type = WebInputEvent::MouseDown;
74 break;
75
76 case WebInputEvent::GestureScrollUpdate:
77 mouse.type = WebInputEvent::MouseMove;
78 break;
79
80 case WebInputEvent::GestureFlingStart:
81 if (gesture.sourceDevice == WebGestureEvent::Touchscreen) {
82 // A scroll gesture on the touchscreen may end with a GestureScrollEnd
83 // when there is no velocity, or a GestureFlingStart when it has a
84 // velocity. In both cases, it should end the drag that was initiated by
85 // the GestureScrollBegin (and subsequent GestureScrollUpdate) events.
86 mouse.type = WebInputEvent::MouseUp;
87 break;
88 } else {
89 return mouse;
90 }
91 case WebInputEvent::GestureScrollEnd:
92 mouse.type = WebInputEvent::MouseUp;
93 break;
94
95 default:
96 break;
97 }
98
99 if (mouse.type == WebInputEvent::Undefined)
100 return mouse;
101
102 mouse.timeStampSeconds = gesture.timeStampSeconds;
103 mouse.modifiers = gesture.modifiers | WebInputEvent::LeftButtonDown;
104 mouse.button = WebMouseEvent::ButtonLeft;
105 mouse.clickCount = (mouse.type == WebInputEvent::MouseDown ||
106 mouse.type == WebInputEvent::MouseUp);
107
108 mouse.x = gesture.x;
109 mouse.y = gesture.y;
110 mouse.windowX = gesture.globalX;
111 mouse.windowY = gesture.globalY;
112 mouse.globalX = gesture.globalX;
113 mouse.globalY = gesture.globalY;
114
115 return mouse;
116 }
117
68 FullscreenMouseLockDispatcher::FullscreenMouseLockDispatcher( 118 FullscreenMouseLockDispatcher::FullscreenMouseLockDispatcher(
69 RenderWidgetFullscreenPepper* widget) : widget_(widget) { 119 RenderWidgetFullscreenPepper* widget) : widget_(widget) {
70 } 120 }
71 121
72 FullscreenMouseLockDispatcher::~FullscreenMouseLockDispatcher() { 122 FullscreenMouseLockDispatcher::~FullscreenMouseLockDispatcher() {
73 } 123 }
74 124
75 void FullscreenMouseLockDispatcher::SendLockMouseRequest( 125 void FullscreenMouseLockDispatcher::SendLockMouseRequest(
76 bool unlocked_by_target) { 126 bool unlocked_by_target) {
77 widget_->Send(new ViewHostMsg_LockMouse(widget_->routing_id(), false, 127 widget_->Send(new ViewHostMsg_LockMouse(widget_->routing_id(), false,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 NOTIMPLEMENTED(); 195 NOTIMPLEMENTED();
146 } 196 }
147 197
148 virtual bool handleInputEvent(const WebInputEvent& event) { 198 virtual bool handleInputEvent(const WebInputEvent& event) {
149 if (!widget_->plugin()) 199 if (!widget_->plugin())
150 return false; 200 return false;
151 201
152 // This cursor info is ignored, we always set the cursor directly from 202 // This cursor info is ignored, we always set the cursor directly from
153 // RenderWidgetFullscreenPepper::DidChangeCursor. 203 // RenderWidgetFullscreenPepper::DidChangeCursor.
154 WebCursorInfo cursor; 204 WebCursorInfo cursor;
155 bool result = widget_->plugin()->HandleInputEvent(event, &cursor);
156 205
157 // For normal web pages, WebCore::EventHandler converts selected 206 // Pepper plugins do not accept gesture events. So do not send the gesture
158 // gesture events into mouse and wheel events. We don't have a WebView 207 // events directly to the plugin. Instead, try to convert them to equivalent
159 // so do this translation here. 208 // mouse events, and then send to the plugin.
160 if (!result && WebInputEvent::isGestureEventType(event.type)) { 209 if (WebInputEvent::isGestureEventType(event.type)) {
210 bool result = false;
211 const WebGestureEvent* gesture_event =
212 static_cast<const WebGestureEvent*>(&event);
161 switch (event.type) { 213 switch (event.type) {
162 case WebInputEvent::GestureScrollUpdate: { 214 case WebInputEvent::GestureTap: {
163 const WebGestureEvent* gesture_event = 215 WebMouseEvent mouse;
164 static_cast<const WebGestureEvent*>(&event);
165 WebMouseWheelEvent wheel_event;
166 wheel_event.timeStampSeconds = gesture_event->timeStampSeconds;
167 wheel_event.type = WebInputEvent::MouseWheel;
168 wheel_event.modifiers = gesture_event->modifiers;
169 216
170 wheel_event.x = gesture_event->x; 217 mouse.timeStampSeconds = gesture_event->timeStampSeconds;
171 wheel_event.y = gesture_event->y; 218 mouse.type = WebInputEvent::MouseMove;
172 wheel_event.windowX = gesture_event->globalX; 219 mouse.modifiers = gesture_event->modifiers;
173 wheel_event.windowY = gesture_event->globalX;
174 wheel_event.globalX = gesture_event->globalX;
175 wheel_event.globalY = gesture_event->globalY;
176 wheel_event.movementX = 0;
177 wheel_event.movementY = 0;
178 220
179 wheel_event.deltaX = gesture_event->data.scrollUpdate.deltaX; 221 mouse.x = gesture_event->x;
180 wheel_event.deltaY = gesture_event->data.scrollUpdate.deltaY; 222 mouse.y = gesture_event->y;
181 wheel_event.wheelTicksX = 223 mouse.windowX = gesture_event->globalX;
182 gesture_event->data.scrollUpdate.deltaX / kTickDivisor; 224 mouse.windowY = gesture_event->globalY;
183 wheel_event.wheelTicksY = 225 mouse.globalX = gesture_event->globalX;
184 gesture_event->data.scrollUpdate.deltaY / kTickDivisor; 226 mouse.globalY = gesture_event->globalY;
185 wheel_event.hasPreciseScrollingDeltas = 1; 227 mouse.movementX = 0;
186 wheel_event.phase = WebMouseWheelEvent::PhaseNone; 228 mouse.movementY = 0;
187 wheel_event.momentumPhase = WebMouseWheelEvent::PhaseNone; 229 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor);
188 230
189 result |= widget_->plugin()->HandleInputEvent(wheel_event, &cursor); 231 mouse.type = WebInputEvent::MouseDown;
232 mouse.button = WebMouseEvent::ButtonLeft;
233 mouse.clickCount = gesture_event->data.tap.tapCount;
234 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor);
235
236 mouse.type = WebInputEvent::MouseUp;
237 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor);
190 break; 238 break;
191 } 239 }
192 case WebInputEvent::GestureTap: {
193 const WebGestureEvent* gesture_event =
194 static_cast<const WebGestureEvent*>(&event);
195 WebMouseEvent mouseEvent;
196 240
197 mouseEvent.timeStampSeconds = gesture_event->timeStampSeconds; 241 default: {
198 mouseEvent.type = WebInputEvent::MouseMove; 242 WebMouseEvent mouse = WebMouseEventFromGestureEvent(*gesture_event);
199 mouseEvent.modifiers = gesture_event->modifiers; 243 if (mouse.type != WebInputEvent::Undefined)
200 244 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor);
201 mouseEvent.x = gesture_event->x;
202 mouseEvent.y = gesture_event->y;
203 mouseEvent.windowX = gesture_event->globalX;
204 mouseEvent.windowY = gesture_event->globalX;
205 mouseEvent.globalX = gesture_event->globalX;
206 mouseEvent.globalY = gesture_event->globalY;
207 mouseEvent.movementX = 0;
208 mouseEvent.movementY = 0;
209 result |= widget_->plugin()->HandleInputEvent(mouseEvent, &cursor);
210
211 mouseEvent.type = WebInputEvent::MouseDown;
212 mouseEvent.button = WebMouseEvent::ButtonLeft;
213 mouseEvent.clickCount = gesture_event->data.tap.tapCount;
214 result |= widget_->plugin()->HandleInputEvent(mouseEvent, &cursor);
215
216 mouseEvent.type = WebInputEvent::MouseUp;
217 result |= widget_->plugin()->HandleInputEvent(mouseEvent, &cursor);
218 break; 245 break;
219 } 246 }
220 default:
221 break;
222 } 247 }
248 return result;
223 } 249 }
224 250
251 bool result = widget_->plugin()->HandleInputEvent(event, &cursor);
252
225 // For normal web pages, WebViewImpl does input event translations and 253 // For normal web pages, WebViewImpl does input event translations and
226 // generates context menu events. Since we don't have a WebView, we need to 254 // generates context menu events. Since we don't have a WebView, we need to
227 // do the necessary translation ourselves. 255 // do the necessary translation ourselves.
228 if (WebInputEvent::isMouseEventType(event.type)) { 256 if (WebInputEvent::isMouseEventType(event.type)) {
229 const WebMouseEvent& mouse_event = 257 const WebMouseEvent& mouse_event =
230 reinterpret_cast<const WebMouseEvent&>(event); 258 reinterpret_cast<const WebMouseEvent&>(event);
231 bool send_context_menu_event = false; 259 bool send_context_menu_event = false;
232 // On Mac/Linux, we handle it on mouse down. 260 // On Mac/Linux, we handle it on mouse down.
233 // On Windows, we handle it on mouse up. 261 // On Windows, we handle it on mouse up.
234 #if defined(OS_WIN) 262 #if defined(OS_WIN)
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 RenderWidgetFullscreenPepper::GetParentContextForPlatformContext3D() { 705 RenderWidgetFullscreenPepper::GetParentContextForPlatformContext3D() {
678 if (!context_) { 706 if (!context_) {
679 CreateContext(); 707 CreateContext();
680 } 708 }
681 if (!context_) 709 if (!context_)
682 return NULL; 710 return NULL;
683 return context_; 711 return context_;
684 } 712 }
685 713
686 } // namespace content 714 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698