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

Unified Diff: Source/core/editing/SurroundingText.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 | « Source/core/editing/PlainTextRange.cpp ('k') | Source/core/editing/TextIterator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/SurroundingText.cpp
diff --git a/Source/core/editing/SurroundingText.cpp b/Source/core/editing/SurroundingText.cpp
index a1481cbf2aab71c13601b105b182acb67e690a10..cf3f8c212b8cfcda1c72c34c2e9c3ee3fd1b4e15 100644
--- a/Source/core/editing/SurroundingText.cpp
+++ b/Source/core/editing/SurroundingText.cpp
@@ -73,7 +73,7 @@ void SurroundingText::initialize(const Position& startPosition, const Position&
if (!forwardIterator.atEnd())
forwardIterator.advance(maxLength - halfMaxLength);
- forwardRange = forwardIterator.range();
+ forwardRange = forwardIterator.createRange();
if (!forwardRange || !Range::create(*document, endPosition, forwardRange->startPosition())->text().length()) {
ASSERT(forwardRange);
return;
@@ -87,15 +87,9 @@ void SurroundingText::initialize(const Position& startPosition, const Position&
if (!backwardsIterator.atEnd())
backwardsIterator.advance(halfMaxLength);
- backwardsRange = backwardsIterator.range();
- if (!backwardsRange) {
- ASSERT(backwardsRange);
- return;
- }
-
- m_startOffsetInContent = Range::create(*document, backwardsRange->endPosition(), startPosition)->text().length();
- m_endOffsetInContent = Range::create(*document, backwardsRange->endPosition(), endPosition)->text().length();
- m_contentRange = Range::create(*document, backwardsRange->endPosition(), forwardRange->startPosition());
+ m_startOffsetInContent = Range::create(*document, backwardsIterator.endPosition(), startPosition)->text().length();
+ m_endOffsetInContent = Range::create(*document, backwardsIterator.endPosition(), endPosition)->text().length();
+ m_contentRange = Range::create(*document, backwardsIterator.endPosition(), forwardRange->startPosition());
ASSERT(m_contentRange);
}
« no previous file with comments | « Source/core/editing/PlainTextRange.cpp ('k') | Source/core/editing/TextIterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698