diff options
Diffstat (limited to 'WebCore/platform/text/SegmentedString.cpp')
-rw-r--r-- | WebCore/platform/text/SegmentedString.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/WebCore/platform/text/SegmentedString.cpp b/WebCore/platform/text/SegmentedString.cpp index 04d6c77..b9ff503 100644 --- a/WebCore/platform/text/SegmentedString.cpp +++ b/WebCore/platform/text/SegmentedString.cpp @@ -52,6 +52,7 @@ const SegmentedString& SegmentedString::operator=(const SegmentedString &other) else m_currentChar = other.m_currentChar; m_closed = other.m_closed; + m_numberOfCharactersConsumedPriorToCurrentString = other.m_numberOfCharactersConsumedPriorToCurrentString; return *this; } @@ -99,6 +100,7 @@ void SegmentedString::append(const SegmentedSubstring &s) ASSERT(!m_closed); if (s.m_length) { if (!m_currentString.m_length) { + m_numberOfCharactersConsumedPriorToCurrentString += m_currentString.numberOfCharactersConsumed(); m_currentString = s; } else { m_substrings.append(s); @@ -110,7 +112,15 @@ void SegmentedString::append(const SegmentedSubstring &s) void SegmentedString::prepend(const SegmentedSubstring &s) { ASSERT(!escaped()); + ASSERT(!s.numberOfCharactersConsumed()); if (s.m_length) { + // 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. + m_numberOfCharactersConsumedPriorToCurrentString += m_currentString.numberOfCharactersConsumed(); + m_numberOfCharactersConsumedPriorToCurrentString -= s.m_length; if (!m_currentString.m_length) m_currentString = s; else { @@ -160,7 +170,12 @@ void SegmentedString::prepend(const SegmentedString &s) void SegmentedString::advanceSubstring() { if (m_composite) { + m_numberOfCharactersConsumedPriorToCurrentString += m_currentString.numberOfCharactersConsumed(); m_currentString = m_substrings.takeFirst(); + // If we've previously consumed some characters of the non-current + // string, we now account for those characters as part of the current + // string, not as part of "prior to current string." + m_numberOfCharactersConsumedPriorToCurrentString -= m_currentString.numberOfCharactersConsumed(); if (m_substrings.isEmpty()) m_composite = false; } else { |