OLD | NEW |
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // MouseLockDispatcher implementation. | 57 // MouseLockDispatcher implementation. |
58 void SendLockMouseRequest(bool unlocked_by_target) override; | 58 void SendLockMouseRequest(bool unlocked_by_target) override; |
59 void SendUnlockMouseRequest() override; | 59 void SendUnlockMouseRequest() override; |
60 | 60 |
61 RenderWidgetFullscreenPepper* widget_; | 61 RenderWidgetFullscreenPepper* widget_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(FullscreenMouseLockDispatcher); | 63 DISALLOW_COPY_AND_ASSIGN(FullscreenMouseLockDispatcher); |
64 }; | 64 }; |
65 | 65 |
66 WebMouseEvent WebMouseEventFromGestureEvent(const WebGestureEvent& gesture) { | 66 WebMouseEvent WebMouseEventFromGestureEvent(const WebGestureEvent& gesture) { |
67 WebMouseEvent mouse; | |
68 | 67 |
69 // Only convert touch screen gesture events, do not convert | 68 // Only convert touch screen gesture events, do not convert |
70 // touchpad/mouse wheel gesture events. (crbug.com/620974) | 69 // touchpad/mouse wheel gesture events. (crbug.com/620974) |
71 if (gesture.sourceDevice != blink::WebGestureDeviceTouchscreen) | 70 if (gesture.sourceDevice != blink::WebGestureDeviceTouchscreen) |
72 return mouse; | 71 return WebMouseEvent(); |
73 | 72 |
| 73 WebInputEvent::Type type = WebInputEvent::Undefined; |
74 switch (gesture.type) { | 74 switch (gesture.type) { |
75 case WebInputEvent::GestureScrollBegin: | 75 case WebInputEvent::GestureScrollBegin: |
76 mouse.type = WebInputEvent::MouseDown; | 76 type = WebInputEvent::MouseDown; |
77 break; | 77 break; |
78 case WebInputEvent::GestureScrollUpdate: | 78 case WebInputEvent::GestureScrollUpdate: |
79 mouse.type = WebInputEvent::MouseMove; | 79 type = WebInputEvent::MouseMove; |
80 break; | 80 break; |
81 case WebInputEvent::GestureFlingStart: | 81 case WebInputEvent::GestureFlingStart: |
82 // A scroll gesture on the touchscreen may end with a GestureScrollEnd | 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 | 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 | 84 // velocity. In both cases, it should end the drag that was initiated by |
85 // the GestureScrollBegin (and subsequent GestureScrollUpdate) events. | 85 // the GestureScrollBegin (and subsequent GestureScrollUpdate) events. |
86 mouse.type = WebInputEvent::MouseUp; | 86 type = WebInputEvent::MouseUp; |
| 87 break; |
87 case WebInputEvent::GestureScrollEnd: | 88 case WebInputEvent::GestureScrollEnd: |
88 mouse.type = WebInputEvent::MouseUp; | 89 type = WebInputEvent::MouseUp; |
89 break; | 90 break; |
90 default: | 91 default: |
91 return mouse; | 92 return WebMouseEvent(); |
92 } | 93 } |
93 | 94 |
94 mouse.timeStampSeconds = gesture.timeStampSeconds; | 95 WebMouseEvent mouse(type, gesture.modifiers | WebInputEvent::LeftButtonDown, |
95 mouse.modifiers = gesture.modifiers | WebInputEvent::LeftButtonDown; | 96 gesture.timeStampSeconds); |
96 mouse.button = WebMouseEvent::Button::Left; | 97 mouse.button = WebMouseEvent::Button::Left; |
97 mouse.clickCount = (mouse.type == WebInputEvent::MouseDown || | 98 mouse.clickCount = (mouse.type == WebInputEvent::MouseDown || |
98 mouse.type == WebInputEvent::MouseUp); | 99 mouse.type == WebInputEvent::MouseUp); |
99 | 100 |
100 mouse.x = gesture.x; | 101 mouse.x = gesture.x; |
101 mouse.y = gesture.y; | 102 mouse.y = gesture.y; |
102 mouse.windowX = gesture.x; | 103 mouse.windowX = gesture.x; |
103 mouse.windowY = gesture.y; | 104 mouse.windowY = gesture.y; |
104 mouse.globalX = gesture.globalX; | 105 mouse.globalX = gesture.globalX; |
105 mouse.globalY = gesture.globalY; | 106 mouse.globalY = gesture.globalY; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 163 |
163 // Pepper plugins do not accept gesture events. So do not send the gesture | 164 // Pepper plugins do not accept gesture events. So do not send the gesture |
164 // events directly to the plugin. Instead, try to convert them to equivalent | 165 // events directly to the plugin. Instead, try to convert them to equivalent |
165 // mouse events, and then send to the plugin. | 166 // mouse events, and then send to the plugin. |
166 if (WebInputEvent::isGestureEventType(event.type)) { | 167 if (WebInputEvent::isGestureEventType(event.type)) { |
167 bool result = false; | 168 bool result = false; |
168 const WebGestureEvent* gesture_event = | 169 const WebGestureEvent* gesture_event = |
169 static_cast<const WebGestureEvent*>(&event); | 170 static_cast<const WebGestureEvent*>(&event); |
170 switch (event.type) { | 171 switch (event.type) { |
171 case WebInputEvent::GestureTap: { | 172 case WebInputEvent::GestureTap: { |
172 WebMouseEvent mouse; | 173 WebMouseEvent mouse(WebInputEvent::MouseMove, |
173 | 174 gesture_event->modifiers, |
174 mouse.timeStampSeconds = gesture_event->timeStampSeconds; | 175 gesture_event->timeStampSeconds); |
175 mouse.type = WebInputEvent::MouseMove; | |
176 mouse.modifiers = gesture_event->modifiers; | |
177 | |
178 mouse.x = gesture_event->x; | 176 mouse.x = gesture_event->x; |
179 mouse.y = gesture_event->y; | 177 mouse.y = gesture_event->y; |
180 mouse.windowX = gesture_event->x; | 178 mouse.windowX = gesture_event->x; |
181 mouse.windowY = gesture_event->y; | 179 mouse.windowY = gesture_event->y; |
182 mouse.globalX = gesture_event->globalX; | 180 mouse.globalX = gesture_event->globalX; |
183 mouse.globalY = gesture_event->globalY; | 181 mouse.globalY = gesture_event->globalY; |
184 mouse.movementX = 0; | 182 mouse.movementX = 0; |
185 mouse.movementY = 0; | 183 mouse.movementY = 0; |
186 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor); | 184 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor); |
187 | 185 |
188 mouse.type = WebInputEvent::MouseDown; | 186 mouse.setType(WebInputEvent::MouseDown); |
189 mouse.button = WebMouseEvent::Button::Left; | 187 mouse.button = WebMouseEvent::Button::Left; |
190 mouse.clickCount = gesture_event->data.tap.tapCount; | 188 mouse.clickCount = gesture_event->data.tap.tapCount; |
191 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor); | 189 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor); |
192 | 190 |
193 mouse.type = WebInputEvent::MouseUp; | 191 mouse.setType(WebInputEvent::MouseUp); |
194 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor); | 192 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor); |
195 break; | 193 break; |
196 } | 194 } |
197 | 195 |
198 default: { | 196 default: { |
199 WebMouseEvent mouse = WebMouseEventFromGestureEvent(*gesture_event); | 197 WebMouseEvent mouse = WebMouseEventFromGestureEvent(*gesture_event); |
200 if (mouse.type != WebInputEvent::Undefined) | 198 if (mouse.type != WebInputEvent::Undefined) |
201 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor); | 199 result |= widget_->plugin()->HandleInputEvent(mouse, &cursor); |
202 break; | 200 break; |
203 } | 201 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 GURL RenderWidgetFullscreenPepper::GetURLForGraphicsContext3D() { | 375 GURL RenderWidgetFullscreenPepper::GetURLForGraphicsContext3D() { |
378 return active_url_; | 376 return active_url_; |
379 } | 377 } |
380 | 378 |
381 void RenderWidgetFullscreenPepper::OnDeviceScaleFactorChanged() { | 379 void RenderWidgetFullscreenPepper::OnDeviceScaleFactorChanged() { |
382 if (compositor_) | 380 if (compositor_) |
383 compositor_->setDeviceScaleFactor(device_scale_factor_); | 381 compositor_->setDeviceScaleFactor(device_scale_factor_); |
384 } | 382 } |
385 | 383 |
386 } // namespace content | 384 } // namespace content |
OLD | NEW |