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

Unified Diff: Source/core/editing/DOMSelection.cpp

Issue 800633004: ShadowRoot's getSelection().getRangeAt(0) returns an incorrect Range object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix test failures Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/DOMSelection.cpp
diff --git a/Source/core/editing/DOMSelection.cpp b/Source/core/editing/DOMSelection.cpp
index 25703e256911f5e5673ad5af24a39089b115e0d4..76d1e5ebbe288eda38ac7c0662bb06d468ebeaa9 100644
--- a/Source/core/editing/DOMSelection.cpp
+++ b/Source/core/editing/DOMSelection.cpp
@@ -369,14 +369,13 @@ PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState
// If you're hitting this, you've added broken multi-range selection support
ASSERT(rangeCount() == 1);
- if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) {
- ASSERT(!shadowAncestor->isShadowRoot());
- ContainerNode* container = shadowAncestor->parentOrShadowHostNode();
- int offset = shadowAncestor->nodeIndex();
- return Range::create(shadowAncestor->document(), container, offset, container, offset);
- }
+ Position anchor = anchorPosition(visibleSelection());
+ if (!anchor.anchorNode()->isInShadowTree())
+ return m_frame->selection().firstRange();
- return m_frame->selection().firstRange();
+ if (!visibleSelection().isBaseFirst())
+ return Range::create(*anchor.document(), focusNode(), focusOffset(), shadowAdjustedNode(anchor), anchorOffset());
Yuta Kitamura 2015/01/07 07:50:57 Does anchorOffset() work for shadowAdjustedNode(an
kojii 2015/01/07 08:20:43 Yes, this |anchorOffset()| is |DOMSelection::ancho
Yuta Kitamura 2015/01/07 08:47:54 Okay, then the PS5 looks fine to me. I don't have
+ return Range::create(*anchor.document(), shadowAdjustedNode(anchor), anchorOffset(), focusNode(), focusOffset());
}
void DOMSelection::removeAllRanges()
« no previous file with comments | « LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698