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

Unified Diff: Source/core/accessibility/AXRenderObject.cpp

Issue 560333002: Avoid more temporary ranges in connection with various TextIterators. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix mac build. Created 6 years, 3 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 | « no previous file | Source/core/dom/DocumentMarkerController.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/accessibility/AXRenderObject.cpp
diff --git a/Source/core/accessibility/AXRenderObject.cpp b/Source/core/accessibility/AXRenderObject.cpp
index 48f8af107b7377f187f18f784f1cc8cebc3941bf..05c40804f5ff5fb854cd1445ab2f7325e8b6ff48 100644
--- a/Source/core/accessibility/AXRenderObject.cpp
+++ b/Source/core/accessibility/AXRenderObject.cpp
@@ -1738,12 +1738,14 @@ VisiblePosition AXRenderObject::visiblePositionForIndex(int index) const
if (index <= 0)
return VisiblePosition(firstPositionInOrBeforeNode(node), DOWNSTREAM);
- RefPtrWillBeRawPtr<Range> range = Range::create(m_renderer->document());
- range->selectNodeContents(node, IGNORE_EXCEPTION);
- CharacterIterator it(range.get());
+ Position start, end;
+ bool selected = Range::selectNodeContents(node, start, end);
+ if (!selected)
+ return VisiblePosition();
+
+ CharacterIterator it(start, end);
it.advance(index - 1);
- return VisiblePosition(Position(it.range()->endContainer(), it.range()->endOffset(), Position::PositionIsOffsetInAnch\
-or), UPSTREAM);
+ return VisiblePosition(Position(it.endContainer(), it.endOffset(), Position::PositionIsOffsetInAnchor), UPSTREAM);
}
int AXRenderObject::indexForVisiblePosition(const VisiblePosition& pos) const
« no previous file with comments | « no previous file | Source/core/dom/DocumentMarkerController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698