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

Unified Diff: Source/core/html/HTMLTextFormControlElement.cpp

Issue 560333002: Avoid more temporary ranges in connection with various TextIterators. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
Index: Source/core/html/HTMLTextFormControlElement.cpp
diff --git a/Source/core/html/HTMLTextFormControlElement.cpp b/Source/core/html/HTMLTextFormControlElement.cpp
index 658ef9df2375ac4015e2f817e6984bd35abc38bf..4174b9743a75bf888f8ecba138b8cbbdbe71c351 100644
--- a/Source/core/html/HTMLTextFormControlElement.cpp
+++ b/Source/core/html/HTMLTextFormControlElement.cpp
@@ -393,11 +393,12 @@ VisiblePosition HTMLTextFormControlElement::visiblePositionForIndex(int index) c
{
if (index <= 0)
return VisiblePosition(firstPositionInNode(innerEditorElement()), DOWNSTREAM);
- RefPtrWillBeRawPtr<Range> range = Range::create(document());
- range->selectNodeContents(innerEditorElement(), ASSERT_NO_EXCEPTION);
- CharacterIterator it(range.get());
+ Position start, end;
+ bool selected = Range::selectNodeContents(innerEditorElement(), start, end);
yosin_UTC9 2014/09/12 01:02:24 It seems utilizing |selected| makes cleaner. if (
Mads Ager (chromium) 2014/09/12 10:52:08 Done.
+ ASSERT_UNUSED(selected, selected);
+ CharacterIterator it(start, end);
it.advance(index - 1);
- return VisiblePosition(it.range()->endPosition(), UPSTREAM);
+ return VisiblePosition(it.endPosition(), UPSTREAM);
}
int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& pos) const
« Source/core/editing/TextIterator.cpp ('K') | « Source/core/editing/TextIterator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698