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..4cfbc0be86d69db9e648c5c39139ff1637fccc48 100644 |
--- a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp |
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp |
@@ -152,4 +152,27 @@ 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; |
+ if (m_singleCharacterBuffer) { |
+ ASSERT(!position); |
+ ASSERT(length() == 1); |
+ output.push(m_singleCharacterBuffer); |
+ } else if (positionNode()) { |
+ flushPositionOffsets(); |
+ unsigned offset = positionStartOffset() + position; |
+ if (string().is8Bit()) |
+ output.push(string().characters8() + offset, lengthToAppend); |
+ else |
+ output.push(string().characters16() + offset, lengthToAppend); |
+ } else { |
+ ASSERT_NOT_REACHED(); // "We shouldn't be attempting to append text that doesn't exist."; |
+ } |
+} |
+ |
} // namespace blink |