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

Unified Diff: third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.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/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

Powered by Google App Engine
This is Rietveld 408576698