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

Unified Diff: Source/WebCore/editing/htmlediting.cpp

Issue 9567016: Merge 108009 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1025/
Patch Set: Created 8 years, 10 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 | « Source/WebCore/editing/htmlediting.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/editing/htmlediting.cpp
===================================================================
--- Source/WebCore/editing/htmlediting.cpp (revision 109365)
+++ Source/WebCore/editing/htmlediting.cpp (working copy)
@@ -1072,31 +1072,24 @@
// opertion is unreliable. TextIterator's TextIteratorEmitsCharactersBetweenAllVisiblePositions mode needs to be fixed,
// or these functions need to be changed to iterate using actual VisiblePositions.
// FIXME: Deploy these functions everywhere that TextIterators are used to convert between VisiblePositions and indices.
-int indexForVisiblePosition(const VisiblePosition& visiblePosition, Element **scope)
+int indexForVisiblePosition(const VisiblePosition& visiblePosition, RefPtr<Element>& scope)
{
if (visiblePosition.isNull())
return 0;
-
+
Position p(visiblePosition.deepEquivalent());
Document* document = p.anchorNode()->document();
-
- Element* root;
Node* shadowRoot = p.anchorNode()->shadowTreeRootNode();
-
+
if (shadowRoot) {
// Use the shadow root for form elements, since TextIterators will not enter shadow content.
ASSERT(shadowRoot->isElementNode());
- root = static_cast<Element*>(shadowRoot);
+ scope = static_cast<Element*>(shadowRoot);
} else
- root = document->documentElement();
-
- if (scope) {
- ASSERT(!*scope);
- *scope = root;
- }
-
- RefPtr<Range> range = Range::create(document, firstPositionInNode(root), p.parentAnchoredEquivalent());
-
+ scope = document->documentElement();
+
+ RefPtr<Range> range = Range::create(document, firstPositionInNode(scope.get()), p.parentAnchoredEquivalent());
+
return TextIterator::rangeLength(range.get(), true);
}
« no previous file with comments | « Source/WebCore/editing/htmlediting.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698