Title: [139401] trunk
- Revision
- 139401
- Author
- shin...@chromium.org
- Date
- 2013-01-10 20:44:20 -0800 (Thu, 10 Jan 2013)
Log Message
When a selected node in nested ShadowDOM is deleted, selection have wrong range.
https://bugs.webkit.org/show_bug.cgi?id=106526
Reviewed by Ryosuke Niwa.
Source/WebCore:
Since FrameSelection and htmlediting did not consider nested Shadow DOM, the FrameSelection still selects
removed elements if selected nodes in nested Shadow DOM are removed.
We have to use containsIncludingShadowDOM to handle with nested Shadow DOM correctly.
Test: fast/dom/shadow/selection-in-nested-shadow.html
* editing/FrameSelection.cpp:
(WebCore::removingNodeRemovesPosition):
* editing/htmlediting.cpp:
(WebCore::updatePositionForNodeRemoval):
LayoutTests:
* fast/dom/shadow/selection-in-nested-shadow-expected.txt: Added.
* fast/dom/shadow/selection-in-nested-shadow.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (139400 => 139401)
--- trunk/LayoutTests/ChangeLog 2013-01-11 04:00:13 UTC (rev 139400)
+++ trunk/LayoutTests/ChangeLog 2013-01-11 04:44:20 UTC (rev 139401)
@@ -1,3 +1,13 @@
+2013-01-10 Shinya Kawanaka <shin...@chromium.org>
+
+ When a selected node in nested ShadowDOM is deleted, selection have wrong range.
+ https://bugs.webkit.org/show_bug.cgi?id=106526
+
+ Reviewed by Ryosuke Niwa.
+
+ * fast/dom/shadow/selection-in-nested-shadow-expected.txt: Added.
+ * fast/dom/shadow/selection-in-nested-shadow.html: Added.
+
2013-01-10 James Robinson <jam...@chromium.org>
[chromium] Store scrollable layer's contents size for coordinated scrollable layers
Added: trunk/LayoutTests/fast/dom/shadow/selection-in-nested-shadow-expected.txt (0 => 139401)
--- trunk/LayoutTests/fast/dom/shadow/selection-in-nested-shadow-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/selection-in-nested-shadow-expected.txt 2013-01-11 04:44:20 UTC (rev 139401)
@@ -0,0 +1,12 @@
+Select text in non-nested ShadowDOM and remove an element containing shadow host.
+Then the anchor node of the selection should become be the parent element of the removed element (container).
+PASS window.getSelection().anchorNode is container
+
+Select text in nested ShadowDOM and remove an element containing shadow host.
+In this case, the anchor node of the selection should also become be the parent element of the removed element (container).
+PASS window.getSelection().anchorNode is container
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/shadow/selection-in-nested-shadow.html (0 => 139401)
--- trunk/LayoutTests/fast/dom/shadow/selection-in-nested-shadow.html (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/selection-in-nested-shadow.html 2013-01-11 04:44:20 UTC (rev 139401)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+
+<div id="container">
+ <div id="container1"><div id="host1"></div></div>
+ <div id="container2"><div id="host2"></div></div>
+</div>
+<pre id="console"></pre>
+
+<script>
+var shadowRoot1 = host1.webkitCreateShadowRoot();
+shadowRoot1.innerHTML = '<div id="target1">Element in Shadow DOM</div>';
+
+var shadowRoot2 = host2.webkitCreateShadowRoot();
+var host3 = document.createElement('div');
+var shadowRoot3 = host3.webkitCreateShadowRoot();
+shadowRoot2.appendChild(host3);
+shadowRoot3.innerHTML = '<div id="target2">Element in nested Shadow DOM</div>';
+
+var target1 = shadowRoot1.getElementById('target1');
+var target2 = shadowRoot3.getElementById('target2');
+
+// non-nested ShadowDOM case.
+debug('Select text in non-nested ShadowDOM and remove an element containing shadow host.');
+debug('Then the anchor node of the selection should become be the parent element of the removed element (container).');
+eventSender.mouseMoveTo(target1.offsetLeft + 2, target1.offsetTop + target1.offsetHeight / 2);
+eventSender.mouseDown();
+eventSender.mouseMoveTo(target1.offsetLeft + target1.offsetWidth - 2, target1.offsetTop + target1.offsetHeight / 2);
+eventSender.mouseUp();
+container.removeChild(container1);
+shouldBe('window.getSelection().anchorNode', 'container');
+debug('');
+
+// nested ShadowDOM case.
+debug('Select text in nested ShadowDOM and remove an element containing shadow host.');
+debug('In this case, the anchor node of the selection should also become be the parent element of the removed element (container).');
+eventSender.mouseMoveTo(target2.offsetLeft + 2, target2.offsetTop + target2.offsetHeight / 2);
+eventSender.mouseDown();
+eventSender.mouseMoveTo(target2.offsetLeft + target2.offsetWidth - 2, target2.offsetTop + target2.offsetHeight / 2);
+eventSender.mouseUp();
+container.removeChild(container2);
+shouldBe('window.getSelection().anchorNode', 'container');
+debug('');
+</script>
+
+<script src=""
+</body>
+
+</html>
Modified: trunk/Source/WebCore/ChangeLog (139400 => 139401)
--- trunk/Source/WebCore/ChangeLog 2013-01-11 04:00:13 UTC (rev 139400)
+++ trunk/Source/WebCore/ChangeLog 2013-01-11 04:44:20 UTC (rev 139401)
@@ -1,3 +1,22 @@
+2013-01-10 Shinya Kawanaka <shin...@chromium.org>
+
+ When a selected node in nested ShadowDOM is deleted, selection have wrong range.
+ https://bugs.webkit.org/show_bug.cgi?id=106526
+
+ Reviewed by Ryosuke Niwa.
+
+ Since FrameSelection and htmlediting did not consider nested Shadow DOM, the FrameSelection still selects
+ removed elements if selected nodes in nested Shadow DOM are removed.
+
+ We have to use containsIncludingShadowDOM to handle with nested Shadow DOM correctly.
+
+ Test: fast/dom/shadow/selection-in-nested-shadow.html
+
+ * editing/FrameSelection.cpp:
+ (WebCore::removingNodeRemovesPosition):
+ * editing/htmlediting.cpp:
+ (WebCore::updatePositionForNodeRemoval):
+
2013-01-10 Hajime Morrita <morr...@google.com>
[Shadow DOM] Refactoring: InsertionPoint could simplify its subclass hooks
Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (139400 => 139401)
--- trunk/Source/WebCore/editing/FrameSelection.cpp 2013-01-11 04:00:13 UTC (rev 139400)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp 2013-01-11 04:44:20 UTC (rev 139401)
@@ -338,7 +338,7 @@
return false;
Element* element = static_cast<Element*>(node);
- return element->contains(position.anchorNode()) || element->contains(position.anchorNode()->shadowAncestorNode());
+ return element->containsIncludingShadowDOM(position.anchorNode());
}
static void clearRenderViewSelection(const Position& position)
Modified: trunk/Source/WebCore/editing/htmlediting.cpp (139400 => 139401)
--- trunk/Source/WebCore/editing/htmlediting.cpp 2013-01-11 04:00:13 UTC (rev 139400)
+++ trunk/Source/WebCore/editing/htmlediting.cpp 2013-01-11 04:44:20 UTC (rev 139401)
@@ -994,15 +994,15 @@
case Position::PositionIsOffsetInAnchor:
if (position.containerNode() == node->parentNode() && static_cast<unsigned>(position.offsetInContainerNode()) > node->nodeIndex())
position.moveToOffset(position.offsetInContainerNode() - 1);
- else if (node->contains(position.containerNode()) || node->contains(position.containerNode()->shadowAncestorNode()))
+ else if (node->containsIncludingShadowDOM(position.containerNode()))
position = positionInParentBeforeNode(node);
break;
case Position::PositionIsAfterAnchor:
- if (node->contains(position.anchorNode()) || node->contains(position.anchorNode()->shadowAncestorNode()))
+ if (node->containsIncludingShadowDOM(position.anchorNode()))
position = positionInParentAfterNode(node);
break;
case Position::PositionIsBeforeAnchor:
- if (node->contains(position.anchorNode()) || node->contains(position.anchorNode()->shadowAncestorNode()))
+ if (node->containsIncludingShadowDOM(position.anchorNode()))
position = positionInParentBeforeNode(node);
break;
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes