Chromium Code Reviews| Index: Source/platform/text/TextBreakIterator.cpp |
| diff --git a/Source/platform/text/TextBreakIterator.cpp b/Source/platform/text/TextBreakIterator.cpp |
| index ec97484b4650a36532906ddba5e4b44967494ada..e744726cef8d6a475c38d7e83989eb04e34b7dde 100644 |
| --- a/Source/platform/text/TextBreakIterator.cpp |
| +++ b/Source/platform/text/TextBreakIterator.cpp |
| @@ -50,6 +50,27 @@ unsigned numGraphemeClusters(const String& string) |
| return num; |
| } |
| +unsigned numCharactersInGraphemeClusters(const String& string, unsigned numGraphemeClusters) |
|
eae
2015/05/14 23:52:48
We already have an implementation of this in HarfB
changseok
2015/05/15 17:08:56
Sorry, I can't follow this meaning. Do you want an
|
| +{ |
| + unsigned stringLength = string.length(); |
| + |
| + if (!stringLength) |
| + return 0; |
| + |
| + // The only Latin-1 Extended Grapheme Cluster is CR LF |
| + if (string.is8Bit() && !string.contains('\r')) |
| + return std::min(stringLength, numGraphemeClusters); |
| + |
| + NonSharedCharacterBreakIterator it(string); |
| + if (!it) |
| + return std::min(stringLength, numGraphemeClusters); |
| + |
| + for (unsigned i = 0; i < numGraphemeClusters; ++i) { |
| + if (it.next() == TextBreakDone) |
| + return stringLength; |
| + } |
| + return it.current(); |
| +} |
| static inline bool isBreakableSpace(UChar ch) |
| { |