Changeset 195281 in webkit
- Timestamp:
- Jan 19, 2016 2:47:11 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r195263 r195281 1 2016-01-19 Ryosuke Niwa <rniwa@webkit.org> 2 3 Text::splitText doesn't update Range end points anchored on parent nodes 4 https://bugs.webkit.org/show_bug.cgi?id=153227 5 6 Reviewed by Antti Koivisto. 7 8 Added a regression test since the rebaselined W3C test is incomprehensible. 9 10 * fast/dom/Range/update-range-in-split-text-expected.txt: Added. 11 * fast/dom/Range/update-range-in-split-text.html: Added. 12 1 13 2016-01-19 Ryosuke Niwa <rniwa@webkit.org> 2 14 -
trunk/LayoutTests/imported/w3c/ChangeLog
r195263 r195281 1 2016-01-19 Ryosuke Niwa <rniwa@webkit.org> 2 3 Text::splitText doesn't update Range end points anchored on parent nodes 4 https://bugs.webkit.org/show_bug.cgi?id=153227 5 6 Reviewed by Antti Koivisto. 7 8 Rebaseline the test now that we're passing more test cases. 9 10 * web-platform-tests/dom/ranges/Range-mutations-expected.txt: 11 1 12 2016-01-19 Ryosuke Niwa <rniwa@webkit.org> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/dom/ranges/Range-mutations-expected.txt
r189471 r195281 100 100 PASS paras[0].firstChild.splitText(1), with unselected range collapsed at (paras[0], 0) 101 101 FAIL paras[0].firstChild.splitText(1), with selected range collapsed at (paras[0], 0) assert_equals: Sanity check: selection's range must initially be the same as the range we added expected object "" but got object "" 102 FAIL paras[0].firstChild.splitText(1), with unselected range on paras[0] from 0 to 1 assert_equals: Wrong end offset expected 2 but got 1 102 PASS paras[0].firstChild.splitText(1), with unselected range on paras[0] from 0 to 1 103 103 FAIL paras[0].firstChild.splitText(1), with selected range on paras[0] from 0 to 1 assert_equals: Sanity check: selection's range must initially be the same as the range we added expected object "Äb̈c̈d̈ëf̈g̈ḧ 104 104 " but got object "Äb̈c̈d̈ëf̈g̈ḧ" 105 FAIL paras[0].firstChild.splitText(1), with unselected range collapsed at (paras[0], 1) assert_equals: Wrong start offset expected 2 but got 1 105 PASS paras[0].firstChild.splitText(1), with unselected range collapsed at (paras[0], 1) 106 106 FAIL paras[0].firstChild.splitText(1), with selected range collapsed at (paras[0], 1) assert_equals: Sanity check: selection's range must initially be the same as the range we added expected object "" but got object "" 107 FAIL paras[0].firstChild.splitText(1), with unselected range from (paras[0].firstChild, 1) to (paras[0], 1) assert_equals: Wrong end offset expected 2 but got 1 107 PASS paras[0].firstChild.splitText(1), with unselected range from (paras[0].firstChild, 1) to (paras[0], 1) 108 108 FAIL paras[0].firstChild.splitText(1), with selected range from (paras[0].firstChild, 1) to (paras[0], 1) assert_equals: Sanity check: selection's range must initially be the same as the range we added expected object "̈b̈c̈d̈ëf̈g̈ḧ 109 109 " but got object "b̈c̈d̈ëf̈g̈ḧ" 110 FAIL paras[0].firstChild.splitText(2), with unselected range from (paras[0].firstChild, 1) to (paras[0], 1) assert_equals: Wrong end offset expected 2 but got 1 110 PASS paras[0].firstChild.splitText(2), with unselected range from (paras[0].firstChild, 1) to (paras[0], 1) 111 111 FAIL paras[0].firstChild.splitText(2), with selected range from (paras[0].firstChild, 1) to (paras[0], 1) assert_equals: Sanity check: selection's range must initially be the same as the range we added expected object "̈b̈c̈d̈ëf̈g̈ḧ 112 112 " but got object "b̈c̈d̈ëf̈g̈ḧ" 113 FAIL paras[0].firstChild.splitText(3), with unselected range from (paras[0].firstChild, 1) to (paras[0], 1) assert_equals: Wrong end offset expected 2 but got 1 113 PASS paras[0].firstChild.splitText(3), with unselected range from (paras[0].firstChild, 1) to (paras[0], 1) 114 114 FAIL paras[0].firstChild.splitText(3), with selected range from (paras[0].firstChild, 1) to (paras[0], 1) assert_equals: Sanity check: selection's range must initially be the same as the range we added expected object "̈b̈c̈d̈ëf̈g̈ḧ 115 115 " but got object "b̈c̈d̈ëf̈g̈ḧ" -
trunk/Source/WebCore/ChangeLog
r195264 r195281 1 2016-01-19 Ryosuke Niwa <rniwa@webkit.org> 2 3 Text::splitText doesn't update Range end points anchored on parent nodes 4 https://bugs.webkit.org/show_bug.cgi?id=153227 5 6 Reviewed by Antti Koivisto. 7 8 When a Text node is split into two and there is a Range whose boundary points' container node 9 is its parent and offset appears after the Text node, we must update the boundary points as specified 10 in step 7 of the concept "split" a Text node at https://dom.spec.whatwg.org/#concept-text-split 11 12 1. Insert new node into parent before node’s next sibling. 13 2. For each range whose start node is node and start offset is greater than offset, set its start node 14 to new node and decrease its start offset by offset. 15 3. For each range whose end node is node and end offset is greater than offset, set its end node to 16 new node and decrease its end offset by offset. 17 4. For each range whose start node is parent and start offset is equal to the index of node + 1, 18 increase its start offset by one. 19 5. For each range whose end node is parent and end offset is equal to the index of node + 1, increase 20 its end offset by one. 21 22 Fixed the bug by implementing steps 4 and 5 in boundaryTextNodesSplit. New behavior matches the DOM spec 23 as well as the behavior of Firefox. 24 25 Test: fast/dom/Range/update-range-in-split-text.html 26 27 * dom/Range.cpp: 28 (WebCore::boundaryTextNodesSplit): See above. 29 * dom/RangeBoundaryPoint.h: 30 (WebCore::RangeBoundaryPoint::setToAfterChild): Added. 31 1 32 2016-01-19 Ryosuke Niwa <rniwa@webkit.org> 2 33 -
trunk/Source/WebCore/dom/Range.cpp
r195264 r195281 1713 1713 static inline void boundaryTextNodesSplit(RangeBoundaryPoint& boundary, Text* oldNode) 1714 1714 { 1715 if (boundary.container() != oldNode) 1716 return; 1717 unsigned boundaryOffset = boundary.offset(); 1718 if (boundaryOffset <= oldNode->length()) 1719 return; 1720 boundary.set(oldNode->nextSibling(), boundaryOffset - oldNode->length(), 0); 1715 if (boundary.container() == oldNode) { 1716 unsigned splitOffset = oldNode->length(); 1717 unsigned boundaryOffset = boundary.offset(); 1718 if (boundaryOffset > splitOffset) 1719 boundary.set(oldNode->nextSibling(), boundaryOffset - splitOffset, 0); 1720 return; 1721 } 1722 auto* parent = oldNode->parentNode(); 1723 if (boundary.container() == parent && boundary.childBefore() == oldNode) { 1724 auto* newChild = oldNode->nextSibling(); 1725 ASSERT(newChild); 1726 boundary.setToAfterChild(*newChild); 1727 } 1721 1728 } 1722 1729 -
trunk/Source/WebCore/dom/RangeBoundaryPoint.h
r191955 r195281 50 50 51 51 void setToBeforeChild(Node&); 52 void setToAfterChild(Node&); 52 53 void setToStartOfNode(PassRefPtr<Node>); 53 54 void setToEndOfNode(PassRefPtr<Node>); … … 139 140 ASSERT(child.parentNode()); 140 141 m_childBeforeBoundary = child.previousSibling(); 142 m_containerNode = child.parentNode(); 143 m_offsetInContainer = m_childBeforeBoundary ? invalidOffset : 0; 144 } 145 146 inline void RangeBoundaryPoint::setToAfterChild(Node& child) 147 { 148 ASSERT(child.parentNode()); 149 m_childBeforeBoundary = &child; 141 150 m_containerNode = child.parentNode(); 142 151 m_offsetInContainer = m_childBeforeBoundary ? invalidOffset : 0;
Note: See TracChangeset
for help on using the changeset viewer.