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

Unified Diff: Source/platform/text/TextBreakIterator.cpp

Issue 1133853006: Elements whose contents start with an astral Unicode symbol disappear when CSS `::first-letter` is … Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed UAF failures for ASan Created 5 years, 4 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 | « Source/platform/text/TextBreakIterator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/text/TextBreakIterator.cpp
diff --git a/Source/platform/text/TextBreakIterator.cpp b/Source/platform/text/TextBreakIterator.cpp
index 648ce8b0a4d1e51f15f8993f42fae425e88f9c3e..98e21342abfcef452a7e745e81df0c57c0d1edc9 100644
--- a/Source/platform/text/TextBreakIterator.cpp
+++ b/Source/platform/text/TextBreakIterator.cpp
@@ -50,6 +50,30 @@ unsigned numGraphemeClusters(const String& string)
return num;
}
+ClusterData countCharactersAndGraphemesInCluster(const UChar* normalizedBuffer, unsigned normalizedBufferLength, uint16_t startIndex, uint16_t endIndex)
+{
+ if (startIndex > endIndex) {
+ uint16_t tempIndex = startIndex;
+ startIndex = endIndex;
+ endIndex = tempIndex;
+ }
+
+ uint16_t length = endIndex - startIndex;
+ ASSERT(static_cast<unsigned>(startIndex + length) <= normalizedBufferLength);
+ TextBreakIterator* cursorPosIterator = cursorMovementIterator(&normalizedBuffer[startIndex], normalizedBufferLength);
+
+ int cursorPos = cursorPosIterator->current();
+ unsigned numGraphemes = 0;
+ while (cursorPos < length) {
+ cursorPos = cursorPosIterator->next();
+ if (cursorPos == TextBreakDone)
+ return ClusterData(numGraphemes, normalizedBufferLength);
+
+ numGraphemes++;
+ }
+
+ return ClusterData(numGraphemes, cursorPos);
+}
static inline bool isBreakableSpace(UChar ch)
{
« no previous file with comments | « Source/platform/text/TextBreakIterator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698