Commit 94681642 authored by scheib@chromium.org's avatar scheib@chromium.org

Remove duplicate webkitpointerlockchange events when unlocking.

https://bugs.webkit.org/show_bug.cgi?id=88917

Reviewed by Dimitri Glazkov.

Source/WebCore:

Subsequent patches adding the new API for entering and exiting
pointer lock would be burdened by handling multiple change events
when the lock target is changed. This change introduces
temporary code to suppress duplicate change events.

Existing tests simplified by removing the duplicate change events.

* page/PointerLockController.cpp:
(WebCore::PointerLockController::requestPointerLock):
(WebCore::PointerLockController::didLosePointerLock):
* page/PointerLockController.h:
(PointerLockController):

LayoutTests:

Part of a series of refactoring changes to update pointer lock API to
the fullscreen locking style. https://bugs.webkit.org/show_bug.cgi?id=84402

Tests simplified by removing the duplicate change events.

* pointer-lock/lock-already-locked-expected.txt:
* pointer-lock/pointerlockchange-pointerlockerror-events-expected.txt:
* pointer-lock/pointerlockchange-pointerlockerror-events.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@120248 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 90fde9f6
2012-06-12 Vincent Scheib <scheib@chromium.org>
Remove duplicate webkitpointerlockchange events when unlocking.
https://bugs.webkit.org/show_bug.cgi?id=88917
Reviewed by Dimitri Glazkov.
Part of a series of refactoring changes to update pointer lock API to
the fullscreen locking style. https://bugs.webkit.org/show_bug.cgi?id=84402
Tests simplified by removing the duplicate change events.
* pointer-lock/lock-already-locked-expected.txt:
* pointer-lock/pointerlockchange-pointerlockerror-events-expected.txt:
* pointer-lock/pointerlockchange-pointerlockerror-events.html:
2012-06-12 Filip Pizlo <fpizlo@apple.com>
DFG should be able to set watchpoints on global variables
......
......@@ -17,8 +17,6 @@ PASS Lock target2 succeeded.
PASS navigator.webkitPointer.isLocked is true
PASS document.onwebkitpointerlockchange event received.
PASS document.webkitPointerLockElement is targetdiv2
PASS document.onwebkitpointerlockchange event received.
PASS document.webkitPointerLockElement is targetdiv2
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -11,7 +11,6 @@ PASS onwebkitpointerlockchange received after: Unlock again.
Lock targetDiv1 again.
PASS onwebkitpointerlockchange received after: Lock targetDiv1 again.
Lock targetDiv2.
PASS onwebkitpointerlockchange received after: Lock targetDiv2.
PASS onwebkitpointerlockchange received after: Lock targetDiv2.
Lock targetDiv2 again.
PASS onwebkitpointerlockchange received after: Lock targetDiv2 again.
......@@ -19,13 +18,11 @@ PASS onwebkitpointerlockchange received after: Lock targetDiv2 again.
Lock targetIframe1.
Lock targetIframe1 (handler for iframe1).
PASS onwebkitpointerlockchange received after: Lock targetIframe1 (handler for iframe1).
PASS onwebkitpointerlockchange received after: Lock targetIframe1.
PASS onwebkitpointerlockchange received after: Lock targetIframe1.
Lock targetIframe2.
Lock targetIframe2 (handler for iframe1).
Lock targetIframe2 (handler for iframe2).
PASS onwebkitpointerlockchange received after: Lock targetIframe2 (handler for iframe2).
PASS onwebkitpointerlockchange received after: Lock targetIframe2 (handler for iframe1).
PASS onwebkitpointerlockchange received after: Lock targetIframe2 (handler for iframe1).
Unlock targetIframe2.
Unlock targetIframe2 (handler for iframe1).
......
......@@ -37,20 +37,18 @@
};
};
function expectOnlyChangeEvent(message, expectedCalls, targetDocument) {
function expectOnlyChangeEvent(message, targetDocument) {
debug(" " + message);
expectedCalls = expectedCalls !== undefined ? expectedCalls : 1;
targetDocument = targetDocument !== undefined ? targetDocument : document;
eventExpected("onwebkitpointerlockchange", message, expectedCalls, targetDocument);
eventExpected("onwebkitpointerlockchange", message, 1, targetDocument);
eventExpected("onwebkitpointerlockerror", message, 0, targetDocument);
};
function expectOnlyErrorEvent(message, expectedCalls, targetDocument) {
function expectOnlyErrorEvent(message, targetDocument) {
debug(" " + message);
expectedCalls = expectedCalls !== undefined ? expectedCalls : 1;
targetDocument = targetDocument !== undefined ? targetDocument : document;
eventExpected("onwebkitpointerlockchange", message, 0, targetDocument);
eventExpected("onwebkitpointerlockerror", message, expectedCalls, targetDocument);
eventExpected("onwebkitpointerlockerror", message, 1, targetDocument);
};
function expectNoEvents(message, targetDocument) {
......@@ -89,12 +87,7 @@
navigator.webkitPointer.lock(targetDiv1);
},
function () {
// FIXME: Only 1 change event should be expected.
// But, we will see 2 until we remove the old code for
// pointerlocklost and remove the call to didLosePointerLock
// made in PointerLockController::requestPointerLock.
// (https://bugs.webkit.org/show_bug.cgi?id=84402)
expectOnlyChangeEvent("Lock targetDiv2.", 2);
expectOnlyChangeEvent("Lock targetDiv2.");
navigator.webkitPointer.lock(targetDiv2);
},
function () {
......@@ -115,13 +108,8 @@
targetIframe2.onload = function () { doNextStep(); }
},
function () {
// FIXME: Only 1 change event should be expected.
// But, we will see 2 until we remove the old code for
// pointerlocklost and remove the call to didLosePointerLock
// made in PointerLockController::requestPointerLock.
// (https://bugs.webkit.org/show_bug.cgi?id=84402)
expectOnlyChangeEvent("Lock targetIframe1.", 2);
expectOnlyChangeEvent("Lock targetIframe1 (handler for iframe1).", 1, targetIframe1.contentDocument);
expectOnlyChangeEvent("Lock targetIframe1.");
expectOnlyChangeEvent("Lock targetIframe1 (handler for iframe1).", targetIframe1.contentDocument);
navigator.webkitPointer.lock(targetIframe1.contentDocument.body);
},
function () {
......@@ -129,13 +117,8 @@
},
function () {
expectNoEvents("Lock targetIframe2.");
// FIXME: Only 1 change event should be expected.
// But, we will see 2 until we remove the old code for
// pointerlocklost and remove the call to didLosePointerLock
// made in PointerLockController::requestPointerLock.
// (https://bugs.webkit.org/show_bug.cgi?id=84402)
expectOnlyChangeEvent("Lock targetIframe2 (handler for iframe1).", 2, targetIframe1.contentDocument);
expectOnlyChangeEvent("Lock targetIframe2 (handler for iframe2).", 1, targetIframe2.contentDocument);
expectOnlyChangeEvent("Lock targetIframe2 (handler for iframe1).", targetIframe1.contentDocument);
expectOnlyChangeEvent("Lock targetIframe2 (handler for iframe2).", targetIframe2.contentDocument);
navigator.webkitPointer.lock(targetIframe2.contentDocument.body);
},
function () {
......@@ -144,7 +127,7 @@
function () {
expectNoEvents("Unlock targetIframe2.");
expectNoEvents("Unlock targetIframe2 (handler for iframe1).", targetIframe1.contentDocument);
expectOnlyChangeEvent("Unlock targetIframe2 (handler for iframe2).", 1, targetIframe2.contentDocument);
expectOnlyChangeEvent("Unlock targetIframe2 (handler for iframe2).", targetIframe2.contentDocument);
navigator.webkitPointer.unlock();
},
function () {
......
2012-06-12 Vincent Scheib <scheib@chromium.org>
Remove duplicate webkitpointerlockchange events when unlocking.
https://bugs.webkit.org/show_bug.cgi?id=88917
Reviewed by Dimitri Glazkov.
Subsequent patches adding the new API for entering and exiting
pointer lock would be burdened by handling multiple change events
when the lock target is changed. This change introduces
temporary code to suppress duplicate change events.
Existing tests simplified by removing the duplicate change events.
* page/PointerLockController.cpp:
(WebCore::PointerLockController::requestPointerLock):
(WebCore::PointerLockController::didLosePointerLock):
* page/PointerLockController.h:
(PointerLockController):
2012-06-13 Silvia Pfeiffer <silviapf@chromium.org>
Update range sliders rendering for volume and playback position of new Chrome video controls.
......
......@@ -62,7 +62,7 @@ void PointerLockController::requestPointerLock(Element* target, PassRefPtr<VoidC
if (successCallback)
successCallback->handleEvent();
} else {
didLosePointerLock();
didLosePointerLock(false);
m_element = target;
if (successCallback)
successCallback->handleEvent();
......@@ -127,10 +127,11 @@ void PointerLockController::didNotAcquirePointerLock()
callbackToIssue->handleEvent();
}
void PointerLockController::didLosePointerLock()
void PointerLockController::didLosePointerLock(bool sendChangeEvent)
{
// FIXME: Keep enqueueEvent usage. (https://bugs.webkit.org/show_bug.cgi?id=84402)
enqueueEvent(eventNames().webkitpointerlockchangeEvent, m_element.get());
if (sendChangeEvent)
enqueueEvent(eventNames().webkitpointerlockchangeEvent, m_element.get());
// FIXME: Remove callback usage. (https://bugs.webkit.org/show_bug.cgi?id=84402)
RefPtr<Element> elementToNotify(m_element);
......
......@@ -50,7 +50,7 @@ public:
void didAcquirePointerLock();
void didNotAcquirePointerLock();
void didLosePointerLock();
void didLosePointerLock(bool sendChangeEvent = true); // FIXME: Remove sendChangeEvent parameter when removing old API. (https://bugs.webkit.org/show_bug.cgi?id=84402)
void dispatchLockedMouseEvent(const PlatformMouseEvent&, const AtomicString& eventType);
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment