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

Unified Diff: third_party/WebKit/Source/platform/text/SegmentedString.cpp

Issue 2127043002: SegmentedString::prepend should know if the prepended string is new or previously consumed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/Source/platform/text/SegmentedString.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/text/SegmentedString.cpp
diff --git a/third_party/WebKit/Source/platform/text/SegmentedString.cpp b/third_party/WebKit/Source/platform/text/SegmentedString.cpp
index ec3507ebc712617ffd802488608d8dcc71ca82d9..944a17725d3033764c6bf867982b72650ae7d3d4 100644
--- a/third_party/WebKit/Source/platform/text/SegmentedString.cpp
+++ b/third_party/WebKit/Source/platform/text/SegmentedString.cpp
@@ -87,22 +87,21 @@ void SegmentedString::push(UChar c)
return;
}
- prepend(SegmentedString(String(&c, 1)));
+ prepend(SegmentedString(String(&c, 1)), PrependType::Unconsume);
}
-void SegmentedString::prepend(const SegmentedSubstring& s)
+void SegmentedString::prepend(const SegmentedSubstring& s, PrependType type)
{
ASSERT(!s.numberOfCharactersConsumed());
if (!s.length())
return;
- // FIXME: We're assuming that the prepend were originally consumed by
- // this SegmentedString. We're also ASSERTing that s is a fresh
- // SegmentedSubstring. These assumptions are sufficient for our
- // current use, but we might need to handle the more elaborate
- // cases in the future.
+ // FIXME: We're also ASSERTing that s is a fresh SegmentedSubstring.
+ // The assumption is sufficient for our current use, but we might
+ // need to handle the more elaborate cases in the future.
m_numberOfCharactersConsumedPriorToCurrentString += m_currentString.numberOfCharactersConsumed();
- m_numberOfCharactersConsumedPriorToCurrentString -= s.length();
+ if (type == PrependType::Unconsume)
+ m_numberOfCharactersConsumedPriorToCurrentString -= s.length();
if (!m_currentString.length()) {
m_currentString = s;
updateAdvanceFunctionPointers();
@@ -136,15 +135,15 @@ void SegmentedString::append(const SegmentedString& s)
m_currentChar = m_currentString.length() ? m_currentString.getCurrentChar() : 0;
}
-void SegmentedString::prepend(const SegmentedString& s)
+void SegmentedString::prepend(const SegmentedString& s, PrependType type)
{
if (s.isComposite()) {
Deque<SegmentedSubstring>::const_reverse_iterator it = s.m_substrings.rbegin();
Deque<SegmentedSubstring>::const_reverse_iterator e = s.m_substrings.rend();
for (; it != e; ++it)
- prepend(*it);
+ prepend(*it, type);
}
- prepend(s.m_currentString);
+ prepend(s.m_currentString, type);
m_currentChar = m_currentString.length() ? m_currentString.getCurrentChar() : 0;
}
« no previous file with comments | « third_party/WebKit/Source/platform/text/SegmentedString.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698