| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "web/WebFrameWidgetBase.h" | 5 #include "web/WebFrameWidgetBase.h" |
| 6 | 6 |
| 7 #include "core/dom/DocumentUserGestureToken.h" |
| 7 #include "core/frame/FrameHost.h" | 8 #include "core/frame/FrameHost.h" |
| 9 #include "core/frame/FrameView.h" |
| 8 #include "core/frame/VisualViewport.h" | 10 #include "core/frame/VisualViewport.h" |
| 9 #include "core/input/EventHandler.h" | 11 #include "core/input/EventHandler.h" |
| 10 #include "core/page/DragActions.h" | 12 #include "core/page/DragActions.h" |
| 11 #include "core/page/DragController.h" | 13 #include "core/page/DragController.h" |
| 12 #include "core/page/DragData.h" | 14 #include "core/page/DragData.h" |
| 13 #include "core/page/DragSession.h" | 15 #include "core/page/DragSession.h" |
| 14 #include "core/page/Page.h" | 16 #include "core/page/Page.h" |
| 17 #include "core/page/PointerLockController.h" |
| 18 #include "platform/UserGestureIndicator.h" |
| 15 #include "public/web/WebAutofillClient.h" | 19 #include "public/web/WebAutofillClient.h" |
| 16 #include "public/web/WebDocument.h" | 20 #include "public/web/WebDocument.h" |
| 17 #include "public/web/WebWidgetClient.h" | 21 #include "public/web/WebWidgetClient.h" |
| 22 #include "web/WebInputEventConversion.h" |
| 18 #include "web/WebLocalFrameImpl.h" | 23 #include "web/WebLocalFrameImpl.h" |
| 19 #include "web/WebViewImpl.h" | 24 #include "web/WebViewImpl.h" |
| 20 | 25 |
| 21 namespace blink { | 26 namespace blink { |
| 22 | 27 |
| 23 namespace { | 28 namespace { |
| 24 | 29 |
| 25 // Helper to get LocalFrame* from WebLocalFrame*. | 30 // Helper to get LocalFrame* from WebLocalFrame*. |
| 26 // TODO(dcheng): This should be moved into WebLocalFrame. | 31 // TODO(dcheng): This should be moved into WebLocalFrame. |
| 27 LocalFrame* toCoreFrame(WebLocalFrame* frame) { | 32 LocalFrame* toCoreFrame(WebLocalFrame* frame) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 216 } |
| 212 | 217 |
| 213 WebViewImpl* WebFrameWidgetBase::view() const { | 218 WebViewImpl* WebFrameWidgetBase::view() const { |
| 214 return toWebLocalFrameImpl(localRoot())->viewImpl(); | 219 return toWebLocalFrameImpl(localRoot())->viewImpl(); |
| 215 } | 220 } |
| 216 | 221 |
| 217 Page* WebFrameWidgetBase::page() const { | 222 Page* WebFrameWidgetBase::page() const { |
| 218 return view()->page(); | 223 return view()->page(); |
| 219 } | 224 } |
| 220 | 225 |
| 226 void WebFrameWidgetBase::didAcquirePointerLock() { |
| 227 page()->pointerLockController().didAcquirePointerLock(); |
| 228 } |
| 229 |
| 230 void WebFrameWidgetBase::didNotAcquirePointerLock() { |
| 231 page()->pointerLockController().didNotAcquirePointerLock(); |
| 232 } |
| 233 |
| 234 void WebFrameWidgetBase::didLosePointerLock() { |
| 235 m_pointerLockGestureToken.clear(); |
| 236 page()->pointerLockController().didLosePointerLock(); |
| 237 } |
| 238 |
| 239 void WebFrameWidgetBase::pointerLockMouseEvent(const WebInputEvent& event) { |
| 240 std::unique_ptr<UserGestureIndicator> gestureIndicator; |
| 241 AtomicString eventType; |
| 242 switch (event.type()) { |
| 243 case WebInputEvent::MouseDown: |
| 244 eventType = EventTypeNames::mousedown; |
| 245 if (!page() || !page()->pointerLockController().element()) |
| 246 break; |
| 247 gestureIndicator = WTF::wrapUnique( |
| 248 new UserGestureIndicator(DocumentUserGestureToken::create( |
| 249 &page()->pointerLockController().element()->document(), |
| 250 UserGestureToken::NewGesture))); |
| 251 m_pointerLockGestureToken = gestureIndicator->currentToken(); |
| 252 break; |
| 253 case WebInputEvent::MouseUp: |
| 254 eventType = EventTypeNames::mouseup; |
| 255 gestureIndicator = WTF::wrapUnique( |
| 256 new UserGestureIndicator(m_pointerLockGestureToken.release())); |
| 257 break; |
| 258 case WebInputEvent::MouseMove: |
| 259 eventType = EventTypeNames::mousemove; |
| 260 break; |
| 261 default: |
| 262 NOTREACHED(); |
| 263 } |
| 264 |
| 265 const WebMouseEvent& mouseEvent = static_cast<const WebMouseEvent&>(event); |
| 266 |
| 267 if (page()) { |
| 268 WebMouseEvent transformedEvent = TransformWebMouseEvent( |
| 269 toWebLocalFrameImpl(localRoot())->frameView(), mouseEvent); |
| 270 page()->pointerLockController().dispatchLockedMouseEvent(transformedEvent, |
| 271 eventType); |
| 272 } |
| 273 } |
| 274 |
| 221 } // namespace blink | 275 } // namespace blink |
| OLD | NEW |