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

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

Issue 565613002: Remove usages of temporary Range objects that end up registered on the (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
« no previous file with comments | « Source/core/editing/TextIterator.h ('k') | Source/core/editing/VisibleSelection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/TextIterator.cpp
diff --git a/Source/core/editing/TextIterator.cpp b/Source/core/editing/TextIterator.cpp
index c11f0d8bc5e3f672b39f41dcf806232618fb6148..3e4f136ac4f818f359cd59f32605bbf48ef88894 100644
--- a/Source/core/editing/TextIterator.cpp
+++ b/Source/core/editing/TextIterator.cpp
@@ -1289,6 +1289,46 @@ SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator(const Range* r,
int startOffset = r->startOffset();
int endOffset = r->endOffset();
+ init(startNode, endNode, startOffset, endOffset);
+}
+
+SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator(const Position& start, const Position& end, TextIteratorBehaviorFlags behavior)
+ : m_node(nullptr)
+ , m_offset(0)
+ , m_handledNode(false)
+ , m_handledChildren(false)
+ , m_startNode(nullptr)
+ , m_startOffset(0)
+ , m_endNode(nullptr)
+ , m_endOffset(0)
+ , m_positionNode(nullptr)
+ , m_positionStartOffset(0)
+ , m_positionEndOffset(0)
+ , m_textOffset(0)
+ , m_textLength(0)
+ , m_lastTextNode(nullptr)
+ , m_lastCharacter(0)
+ , m_singleCharacterBuffer(0)
+ , m_havePassedStartNode(false)
+ , m_shouldHandleFirstLetter(false)
+ , m_stopsOnFormControls(behavior & TextIteratorStopsOnFormControls)
+ , m_shouldStop(false)
+ , m_emitsOriginalText(false)
+{
+ ASSERT(behavior == TextIteratorDefaultBehavior || behavior == TextIteratorStopsOnFormControls);
+
+ Node* startNode = start.deprecatedNode();
+ if (!startNode)
+ return;
+ Node* endNode = end.deprecatedNode();
+ int startOffset = start.deprecatedEditingOffset();
+ int endOffset = end.deprecatedEditingOffset();
+
+ init(startNode, endNode, startOffset, endOffset);
+}
+
+void SimplifiedBackwardsTextIterator::init(Node* startNode, Node* endNode, int startOffset, int endOffset)
+{
if (!startNode->offsetInCharacters() && startOffset >= 0) {
// NodeTraversal::childAt() will return 0 if the offset is out of range. We rely on this behavior
// instead of calling countChildren() to avoid traversing the children twice.
@@ -1713,6 +1753,16 @@ BackwardsCharacterIterator::BackwardsCharacterIterator(const Range* range, TextI
m_textIterator.advance();
}
+BackwardsCharacterIterator::BackwardsCharacterIterator(const Position& start, const Position& end, TextIteratorBehaviorFlags behavior)
+ : m_offset(0)
+ , m_runOffset(0)
+ , m_atBreak(true)
+ , m_textIterator(start, end, behavior)
+{
+ while (!atEnd() && !m_textIterator.length())
+ m_textIterator.advance();
+}
+
PassRefPtrWillBeRawPtr<Range> BackwardsCharacterIterator::range() const
{
RefPtrWillBeRawPtr<Range> r = m_textIterator.range();
« no previous file with comments | « Source/core/editing/TextIterator.h ('k') | Source/core/editing/VisibleSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698