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