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

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

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.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp b/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp
index 3d8aeab7673cc8d8e41059adffc7ebadd6fadcd2..7699e3fda12c98fb1f7867b20b14c3b112b30f72 100644
--- a/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp
@@ -410,6 +410,41 @@ bool SimplifiedBackwardsTextIteratorAlgorithm<Strategy>::isBetweenSurrogatePair(
return position > 0 && position < length() && U16_IS_TRAIL(characterAt(position - 1)) && U16_IS_LEAD(characterAt(position));
}
+template <typename Strategy>
+int SimplifiedBackwardsTextIteratorAlgorithm<Strategy>::copyTextTo(BackwardsTextBuffer& output, int position, int minLength) const
+{
+ int copiedLength = isBetweenSurrogatePair(position + minLength) ? minLength + 1 : minLength;
+ copyCodeUnitsTo(output, position, copiedLength);
+ return copiedLength;
+}
+
+template <typename Strategy>
+int SimplifiedBackwardsTextIteratorAlgorithm<Strategy>::copyTextTo(BackwardsTextBuffer& output, int position) const
+{
+ return copyTextTo(output, position, m_textLength - position);
+}
+
+template <typename Strategy>
+void SimplifiedBackwardsTextIteratorAlgorithm<Strategy>::copyCodeUnitsTo(BackwardsTextBuffer& 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.push(m_singleCharacterBuffer);
+ } else {
+ int offset = m_textOffset + m_textLength - position - copyLength;
+ if (m_textContainer.is8Bit())
+ output.push(m_textContainer.characters8() + offset, copyLength);
+ else
+ output.push(m_textContainer.characters16() + offset, copyLength);
+ }
+}
+
template class CORE_TEMPLATE_EXPORT SimplifiedBackwardsTextIteratorAlgorithm<EditingStrategy>;
template class CORE_TEMPLATE_EXPORT SimplifiedBackwardsTextIteratorAlgorithm<EditingInComposedTreeStrategy>;

Powered by Google App Engine
This is Rietveld 408576698