Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Issue 23071006: Make Range::selectNode() and Range::surroundContents() to work with detached node (Closed)

Created:
7 years, 4 months ago by yosin_UTC9
Modified:
7 years, 3 months ago
Reviewers:
tkent, Mike West
CC:
blink-reviews, dglazkov+blink, eae+blinkwatch, adamk+blink_chromium.org
Visibility:
Public.

Description

Make Range::selectNode() and Range::surroundContents() to work with detached node This patch makes Range::selectNode() and Range::surroundContents() to work with detached node by changing Range::selectNode() to call setStart/setEnd directly instead of via Range::setStartBefore/setEndAfter, which throw exception for detached node. As of the spec, http://dom.spec.whatwg.org/#interface-range, Range::selectNode() accepts detached node but Range::setStartBefore/setEndAfter don't. This patch also updates following layout tests: - LayoutTests/fast/dom/Range/range-exceptions.js Range::selectNode() for detached node no more throw exception. - LayoutTests/fast/dom/Range/resources/intersectsNode.js Range::selectNode() throws an exception with detail message. BUG=275848 TEST=LayoutTests/fast/dom/Range/selectNode-for-detached-node.html, LayoutTests/fast/dom/Range/surroundContents-for-detached-node.html

Patch Set 1 : 2013-08-22T16:53:38 #

Total comments: 7

Patch Set 2 : 2013-08-22T18:44:46 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+71 lines, -14 lines) Patch
M LayoutTests/fast/dom/Range/range-exceptions-expected.txt View 1 chunk +0 lines, -2 lines 0 comments Download
M LayoutTests/fast/dom/Range/range-intersectsNode-expected.txt View 1 1 chunk +1 line, -1 line 0 comments Download
M LayoutTests/fast/dom/Range/resources/intersectsNode.js View 1 1 chunk +1 line, -1 line 0 comments Download
M LayoutTests/fast/dom/Range/script-tests/range-exceptions.js View 1 chunk +0 lines, -6 lines 0 comments Download
A LayoutTests/fast/dom/Range/selectNode-for-detached-node.html View 1 1 chunk +20 lines, -0 lines 0 comments Download
A LayoutTests/fast/dom/Range/selectNode-for-detached-node-expected.txt View 1 1 chunk +6 lines, -0 lines 0 comments Download
A LayoutTests/fast/dom/Range/surroundContents-for-detached-node.html View 1 chunk +29 lines, -0 lines 0 comments Download
A LayoutTests/fast/dom/Range/surroundContents-for-detached-node-expected.txt View 1 chunk +6 lines, -0 lines 0 comments Download
M Source/core/dom/Range.cpp View 1 3 chunks +8 lines, -4 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
Mike West
I'll defer to tkent for the substance of the change. That said, a few comments ...
7 years, 4 months ago (2013-08-22 08:17:11 UTC) #1
yosin_UTC9
PTAL https://codereview.chromium.org/23071006/diff/3001/Source/core/dom/Range.cpp File Source/core/dom/Range.cpp (right): https://codereview.chromium.org/23071006/diff/3001/Source/core/dom/Range.cpp#newcode1330 Source/core/dom/Range.cpp:1330: es.throwDOMException(InvalidNodeTypeError); On 2013/08/22 08:17:11, Mike West wrote: > ...
7 years, 4 months ago (2013-08-22 09:48:44 UTC) #2
yosin_UTC9
PTAL - Changed Range.cpp for review comments. - Update tests for new error message by ...
7 years, 4 months ago (2013-08-22 09:58:30 UTC) #3
Mike West
https://codereview.chromium.org/23071006/diff/3001/Source/core/dom/Range.cpp File Source/core/dom/Range.cpp (right): https://codereview.chromium.org/23071006/diff/3001/Source/core/dom/Range.cpp#newcode1337 Source/core/dom/Range.cpp:1337: setStart(refNode->parentNode(), refNode->nodeIndex(), es); On 2013/08/22 09:48:44, Yoshifumi Inoue wrote: ...
7 years, 4 months ago (2013-08-22 10:23:47 UTC) #4
Mike West
On 2013/08/22 10:23:47, Mike West wrote: > https://codereview.chromium.org/23071006/diff/3001/Source/core/dom/Range.cpp > File Source/core/dom/Range.cpp (right): > > https://codereview.chromium.org/23071006/diff/3001/Source/core/dom/Range.cpp#newcode1337 ...
7 years, 4 months ago (2013-08-22 11:10:25 UTC) #5
Stepien Nicolas
7 years, 4 months ago (2013-08-22 11:52:04 UTC) #6
>As of the spec, http://dom.spec.whatwg.org/#interface-range,
Range::selectNode() accepts detached node but Range::setStartBefore/setEndAfter
don't. 

I don't know where you got that idea, but we should be able to use
setStartBefore/setStartAfter/setEndBefore/setEndAfter on detached nodes, as long
as they have a parent:
http://dom.spec.whatwg.org/#dom-range-setstartbefore
http://dom.spec.whatwg.org/#dom-range-setstartafter
http://dom.spec.whatwg.org/#dom-range-setendbefore
http://dom.spec.whatwg.org/#dom-range-setendafter

The spec it is pretty clear about the methods' instructions, so you might want
to review all range methods to see if they work as defined, whether it's on
detached node or not.

Powered by Google App Engine
This is Rietveld 408576698