Index: Source/platform/text/TextBreakIterator.cpp |
diff --git a/Source/platform/text/TextBreakIterator.cpp b/Source/platform/text/TextBreakIterator.cpp |
index ec97484b4650a36532906ddba5e4b44967494ada..750fce265531c3b041cb37bf6abf3f16589e99e3 100644 |
--- a/Source/platform/text/TextBreakIterator.cpp |
+++ b/Source/platform/text/TextBreakIterator.cpp |
@@ -50,6 +50,26 @@ 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], length); |
+ |
+ int cursorPos = cursorPosIterator->current(); |
+ int numGraphemes = -1; |
+ while (0 <= cursorPos) { |
+ cursorPos = cursorPosIterator->next(); |
+ numGraphemes++; |
+ } |
+ |
+ return ClusterData(std::max(numGraphemes, 0), cursorPosIterator->current()); |
+} |
static inline bool isBreakableSpace(UChar ch) |
{ |