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

Side by Side Diff: third_party/WebKit/Source/core/frame/WebFrameWidgetBase.cpp

Issue 2807433003: No pointer captured when the pointer lock is applied (Closed)
Patch Set: pointer lock Created 3 years, 6 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
OLDNEW
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 "core/frame/WebFrameWidgetBase.h" 5 #include "core/frame/WebFrameWidgetBase.h"
6 6
7 #include "core/dom/DocumentUserGestureToken.h" 7 #include "core/dom/DocumentUserGestureToken.h"
8 #include "core/events/WebInputEventConversion.h" 8 #include "core/events/WebInputEventConversion.h"
9 #include "core/exported/WebViewBase.h" 9 #include "core/exported/WebViewBase.h"
10 #include "core/frame/LocalFrameView.h" 10 #include "core/frame/LocalFrameView.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 WebViewBase* WebFrameWidgetBase::View() const { 231 WebViewBase* WebFrameWidgetBase::View() const {
232 return ToWebLocalFrameBase(LocalRoot())->ViewImpl(); 232 return ToWebLocalFrameBase(LocalRoot())->ViewImpl();
233 } 233 }
234 234
235 Page* WebFrameWidgetBase::GetPage() const { 235 Page* WebFrameWidgetBase::GetPage() const {
236 return View()->GetPage(); 236 return View()->GetPage();
237 } 237 }
238 238
239 void WebFrameWidgetBase::DidAcquirePointerLock() { 239 void WebFrameWidgetBase::DidAcquirePointerLock() {
240 GetPage()->GetPointerLockController().DidAcquirePointerLock(); 240 GetPage()->GetPointerLockController().DidAcquirePointerLock();
241
242 LocalFrame* focusedFrame = FocusedLocalFrameInWidget();
243 if (focusedFrame) {
244 focusedFrame->GetEventHandler().ReleaseMousePointerCapture();
245 }
241 } 246 }
242 247
243 void WebFrameWidgetBase::DidNotAcquirePointerLock() { 248 void WebFrameWidgetBase::DidNotAcquirePointerLock() {
244 GetPage()->GetPointerLockController().DidNotAcquirePointerLock(); 249 GetPage()->GetPointerLockController().DidNotAcquirePointerLock();
245 } 250 }
246 251
247 void WebFrameWidgetBase::DidLosePointerLock() { 252 void WebFrameWidgetBase::DidLosePointerLock() {
248 pointer_lock_gesture_token_.Clear(); 253 pointer_lock_gesture_token_.Clear();
249 GetPage()->GetPointerLockController().DidLosePointerLock(); 254 GetPage()->GetPointerLockController().DidLosePointerLock();
250 } 255 }
251 256
252 void WebFrameWidgetBase::PointerLockMouseEvent(const WebInputEvent& event) { 257 // TODO(665924): Remove direct dispatches of mouse events from
258 // PointerLockController, instead passing them through EventHandler.
259 void WebFrameWidgetBase::PointerLockMouseEvent(
260 const WebCoalescedInputEvent& coalesced_event) {
261 const WebInputEvent& input_event = coalesced_event.Event();
262 const WebMouseEvent& mouse_event =
263 static_cast<const WebMouseEvent&>(input_event);
264 WebMouseEvent transformed_event = TransformWebMouseEvent(
265 ToWebLocalFrameBase(LocalRoot())->GetFrameView(), mouse_event);
266
267 LocalFrame* focusedFrame = FocusedLocalFrameInWidget();
268 if (focusedFrame) {
269 focusedFrame->GetEventHandler().ProcessPendingPointerCaptureForPointerLock(
270 transformed_event);
271 }
272
253 std::unique_ptr<UserGestureIndicator> gesture_indicator; 273 std::unique_ptr<UserGestureIndicator> gesture_indicator;
254 AtomicString event_type; 274 AtomicString event_type;
255 switch (event.GetType()) { 275 switch (input_event.GetType()) {
256 case WebInputEvent::kMouseDown: 276 case WebInputEvent::kMouseDown:
257 event_type = EventTypeNames::mousedown; 277 event_type = EventTypeNames::mousedown;
258 if (!GetPage() || !GetPage()->GetPointerLockController().GetElement()) 278 if (!GetPage() || !GetPage()->GetPointerLockController().GetElement())
259 break; 279 break;
260 gesture_indicator = WTF::WrapUnique(new UserGestureIndicator( 280 gesture_indicator = WTF::WrapUnique(new UserGestureIndicator(
261 DocumentUserGestureToken::Create(&GetPage() 281 DocumentUserGestureToken::Create(&GetPage()
262 ->GetPointerLockController() 282 ->GetPointerLockController()
263 .GetElement() 283 .GetElement()
264 ->GetDocument(), 284 ->GetDocument(),
265 UserGestureToken::kNewGesture))); 285 UserGestureToken::kNewGesture)));
266 pointer_lock_gesture_token_ = gesture_indicator->CurrentToken(); 286 pointer_lock_gesture_token_ = gesture_indicator->CurrentToken();
267 break; 287 break;
268 case WebInputEvent::kMouseUp: 288 case WebInputEvent::kMouseUp:
269 event_type = EventTypeNames::mouseup; 289 event_type = EventTypeNames::mouseup;
270 gesture_indicator = WTF::WrapUnique( 290 gesture_indicator = WTF::WrapUnique(
271 new UserGestureIndicator(std::move(pointer_lock_gesture_token_))); 291 new UserGestureIndicator(std::move(pointer_lock_gesture_token_)));
272 break; 292 break;
273 case WebInputEvent::kMouseMove: 293 case WebInputEvent::kMouseMove:
274 event_type = EventTypeNames::mousemove; 294 event_type = EventTypeNames::mousemove;
275 break; 295 break;
276 default: 296 default:
277 NOTREACHED(); 297 NOTREACHED();
278 } 298 }
279 299
280 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event);
281
282 if (GetPage()) { 300 if (GetPage()) {
283 WebMouseEvent transformed_event = TransformWebMouseEvent(
284 ToWebLocalFrameBase(LocalRoot())->GetFrameView(), mouse_event);
285 GetPage()->GetPointerLockController().DispatchLockedMouseEvent( 301 GetPage()->GetPointerLockController().DispatchLockedMouseEvent(
286 transformed_event, event_type); 302 transformed_event, event_type);
287 } 303 }
288 } 304 }
289 305
290 void WebFrameWidgetBase::ShowContextMenu(WebMenuSourceType source_type) { 306 void WebFrameWidgetBase::ShowContextMenu(WebMenuSourceType source_type) {
291 if (!GetPage()) 307 if (!GetPage())
292 return; 308 return;
293 309
294 GetPage()->GetContextMenuController().ClearContextMenu(); 310 GetPage()->GetContextMenuController().ClearContextMenu();
295 { 311 {
296 ContextMenuAllowedScope scope; 312 ContextMenuAllowedScope scope;
297 if (LocalFrame* focused_frame = 313 if (LocalFrame* focused_frame =
298 GetPage()->GetFocusController().FocusedFrame()) { 314 GetPage()->GetFocusController().FocusedFrame()) {
299 focused_frame->GetEventHandler().ShowNonLocatedContextMenu(nullptr, 315 focused_frame->GetEventHandler().ShowNonLocatedContextMenu(nullptr,
300 source_type); 316 source_type);
301 } 317 }
302 } 318 }
303 } 319 }
304 320
321 LocalFrame* WebFrameWidgetBase::FocusedLocalFrameInWidget() const {
322 LocalFrame* frame = GetPage()->GetFocusController().FocusedFrame();
323 return (frame && frame->LocalFrameRoot() == ToCoreFrame(LocalRoot()))
324 ? frame
325 : nullptr;
326 }
327
305 } // namespace blink 328 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/WebFrameWidgetBase.h ('k') | third_party/WebKit/Source/core/input/EventHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698