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

Unified Diff: third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.h

Issue 1604783002: ALL-IN-ONE: Optimization to previousBoundary() and nextBoundary() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@progressive_accumulator
Patch Set: Created 4 years, 11 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: third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.h
diff --git a/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.h b/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.h
index fa96a52f9c13386cb66fcb39b074b66bb84df7c4..aacc9229b5f637c97243e66632d2c21537383e1a 100644
--- a/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.h
+++ b/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.h
@@ -28,6 +28,7 @@
#include "core/editing/Position.h"
#include "core/editing/iterators/FullyClippedStateStack.h"
+#include "core/editing/iterators/TextBuffer.h"
#include "core/editing/iterators/TextIteratorFlags.h"
#include "platform/heap/Heap.h"
@@ -60,16 +61,8 @@ public:
// Calculate the minimum |actualLength >= minLength| such that code units
// with offset range [position, position + actualLength) are whole code
// points. Prepend these code points to |output| and return |actualLength|.
- template<typename BufferType>
- int copyTextTo(BufferType& output, int position, int minLength) const
- {
- int copiedLength = isBetweenSurrogatePair(position + minLength) ? minLength + 1 : minLength;
- copyCodeUnitsTo(output, position, copiedLength);
- return copiedLength;
- }
-
- template<typename BufferType>
- int copyTextTo(BufferType& output, int position = 0) const { return copyTextTo(output, position, m_textLength - position); }
+ int copyTextTo(BackwardsTextBuffer& output, int position, int minLength) const;
+ int copyTextTo(BackwardsTextBuffer& output, int position = 0) const;
Node* startContainer() const;
int endOffset() const;
@@ -92,21 +85,7 @@ private:
// Prepend code units with offset range [position, position + copyLength)
// to the output buffer.
- template<typename BufferType>
- void copyCodeUnitsTo(BufferType& output, int position, int copyLength) const
- {
- ASSERT(position >= 0);
- ASSERT(copyLength >= 0);
- ASSERT(position + copyLength <= m_textLength);
- // Make sure there's no integer overflow.
- ASSERT(position + copyLength >= position);
- if (m_textLength == 0 || copyLength == 0)
- return;
- if (m_singleCharacterBuffer)
- output.prepend(&m_singleCharacterBuffer, 1);
- else
- m_textContainer.prependTo(output, m_textOffset + m_textLength - position - copyLength, copyLength);
- }
+ void copyCodeUnitsTo(BackwardsTextBuffer& output, int position, int copyLength) const;
// Current position, not necessarily of the text being returned, but position
// as we walk through the DOM tree.

Powered by Google App Engine
This is Rietveld 408576698