Diff
Modified: trunk/LayoutTests/ChangeLog (209647 => 209648)
--- trunk/LayoutTests/ChangeLog 2016-12-10 04:27:26 UTC (rev 209647)
+++ trunk/LayoutTests/ChangeLog 2016-12-10 05:18:33 UTC (rev 209648)
@@ -1,3 +1,20 @@
+2016-12-09 Ryosuke Niwa <[email protected]>
+
+ document.pointerLockElement exposes a node inside a shadow tree
+ https://bugs.webkit.org/show_bug.cgi?id=165702
+
+ Reviewed by Simon Fraser.
+
+ Added tests for pointer locks inside a shadow root as well as one assigned to a slot.
+
+ * fast/shadow-dom/pointerlockelement-in-shadow-tree-expected.txt: Added.
+ * fast/shadow-dom/pointerlockelement-in-shadow-tree.html: Added.
+ * fast/shadow-dom/pointerlockelement-in-slot-expected.txt: Added.
+ * fast/shadow-dom/pointerlockelement-in-slot.html: Added.
+ * platform/efl/TestExpectations:
+ * platform/gtk/TestExpectations:
+ * platform/ios-simulator/TestExpectations:
+
2016-12-09 Daniel Bates <[email protected]>
Add reflected nonce attribute to HTML Link element IDL
Added: trunk/LayoutTests/fast/shadow-dom/pointerlockelement-in-shadow-tree-expected.txt (0 => 209648)
--- trunk/LayoutTests/fast/shadow-dom/pointerlockelement-in-shadow-tree-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/pointerlockelement-in-shadow-tree-expected.txt 2016-12-10 05:18:33 UTC (rev 209648)
@@ -0,0 +1,16 @@
+Test pointerLockElement is the node in the same tree as the context object.
+To manually test, click on "Click here" below.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.pointerLockElement is null
+PASS shadowRoot.pointerLockElement is null
+PASS document.pointerLockElement is shadowHost
+PASS shadowRoot.pointerLockElement is target
+PASS document.pointerLockElement is null
+PASS shadowRoot.pointerLockElement is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/shadow-dom/pointerlockelement-in-shadow-tree.html (0 => 209648)
--- trunk/LayoutTests/fast/shadow-dom/pointerlockelement-in-shadow-tree.html (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/pointerlockelement-in-shadow-tree.html 2016-12-10 05:18:33 UTC (rev 209648)
@@ -0,0 +1,53 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="host"></div>
+<script>
+description('Test pointerLockElement is the node in the same tree as the context object.<br>'
+ + 'To manually test, click on "Click here" below.');
+window.jsTestIsAsync = true;
+
+shadowHost = document.getElementById('host');
+shadowRoot = shadowHost.attachShadow({mode: 'closed'});
+shadowRoot.innerHTML = '<span tabindex=0>Click here</span>';
+target = shadowRoot.firstChild;
+
+target._onclick_ = function () {
+ shouldBe("document.pointerLockElement", "null");
+ shouldBe("shadowRoot.pointerLockElement", "null");
+ target.requestPointerLock();
+}
+
+function clickElement(element) {
+ eventSender.mouseMoveTo(element.offsetLeft + 5, element.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+
+if (window.eventSender)
+ clickElement(target);
+
+let state = 0;
+document.addEventListener('pointerlockchange', function () {
+ switch (state) {
+ case 0:
+ shouldBe("document.pointerLockElement", "shadowHost");
+ shouldBe("shadowRoot.pointerLockElement", "target");
+ document.exitPointerLock();
+ break;
+ case 1:
+ shouldBe("document.pointerLockElement", "null");
+ shouldBe("shadowRoot.pointerLockElement", "null");
+ finishJSTest();
+ break;
+ }
+ state++;
+});
+
+</script>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/shadow-dom/pointerlockelement-in-slot-expected.txt (0 => 209648)
--- trunk/LayoutTests/fast/shadow-dom/pointerlockelement-in-slot-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/pointerlockelement-in-slot-expected.txt 2016-12-10 05:18:33 UTC (rev 209648)
@@ -0,0 +1,19 @@
+Test pointerLockElement is the node in the same tree as the context object.
+To manually test, click on "Click here" below.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.pointerLockElement is null
+PASS shadowRoot.pointerLockElement is null
+PASS document.pointerLockElement is target
+PASS shadowRoot.pointerLockElement is null
+PASS anotherShadowRoot.pointerLockElement is null
+PASS document.pointerLockElement is null
+PASS shadowRoot.pointerLockElement is null
+PASS anotherShadowRoot.pointerLockElement is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Click here
+
Added: trunk/LayoutTests/fast/shadow-dom/pointerlockelement-in-slot.html (0 => 209648)
--- trunk/LayoutTests/fast/shadow-dom/pointerlockelement-in-slot.html (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/pointerlockelement-in-slot.html 2016-12-10 05:18:33 UTC (rev 209648)
@@ -0,0 +1,58 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="host"><span id="target" tabindex=0>Click here</span></div>
+<div id="anotherHost"></div>
+<script>
+description('Test pointerLockElement is the node in the same tree as the context object.<br>'
+ + 'To manually test, click on "Click here" below.');
+window.jsTestIsAsync = true;
+
+shadowHost = document.getElementById('host');
+shadowRoot = shadowHost.attachShadow({mode: 'closed'});
+shadowRoot.innerHTML = '<slot></slot>';
+
+target = document.getElementById('target');
+anotherShadowRoot = document.getElementById('anotherHost').attachShadow({mode: 'closed'});
+
+target._onclick_ = function () {
+ shouldBe("document.pointerLockElement", "null");
+ shouldBe("shadowRoot.pointerLockElement", "null");
+ target.requestPointerLock();
+}
+
+function clickElement(element) {
+ eventSender.mouseMoveTo(element.offsetLeft + 5, element.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+
+if (window.eventSender)
+ clickElement(target);
+
+let state = 0;
+document.addEventListener('pointerlockchange', function () {
+ switch (state) {
+ case 0:
+ shouldBe("document.pointerLockElement", "target");
+ shouldBe("shadowRoot.pointerLockElement", "null");
+ shouldBe("anotherShadowRoot.pointerLockElement", "null");
+ document.exitPointerLock();
+ break;
+ case 1:
+ shouldBe("document.pointerLockElement", "null");
+ shouldBe("shadowRoot.pointerLockElement", "null");
+ shouldBe("anotherShadowRoot.pointerLockElement", "null");
+ finishJSTest();
+ break;
+ }
+ state++;
+});
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/platform/efl/TestExpectations (209647 => 209648)
--- trunk/LayoutTests/platform/efl/TestExpectations 2016-12-10 04:27:26 UTC (rev 209647)
+++ trunk/LayoutTests/platform/efl/TestExpectations 2016-12-10 05:18:33 UTC (rev 209648)
@@ -1523,6 +1523,8 @@
# Requires POINTER_LOCK support.
webkit.org/b/88080 pointer-lock [ Skip ]
webkit.org/b/88080 http/tests/pointer-lock [ Skip ]
+webkit.org/b/88080 fast/shadow-dom/pointerlockelement-in-shadow-tree.html [ Skip ]
+webkit.org/b/88080 fast/shadow-dom/pointerlockelement-in-slot.html [ Skip ]
# Requires INDIE_UI support
webkit.org/b/111446 indieui [ Skip ]
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (209647 => 209648)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2016-12-10 04:27:26 UTC (rev 209647)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2016-12-10 05:18:33 UTC (rev 209648)
@@ -281,7 +281,10 @@
# As well as testing fullscreen functionality, these tests also utilize the pointer lock feature.
webkit.org/b/99036 http/tests/fullscreen [ Skip ]
webkit.org/b/99036 http/tests/pointer-lock [ Skip ]
+webkit.org/b/99036 fast/shadow-dom/pointerlockelement-in-shadow-tree.html [ Skip ]
+webkit.org/b/99036 fast/shadow-dom/pointerlockelement-in-slot.html [ Skip ]
+
# IETC flexbox failures
webkit.org/b/85211 ietestcenter/css3/flexbox/flexbox-align-stretch-001.htm [ ImageOnlyFailure ]
webkit.org/b/85212 ietestcenter/css3/flexbox/flexbox-layout-002.htm [ ImageOnlyFailure ]
Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (209647 => 209648)
--- trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-12-10 04:27:26 UTC (rev 209647)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-12-10 05:18:33 UTC (rev 209648)
@@ -129,6 +129,8 @@
# Pointer-lock not supported on iOS
pointer-lock
http/tests/pointer-lock
+fast/shadow-dom/pointerlockelement-in-shadow-tree.html
+fast/shadow-dom/pointerlockelement-in-slot.html
# FIXME: Media tests not supported on iOS
http/tests/media
Modified: trunk/Source/WebCore/ChangeLog (209647 => 209648)
--- trunk/Source/WebCore/ChangeLog 2016-12-10 04:27:26 UTC (rev 209647)
+++ trunk/Source/WebCore/ChangeLog 2016-12-10 05:18:33 UTC (rev 209648)
@@ -1,3 +1,28 @@
+2016-12-09 Ryosuke Niwa <[email protected]>
+
+ document.pointerLockElement exposes a node inside a shadow tree
+ https://bugs.webkit.org/show_bug.cgi?id=165702
+
+ Reviewed by Simon Fraser.
+
+ Expose pointerLockElement on ShadowRoot as spec'ed (DocumentOrShadowRoot):
+ https://w3c.github.io/pointerlock/#extensions-to-the-documentorshadowroot-mixin
+
+ Use ancestorElementInThisScope to find the correct node in pointerLockElement.
+
+ Tests: fast/shadow-dom/pointerlockelement-in-shadow-tree.html
+ fast/shadow-dom/pointerlockelement-in-slot.html
+
+ * dom/Document.cpp:
+ (WebCore::Document::pointerLockElement): Moved to TreeScope.
+ * dom/Document.h:
+ * dom/Document.idl: Moved ointerLockElement to DocumentOrShadowRoot.idl.
+ * dom/DocumentOrShadowRoot.idl: Ditto.
+ * dom/TreeScope.cpp:
+ (WebCore::TreeScope::focusedElementInScope): Use documentScope instead of acessing it via m_rootNode.
+ (WebCore::TreeScope::pointerLockElement): Moved from Document.
+ * dom/TreeScope.h:
+
2016-12-09 Daniel Bates <[email protected]>
Add reflected nonce attribute to HTML Link element IDL
Modified: trunk/Source/WebCore/dom/Document.cpp (209647 => 209648)
--- trunk/Source/WebCore/dom/Document.cpp 2016-12-10 04:27:26 UTC (rev 209647)
+++ trunk/Source/WebCore/dom/Document.cpp 2016-12-10 05:18:33 UTC (rev 209648)
@@ -6040,17 +6040,6 @@
page->pointerLockController().requestPointerUnlock();
}
-Element* Document::pointerLockElement() const
-{
- Page* page = this->page();
- if (!page || page->pointerLockController().lockPending())
- return nullptr;
- auto* element = page->pointerLockController().element();
- if (!element || &element->document() != this)
- return nullptr;
- return element;
-}
-
#endif
void Document::decrementLoadEventDelayCount()
Modified: trunk/Source/WebCore/dom/Document.h (209647 => 209648)
--- trunk/Source/WebCore/dom/Document.h 2016-12-10 04:27:26 UTC (rev 209647)
+++ trunk/Source/WebCore/dom/Document.h 2016-12-10 05:18:33 UTC (rev 209648)
@@ -1122,7 +1122,6 @@
#if ENABLE(POINTER_LOCK)
WEBCORE_EXPORT void exitPointerLock();
- WEBCORE_EXPORT Element* pointerLockElement() const;
#endif
// Used to allow element that loads data without going through a FrameLoader to delay the 'load' event.
Modified: trunk/Source/WebCore/dom/Document.idl (209647 => 209648)
--- trunk/Source/WebCore/dom/Document.idl 2016-12-10 04:27:26 UTC (rev 209647)
+++ trunk/Source/WebCore/dom/Document.idl 2016-12-10 05:18:33 UTC (rev 209648)
@@ -153,7 +153,6 @@
#endif
[Conditional=POINTER_LOCK] void exitPointerLock();
- [Conditional=POINTER_LOCK] readonly attribute Element? pointerLockElement;
[Conditional=CSS_REGIONS] DOMNamedFlowCollection webkitGetNamedFlows();
Modified: trunk/Source/WebCore/dom/DocumentOrShadowRoot.idl (209647 => 209648)
--- trunk/Source/WebCore/dom/DocumentOrShadowRoot.idl 2016-12-10 04:27:26 UTC (rev 209647)
+++ trunk/Source/WebCore/dom/DocumentOrShadowRoot.idl 2016-12-10 05:18:33 UTC (rev 209648)
@@ -31,4 +31,5 @@
] interface DocumentOrShadowRoot {
Element? elementFromPoint(optional long x = 0, optional long y = 0); // FIXME: x and y should be double and not be optional.
readonly attribute Element? activeElement;
+ [Conditional=POINTER_LOCK] readonly attribute Element? pointerLockElement;
};
Modified: trunk/Source/WebCore/dom/TreeScope.cpp (209647 => 209648)
--- trunk/Source/WebCore/dom/TreeScope.cpp 2016-12-10 04:27:26 UTC (rev 209647)
+++ trunk/Source/WebCore/dom/TreeScope.cpp 2016-12-10 05:18:33 UTC (rev 209648)
@@ -39,6 +39,7 @@
#include "HitTestResult.h"
#include "IdTargetObserverRegistry.h"
#include "Page.h"
+#include "PointerLockController.h"
#include "RenderView.h"
#include "RuntimeEnabledFeatures.h"
#include "ShadowRoot.h"
@@ -377,7 +378,7 @@
Element* TreeScope::focusedElementInScope()
{
- Document& document = m_rootNode.document();
+ Document& document = documentScope();
Element* element = document.focusedElement();
if (!element && document.page())
@@ -386,6 +387,22 @@
return ancestorElementInThisScope(element);
}
+#if ENABLE(POINTER_LOCK)
+
+Element* TreeScope::pointerLockElement() const
+{
+ Document& document = documentScope();
+ Page* page = document.page();
+ if (!page || page->pointerLockController().lockPending())
+ return nullptr;
+ auto* element = page->pointerLockController().element();
+ if (!element || &element->document() != &document)
+ return nullptr;
+ return ancestorElementInThisScope(element);
+}
+
+#endif
+
static void listTreeScopes(Node* node, Vector<TreeScope*, 5>& treeScopes)
{
while (true) {
Modified: trunk/Source/WebCore/dom/TreeScope.h (209647 => 209648)
--- trunk/Source/WebCore/dom/TreeScope.h 2016-12-10 04:27:26 UTC (rev 209647)
+++ trunk/Source/WebCore/dom/TreeScope.h 2016-12-10 05:18:33 UTC (rev 209648)
@@ -52,6 +52,8 @@
void setParentTreeScope(TreeScope&);
Element* focusedElementInScope();
+ Element* pointerLockElement() const;
+
WEBCORE_EXPORT Element* getElementById(const AtomicString&) const;
WEBCORE_EXPORT Element* getElementById(const String&) const;
const Vector<Element*>* getAllElementsById(const AtomicString&) const;