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

Issue 800633004: ShadowRoot's getSelection().getRangeAt(0) returns an incorrect Range object (Closed)

Created:
5 years, 11 months ago by kojii
Modified:
5 years, 11 months ago
CC:
blink-reviews
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Target Ref:
refs/heads/master
Project:
blink
Visibility:
Public.

Description

ShadowRoot's getSelection().getRangeAt(0) returns an incorrect Range object DOMSelection::getRangeAt() uses different calculation from what we do in other methods such as DOMSelection::anchorNode(), and it always returns parentOrShadowHostNode(), which is incorrect. This patch makes DOMSelection::getRangeAt() to use the same logic as DOMSelection::anchorNode() etc. if the selection is within a shadow tree. We keep existing code if the selection is not within a shadow tree because it has a special case to return m_logicalSelection so that we can return the range set by scripts without it being canonicalized. BUG=380690 TEST=LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=187976

Patch Set 1 #

Patch Set 2 : #

Total comments: 10

Patch Set 3 : #

Total comments: 2

Patch Set 4 : Removed an excessive ASSERT #

Patch Set 5 : Fix test failures #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+40 lines, -7 lines) Patch
A LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html View 1 2 1 chunk +34 lines, -0 lines 0 comments Download
M Source/core/editing/DOMSelection.cpp View 1 2 3 4 1 chunk +6 lines, -7 lines 3 comments Download

Messages

Total messages: 18 (7 generated)
kojii
PTAL!
5 years, 11 months ago (2015-01-06 08:03:33 UTC) #2
kojii
5 years, 11 months ago (2015-01-06 08:18:34 UTC) #4
yosin_UTC9
https://codereview.chromium.org/800633004/diff/20001/LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html File LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html (right): https://codereview.chromium.org/800633004/diff/20001/LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html#newcode11 LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html:11: assert_equals(selection.anchorNode, textNode); Since we change |getRangeAt()| function, we don't ...
5 years, 11 months ago (2015-01-06 08:39:37 UTC) #5
yosin_UTC9
LGTM w/ nit https://codereview.chromium.org/800633004/diff/40001/Source/core/editing/DOMSelection.cpp File Source/core/editing/DOMSelection.cpp (right): https://codereview.chromium.org/800633004/diff/40001/Source/core/editing/DOMSelection.cpp#newcode376 Source/core/editing/DOMSelection.cpp:376: ASSERT(anchor); I think we don't need ...
5 years, 11 months ago (2015-01-07 01:06:29 UTC) #6
kojii
yutak@, PTAL! https://codereview.chromium.org/800633004/diff/20001/LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html File LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html (right): https://codereview.chromium.org/800633004/diff/20001/LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html#newcode11 LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html:11: assert_equals(selection.anchorNode, textNode); On 2015/01/06 08:39:37, Yosi_afk_til_01_05 wrote: ...
5 years, 11 months ago (2015-01-07 06:53:53 UTC) #11
Yuta Kitamura
https://codereview.chromium.org/800633004/diff/140001/Source/core/editing/DOMSelection.cpp File Source/core/editing/DOMSelection.cpp (right): https://codereview.chromium.org/800633004/diff/140001/Source/core/editing/DOMSelection.cpp#newcode377 Source/core/editing/DOMSelection.cpp:377: return Range::create(*anchor.document(), focusNode(), focusOffset(), shadowAdjustedNode(anchor), anchorOffset()); Does anchorOffset() work ...
5 years, 11 months ago (2015-01-07 07:50:57 UTC) #12
kojii
https://codereview.chromium.org/800633004/diff/140001/Source/core/editing/DOMSelection.cpp File Source/core/editing/DOMSelection.cpp (right): https://codereview.chromium.org/800633004/diff/140001/Source/core/editing/DOMSelection.cpp#newcode377 Source/core/editing/DOMSelection.cpp:377: return Range::create(*anchor.document(), focusNode(), focusOffset(), shadowAdjustedNode(anchor), anchorOffset()); On 2015/01/07 07:50:57, ...
5 years, 11 months ago (2015-01-07 08:20:43 UTC) #13
Yuta Kitamura
lgtm https://codereview.chromium.org/800633004/diff/140001/Source/core/editing/DOMSelection.cpp File Source/core/editing/DOMSelection.cpp (right): https://codereview.chromium.org/800633004/diff/140001/Source/core/editing/DOMSelection.cpp#newcode377 Source/core/editing/DOMSelection.cpp:377: return Range::create(*anchor.document(), focusNode(), focusOffset(), shadowAdjustedNode(anchor), anchorOffset()); On 2015/01/07 ...
5 years, 11 months ago (2015-01-07 08:47:54 UTC) #14
kojii
On 2015/01/07 08:47:54, Yuta Kitamura wrote: > Okay, then the PS5 looks fine to me. ...
5 years, 11 months ago (2015-01-07 15:28:21 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/800633004/140001
5 years, 11 months ago (2015-01-07 15:30:09 UTC) #17
commit-bot: I haz the power
5 years, 11 months ago (2015-01-07 15:33:38 UTC) #18
Message was sent while issue was closed.
Committed patchset #5 (id:140001) as
https://src.chromium.org/viewvc/blink?view=rev&revision=187976

Powered by Google App Engine
This is Rietveld 408576698