Diff
Modified: trunk/LayoutTests/ChangeLog (236518 => 236519)
--- trunk/LayoutTests/ChangeLog 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/LayoutTests/ChangeLog 2018-09-26 20:02:57 UTC (rev 236519)
@@ -1,3 +1,32 @@
+2018-09-26 Ryosuke Niwa <rn...@webkit.org>
+
+ Selection should work across shadow boundary when initiated by a mouse drag
+ https://bugs.webkit.org/show_bug.cgi?id=151380
+ <rdar://problem/24363872>
+
+ Reviewed by Antti Koivisto and Wenson Hsieh.
+
+ Added regression tests using ref tests since getSelection() doesn't expose any node inside a shadow tree.
+
+ * editing/selection/selection-across-shadow-boundaries-mixed-editability-1-expected.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-mixed-editability-1.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-mixed-editability-2-expected.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-mixed-editability-2.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-mixed-editability-3-expected.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-mixed-editability-3.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-mixed-editability-4-expected.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-mixed-editability-4.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-mixed-editability-5-expected.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-mixed-editability-5.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-readonly-1-expected.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-readonly-1.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-readonly-2-expected.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-readonly-2.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-readonly-3-expected.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-readonly-3.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-user-select-all-1-expected.html: Added.
+ * editing/selection/selection-across-shadow-boundaries-user-select-all-1.html: Added.
+
2018-09-26 Alicia Boya GarcĂa <ab...@igalia.com>
[GTK] Unreviewed test gardening
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-1-expected.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-1-expected.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-1-expected.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests selecting content starting in an editable element to a shadow tree.<br>
+To manually test, select "hello world" below by a mouse drag from "h" to "d". WebKit should only select "hello".</p>
+<div id="container" contenteditable>hello <div>world</div></div>
+<script>
+container.focus();
+getSelection().setBaseAndExtent(container, 0, container, 1);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-1.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-1.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-1.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,32 @@
+<!DOCTYPE html><!-- webkit-test-runner [ internal:selectionAcrossShadowBoundariesEnabled=true ] -->
+<html>
+<body>
+<p>This tests selecting content starting in an editable element to a shadow tree.<br>
+To manually test, select "hello world" below by a mouse drag from "h" to "d". WebKit should only select "hello".</p>
+<div id="container" contenteditable>hello </div>
+<script>
+
+const host = document.createElement('div');
+container.appendChild(host);
+const shadowRoot = host.attachShadow({mode: 'closed'});
+shadowRoot.textContent = 'world';
+
+if (window.eventSender) {
+ eventSender.dragMode = false;
+ eventSender.mouseMoveTo(container.offsetLeft + 1, container.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(container.offsetLeft + container.offsetWidth - 5, container.offsetTop + container.offsetHeight - 5);
+ eventSender.mouseUp();
+ if (getSelection().startContainer.getRootNode() != document)
+ document.write("The start container's root node was not the document");
+ if (getSelection().startContainer != getSelection().endContainer)
+ document.write("The end container was different from the start container");
+ if (getSelection().getRangeAt(0).startContainer.getRootNode() != document)
+ document.write("The range's start container's root node was not the document");
+ if (getSelection().getRangeAt(0).endContainer != getSelection().getRangeAt(0).startContainer)
+ document.write("The range's end container was different from its start container");
+}
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-2-expected.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-2-expected.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-2-expected.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests selecting content starting in a shadow tree out to an editable element.<br>
+To manually test, select "hello world" below by a mouse drag from "h" to "d". WebKit should only select "hello".</p>
+<div id="container" contenteditable>hello <div>world</div></div>
+<script>
+container.focus();
+getSelection().setBaseAndExtent(container, 0, container, 1);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-2.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-2.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-2.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,32 @@
+<!DOCTYPE html><!-- webkit-test-runner [ internal:selectionAcrossShadowBoundariesEnabled=true ] -->
+<html>
+<body>
+<p>This tests selecting content starting in a shadow tree out to an editable element.<br>
+To manually test, select "hello world" below by a mouse drag from "h" to "d". WebKit should only select "hello".</p>
+<div id="container" contenteditable>world</div>
+<script>
+
+const host = document.createElement('div');
+container.prepend(host);
+const shadowRoot = host.attachShadow({mode: 'closed'});
+shadowRoot.textContent = 'hello ';
+
+if (window.eventSender) {
+ eventSender.dragMode = false;
+ eventSender.mouseMoveTo(container.offsetLeft + 1, container.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(container.offsetLeft + container.offsetWidth - 5, container.offsetTop + container.offsetHeight - 5);
+ eventSender.mouseUp();
+ if (getSelection().startContainer.getRootNode() != document)
+ document.write("The start container's root node was not the document");
+ if (getSelection().startContainer != getSelection().endContainer)
+ document.write("The end container was different from the start container");
+ if (getSelection().getRangeAt(0).startContainer.getRootNode() != document)
+ document.write("The range's start container's root node was not the document");
+ if (getSelection().getRangeAt(0).endContainer != getSelection().getRangeAt(0).startContainer)
+ document.write("The range's end container was different from its start container");
+}
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-3-expected.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-3-expected.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-3-expected.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests selecting content starting in an editable region in a shadow tree to an editable region in the document tree.<br>
+To manually test, select "hello world" below by a mouse drag from "h" to "d". WebKit should only select "hello".</p>
+<div id="container"><div contenteditable>hello</div> world</div>
+<script>
+container.focus();
+getSelection().selectAllChildren(container.firstChild);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-3.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-3.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-3.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,32 @@
+<!DOCTYPE html><!-- webkit-test-runner [ internal:selectionAcrossShadowBoundariesEnabled=true ] -->
+<html>
+<body>
+<p>This tests selecting content starting in an editable region in a shadow tree to an editable region in the document tree.<br>
+To manually test, select "hello world" below by a mouse drag from "h" to "d". WebKit should only select "hello".</p>
+<div id="container" contenteditable>world</div>
+<script>
+
+const host = document.createElement('div');
+container.prepend(host);
+const shadowRoot = host.attachShadow({mode: 'closed'});
+shadowRoot.innerHTML = '<div contenteditable>hello </div>';
+
+if (window.eventSender) {
+ eventSender.dragMode = false;
+ eventSender.mouseMoveTo(container.offsetLeft + 1, container.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(container.offsetLeft + container.offsetWidth - 5, container.offsetTop + container.offsetHeight - 5);
+ eventSender.mouseUp();
+ if (getSelection().startContainer.getRootNode() != document)
+ document.write("The start container's root node was not the document");
+ if (getSelection().startContainer != getSelection().endContainer)
+ document.write("The end container was different from the start container");
+ if (getSelection().getRangeAt(0).startContainer.getRootNode() != document)
+ document.write("The range's start container's root node was not the document");
+ if (getSelection().getRangeAt(0).endContainer != getSelection().getRangeAt(0).startContainer)
+ document.write("The range's end container was different from its start container");
+}
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-4-expected.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-4-expected.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-4-expected.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests selecting content starting in a shadow tree inside an editable region to the outside.<br>
+To manually test, select "hello world" below by a mouse drag from the bottom right to the top left.<br>
+WebKit should not extend the selection to the editable region outside the shadow tree.</p>
+<div id="container" contenteditable>hello <div>world</div></div>
+<script>
+container.focus();
+getSelection().selectAllChildren(container.lastChild);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-4.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-4.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-4.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,33 @@
+<!DOCTYPE html><!-- webkit-test-runner [ internal:selectionAcrossShadowBoundariesEnabled=true ] -->
+<html>
+<body>
+<p>This tests selecting content starting in a shadow tree inside an editable region to the outside.<br>
+To manually test, select "hello world" below by a mouse drag from the bottom right to the top left.<br>
+WebKit should not extend the selection to the editable region outside the shadow tree.</p>
+<div id="container" contenteditable>hello </div>
+<script>
+
+const host = document.createElement('div');
+container.appendChild(host);
+const shadowRoot = host.attachShadow({mode: 'closed'});
+shadowRoot.textContent = 'world';
+
+if (window.eventSender) {
+ eventSender.dragMode = false;
+ eventSender.mouseMoveTo(container.offsetLeft + container.offsetWidth - 5, container.offsetTop + container.offsetHeight - 5);
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(container.offsetLeft - 1, container.offsetTop - 5);
+ eventSender.mouseUp();
+ if (getSelection().startContainer.getRootNode() != document)
+ document.write("The start container's root node was not the document");
+ if (getSelection().startContainer != getSelection().endContainer)
+ document.write("The end container was different from the start container");
+ if (getSelection().getRangeAt(0).startContainer.getRootNode() != document)
+ document.write("The range's start container's root node was not the document");
+ if (getSelection().getRangeAt(0).endContainer != getSelection().getRangeAt(0).startContainer)
+ document.write("The range's end container was different from its start container");
+}
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-5-expected.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-5-expected.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-5-expected.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests selecting content starting in a shadow tree inside a non-editable region in an editable region to outside the editable region.<br>
+To manually test, select "hello world WebKit" below by a mouse drag from the bottom right to the top left.<br>
+WebKit should not extend the selection to outside the shadow tree.</p>
+<div id="container" contenteditable>hello<br>world<div>WebKit</div></div>
+<script>
+container.focus();
+getSelection().selectAllChildren(container.lastChild);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-5.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-5.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-mixed-editability-5.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,33 @@
+<!DOCTYPE html><!-- webkit-test-runner [ internal:selectionAcrossShadowBoundariesEnabled=true ] -->
+<html>
+<body>
+<p>This tests selecting content starting in a shadow tree inside a non-editable region in an editable region to outside the editable region.<br>
+To manually test, select "hello world WebKit" below by a mouse drag from the bottom right to the top left.<br>
+WebKit should not extend the selection to outside the shadow tree.</p>
+<div id="container" contenteditable>hello <div contenteditable="false">world</div></div>
+<script>
+
+const host = document.createElement('div');
+container.lastChild.append(host);
+const shadowRoot = host.attachShadow({mode: 'closed'});
+shadowRoot.textContent = ' WebKit';
+
+if (window.eventSender) {
+ eventSender.dragMode = false;
+ eventSender.mouseMoveTo(container.offsetLeft + container.offsetWidth - 5, container.offsetTop + container.offsetHeight - 5);
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(container.offsetLeft + 1, container.offsetTop + 5);
+ eventSender.mouseUp();
+ if (getSelection().startContainer.getRootNode() != document)
+ document.write("The start container's root node was not the document");
+ if (getSelection().startContainer != getSelection().endContainer)
+ document.write("The end container was different from the start container");
+ if (getSelection().getRangeAt(0).startContainer.getRootNode() != document)
+ document.write("The range's start container's root node was not the document");
+ if (getSelection().getRangeAt(0).endContainer != getSelection().getRangeAt(0).startContainer)
+ document.write("The range's end container was different from its start container");
+}
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-1-expected.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-1-expected.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-1-expected.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests selecting content starting in the document into a shadow tree.<br>
+To manually test, select "hello world" below by a mouse drag. WebKit should select the phrase.</p>
+<div id="container">hello <div>world</div></div>
+<script>
+getSelection().selectAllChildren(container);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-1.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-1.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-1.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,32 @@
+<!DOCTYPE html><!-- webkit-test-runner [ internal:selectionAcrossShadowBoundariesEnabled=true ] -->
+<html>
+<body>
+<p>This tests selecting content starting in the document into a shadow tree.<br>
+To manually test, select "hello world" below by a mouse drag. WebKit should select the phrase.</p>
+<div id="container">hello </div>
+<script>
+
+const host = document.createElement('div');
+container.appendChild(host);
+const shadowRoot = host.attachShadow({mode: 'closed'});
+shadowRoot.textContent = 'world';
+
+if (window.eventSender) {
+ eventSender.dragMode = false;
+ eventSender.mouseMoveTo(container.offsetLeft - 2, container.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(container.offsetLeft + container.offsetWidth - 5, container.offsetTop + container.offsetHeight - 5);
+ eventSender.mouseUp();
+ if (getSelection().startContainer.getRootNode() != document)
+ document.write("The start container's root node was not the document");
+ if (getSelection().endContainer.getRootNode() != document)
+ document.write("The end container's root node was not the document");
+ if (getSelection().getRangeAt(0).startContainer.getRootNode() != document)
+ document.write("The range's start container's root node was not the document");
+ if (getSelection().getRangeAt(0).endContainer.getRootNode() != document)
+ document.write("The range's end container's root node was not the document");
+}
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-2-expected.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-2-expected.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-2-expected.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests selecting content starting in a shadow tree out to the document.<br>
+To manually test, select "hello world" below by a mouse drag. WebKit should select the phrase.</p>
+<div id="container">hello <div>world</div></div>
+<script>
+getSelection().selectAllChildren(container);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-2.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-2.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-2.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,32 @@
+<!DOCTYPE html><!-- webkit-test-runner [ internal:selectionAcrossShadowBoundariesEnabled=true ] -->
+<html>
+<body>
+<p>This tests selecting content starting in a shadow tree out to the document.<br>
+To manually test, select "hello world" below by a mouse drag. WebKit should select the phrase.</p>
+<div id="container">world</div>
+<script>
+
+const host = document.createElement('div');
+container.prepend(host);
+const shadowRoot = host.attachShadow({mode: 'closed'});
+shadowRoot.textContent = 'hello ';
+
+if (window.eventSender) {
+ eventSender.dragMode = false;
+ eventSender.mouseMoveTo(container.offsetLeft - 2, container.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(container.offsetLeft + container.offsetWidth - 5, container.offsetTop + container.offsetHeight - 5);
+ eventSender.mouseUp();
+ if (getSelection().startContainer.getRootNode() != document)
+ document.write("The start container's root node was not the document");
+ if (getSelection().endContainer.getRootNode() != document)
+ document.write("The end container's root node was not the document");
+ if (getSelection().getRangeAt(0).startContainer.getRootNode() != document)
+ document.write("The range's start container's root node was not the document");
+ if (getSelection().getRangeAt(0).endContainer.getRootNode() != document)
+ document.write("The range's end container's root node was not the document");
+}
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-3-expected.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-3-expected.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-3-expected.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests selecting content starting in one shadow tree and ending another shadow tree.<br>
+To manually test, select "hello world" below by a mouse drag. WebKit should select the phrase.</p>
+<div id="container">hello <div>world</div></div>
+<script>
+getSelection().selectAllChildren(container);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-3.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-3.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-readonly-3.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,36 @@
+<!DOCTYPE html><!-- webkit-test-runner [ internal:selectionAcrossShadowBoundariesEnabled=true ] -->
+<html>
+<body>
+<p>This tests selecting content starting in one shadow tree and ending another shadow tree.<br>
+To manually test, select "hello world" below by a mouse drag. WebKit should select the phrase.</p>
+<div id="container"></div>
+<script>
+
+const host1 = document.createElement('div');
+const shadowRoot1 = host1.attachShadow({mode: 'closed'});
+shadowRoot1.textContent = 'hello ';
+
+const host2 = document.createElement('div');
+const shadowRoot2 = host2.attachShadow({mode: 'closed'});
+shadowRoot2.textContent = 'world';
+container.append(host1, host2);
+
+if (window.eventSender) {
+ eventSender.dragMode = false;
+ eventSender.mouseMoveTo(container.offsetLeft - 2, container.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(container.offsetLeft + container.offsetWidth - 5, container.offsetTop + container.offsetHeight - 5);
+ eventSender.mouseUp();
+ if (getSelection().startContainer.getRootNode() != document)
+ document.write("The start container's root node was not the document");
+ if (getSelection().endContainer.getRootNode() != document)
+ document.write("The end container's root node was not the document");
+ if (getSelection().getRangeAt(0).startContainer.getRootNode() != document)
+ document.write("The range's start container's root node was not the document");
+ if (getSelection().getRangeAt(0).endContainer.getRootNode() != document)
+ document.write("The range's end container's root node was not the document");
+}
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-user-select-all-1-expected.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-user-select-all-1-expected.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-user-select-all-1-expected.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests selecting content starting in a shadow tree inside a <code>user-select: all</code> in an editable region in to outside the editable region.<br>
+To manually test, select "hello world WebKit rocks" below by a mouse drag from "h" to "s". WebKit should select "hello".</p>
+<div id="container"><div contenteditable><div id="selected">hello</div>world<br>WebKit</div>rocks</div>
+<script>
+getSelection().selectAllChildren(selected);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-user-select-all-1.html (0 => 236519)
--- trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-user-select-all-1.html (rev 0)
+++ trunk/LayoutTests/editing/selection/selection-across-shadow-boundaries-user-select-all-1.html 2018-09-26 20:02:57 UTC (rev 236519)
@@ -0,0 +1,32 @@
+<!DOCTYPE html><!-- webkit-test-runner [ internal:selectionAcrossShadowBoundariesEnabled=true ] -->
+<html>
+<body>
+<p>This tests selecting content starting in a shadow tree inside a <code>user-select: all</code> in an editable region in to outside the editable region.<br>
+To manually test, select "hello world WebKit rocks" below by a mouse drag from "h" to "s". WebKit should select "hello".</p>
+<div id="container"><div contenteditable><div style="user-select: all">world</div> WebKit</div>rocks</div>
+<script>
+
+const host = document.createElement('div');
+container.firstChild.prepend(host);
+const shadowRoot = host.attachShadow({mode: 'closed'});
+shadowRoot.textContent = 'hello ';
+
+if (window.eventSender) {
+ eventSender.dragMode = false;
+ eventSender.mouseMoveTo(container.offsetLeft + 1, container.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(container.offsetLeft + container.offsetWidth - 5, container.offsetTop + container.offsetHeight - 5);
+ eventSender.mouseUp();
+ if (getSelection().startContainer.getRootNode() != document)
+ document.write("The start container's root node was not the document");
+ if (getSelection().startContainer != getSelection().endContainer)
+ document.write("The end container was different from the start container");
+ if (getSelection().getRangeAt(0).startContainer.getRootNode() != document)
+ document.write("The range's start container's root node was not the document");
+ if (getSelection().getRangeAt(0).endContainer != getSelection().getRangeAt(0).startContainer)
+ document.write("The range's end container was different from its start container");
+}
+
+</script>
+</body>
+</html>
Modified: trunk/LayoutTests/platform/win/TestExpectations (236518 => 236519)
--- trunk/LayoutTests/platform/win/TestExpectations 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/LayoutTests/platform/win/TestExpectations 2018-09-26 20:02:57 UTC (rev 236519)
@@ -101,6 +101,15 @@
webkit.org/b/173281 editing/style/set-foreColor-with-color-filter.html [ Skip ]
webkit.org/b/173281 editing/style/set-backColor-with-color-filter.html [ Skip ]
webkit.org/b/173281 editing/style/inverse-color-filter.html [ Skip ]
+webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-mixed-editability-1.html [ Skip ]
+webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-mixed-editability-2.html [ Skip ]
+webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-mixed-editability-3.html [ Skip ]
+webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-mixed-editability-4.html [ Skip ]
+webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-mixed-editability-5.html [ Skip ]
+webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-readonly-1.html [ Skip ]
+webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-readonly-2.html [ Skip ]
+webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-readonly-3.html [ Skip ]
+webkit.org/b/173281 editing/selection/selection-across-shadow-boundaries-user-select-all-1.html [ Skip ]
# TODO HW filters not yet supported on Windows
webkit.org/b/74716 css3/filters/effect-blur-hw.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (236518 => 236519)
--- trunk/Source/WebCore/ChangeLog 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/Source/WebCore/ChangeLog 2018-09-26 20:02:57 UTC (rev 236519)
@@ -1,3 +1,46 @@
+2018-09-26 Ryosuke Niwa <rn...@webkit.org>
+
+ Selection should work across shadow boundary when initiated by a mouse drag
+ https://bugs.webkit.org/show_bug.cgi?id=151380
+ <rdar://problem/24363872>
+
+ Reviewed by Antti Koivisto and Wenson Hsieh.
+
+ This patch adds the basic support for selecting content across shadow DOM boundaries to VisibleSelection,
+ which is enough to allow users to select content across shadow DOM boundaries via a mouse drag.
+
+ This is the first step in allowing users to select, copy and paste content across shadow DOM boundaries,
+ which is a serious user experience regression right now. The new behavior is disabled by default under
+ an interal debug feature flag: selectionAcrossShadowBoundariesEnabled.
+
+ Like Chrome, we are not going to support selecting editable content across shadow DOM boundaries since
+ we'd have to generalize every editing commands to make that work, and there aren't any HTML editors that
+ use shadow DOM boundaries within an editable region yet. For simplicity, we also don't support extending
+ a selection out of a shadow root which resides inside an editing region.
+
+ The keyboard based navigation & manipulation of selection as well as allowing copy & paste of content
+ across shadow DOM boundaries will be implemented by separate patches. DOMSelection will not expose this new
+ behavior either. This is tracked in the spec as https://github.com/w3c/webcomponents/issues/79
+
+ Tests: editing/selection/selection-across-shadow-boundaries-mixed-editability-1.html
+ editing/selection/selection-across-shadow-boundaries-mixed-editability-2.html
+ editing/selection/selection-across-shadow-boundaries-mixed-editability-3.html
+ editing/selection/selection-across-shadow-boundaries-mixed-editability-4.html
+ editing/selection/selection-across-shadow-boundaries-mixed-editability-5.html
+ editing/selection/selection-across-shadow-boundaries-readonly-1.html
+ editing/selection/selection-across-shadow-boundaries-readonly-2.html
+ editing/selection/selection-across-shadow-boundaries-readonly-3.html
+ editing/selection/selection-across-shadow-boundaries-user-select-all-1.html
+
+ * editing/VisibleSelection.cpp:
+ (WebCore::isInUserAgentShadowRootOrHasEditableShadowAncestor): Added.
+ (WebCore::VisibleSelection::adjustSelectionToAvoidCrossingShadowBoundaries): When the feature is enabled,
+ allow crossing shadow DOM boundaries except when either end is inside an user agent shadow root, or one of
+ its shadow includign ancestor is inside an editable region. The latter check is needed to disallow
+ an extension of a selection starting in a shadow tree inside a non-editable region inside an editable region
+ to outside the editable region. The rest of the editing code is not ready to deal with selection like that.
+ * page/Settings.yaml: Added an internal debug feature to enable this new behavior.
+
2018-09-26 Chris Dumez <cdu...@apple.com>
Ignore-opens-during-unload counter of a parent should apply to its children during beforeunload event
Modified: trunk/Source/WebCore/editing/VisibleSelection.cpp (236518 => 236519)
--- trunk/Source/WebCore/editing/VisibleSelection.cpp 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/Source/WebCore/editing/VisibleSelection.cpp 2018-09-26 20:02:57 UTC (rev 236519)
@@ -30,6 +30,7 @@
#include "Editing.h"
#include "Element.h"
#include "HTMLInputElement.h"
+#include "Settings.h"
#include "TextIterator.h"
#include "VisibleUnits.h"
#include <stdio.h>
@@ -504,23 +505,45 @@
return Position();
}
+static bool isInUserAgentShadowRootOrHasEditableShadowAncestor(Node& node)
+{
+ auto* shadowRoot = node.containingShadowRoot();
+ if (!shadowRoot)
+ return false;
+
+ if (shadowRoot->mode() == ShadowRootMode::UserAgent)
+ return true;
+
+ for (RefPtr<Node> currentNode = &node; currentNode; currentNode = currentNode->parentOrShadowHostNode()) {
+ if (currentNode->hasEditableStyle())
+ return true;
+ }
+ return false;
+}
+
void VisibleSelection::adjustSelectionToAvoidCrossingShadowBoundaries()
{
if (m_base.isNull() || m_start.isNull() || m_end.isNull())
return;
- if (&m_start.anchorNode()->treeScope() == &m_end.anchorNode()->treeScope())
+ auto startNode = makeRef(*m_start.anchorNode());
+ auto endNode = makeRef(*m_end.anchorNode());
+ if (&startNode->treeScope() == &endNode->treeScope())
return;
+ if (startNode->document().settings().selectionAcrossShadowBoundariesEnabled()) {
+ if (!isInUserAgentShadowRootOrHasEditableShadowAncestor(startNode)
+ && !isInUserAgentShadowRootOrHasEditableShadowAncestor(endNode))
+ return;
+ }
+
if (m_baseIsFirst) {
- m_extent = adjustPositionForEnd(m_end, m_start.containerNode());
+ m_extent = adjustPositionForEnd(m_end, startNode.ptr());
m_end = m_extent;
} else {
- m_extent = adjustPositionForStart(m_start, m_end.containerNode());
+ m_extent = adjustPositionForStart(m_start, endNode.ptr());
m_start = m_extent;
}
-
- ASSERT(&m_start.anchorNode()->treeScope() == &m_end.anchorNode()->treeScope());
}
void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries()
Modified: trunk/Source/WebCore/page/Settings.yaml (236518 => 236519)
--- trunk/Source/WebCore/page/Settings.yaml 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/Source/WebCore/page/Settings.yaml 2018-09-26 20:02:57 UTC (rev 236519)
@@ -389,6 +389,8 @@
initial: defaultSmartInsertDeleteEnabled
selectTrailingWhitespaceEnabled:
initial: defaultSelectTrailingWhitespaceEnabled
+selectionAcrossShadowBoundariesEnabled:
+ initial: false
useLegacyBackgroundSizeShorthandBehavior:
initial: false
Modified: trunk/Source/WebKit/ChangeLog (236518 => 236519)
--- trunk/Source/WebKit/ChangeLog 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/Source/WebKit/ChangeLog 2018-09-26 20:02:57 UTC (rev 236519)
@@ -1,3 +1,16 @@
+2018-09-26 Ryosuke Niwa <rn...@webkit.org>
+
+ Selection should work across shadow boundary when initiated by a mouse drag
+ https://bugs.webkit.org/show_bug.cgi?id=151380
+ <rdar://problem/24363872>
+
+ Reviewed by Antti Koivisto.
+
+ Added SelectionAcrossShadowBoundariesEnabled as an internal debug feature,
+ and moved CSSCustomPropertiesAndValuesEnabled to where other experimental features are located.
+
+ * Shared/WebPreferences.yaml:
+
2018-09-26 Chris Dumez <cdu...@apple.com>
Unreviewed, apply post-landing review comments after r236512.
Modified: trunk/Source/WebKit/Shared/WebPreferences.yaml (236518 => 236519)
--- trunk/Source/WebKit/Shared/WebPreferences.yaml 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/Source/WebKit/Shared/WebPreferences.yaml 2018-09-26 20:02:57 UTC (rev 236519)
@@ -1257,6 +1257,14 @@
webcoreBinding: RuntimeEnabledFeatures
webcoreName: serverTimingEnabled
+CSSCustomPropertiesAndValuesEnabled:
+ type: bool
+ defaultValue: false
+ humanReadableName: "CSS Custom Properties and Values API"
+ humanReadableDescription: "Enable CSS Custom Properties and Values API"
+ webcoreBinding: RuntimeEnabledFeatures
+ category: experimental
+
# For internal features:
# The type should be boolean.
# You must provide a humanReadableName and humanReadableDescription for all debug features. They
@@ -1341,7 +1349,7 @@
AriaReflectionEnabled:
type: bool
- defaultValue: true
+ defaultValue: false
humanReadableName: "ARIA Reflection"
humanReadableDescription: "ARIA Reflection support"
category: internal
@@ -1355,10 +1363,10 @@
webcoreBinding: RuntimeEnabledFeatures
category: internal
-CSSCustomPropertiesAndValuesEnabled:
+SelectionAcrossShadowBoundariesEnabled:
type: bool
- defaultValue: false
- humanReadableName: "CSS Custom Properties and Values API"
- humanReadableDescription: "Enable CSS Custom Properties and Values API"
- webcoreBinding: RuntimeEnabledFeatures
- category: experimental
+ defaultValue: true
+ humanReadableName: "Selection across shadow DOM"
+ humanReadableDescription: "Allow user-initiated selection across shadow DOM boundaries"
+ category: internal
+ webcoreName: selectionAcrossShadowBoundariesEnabled
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (236518 => 236519)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2018-09-26 20:02:57 UTC (rev 236519)
@@ -1,3 +1,22 @@
+2018-09-26 Ryosuke Niwa <rn...@webkit.org>
+
+ Selection should work across shadow boundary when initiated by a mouse drag
+ https://bugs.webkit.org/show_bug.cgi?id=151380
+ <rdar://problem/24363872>
+
+ Reviewed by Wenson Hsieh.
+
+ Added selectionAcrossShadowBoundariesEnabled as a preference to be used in DumpRenderTree.
+
+ * WebView/WebPreferenceKeysPrivate.h:
+ * WebView/WebPreferences.mm:
+ (+[WebPreferences initialize]):
+ (-[WebPreferences selectionAcrossShadowBoundariesEnabled]):
+ (-[WebPreferences setSelectionAcrossShadowBoundariesEnabled:]):
+ * WebView/WebPreferencesPrivate.h:
+ * WebView/WebView.mm:
+ (-[WebView _preferencesChanged:]):
+
2018-09-24 Wenson Hsieh <wenson_hs...@apple.com>
Refactor Editor::fontAttributesForSelectionStart to be platform-agnostic
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h (236518 => 236519)
--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h 2018-09-26 20:02:57 UTC (rev 236519)
@@ -262,3 +262,4 @@
#define WebKitAriaReflectionEnabledPreferenceKey @"WebKitAriaReflectionEnabled"
#define WebKitMediaCapabilitiesEnabledPreferenceKey @"WebKitMediaCapabilitiesEnabled"
#define WebKitServerTimingEnabledPreferenceKey @"WebKitServerTimingEnabled"
+#define WebKitSelectionAcrossShadowBoundariesEnabledPreferenceKey @"WebKitSelectionAcrossShadowBoundariesEnabled"
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm (236518 => 236519)
--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm 2018-09-26 20:02:57 UTC (rev 236519)
@@ -664,6 +664,7 @@
#if ENABLE(WEB_RTC)
[NSNumber numberWithBool:YES], WebKitPeerConnectionEnabledPreferenceKey,
#endif
+ [NSNumber numberWithBool:NO], WebKitSelectionAcrossShadowBoundariesEnabledPreferenceKey,
#if ENABLE(INTERSECTION_OBSERVER)
@NO, WebKitIntersectionObserverEnabledPreferenceKey,
#endif
@@ -3365,6 +3366,16 @@
[self _setBoolValue:flag forKey:WebKitServerTimingEnabledPreferenceKey];
}
+- (BOOL)selectionAcrossShadowBoundariesEnabled
+{
+ return [self _boolValueForKey:WebKitSelectionAcrossShadowBoundariesEnabledPreferenceKey];
+}
+
+- (void)setSelectionAcrossShadowBoundariesEnabled:(BOOL)flag
+{
+ [self _setBoolValue:flag forKey:WebKitSelectionAcrossShadowBoundariesEnabledPreferenceKey];
+}
+
@end
@implementation WebPreferences (WebInternal)
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h (236518 => 236519)
--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h 2018-09-26 20:02:57 UTC (rev 236519)
@@ -582,6 +582,9 @@
- (void)setServerTimingEnabled:(BOOL)flag;
- (BOOL)serverTimingEnabled;
+- (void)setSelectionAcrossShadowBoundariesEnabled:(BOOL)flag;
+- (BOOL)selectionAcrossShadowBoundariesEnabled;
+
@property (nonatomic) BOOL visualViewportEnabled;
@property (nonatomic) BOOL visualViewportAPIEnabled;
@property (nonatomic) BOOL CSSOMViewScrollingAPIEnabled;
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (236518 => 236519)
--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2018-09-26 20:02:57 UTC (rev 236519)
@@ -3170,6 +3170,8 @@
settings.setMediaCapabilitiesEnabled([preferences mediaCapabilitiesEnabled]);
RuntimeEnabledFeatures::sharedFeatures().setServerTimingEnabled([preferences serverTimingEnabled]);
+
+ settings.setSelectionAcrossShadowBoundariesEnabled(preferences.selectionAcrossShadowBoundariesEnabled);
}
static inline IMP getMethod(id o, SEL s)
Modified: trunk/Tools/ChangeLog (236518 => 236519)
--- trunk/Tools/ChangeLog 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/Tools/ChangeLog 2018-09-26 20:02:57 UTC (rev 236519)
@@ -1,5 +1,22 @@
2018-09-26 Ryosuke Niwa <rn...@webkit.org>
+ Selection should work across shadow boundary when initiated by a mouse drag
+ https://bugs.webkit.org/show_bug.cgi?id=151380
+ <rdar://problem/24363872>
+
+ Reviewed by Wenson Hsieh.
+
+ Added the support for internal:selectionAcrossShadowBoundariesEnabled test option.
+
+ * DumpRenderTree/TestOptions.cpp:
+ (TestOptions::TestOptions):
+ * DumpRenderTree/TestOptions.h:
+ * DumpRenderTree/mac/DumpRenderTree.mm:
+ (resetWebPreferencesToConsistentValues):
+ (setWebPreferencesForTestOptions):
+
+2018-09-26 Ryosuke Niwa <rn...@webkit.org>
+
MiniBrowser doesn't respect default enabled-ness of experimental and internal debug features
https://bugs.webkit.org/show_bug.cgi?id=189989
Modified: trunk/Tools/DumpRenderTree/TestOptions.cpp (236518 => 236519)
--- trunk/Tools/DumpRenderTree/TestOptions.cpp 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/Tools/DumpRenderTree/TestOptions.cpp 2018-09-26 20:02:57 UTC (rev 236519)
@@ -101,6 +101,8 @@
allowCrossOriginSubresourcesToAskForCredentials = parseBooleanTestHeaderValue(value);
else if (key == "experimental:WebAnimationsCSSIntegrationEnabled")
enableWebAnimationsCSSIntegration = parseBooleanTestHeaderValue(value);
+ else if (key == "internal:selectionAcrossShadowBoundariesEnabled")
+ enableSelectionAcrossShadowBoundaries = parseBooleanTestHeaderValue(value);
else if (key == "enableColorFilter")
enableColorFilter = parseBooleanTestHeaderValue(value);
else if (key == "jscOptions")
Modified: trunk/Tools/DumpRenderTree/TestOptions.h (236518 => 236519)
--- trunk/Tools/DumpRenderTree/TestOptions.h 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/Tools/DumpRenderTree/TestOptions.h 2018-09-26 20:02:57 UTC (rev 236519)
@@ -43,6 +43,7 @@
bool dumpJSConsoleLogInStdErr { false };
bool allowCrossOriginSubresourcesToAskForCredentials { false };
bool enableColorFilter { false };
+ bool enableSelectionAcrossShadowBoundaries { false };
std::string jscOptions;
TestOptions(const std::string& pathOrURL, const std::string& absolutePath);
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (236518 => 236519)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2018-09-26 19:47:46 UTC (rev 236518)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2018-09-26 20:02:57 UTC (rev 236519)
@@ -990,6 +990,8 @@
[preferences setCacheAPIEnabled:NO];
preferences.mediaCapabilitiesEnabled = YES;
+ preferences.selectionAcrossShadowBoundariesEnabled = NO;
+
[WebPreferences _clearNetworkLoaderSession];
[WebPreferences _setCurrentNetworkLoaderSessionCookieAcceptPolicy:NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain];
}
@@ -1008,6 +1010,7 @@
preferences.allowCrossOriginSubresourcesToAskForCredentials = options.allowCrossOriginSubresourcesToAskForCredentials;
preferences.webAnimationsCSSIntegrationEnabled = options.enableWebAnimationsCSSIntegration;
preferences.colorFilterEnabled = options.enableColorFilter;
+ preferences.selectionAcrossShadowBoundariesEnabled = options.enableSelectionAcrossShadowBoundaries;
}
// Called once on DumpRenderTree startup.