Changeset 207689 in webkit
- Timestamp:
- Oct 21, 2016 11:45:39 AM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207688 r207689 1 2016-10-21 Jeremy Jones <jeremyj@apple.com> 2 3 Implement basic pointer lock behavior for WebKit and WebKit2. 4 https://bugs.webkit.org/show_bug.cgi?id=162745 5 6 Reviewed by Simon Fraser. 7 8 When ENABLE_POINTER_LOCK is enabled, these tests now pass with DumpRenderTree. 9 LayoutTests/pointer-lock/lock-already-locked.html 10 LayoutTests/pointer-lock/lock-element-not-in-dom.html 11 LayoutTests/pointer-lock/locked-element-iframe-removed-from-dom.html 12 LayoutTests/pointer-lock/mouse-event-api.html 13 14 Export pointer lock symbols and cancel pointer lock on "escape". 15 16 * dom/Document.h: Export symbols. 17 * dom/Element.h: Export symbols. 18 * page/EventHandler.cpp: 19 (WebCore::EventHandler::keyEvent): Cancel pointer lock on "escape". 20 * page/PointerLockController.cpp: Add missing include. 21 * page/PointerLockController.h: Export symbols. 22 1 23 2016-10-21 Jer Noble <jer.noble@apple.com> 2 24 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r207687 r207689 1516 1516 3FBC4AF3189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3FBC4AF1189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.mm */; }; 1517 1517 3FBC4AF4189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FBC4AF2189881560046EE38 /* WebVideoFullscreenInterfaceAVKit.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1518 3FF813A71DBA8640009BF001 /* PointerLockController.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CFC434F192406A900A0D3B5 /* PointerLockController.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1518 1519 3FFFF9A8159D9A550020BBD5 /* WebKitCSSViewportRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FFFF9A6159D9A550020BBD5 /* WebKitCSSViewportRule.cpp */; }; 1519 1520 3FFFF9A9159D9A550020BBD5 /* WebKitCSSViewportRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FFFF9A7159D9A550020BBD5 /* WebKitCSSViewportRule.h */; }; … … 26493 26494 BCBB8ABB13F1AFB000734DF0 /* PODRedBlackTree.h in Headers */, 26494 26495 B2B1F7170D00CAA8004AEA64 /* PointerEventsHitRules.h in Headers */, 26496 3FF813A71DBA8640009BF001 /* PointerLockController.h in Headers */, 26495 26497 84730D921248F0B300D3A9C9 /* PointLightSource.h in Headers */, 26496 26498 97059978107D975200A50A7C /* PolicyCallback.h in Headers */, -
trunk/Source/WebCore/dom/Document.h
r207669 r207689 1124 1124 1125 1125 #if ENABLE(POINTER_LOCK) 1126 void exitPointerLock();1127 Element* pointerLockElement() const;1126 WEBCORE_EXPORT void exitPointerLock(); 1127 WEBCORE_EXPORT Element* pointerLockElement() const; 1128 1128 #endif 1129 1129 -
trunk/Source/WebCore/dom/Element.h
r207521 r207689 478 478 479 479 #if ENABLE(POINTER_LOCK) 480 void requestPointerLock();480 WEBCORE_EXPORT void requestPointerLock(); 481 481 #endif 482 482 -
trunk/Source/WebCore/page/ChromeClient.h
r202425 r207689 406 406 virtual bool requestPointerLock() { return false; } 407 407 virtual void requestPointerUnlock() { } 408 virtual bool isPointerLocked() { return false; }409 408 #endif 410 409 -
trunk/Source/WebCore/page/EventHandler.cpp
r206941 r207689 74 74 #include "PlatformWheelEvent.h" 75 75 #include "PluginDocument.h" 76 #include "PointerLockController.h" 76 77 #include "RenderFrameSet.h" 77 78 #include "RenderLayer.h" … … 3063 3064 LOG(Editing, "EventHandler %p keyEvent (text %s keyIdentifier %s)", this, initialKeyEvent.text().utf8().data(), initialKeyEvent.keyIdentifier().utf8().data()); 3064 3065 3066 #if ENABLE(POINTER_LOCK) 3067 if (initialKeyEvent.type() == PlatformEvent::KeyDown && initialKeyEvent.windowsVirtualKeyCode() == VK_ESCAPE && m_frame.page()->pointerLockController().element()) { 3068 m_frame.page()->pointerLockController().requestPointerUnlock(); 3069 return true; 3070 } 3071 #endif 3072 3065 3073 #if ENABLE(FULLSCREEN_API) 3066 3074 if (m_frame.document()->webkitIsFullScreen() && !isKeyEventAllowedInFullScreen(initialKeyEvent)) -
trunk/Source/WebCore/page/PointerLockController.cpp
r190456 r207689 32 32 #include "Element.h" 33 33 #include "Event.h" 34 #include "EventNames.h" 34 35 #include "Page.h" 35 36 #include "PlatformMouseEvent.h" … … 64 65 return; 65 66 } 67 m_element = target; 66 68 enqueueEvent(eventNames().pointerlockchangeEvent, target); 67 m_element = target; 68 } else if (m_page.chrome().client().requestPointerLock()) { 69 } else { 69 70 m_lockPending = true; 70 71 m_element = target; 71 } else 72 enqueueEvent(eventNames().pointerlockerrorEvent, target); 72 if (!m_page.chrome().client().requestPointerLock()) { 73 m_element = nullptr; 74 m_lockPending = false; 75 enqueueEvent(eventNames().pointerlockerrorEvent, target); 76 } 77 } 73 78 } 74 79 -
trunk/Source/WebCore/page/PointerLockController.h
r166679 r207689 51 51 Element* element() const; 52 52 53 void didAcquirePointerLock();54 void didNotAcquirePointerLock();55 void didLosePointerLock();53 WEBCORE_EXPORT void didAcquirePointerLock(); 54 WEBCORE_EXPORT void didNotAcquirePointerLock(); 55 WEBCORE_EXPORT void didLosePointerLock(); 56 56 void dispatchLockedMouseEvent(const PlatformMouseEvent&, const AtomicString& eventType); 57 57 -
trunk/Source/WebKit/mac/ChangeLog
r207642 r207689 1 2016-10-21 Jeremy Jones <jeremyj@apple.com> 2 3 Implement basic pointer lock behavior for WebKit and WebKit2. 4 https://bugs.webkit.org/show_bug.cgi?id=162745 5 6 Reviewed by Simon Fraser. 7 8 Add basic pointer lock functionality. User permission is not yet implemented. 9 10 * WebCoreSupport/WebChromeClient.h: 11 * WebCoreSupport/WebChromeClient.mm: 12 (WebChromeClient::requestPointerLock): 13 (WebChromeClient::requestPointerUnlock): 14 1 15 2016-10-19 Myles C. Maxfield <mmaxfield@apple.com> 2 16 -
trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h
r202425 r207689 136 136 std::unique_ptr<WebCore::ColorChooser> createColorChooser(WebCore::ColorChooserClient*, const WebCore::Color&) override; 137 137 #endif 138 139 #if ENABLE(POINTER_LOCK) 140 bool requestPointerLock() override; 141 void requestPointerUnlock() override; 142 #endif 138 143 139 144 WebCore::KeyboardUIMode keyboardUIMode() override; -
trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
r202425 r207689 78 78 #import <WebCore/Page.h> 79 79 #import <WebCore/PlatformScreen.h> 80 #import <WebCore/PointerLockController.h> 80 81 #import <WebCore/ResourceRequest.h> 81 82 #import <WebCore/SerializedCryptoKeyWrap.h> … … 710 711 #endif 711 712 713 #if ENABLE(POINTER_LOCK) 714 bool WebChromeClient::requestPointerLock() 715 { 716 #if PLATFORM(MAC) 717 if (![m_webView page]) 718 return false; 719 720 CGDisplayHideCursor(CGMainDisplayID()); 721 CGAssociateMouseAndMouseCursorPosition(false); 722 [m_webView page]->pointerLockController().didAcquirePointerLock(); 723 724 return true; 725 #else 726 return false; 727 #endif 728 } 729 730 void WebChromeClient::requestPointerUnlock() 731 { 732 #if PLATFORM(MAC) 733 CGDisplayShowCursor(CGMainDisplayID()); 734 CGAssociateMouseAndMouseCursorPosition(true); 735 if ([m_webView page]) 736 [m_webView page]->pointerLockController().didLosePointerLock(); 737 #endif 738 } 739 #endif 740 712 741 void WebChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser> chooser) 713 742 { -
trunk/Source/WebKit2/ChangeLog
r207670 r207689 1 2016-10-21 Jeremy Jones <jeremyj@apple.com> 2 3 Implement basic pointer lock behavior for WebKit and WebKit2. 4 https://bugs.webkit.org/show_bug.cgi?id=162745 5 6 Reviewed by Simon Fraser. 7 8 Enable basic pointer lock functionality by plumbing requests through WebPage IPC. 9 Pass through mouse movement deltas. 10 Unlock pointer when view is no longer visible. 11 12 * Shared/WebEventConversion.cpp: 13 (WebKit::WebKit2PlatformMouseEvent::WebKit2PlatformMouseEvent): Pass along mouse movement. 14 * UIProcess/WebPageProxy.cpp: 15 (WebKit::WebPageProxy::dispatchViewStateChange): Unlock pointer when page is not visible. 16 (WebKit::WebPageProxy::requestPointerLock): Hide and disassociate pointer. 17 (WebKit::WebPageProxy::requestPointerUnlock): Show and associate pointer. 18 * UIProcess/WebPageProxy.h: 19 * UIProcess/WebPageProxy.messages.in: Add methods. 20 * WebProcess/WebCoreSupport/WebChromeClient.cpp: 21 (WebKit::WebChromeClient::requestPointerLock): Pass along to web page. 22 (WebKit::WebChromeClient::requestPointerUnlock): Ditto. 23 * WebProcess/WebCoreSupport/WebChromeClient.h: 24 * WebProcess/WebPage/WebPage.cpp: 25 (WebKit::WebPage::didAcquirePointerLock): Forward to PointerLockController. 26 (WebKit::WebPage::didNotAcquirePointerLock): Ditto. 27 (WebKit::WebPage::didLosePointerLock): Ditto. 28 * WebProcess/WebPage/WebPage.h: 29 * WebProcess/WebPage/WebPage.messages.in: Add methods. 30 1 31 2016-10-21 Wenson Hsieh <wenson_hsieh@apple.com> 2 32 -
trunk/Source/WebKit2/Shared/WebEventConversion.cpp
r206828 r207689 101 101 102 102 m_position = webEvent.position(); 103 #if ENABLE(POINTER_LOCK) 104 m_movementDelta = WebCore::IntPoint(webEvent.deltaX(), webEvent.deltaY()); 105 #endif 103 106 m_globalPosition = webEvent.globalPosition(); 104 107 m_clickCount = webEvent.clickCount(); -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r207648 r207689 1550 1550 m_process->responsivenessTimer().stop(); 1551 1551 1552 #if ENABLE(POINTER_LOCK) 1553 if ((changed & ViewState::IsVisible) && !isViewVisible()) 1554 requestPointerUnlock(); 1555 #endif 1556 1552 1557 if (changed & ViewState::IsInWindow) { 1553 1558 if (isInWindow()) … … 6621 6626 m_process->send(Messages::WebPage::SetUserInterfaceLayoutDirection(static_cast<uint32_t>(userInterfaceLayoutDirection)), m_pageID); 6622 6627 } 6628 6629 #if ENABLE(POINTER_LOCK) 6630 void WebPageProxy::requestPointerLock() 6631 { 6632 if (!isViewVisible()) { 6633 m_process->send(Messages::WebPage::DidNotAcquirePointerLock(), m_pageID); 6634 return; 6635 } 6636 6637 didAllowPointerLock(); 6638 } 6639 6640 void WebPageProxy::didAllowPointerLock() 6641 { 6642 CGDisplayHideCursor(CGMainDisplayID()); 6643 CGAssociateMouseAndMouseCursorPosition(false); 6644 m_process->send(Messages::WebPage::DidAcquirePointerLock(), m_pageID); 6645 } 6646 6647 void WebPageProxy::didDenyPointerLock() 6648 { 6649 m_process->send(Messages::WebPage::DidNotAcquirePointerLock(), m_pageID); 6650 } 6651 6652 void WebPageProxy::requestPointerUnlock() 6653 { 6654 CGDisplayShowCursor(CGMainDisplayID()); 6655 CGAssociateMouseAndMouseCursorPosition(true); 6656 m_process->send(Messages::WebPage::DidLosePointerLock(), m_pageID); 6657 } 6658 #endif 6659 6623 6660 6624 6661 } // namespace WebKit -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r207463 r207689 947 947 void setVolumeOfMediaElement(double, uint64_t); 948 948 #endif 949 950 #if ENABLE(POINTER_LOCK) 951 void didAllowPointerLock(); 952 void didDenyPointerLock(); 953 #endif 949 954 950 955 // WebPopupMenuProxy::Client … … 1167 1172 #if PLATFORM(GTK) 1168 1173 void failedToShowPopupMenu() override; 1174 #endif 1175 1176 #if ENABLE(POINTER_LOCK) 1177 void requestPointerLock(); 1178 void requestPointerUnlock(); 1169 1179 #endif 1170 1180 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r207463 r207689 459 459 #endif 460 460 461 #if ENABLE(POINTER_LOCK) 462 RequestPointerLock() 463 RequestPointerUnlock() 464 #endif 465 461 466 ImageOrMediaDocumentSizeChanged(WebCore::IntSize newSize) 462 467 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
r206132 r207689 456 456 } 457 457 458 #if ENABLE(POINTER_LOCK) 459 bool WebChromeClient::requestPointerLock() 460 { 461 m_page->send(Messages::WebPageProxy::RequestPointerLock()); 462 return true; 463 } 464 465 void WebChromeClient::requestPointerUnlock() 466 { 467 m_page->send(Messages::WebPageProxy::RequestPointerUnlock()); 468 } 469 #endif 470 458 471 void WebChromeClient::invalidateRootView(const IntRect&) 459 472 { -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
r203312 r207689 192 192 void scheduleAnimation() override; 193 193 #endif 194 195 #if ENABLE(POINTER_LOCK) 196 bool requestPointerLock() override; 197 void requestPointerUnlock() override; 198 #endif 194 199 195 200 void didAssociateFormControls(const Vector<RefPtr<WebCore::Element>>&) override; -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r207670 r207689 153 153 #include <WebCore/PlatformKeyboardEvent.h> 154 154 #include <WebCore/PluginDocument.h> 155 #include <WebCore/PointerLockController.h> 155 156 #include <WebCore/PrintContext.h> 156 157 #include <WebCore/Range.h> … … 5614 5615 #endif 5615 5616 5617 #if ENABLE(POINTER_LOCK) 5618 void WebPage::didAcquirePointerLock() 5619 { 5620 corePage()->pointerLockController().didAcquirePointerLock(); 5621 } 5622 5623 void WebPage::didNotAcquirePointerLock() 5624 { 5625 corePage()->pointerLockController().didNotAcquirePointerLock(); 5626 } 5627 5628 void WebPage::didLosePointerLock() 5629 { 5630 corePage()->pointerLockController().didLosePointerLock(); 5631 } 5632 #endif 5633 5616 5634 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r207563 r207689 962 962 void gamepadActivity(const Vector<GamepadData>&); 963 963 #endif 964 965 #if ENABLE(POINTER_LOCK) 966 void didAcquirePointerLock(); 967 void didNotAcquirePointerLock(); 968 void didLosePointerLock(); 969 #endif 964 970 965 971 private: -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r207463 r207689 429 429 #endif 430 430 431 #if ENABLE(POINTER_LOCK) 432 DidAcquirePointerLock() 433 DidNotAcquirePointerLock() 434 DidLosePointerLock() 435 #endif 436 431 437 ClearWheelEventTestTrigger() 432 438 SetShouldScaleViewToFitDocument(bool shouldScaleViewToFitDocument)
Note: See TracChangeset
for help on using the changeset viewer.