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

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

Issue 1647483003: Introduce TextBuffer as Output Type of copyTextTo() for Text Iterators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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/TextIterator.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
index 0bd2c59c69a47d009ac9805730df94b9cc459c25..eb2d17e05c9280ad9fcc87f057085ee6f0b95339 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -1112,6 +1112,26 @@ bool TextIteratorAlgorithm<Strategy>::isBetweenSurrogatePair(int position) const
return position > 0 && position < length() && U16_IS_LEAD(characterAt(position - 1)) && U16_IS_TRAIL(characterAt(position));
}
+template <typename Strategy>
+int TextIteratorAlgorithm<Strategy>::copyTextTo(ForwardsTextBuffer& output, int position, int minLength) const
+{
+ int copiedLength = isBetweenSurrogatePair(position + minLength) ? minLength + 1 : minLength;
+ copyCodeUnitsTo(output, position, copiedLength);
+ return copiedLength;
+}
+
+template <typename Strategy>
+int TextIteratorAlgorithm<Strategy>::copyTextTo(ForwardsTextBuffer& output, int position) const
+{
+ return copyTextTo(output, position, length() - position);
+}
+
+template <typename Strategy>
+void TextIteratorAlgorithm<Strategy>::copyCodeUnitsTo(ForwardsTextBuffer& output, int position, int copyLength) const
+{
+ m_textState.appendTextTo(output, position, copyLength);
+}
+
// --------
template <typename Strategy>

Powered by Google App Engine
This is Rietveld 408576698