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) |
{ |