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

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 break;
piman 2013/02/01 19:19:52 I don't understand this. A FlingStart should be a
sadrul 2013/02/01 19:58:05 Done.
83 case WebInputEvent::GestureScrollEnd:
84 mouse.type = WebInputEvent::MouseUp;
85 break;
86
87 default:
88 break;
89 }
90
91 if (mouse.type == WebInputEvent::Undefined)
92 return mouse;
93
94 mouse.timeStampSeconds = gesture.timeStampSeconds;
95 mouse.modifiers = gesture.modifiers | WebInputEvent::LeftButtonDown;
96 mouse.button = WebMouseEvent::ButtonLeft;
97 mouse.clickCount = (mouse.type == WebInputEvent::MouseDown ||
98 mouse.type == WebInputEvent::MouseUp);
99
100 mouse.x = gesture.x;
101 mouse.y = gesture.y;
102 mouse.windowX = gesture.globalX;
103 mouse.windowY = gesture.globalY;
104 mouse.globalX = gesture.globalX;
105 mouse.globalY = gesture.globalY;
106
107 return mouse;
108 }
109
68 FullscreenMouseLockDispatcher::FullscreenMouseLockDispatcher( 110 FullscreenMouseLockDispatcher::FullscreenMouseLockDispatcher(
69 RenderWidgetFullscreenPepper* widget) : widget_(widget) { 111 RenderWidgetFullscreenPepper* widget) : widget_(widget) {
70 } 112 }
71 113
72 FullscreenMouseLockDispatcher::~FullscreenMouseLockDispatcher() { 114 FullscreenMouseLockDispatcher::~FullscreenMouseLockDispatcher() {
73 } 115 }
74 116
75 void FullscreenMouseLockDispatcher::SendLockMouseRequest( 117 void FullscreenMouseLockDispatcher::SendLockMouseRequest(
76 bool unlocked_by_target) { 118 bool unlocked_by_target) {
77 widget_->Send(new ViewHostMsg_LockMouse(widget_->routing_id(), false, 119 widget_->Send(new ViewHostMsg_LockMouse(widget_->routing_id(), false,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 NOTIMPLEMENTED(); 187 NOTIMPLEMENTED();
146 } 188 }
147 189
148 virtual bool handleInputEvent(const WebInputEvent& event) { 190 virtual bool handleInputEvent(const WebInputEvent& event) {
149 if (!widget_->plugin()) 191 if (!widget_->plugin())
150 return false; 192 return false;
151 193
152 // This cursor info is ignored, we always set the cursor directly from 194 // This cursor info is ignored, we always set the cursor directly from
153 // RenderWidgetFullscreenPepper::DidChangeCursor. 195 // RenderWidgetFullscreenPepper::DidChangeCursor.
154 WebCursorInfo cursor; 196 WebCursorInfo cursor;
155 bool result = widget_->plugin()->HandleInputEvent(event, &cursor);
156 197
157 // For normal web pages, WebCore::EventHandler converts selected 198 // 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 199 // events directly to the plugin. Instead, try to convert them to equivalent
159 // so do this translation here. 200 // mouse events, and then send to the plugin.
160 if (!result && WebInputEvent::isGestureEventType(event.type)) { 201 if (WebInputEvent::isGestureEventType(event.type)) {
202 bool result = false;
203 const WebGestureEvent* gesture_event =
204 static_cast<const WebGestureEvent*>(&event);
161 switch (event.type) { 205 switch (event.type) {
162 case WebInputEvent::GestureScrollUpdate: { 206 case WebInputEvent::GestureTap: {
163 const WebGestureEvent* gesture_event = 207 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 208
170 wheel_event.x = gesture_event->x; 209 mouse.timeStampSeconds = gesture_event->timeStampSeconds;
171 wheel_event.y = gesture_event->y; 210 mouse.type = WebInputEvent::MouseMove;
172 wheel_event.windowX = gesture_event->globalX; 211 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 212
179 wheel_event.deltaX = gesture_event->data.scrollUpdate.deltaX; 213 mouse.x = gesture_event->x;
180 wheel_event.deltaY = gesture_event->data.scrollUpdate.deltaY; 214 mouse.y = gesture_event->y;
181 wheel_event.wheelTicksX = 215 mouse.windowX = gesture_event->globalX;
182 gesture_event->data.scrollUpdate.deltaX / kTickDivisor; 216 mouse.windowY = gesture_event->globalY;
183 wheel_event.wheelTicksY = 217 mouse.globalX = gesture_event->globalX;
184 gesture_event->data.scrollUpdate.deltaY / kTickDivisor; 218 mouse.globalY = gesture_event->globalY;
185 wheel_event.hasPreciseScrollingDeltas = 1; 219 mouse.movementX = 0;
186 wheel_event.phase = WebMouseWheelEvent::PhaseNone; 220 mouse.movementY = 0;
187 wheel_event.momentumPhase = WebMouseWheelEvent::PhaseNone; 221 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor);
188 222
189 result |= widget_->plugin()->HandleInputEvent(wheel_event, &cursor); 223 mouse.type = WebInputEvent::MouseDown;
224 mouse.button = WebMouseEvent::ButtonLeft;
225 mouse.clickCount = gesture_event->data.tap.tapCount;
226 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor);
227
228 mouse.type = WebInputEvent::MouseUp;
229 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor);
190 break; 230 break;
191 } 231 }
192 case WebInputEvent::GestureTap: {
193 const WebGestureEvent* gesture_event =
194 static_cast<const WebGestureEvent*>(&event);
195 WebMouseEvent mouseEvent;
196 232
197 mouseEvent.timeStampSeconds = gesture_event->timeStampSeconds; 233 default: {
198 mouseEvent.type = WebInputEvent::MouseMove; 234 // This works for pepper plugins. However, this may break scrolling in
199 mouseEvent.modifiers = gesture_event->modifiers; 235 // fullscreen PDF. So, we should continue to generate wheel events for
piman 2013/02/01 19:19:52 fullscreen PDF doesn't use this codepath (only use
sadrul 2013/02/01 19:58:05 Whoops. This comment was for myself to check the P
200 236 // GestureScrollUpdate if the plugin accepts raw touch events. A
201 mouseEvent.x = gesture_event->x; 237 // better solution would be to make sure the browser sends touch
202 mouseEvent.y = gesture_event->y; 238 // events if the plugin accepts raw events, and convert those touch
203 mouseEvent.windowX = gesture_event->globalX; 239 // events to mouse events (and continue to generate wheel events out
204 mouseEvent.windowY = gesture_event->globalX; 240 // of GestureScrollUpdate events).
205 mouseEvent.globalX = gesture_event->globalX; 241 WebMouseEvent mouse = WebMouseEventFromGestureEvent(*gesture_event);
206 mouseEvent.globalY = gesture_event->globalY; 242 if (mouse.type != WebInputEvent::Undefined)
207 mouseEvent.movementX = 0; 243 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor);
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; 244 break;
219 } 245 }
220 default:
221 break;
222 } 246 }
247 return result;
223 } 248 }
224 249
250 bool result = widget_->plugin()->HandleInputEvent(event, &cursor);
251
225 // For normal web pages, WebViewImpl does input event translations and 252 // 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 253 // generates context menu events. Since we don't have a WebView, we need to
227 // do the necessary translation ourselves. 254 // do the necessary translation ourselves.
228 if (WebInputEvent::isMouseEventType(event.type)) { 255 if (WebInputEvent::isMouseEventType(event.type)) {
229 const WebMouseEvent& mouse_event = 256 const WebMouseEvent& mouse_event =
230 reinterpret_cast<const WebMouseEvent&>(event); 257 reinterpret_cast<const WebMouseEvent&>(event);
231 bool send_context_menu_event = false; 258 bool send_context_menu_event = false;
232 // On Mac/Linux, we handle it on mouse down. 259 // On Mac/Linux, we handle it on mouse down.
233 // On Windows, we handle it on mouse up. 260 // On Windows, we handle it on mouse up.
234 #if defined(OS_WIN) 261 #if defined(OS_WIN)
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 RenderWidgetFullscreenPepper::GetParentContextForPlatformContext3D() { 704 RenderWidgetFullscreenPepper::GetParentContextForPlatformContext3D() {
678 if (!context_) { 705 if (!context_) {
679 CreateContext(); 706 CreateContext();
680 } 707 }
681 if (!context_) 708 if (!context_)
682 return NULL; 709 return NULL;
683 return context_; 710 return context_;
684 } 711 }
685 712
686 } // namespace content 713 } // 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