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

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

Issue 1651263003: Detemplatize TextIterator::copyTextTo with ForwardsTextBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@text_buffers
Patch Set: Change ref parameters to ptrs 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/TextIteratorTextState.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp
index 42cfafb24ca2e6344b82f8e57bbd7318aad1a857..ecfab53065ac4731fc22a8ae23255ace2dcc921b 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp
@@ -152,4 +152,30 @@ void TextIteratorTextState::emitText(Node* textNode, LayoutText* layoutObject, i
m_hasEmitted = true;
}
+void TextIteratorTextState::appendTextTo(ForwardsTextBuffer* output, unsigned position, unsigned lengthToAppend) const
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(position + lengthToAppend <= static_cast<unsigned>(length()));
+ // Make sure there's no integer overflow.
+ ASSERT_WITH_SECURITY_IMPLICATION(position + lengthToAppend >= position);
+ if (!lengthToAppend)
+ return;
+ ASSERT(output);
+ if (m_singleCharacterBuffer) {
+ ASSERT(!position);
+ ASSERT(length() == 1);
+ output->pushCharacters(m_singleCharacterBuffer, 1);
+ return;
+ }
+ if (positionNode()) {
+ flushPositionOffsets();
+ unsigned offset = positionStartOffset() + position;
+ if (string().is8Bit())
+ output->pushRange(string().characters8() + offset, lengthToAppend);
+ else
+ output->pushRange(string().characters16() + offset, lengthToAppend);
+ return;
+ }
+ ASSERT_NOT_REACHED(); // "We shouldn't be attempting to append text that doesn't exist.";
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698