diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 69f49889842d736fd5f841e8eb0c4d36d47a5aa1..58e2d29836209f98712aa833380f6953e0faa493 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,17 @@ +2012-09-05 Vincent Scheib + + webkitPointerLockElement returns null when pointer lock request is pending. + https://bugs.webkit.org/show_bug.cgi?id=91186 + + Reviewed by Dimitri Glazkov. + + * pointer-lock/locked-element-iframe-removed-from-dom-expected.txt: + * pointer-lock/locked-element-iframe-removed-from-dom.html: + Updated to reflect new behavior of null returned when lock is pending. + * pointer-lock/pointerlockelement-null-when-pending-expected.txt: Added. + * pointer-lock/pointerlockelement-null-when-pending.html: Added. + New test specifically for testing null return when lock is pending. + 2012-09-05 Christophe Dumez [EFL][WK2] Provide implementation for TestRunner::pathToLocalResource() diff --git a/LayoutTests/pointer-lock/locked-element-iframe-removed-from-dom-expected.txt b/LayoutTests/pointer-lock/locked-element-iframe-removed-from-dom-expected.txt index 182518694e08ea69d5adeaf25ecb8a403f39faee..c9da65caa8fb21f73e9dbd433b436b3d9543b3e3 100644 --- a/LayoutTests/pointer-lock/locked-element-iframe-removed-from-dom-expected.txt +++ b/LayoutTests/pointer-lock/locked-element-iframe-removed-from-dom-expected.txt @@ -10,7 +10,7 @@ PASS targetIframe1.contentDocument.webkitPointerLockElement is targetDiv1 PASS targetDiv1.parentElement.parentElement is targetIframe1.contentDocument.body Remove iframe & immediately lock target2. (main document handler) Remove iframe & immediately lock target2. (iframe handler) -PASS document.webkitPointerLockElement is targetDiv2 +PASS document.webkitPointerLockElement is null PASS onwebkitpointerlockchange received after: Remove iframe & immediately lock target2. (main document handler) PASS successfullyParsed is true diff --git a/LayoutTests/pointer-lock/locked-element-iframe-removed-from-dom.html b/LayoutTests/pointer-lock/locked-element-iframe-removed-from-dom.html index d987d5138f4f1304ae0fa6c4237408980cbb8e33..01f59ee78c831f76c8f2844feec51204afdb36f3 100644 --- a/LayoutTests/pointer-lock/locked-element-iframe-removed-from-dom.html +++ b/LayoutTests/pointer-lock/locked-element-iframe-removed-from-dom.html @@ -38,7 +38,7 @@ expectNoEvents("Remove iframe & immediately lock target2. (iframe handler)", targetIframe1.contentDocument); targetIframe1.parentElement.removeChild(targetIframe1); targetDiv2.webkitRequestPointerLock(); - shouldBe("document.webkitPointerLockElement", "targetDiv2"); + shouldBe("document.webkitPointerLockElement", "null"); // doNextStep called by event handler. }, ]; diff --git a/LayoutTests/pointer-lock/pointerlockelement-null-when-pending-expected.txt b/LayoutTests/pointer-lock/pointerlockelement-null-when-pending-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..3cfbbfc76f35a04f7cabca4407926a194f006d22 --- /dev/null +++ b/LayoutTests/pointer-lock/pointerlockelement-null-when-pending-expected.txt @@ -0,0 +1,18 @@ +Test pointerLockElement is null when a lock is pending. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS document.webkitPointerLockElement is null + Lock. +PASS document.webkitPointerLockElement is null +PASS onwebkitpointerlockchange received after: Lock. +PASS document.webkitPointerLockElement is targetDiv1 + Unlock. +PASS document.webkitPointerLockElement is targetDiv1 +PASS onwebkitpointerlockchange received after: Unlock. +PASS document.webkitPointerLockElement is null +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/pointer-lock/pointerlockelement-null-when-pending.html b/LayoutTests/pointer-lock/pointerlockelement-null-when-pending.html new file mode 100644 index 0000000000000000000000000000000000000000..79342865e7f675e3f5758c48f9bbd8bde6194720 --- /dev/null +++ b/LayoutTests/pointer-lock/pointerlockelement-null-when-pending.html @@ -0,0 +1,46 @@ + + + + + + + +
+
+
+ + + + diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 74218156c035e5cd54949fee581eae0d9738a761..a603afb43b8adfa0808b7a7d56be73de0566d0c9 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,33 @@ +2012-09-05 Vincent Scheib + + webkitPointerLockElement returns null when pointer lock request is pending. + https://bugs.webkit.org/show_bug.cgi?id=91186 + + Reviewed by Dimitri Glazkov. + + Script should wait for a pointerlockchange event before detecting + if it has acquired lock. However, if a script attempted to poll + pointerLockElement it could be confused when lock was still pending. + This change ensures that if lock is not yet acquired then + pointerLockElement will return null. + + Test: pointer-lock/pointerlockelement-null-when-pending.html + + * dom/Document.cpp: + (WebCore::Document::webkitPointerLockElement): + * page/PointerLockController.cpp: + (WebCore::PointerLockController::requestPointerLock): + (WebCore::PointerLockController::elementRemoved): + (WebCore::PointerLockController::documentDetached): + (WebCore::PointerLockController::lockPending): + (WebCore): + (WebCore::PointerLockController::didAcquirePointerLock): + (WebCore::PointerLockController::didNotAcquirePointerLock): + (WebCore::PointerLockController::didLosePointerLock): + (WebCore::PointerLockController::clearElement): + * page/PointerLockController.h: + (PointerLockController): + 2012-09-05 Sami Kyostila [chromium] Wire up scrollable sublayers in ScrollingCoordinatorChromium diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp index 1da1c81632265d5f112feead72534a4e74d19397..49d00c5babf05341afb5b560da80043abe8a773b 100644 --- a/Source/WebCore/dom/Document.cpp +++ b/Source/WebCore/dom/Document.cpp @@ -5872,7 +5872,7 @@ void Document::webkitExitPointerLock() Element* Document::webkitPointerLockElement() const { - if (!page()) + if (!page() || page()->pointerLockController()->lockPending()) return 0; if (Element* element = page()->pointerLockController()->element()) { if (element->document() == this) diff --git a/Source/WebCore/page/PointerLockController.cpp b/Source/WebCore/page/PointerLockController.cpp index ad796096251026a038b321780714a0d94ff4e5f3..ddbb84fd0190bff1651c653e6779c9af9c99a7a6 100644 --- a/Source/WebCore/page/PointerLockController.cpp +++ b/Source/WebCore/page/PointerLockController.cpp @@ -62,6 +62,7 @@ void PointerLockController::requestPointerLock(Element* target) enqueueEvent(eventNames().webkitpointerlockchangeEvent, target); m_element = target; } else if (m_page->chrome()->client()->requestPointerLock()) { + m_lockPending = true; m_element = target; } else { enqueueEvent(eventNames().webkitpointerlockerrorEvent, target); @@ -79,7 +80,7 @@ void PointerLockController::elementRemoved(Element* element) m_documentOfRemovedElementWhileWaitingForUnlock = m_element->document(); // Set element null immediately to block any future interaction with it // including mouse events received before the unlock completes. - m_element = 0; + clearElement(); requestPointerUnlock(); } } @@ -87,11 +88,16 @@ void PointerLockController::elementRemoved(Element* element) void PointerLockController::documentDetached(Document* document) { if (m_element && m_element->document() == document) { - m_element = 0; + clearElement(); requestPointerUnlock(); } } +bool PointerLockController::lockPending() const +{ + return m_lockPending; +} + Element* PointerLockController::element() const { return m_element.get(); @@ -100,18 +106,19 @@ Element* PointerLockController::element() const void PointerLockController::didAcquirePointerLock() { enqueueEvent(eventNames().webkitpointerlockchangeEvent, m_element.get()); + m_lockPending = false; } void PointerLockController::didNotAcquirePointerLock() { enqueueEvent(eventNames().webkitpointerlockerrorEvent, m_element.get()); - m_element = 0; + clearElement(); } void PointerLockController::didLosePointerLock() { enqueueEvent(eventNames().webkitpointerlockchangeEvent, m_element ? m_element->document() : m_documentOfRemovedElementWhileWaitingForUnlock.get()); - m_element = 0; + clearElement(); m_documentOfRemovedElementWhileWaitingForUnlock = 0; } @@ -127,6 +134,12 @@ void PointerLockController::dispatchLockedMouseEvent(const PlatformMouseEvent& e m_element->dispatchMouseEvent(event, eventNames().clickEvent, event.clickCount()); } +void PointerLockController::clearElement() +{ + m_lockPending = false; + m_element = 0; +} + void PointerLockController::enqueueEvent(const AtomicString& type, Element* element) { if (element) diff --git a/Source/WebCore/page/PointerLockController.h b/Source/WebCore/page/PointerLockController.h index a942f9368c438cc6c2713435415b6a04eb9ae723..c820754ae1a4ecc53d116a8d421db4f66c44e374 100644 --- a/Source/WebCore/page/PointerLockController.h +++ b/Source/WebCore/page/PointerLockController.h @@ -48,6 +48,7 @@ public: void requestPointerUnlock(); void elementRemoved(Element*); void documentDetached(Document*); + bool lockPending() const; Element* element() const; void didAcquirePointerLock(); @@ -57,9 +58,11 @@ public: private: explicit PointerLockController(Page*); + void clearElement(); void enqueueEvent(const AtomicString& type, Element*); void enqueueEvent(const AtomicString& type, Document*); Page* m_page; + bool m_lockPending; RefPtr m_element; RefPtr m_documentOfRemovedElementWhileWaitingForUnlock; };