Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/ranges/Range-mutations-expected.txt (204310 => 204311)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/ranges/Range-mutations-expected.txt 2016-08-09 22:25:37 UTC (rev 204310)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/ranges/Range-mutations-expected.txt 2016-08-09 22:30:46 UTC (rev 204311)
@@ -63,9 +63,9 @@
FAIL detachedTextNode.splitText(1), with selected range collapsed at (detachedTextNode, 1) assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
PASS detachedTextNode.splitText(detachedTextNode.length), with unselected range collapsed at (detachedTextNode, detachedTextNode.length)
FAIL detachedTextNode.splitText(detachedTextNode.length), with selected range collapsed at (detachedTextNode, detachedTextNode.length) assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
-FAIL detachedTextNode.splitText(1), with unselected range on detachedTextNode from 1 to 3 assert_equals: Wrong end offset expected 1 but got 3
+PASS detachedTextNode.splitText(1), with unselected range on detachedTextNode from 1 to 3
FAIL detachedTextNode.splitText(1), with selected range on detachedTextNode from 1 to 3 assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
-FAIL detachedTextNode.splitText(2), with unselected range on detachedTextNode from 1 to 3 assert_equals: Wrong end offset expected 2 but got 3
+PASS detachedTextNode.splitText(2), with unselected range on detachedTextNode from 1 to 3
FAIL detachedTextNode.splitText(2), with selected range on detachedTextNode from 1 to 3 assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
PASS detachedTextNode.splitText(3), with unselected range on detachedTextNode from 1 to 3
FAIL detachedTextNode.splitText(3), with selected range on detachedTextNode from 1 to 3 assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
@@ -77,9 +77,9 @@
FAIL detachedForeignTextNode.splitText(1), with selected range collapsed at (detachedForeignTextNode, 1) assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
PASS detachedForeignTextNode.splitText(detachedForeignTextNode.length), with unselected range collapsed at (detachedForeignTextNode, detachedForeignTextNode.length)
FAIL detachedForeignTextNode.splitText(detachedForeignTextNode.length), with selected range collapsed at (detachedForeignTextNode, detachedForeignTextNode.length) assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
-FAIL detachedForeignTextNode.splitText(1), with unselected range on detachedForeignTextNode from 1 to 3 assert_equals: Wrong end offset expected 1 but got 3
+PASS detachedForeignTextNode.splitText(1), with unselected range on detachedForeignTextNode from 1 to 3
FAIL detachedForeignTextNode.splitText(1), with selected range on detachedForeignTextNode from 1 to 3 assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
-FAIL detachedForeignTextNode.splitText(2), with unselected range on detachedForeignTextNode from 1 to 3 assert_equals: Wrong end offset expected 2 but got 3
+PASS detachedForeignTextNode.splitText(2), with unselected range on detachedForeignTextNode from 1 to 3
FAIL detachedForeignTextNode.splitText(2), with selected range on detachedForeignTextNode from 1 to 3 assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
PASS detachedForeignTextNode.splitText(3), with unselected range on detachedForeignTextNode from 1 to 3
FAIL detachedForeignTextNode.splitText(3), with selected range on detachedForeignTextNode from 1 to 3 assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
@@ -91,9 +91,9 @@
FAIL detachedXmlTextNode.splitText(1), with selected range collapsed at (detachedXmlTextNode, 1) assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
PASS detachedXmlTextNode.splitText(detachedXmlTextNode.length), with unselected range collapsed at (detachedXmlTextNode, detachedXmlTextNode.length)
FAIL detachedXmlTextNode.splitText(detachedXmlTextNode.length), with selected range collapsed at (detachedXmlTextNode, detachedXmlTextNode.length) assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
-FAIL detachedXmlTextNode.splitText(1), with unselected range on detachedXmlTextNode from 1 to 3 assert_equals: Wrong end offset expected 1 but got 3
+PASS detachedXmlTextNode.splitText(1), with unselected range on detachedXmlTextNode from 1 to 3
FAIL detachedXmlTextNode.splitText(1), with selected range on detachedXmlTextNode from 1 to 3 assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
-FAIL detachedXmlTextNode.splitText(2), with unselected range on detachedXmlTextNode from 1 to 3 assert_equals: Wrong end offset expected 2 but got 3
+PASS detachedXmlTextNode.splitText(2), with unselected range on detachedXmlTextNode from 1 to 3
FAIL detachedXmlTextNode.splitText(2), with selected range on detachedXmlTextNode from 1 to 3 assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
PASS detachedXmlTextNode.splitText(3), with unselected range on detachedXmlTextNode from 1 to 3
FAIL detachedXmlTextNode.splitText(3), with selected range on detachedXmlTextNode from 1 to 3 assert_equals: Sanity check: selection must have exactly one range after adding the range expected 1 but got 0
Modified: trunk/Source/WebCore/ChangeLog (204310 => 204311)
--- trunk/Source/WebCore/ChangeLog 2016-08-09 22:25:37 UTC (rev 204310)
+++ trunk/Source/WebCore/ChangeLog 2016-08-09 22:30:46 UTC (rev 204311)
@@ -1,5 +1,25 @@
2016-08-09 Chris Dumez <[email protected]>
+ Calling splitText() on a parent-less Text node should update associated ranges
+ https://bugs.webkit.org/show_bug.cgi?id=160710
+
+ Reviewed by Ryosuke Niwa.
+
+ Calling splitText() on a parent-less Text node should update associated ranges:
+ - https://dom.spec.whatwg.org/#concept-text-split (Step 9)
+
+ Previously, we would only update ranges for Text nodes that have a parent.
+
+ No new tests, rebaselined existing test.
+
+ * dom/Range.cpp:
+ (WebCore::boundaryTextNodesSplit):
+ (WebCore::Range::textNodeSplit): Deleted.
+ * dom/Text.cpp:
+ (WebCore::Text::splitText):
+
+2016-08-09 Chris Dumez <[email protected]>
+
Drop unused NodeListsNodeData::isEmpty()
https://bugs.webkit.org/show_bug.cgi?id=160704
Modified: trunk/Source/WebCore/dom/Range.cpp (204310 => 204311)
--- trunk/Source/WebCore/dom/Range.cpp 2016-08-09 22:25:37 UTC (rev 204310)
+++ trunk/Source/WebCore/dom/Range.cpp 2016-08-09 22:30:46 UTC (rev 204311)
@@ -1667,14 +1667,20 @@
static inline void boundaryTextNodesSplit(RangeBoundaryPoint& boundary, Text* oldNode)
{
+ auto* parent = oldNode->parentNode();
if (boundary.container() == oldNode) {
unsigned splitOffset = oldNode->length();
unsigned boundaryOffset = boundary.offset();
- if (boundaryOffset > splitOffset)
- boundary.set(*oldNode->nextSibling(), boundaryOffset - splitOffset, 0);
+ if (boundaryOffset > splitOffset) {
+ if (parent)
+ boundary.set(*oldNode->nextSibling(), boundaryOffset - splitOffset, 0);
+ else
+ boundary.setOffset(splitOffset);
+ }
return;
}
- auto* parent = oldNode->parentNode();
+ if (!parent)
+ return;
if (boundary.container() == parent && boundary.childBefore() == oldNode) {
auto* newChild = oldNode->nextSibling();
ASSERT(newChild);
@@ -1686,7 +1692,6 @@
{
ASSERT(oldNode);
ASSERT(&oldNode->document() == &ownerDocument());
- ASSERT(oldNode->parentNode());
ASSERT(oldNode->isTextNode());
ASSERT(oldNode->nextSibling());
ASSERT(oldNode->nextSibling()->isTextNode());
Modified: trunk/Source/WebCore/dom/Text.cpp (204310 => 204311)
--- trunk/Source/WebCore/dom/Text.cpp 2016-08-09 22:25:37 UTC (rev 204310)
+++ trunk/Source/WebCore/dom/Text.cpp 2016-08-09 22:30:46 UTC (rev 204311)
@@ -79,8 +79,7 @@
if (ec)
return 0;
- if (parentNode())
- document().textNodeSplit(this);
+ document().textNodeSplit(this);
if (renderer())
renderer()->setTextWithOffset(data(), 0, oldStr.length());