Commit 6ed01762 authored by scheib@chromium.org's avatar scheib@chromium.org

Add new Pointer Lock spec attribute webkitPointerLockElement.

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

Source/WebCore:

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

New attribute webkitPointerLockElement added. Follow up patches
will remove the previous isLocked attribute. Tests updated to use
the new attribute.

* bindings/generic/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::webkitPointerLockElementEnabled):
* dom/Document.cpp:
(WebCore):
(WebCore::Document::webkitPointerLockElement):
* dom/Document.h:
(Document):
* dom/Document.idl:
* page/PointerLockController.h:
(WebCore::PointerLockController::element):

Tools:

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

New attribute webkitPointerLockElement added. Follow up patches
will remove the previous isLocked attribute. Tests updated to use
the new attribute.

WebViewHost logic required modification to correctly repond to
a lock, unlock, pointerLockElement call series. Specifically,
unlocking must be queued after a lock command is issued always
as the lock state may not be set yet with a lock request in flight.

* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::requestPointerUnlock): Always post didLosePointerLock task.
(WebViewHost::didLosePointerLock): Signal didLosePointerLock only if pointer was locked.

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

New attribute webkitPointerLockElement added. Follow up patches
will remove the previous isLocked attribute. Tests updated to use
the new attribute.

Reviewed by Dimitri Glazkov.

* pointer-lock/lock-already-locked-expected.txt:
* pointer-lock/lock-already-locked.html:
* pointer-lock/pointer-lock-api-expected.txt:
* pointer-lock/pointer-lock-api.html:
* pointer-lock/pointerlocklost-event-expected.txt:
* pointer-lock/pointerlocklost-event.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@120031 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 14e896e6
2012-06-11 Vincent Scheib <scheib@chromium.org>
Add new Pointer Lock spec attribute webkitPointerLockElement.
https://bugs.webkit.org/show_bug.cgi?id=88799
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
New attribute webkitPointerLockElement added. Follow up patches
will remove the previous isLocked attribute. Tests updated to use
the new attribute.
Reviewed by Dimitri Glazkov.
* pointer-lock/lock-already-locked-expected.txt:
* pointer-lock/lock-already-locked.html:
* pointer-lock/pointer-lock-api-expected.txt:
* pointer-lock/pointer-lock-api.html:
* pointer-lock/pointerlocklost-event-expected.txt:
* pointer-lock/pointerlocklost-event.html:
2012-06-11 Dominic Cooney <dominicc@chromium.org>
[Chromium] Unreviewed: http/tests/xmlhttprequest/origin-exact-matching.html is timing out on XP about half the time
......
......@@ -7,14 +7,18 @@ PASS navigator.webkitPointer.isLocked is false
PASS Lock target1 succeeded.
PASS navigator.webkitPointer.isLocked is true
PASS document.onwebkitpointerlockchange event received.
PASS document.webkitPointerLockElement is targetdiv1
PASS Lock target1 succeeded again.
PASS navigator.webkitPointer.isLocked is true
PASS document.onwebkitpointerlockchange event received.
PASS document.webkitPointerLockElement is targetdiv1
PASS expectTarget1Unlock is true
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
......
......@@ -16,8 +16,12 @@
targetdiv2 = document.getElementById("target2");
// Expect change event only for all transitions below.
document.onwebkitpointerlockchange =
function () { testPassed("document.onwebkitpointerlockchange event received."); };
expectedTargetToBeLockedString = "";
document.onwebkitpointerlockchange = function ()
{
testPassed("document.onwebkitpointerlockchange event received.");
shouldBe("document.webkitPointerLockElement", expectedTargetToBeLockedString);
};
document.onwebkitpointerlockerror =
function () { testFailed("document.onwebkitpointerlockerror event received."); finishJSTest(); };
......@@ -45,6 +49,7 @@
testFailed("Lock failed.");
finishJSTest();
});
expectedTargetToBeLockedString = "targetdiv1";
},
function () {
navigator.webkitPointer.lock(targetdiv1,
......@@ -57,7 +62,7 @@
testFailed("Lock failed.");
finishJSTest();
});
expectedTargetToBeLockedString = "targetdiv1";
},
function () {
expectTarget1Unlock = true;
......@@ -71,7 +76,7 @@
testFailed("Lock failed.");
finishJSTest();
});
expectedTargetToBeLockedString = "targetdiv2";
},
finishJSTest
];
......
Basic API existence test for Pointer Lock.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS navigator.webkitPointer is defined.
PASS typeof navigator.webkitPointer.isLocked is 'boolean'
PASS navigator.webkitPointer.isLocked is false
PASS navigator.webkitPointer.lock() threw exception TypeError: Not enough arguments.
PASS navigator.webkitPointer.lock(document) is undefined
PASS navigator.webkitPointer.lock(document.body) is undefined
PASS navigator.webkitPointer.unlock() is undefined
PASS document.onwebkitpointerlockchange is defined.
PASS document.onwebkitpointerlockerror is defined.
PASS document.webkitPointerLockElement is null
PASS successfullyParsed is true
TEST COMPLETE
doNextStep for manual testing
......@@ -4,14 +4,43 @@
<script src="../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<button onclick="doNextStep('manual');">doNextStep for manual testing</button>
<script>
shouldBeDefined("navigator.webkitPointer");
shouldEvaluateTo("navigator.webkitPointer.isLocked", false);
shouldThrow("navigator.webkitPointer.lock()", "'TypeError: Not enough arguments'");
shouldEvaluateTo("navigator.webkitPointer.lock(document)", "undefined");
shouldEvaluateTo("navigator.webkitPointer.unlock()", "undefined");
shouldBeDefined("document.onwebkitpointerlockchange");
shouldBeDefined("document.onwebkitpointerlockerror");
description("Basic API existence test for Pointer Lock.")
window.jsTestIsAsync = true;
currentStep = 0;
function doNextStep(manual)
{
if (!window.layoutTestController && !manual)
return;
if (currentStep < todo.length)
setTimeout(function () { todo[currentStep++](); }, 0);
else if (currentStep++ == todo.length)
setTimeout(function () { finishJSTest(); }, 0);
}
todo = [
function () {
shouldBeDefined("navigator.webkitPointer");
shouldEvaluateTo("navigator.webkitPointer.isLocked", false);
shouldThrow("navigator.webkitPointer.lock()", "'TypeError: Not enough arguments'");
shouldEvaluateTo("navigator.webkitPointer.lock(document.body)", "undefined");
// Exit call stack to allow lock to take effect.
doNextStep();
},
function () {
shouldEvaluateTo("navigator.webkitPointer.unlock()", "undefined");
// Exit call stack to allow unlock to take effect.
doNextStep();
},
function () {
shouldBeDefined("document.onwebkitpointerlockchange");
shouldBeDefined("document.onwebkitpointerlockerror");
shouldEvaluateTo("document.webkitPointerLockElement", null);
doNextStep();
},
];
doNextStep();
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
......
......@@ -5,14 +5,17 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS window.layoutTestController is defined.
PASS navigator.webkitPointer.isLocked is true
PASS document.webkitPointerLockElement is targetdiv
JavaScript initiated unlock.
PASS webkitpointerlocklost handler call 0
PASS webkitpointerlocklost handler call 1
PASS All expected webkitpointerlocklost events received.
PASS onwebkitpointerlockchange received.
PASS All expected onwebkitpointerlockchange events received.
PASS document.webkitPointerLockElement is null
PASS navigator.webkitPointer.isLocked is false
PASS navigator.webkitPointer.isLocked is true
PASS document.webkitPointerLockElement is targetdiv
Host initiated unlock.
PASS webkitpointerlocklost handler call 0
PASS webkitpointerlocklost handler call 1
......@@ -20,6 +23,7 @@ PASS All expected webkitpointerlocklost events received.
PASS onwebkitpointerlockchange received.
PASS All expected onwebkitpointerlockchange events received.
PASS navigator.webkitPointer.isLocked is false
PASS document.webkitPointerLockElement is null
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -65,12 +65,14 @@
});
},
function () {
shouldBe("document.webkitPointerLockElement", "targetdiv");
debug("JavaScript initiated unlock.")
locklostreceipts = 0;
navigator.webkitPointer.unlock();
},
function () {
// locklostHandler will catch unlocks and call doNextStep to bring us here.
shouldBe("document.webkitPointerLockElement", "null");
shouldBe("navigator.webkitPointer.isLocked", "false");
doNextStep();
},
......@@ -86,6 +88,7 @@
});
},
function () {
shouldBe("document.webkitPointerLockElement", "targetdiv");
debug("Host initiated unlock.")
lockchangeToUnlockedReceipts = 0;
locklostreceipts = 0;
......@@ -94,6 +97,7 @@
function () {
// locklostHandler will catch unlocks and call doNextStep to bring us here.
shouldBe("navigator.webkitPointer.isLocked", "false");
shouldBe("document.webkitPointerLockElement", "null");
doNextStep();
},
finishJSTest
......
2012-06-11 Vincent Scheib <scheib@chromium.org>
Add new Pointer Lock spec attribute webkitPointerLockElement.
https://bugs.webkit.org/show_bug.cgi?id=88799
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
New attribute webkitPointerLockElement added. Follow up patches
will remove the previous isLocked attribute. Tests updated to use
the new attribute.
* bindings/generic/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::webkitPointerLockElementEnabled):
* dom/Document.cpp:
(WebCore):
(WebCore::Document::webkitPointerLockElement):
* dom/Document.h:
(Document):
* dom/Document.idl:
* page/PointerLockController.h:
(WebCore::PointerLockController::element):
2012-06-11 Vincent Scheib <scheib@chromium.org>
Consolidate Pointer Lock runtime enabled flags to just one.
......
......@@ -120,6 +120,7 @@
#include "PageTransitionEvent.h"
#include "PlatformKeyboardEvent.h"
#include "PluginDocument.h"
#include "PointerLockController.h"
#include "PopStateEvent.h"
#include "ProcessingInstruction.h"
#include "RegisteredEventListener.h"
......@@ -5731,6 +5732,13 @@ void Document::addDocumentToFullScreenChangeEventQueue(Document* doc)
}
#endif
#if ENABLE(POINTER_LOCK)
Element* Document::webkitPointerLockElement() const
{
return page() ? page()->pointerLockController()->element() : 0;
}
#endif
void Document::decrementLoadEventDelayCount()
{
ASSERT(m_loadEventDelayCount);
......
......@@ -1064,6 +1064,10 @@ public:
void webkitExitFullscreen();
#endif
#if ENABLE(POINTER_LOCK)
Element* webkitPointerLockElement() const;
#endif
// Used to allow element that loads data without going through a FrameLoader to delay the 'load' event.
void incrementLoadEventDelayCount() { ++m_loadEventDelayCount; }
void decrementLoadEventDelayCount();
......
......@@ -257,6 +257,8 @@ module core {
[V8EnabledAtRuntime] void webkitExitFullscreen();
#endif
readonly attribute [Conditional=POINTER_LOCK, V8EnabledAtRuntime=pointerLock] Element webkitPointerLockElement;
#if defined(ENABLE_CSS_REGIONS) && ENABLE_CSS_REGIONS
WebKitNamedFlow webkitGetFlowByName(in DOMString name);
#endif
......
......@@ -91,6 +91,11 @@ bool PointerLockController::isLocked()
return m_page->chrome()->client()->isPointerLocked();
}
Element* PointerLockController::element() const
{
return m_element.get();
}
void PointerLockController::didAcquirePointerLock()
{
// FIXME: Keep enqueueEvent usage. (https://bugs.webkit.org/show_bug.cgi?id=84402)
......
......@@ -46,6 +46,7 @@ public:
void requestPointerLock(Element* target, PassRefPtr<VoidCallback> successCallback, PassRefPtr<VoidCallback> failureCallback);
void requestPointerUnlock();
bool isLocked();
Element* element() const;
void didAcquirePointerLock();
void didNotAcquirePointerLock();
......
2012-06-11 Vincent Scheib <scheib@chromium.org>
Add new Pointer Lock spec attribute webkitPointerLockElement.
https://bugs.webkit.org/show_bug.cgi?id=88799
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
New attribute webkitPointerLockElement added. Follow up patches
will remove the previous isLocked attribute. Tests updated to use
the new attribute.
WebViewHost logic required modification to correctly repond to
a lock, unlock, pointerLockElement call series. Specifically,
unlocking must be queued after a lock command is issued always
as the lock state may not be set yet with a lock request in flight.
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::requestPointerUnlock): Always post didLosePointerLock task.
(WebViewHost::didLosePointerLock): Signal didLosePointerLock only if pointer was locked.
2012-06-11 Alexis Menard <alexis.menard@openbossa.org>
[CSS3 Backgrounds and Borders] Protect box-decoration-break behind a feature flag.
......
......@@ -845,8 +845,7 @@ bool WebViewHost::requestPointerLock()
void WebViewHost::requestPointerUnlock()
{
if (m_pointerLocked)
postDelayedTask(new HostMethodTask(this, &WebViewHost::didLosePointerLock), 0);
postDelayedTask(new HostMethodTask(this, &WebViewHost::didLosePointerLock), 0);
}
bool WebViewHost::isPointerLocked()
......@@ -869,9 +868,10 @@ void WebViewHost::didNotAcquirePointerLock()
void WebViewHost::didLosePointerLock()
{
ASSERT(m_pointerLocked);
bool wasLocked = m_pointerLocked;
m_pointerLocked = false;
webWidget()->didLosePointerLock();
if (wasLocked)
webWidget()->didLosePointerLock();
}
#endif
......
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