- Revision
- 211249
- Author
- commit-qu...@webkit.org
- Date
- 2017-01-26 18:17:25 -0800 (Thu, 26 Jan 2017)
Log Message
Page should be able to request pointer lock without user gesture if it relinquished it without a user gesture
https://bugs.webkit.org/show_bug.cgi?id=167126
Patch by Jeremy Jones <jere...@apple.com> on 2017-01-26
Reviewed by Jon Lee.
Source/WebCore:
Enabled pointer-lock/locked-element-removed-from-dom.html for WK2.
Not enable in WK1 because of https://bugs.webkit.org/show_bug.cgi?id=167127
This change allows a page to lock the pointer again without a user gesture if it was unlocked by
the page and not by the user. See https://www.w3.org/TR/2016/REC-pointerlock-20161027/ 5.1 Methods
* page/PointerLockController.cpp:
When a document acquires pointer lock with a user gesture, that document is allowed to request pointer lock again
until the user takes an action to end pointer lock. We know it is a user action because user actions always
call requestPointerUnlockAndForceCursorVisible().
When the page requests a pointer unlock (via requestPointerUnlock), that document is allowed to continue to relock
the page. This continues until there is either an unlock request form the user
via requestPointerUnlockAndForceCursorVisible or a didLosePointerLock without a pointer unlock request.
(WebCore::PointerLockController::PointerLockController):
(WebCore::PointerLockController::requestPointerLock):
(WebCore::PointerLockController::requestPointerUnlock):
(WebCore::PointerLockController::requestPointerUnlockAndForceCursorVisible):
(WebCore::PointerLockController::elementRemoved):
(WebCore::PointerLockController::documentDetached):
(WebCore::PointerLockController::didAcquirePointerLock):
(WebCore::PointerLockController::didLosePointerLock):
(WebCore::PointerLockController::clearElement):
* page/PointerLockController.h:
LayoutTests:
Enable pointer-lock/locked-element-removed-from-dom.html for WK2 by enabling for Mac and disabling for WK1.
Not enable in WK1 becuase of https://bugs.webkit.org/show_bug.cgi?id=167127
* platform/mac-wk1/TestExpectations:
* platform/mac/TestExpectations:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (211248 => 211249)
--- trunk/LayoutTests/ChangeLog 2017-01-27 02:00:17 UTC (rev 211248)
+++ trunk/LayoutTests/ChangeLog 2017-01-27 02:17:25 UTC (rev 211249)
@@ -1,3 +1,16 @@
+2017-01-26 Jeremy Jones <jere...@apple.com>
+
+ Page should be able to request pointer lock without user gesture if it relinquished it without a user gesture
+ https://bugs.webkit.org/show_bug.cgi?id=167126
+
+ Reviewed by Jon Lee.
+
+ Enable pointer-lock/locked-element-removed-from-dom.html for WK2 by enabling for Mac and disabling for WK1.
+ Not enable in WK1 becuase of https://bugs.webkit.org/show_bug.cgi?id=167127
+
+ * platform/mac-wk1/TestExpectations:
+ * platform/mac/TestExpectations:
+
2017-01-26 Andy Estes <aes...@apple.com>
[QuickLook] REGRESSION (WebKit2): Requests are made to invalid x-apple-ql-id: URLs
Modified: trunk/LayoutTests/platform/mac/TestExpectations (211248 => 211249)
--- trunk/LayoutTests/platform/mac/TestExpectations 2017-01-27 02:00:17 UTC (rev 211248)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2017-01-27 02:17:25 UTC (rev 211249)
@@ -280,7 +280,6 @@
# Pointer Lock can only check some of the API at the moment.
pointer-lock/bug90391-move-then-window-open-crash.html
pointer-lock/locked-element-iframe-removed-from-dom.html
-pointer-lock/locked-element-removed-from-dom.html
pointer-lock/pointerlockchange-event-on-lock-lost.html
pointer-lock/pointerlockchange-pointerlockerror-events.html
pointer-lock/pointerlockelement-null-when-pending.html
Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (211248 => 211249)
--- trunk/LayoutTests/platform/mac-wk1/TestExpectations 2017-01-27 02:00:17 UTC (rev 211248)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations 2017-01-27 02:17:25 UTC (rev 211249)
@@ -313,3 +313,5 @@
webkit.org/b/167372 media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-styles.html [ Pass Failure ]
webkit.org/b/163598 media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-buttons-styles.html [ Pass Timeout ]
+
+webkit.org/b/167127 pointer-lock/locked-element-removed-from-dom.html
Modified: trunk/Source/WebCore/ChangeLog (211248 => 211249)
--- trunk/Source/WebCore/ChangeLog 2017-01-27 02:00:17 UTC (rev 211248)
+++ trunk/Source/WebCore/ChangeLog 2017-01-27 02:17:25 UTC (rev 211249)
@@ -1,3 +1,37 @@
+2017-01-26 Jeremy Jones <jere...@apple.com>
+
+ Page should be able to request pointer lock without user gesture if it relinquished it without a user gesture
+ https://bugs.webkit.org/show_bug.cgi?id=167126
+
+ Reviewed by Jon Lee.
+
+ Enabled pointer-lock/locked-element-removed-from-dom.html for WK2.
+ Not enable in WK1 because of https://bugs.webkit.org/show_bug.cgi?id=167127
+
+ This change allows a page to lock the pointer again without a user gesture if it was unlocked by
+ the page and not by the user. See https://www.w3.org/TR/2016/REC-pointerlock-20161027/ 5.1 Methods
+
+ * page/PointerLockController.cpp:
+
+ When a document acquires pointer lock with a user gesture, that document is allowed to request pointer lock again
+ until the user takes an action to end pointer lock. We know it is a user action because user actions always
+ call requestPointerUnlockAndForceCursorVisible().
+
+ When the page requests a pointer unlock (via requestPointerUnlock), that document is allowed to continue to relock
+ the page. This continues until there is either an unlock request form the user
+ via requestPointerUnlockAndForceCursorVisible or a didLosePointerLock without a pointer unlock request.
+
+ (WebCore::PointerLockController::PointerLockController):
+ (WebCore::PointerLockController::requestPointerLock):
+ (WebCore::PointerLockController::requestPointerUnlock):
+ (WebCore::PointerLockController::requestPointerUnlockAndForceCursorVisible):
+ (WebCore::PointerLockController::elementRemoved):
+ (WebCore::PointerLockController::documentDetached):
+ (WebCore::PointerLockController::didAcquirePointerLock):
+ (WebCore::PointerLockController::didLosePointerLock):
+ (WebCore::PointerLockController::clearElement):
+ * page/PointerLockController.h:
+
2017-01-26 Andy Estes <aes...@apple.com>
[QuickLook] REGRESSION (WebKit2): Requests are made to invalid x-apple-ql-id: URLs
Modified: trunk/Source/WebCore/page/PointerLockController.cpp (211248 => 211249)
--- trunk/Source/WebCore/page/PointerLockController.cpp 2017-01-27 02:00:17 UTC (rev 211248)
+++ trunk/Source/WebCore/page/PointerLockController.cpp 2017-01-27 02:17:25 UTC (rev 211249)
@@ -43,7 +43,6 @@
PointerLockController::PointerLockController(Page& page)
: m_page(page)
- , m_lockPending(false)
{
}
@@ -54,7 +53,7 @@
return;
}
- if (!ScriptController::processingUserGesture()) {
+ if (m_documentAllowedToRelockWithoutUserGesture != &target->document() && !ScriptController::processingUserGesture()) {
enqueueEvent(eventNames().pointerlockerrorEvent, target);
return;
}
@@ -77,8 +76,7 @@
m_lockPending = true;
m_element = target;
if (!m_page.chrome().client().requestPointerLock()) {
- m_element = nullptr;
- m_lockPending = false;
+ clearElement();
enqueueEvent(eventNames().pointerlockerrorEvent, target);
}
}
@@ -89,14 +87,18 @@
if (!m_element)
return;
+ m_unlockPending = true;
m_page.chrome().client().requestPointerUnlock();
}
void PointerLockController::requestPointerUnlockAndForceCursorVisible()
{
+ m_documentAllowedToRelockWithoutUserGesture = nullptr;
+
if (!m_element)
return;
+ m_unlockPending = true;
m_page.chrome().client().requestPointerUnlock();
m_forceCursorVisibleUponUnlock = true;
}
@@ -107,8 +109,8 @@
m_documentOfRemovedElementWhileWaitingForUnlock = &m_element->document();
// Set element null immediately to block any future interaction with it
// including mouse events received before the unlock completes.
+ requestPointerUnlock();
clearElement();
- requestPointerUnlock();
}
}
@@ -115,8 +117,9 @@
void PointerLockController::documentDetached(Document& document)
{
if (m_element && &m_element->document() == &document) {
+ m_documentOfRemovedElementWhileWaitingForUnlock = &m_element->document();
+ requestPointerUnlock();
clearElement();
- requestPointerUnlockAndForceCursorVisible();
}
}
@@ -139,6 +142,8 @@
{
enqueueEvent(eventNames().pointerlockchangeEvent, m_element.get());
m_lockPending = false;
+ m_forceCursorVisibleUponUnlock = false;
+ m_documentAllowedToRelockWithoutUserGesture = &m_element->document();
}
void PointerLockController::didNotAcquirePointerLock()
@@ -145,12 +150,17 @@
{
enqueueEvent(eventNames().pointerlockerrorEvent, m_element.get());
clearElement();
+ m_unlockPending = false;
}
void PointerLockController::didLosePointerLock()
{
+ if (!m_unlockPending)
+ m_documentAllowedToRelockWithoutUserGesture = nullptr;
+
enqueueEvent(eventNames().pointerlockchangeEvent, m_element ? &m_element->document() : m_documentOfRemovedElementWhileWaitingForUnlock.get());
clearElement();
+ m_unlockPending = false;
m_documentOfRemovedElementWhileWaitingForUnlock = nullptr;
if (m_forceCursorVisibleUponUnlock) {
m_forceCursorVisibleUponUnlock = false;
Modified: trunk/Source/WebCore/page/PointerLockController.h (211248 => 211249)
--- trunk/Source/WebCore/page/PointerLockController.h 2017-01-27 02:00:17 UTC (rev 211248)
+++ trunk/Source/WebCore/page/PointerLockController.h 2017-01-27 02:17:25 UTC (rev 211249)
@@ -64,10 +64,12 @@
void enqueueEvent(const AtomicString& type, Element*);
void enqueueEvent(const AtomicString& type, Document*);
Page& m_page;
- bool m_lockPending;
+ bool m_lockPending { false };
+ bool m_unlockPending { false };
bool m_forceCursorVisibleUponUnlock { false };
RefPtr<Element> m_element;
RefPtr<Document> m_documentOfRemovedElementWhileWaitingForUnlock;
+ RefPtr<Document> m_documentAllowedToRelockWithoutUserGesture;
};
} // namespace WebCore