Bug 1745113 Part 3 - Change CountGraphemeClusters() to take a Span parameter. r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D135641
This commit is contained in:
@@ -167,8 +167,9 @@ bool IsClusterExtender(uint32_t aCh, uint8_t aCategory) {
|
||||
(aCh >= 0xe0020 && aCh <= 0xe007f)); // emoji (flag) tag characters
|
||||
}
|
||||
|
||||
uint32_t CountGraphemeClusters(const char16_t* aText, uint32_t aLength) {
|
||||
intl::GraphemeClusterBreakIteratorUtf16 iter(aText, aLength);
|
||||
uint32_t CountGraphemeClusters(Span<const char16_t> aText) {
|
||||
intl::GraphemeClusterBreakIteratorUtf16 iter(aText.Elements(),
|
||||
aText.Length());
|
||||
uint32_t result = 0;
|
||||
while (!iter.AtEnd()) {
|
||||
++result;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "mozilla/intl/UnicodeProperties.h"
|
||||
|
||||
#include "mozilla/Span.h"
|
||||
#include "nsBidiUtils.h"
|
||||
#include "nsUGenCategory.h"
|
||||
#include "harfbuzz/hb.h"
|
||||
@@ -159,7 +160,7 @@ inline bool IsClusterExtender(uint32_t aCh) {
|
||||
}
|
||||
|
||||
// Count the number of grapheme clusters in the given string
|
||||
uint32_t CountGraphemeClusters(const char16_t* aText, uint32_t aLength);
|
||||
uint32_t CountGraphemeClusters(Span<const char16_t> aText);
|
||||
|
||||
// Determine whether a character is a "combining diacritic" for the purpose
|
||||
// of diacritic-insensitive text search. Examples of such characters include
|
||||
|
||||
@@ -10481,7 +10481,7 @@ uint32_t nsTextFrame::CountGraphemeClusters() const {
|
||||
nsAutoString content;
|
||||
frag->AppendTo(content, AssertedCast<uint32_t>(GetContentOffset()),
|
||||
AssertedCast<uint32_t>(GetContentLength()));
|
||||
return unicode::CountGraphemeClusters(content.Data(), content.Length());
|
||||
return unicode::CountGraphemeClusters(content);
|
||||
}
|
||||
|
||||
bool nsTextFrame::HasNonSuppressedText() const {
|
||||
|
||||
@@ -1681,10 +1681,8 @@ void CounterStyle::GetCounterText(CounterValue aOrdinal,
|
||||
GetPad(pad);
|
||||
int32_t diff =
|
||||
pad.width -
|
||||
narrow_cast<int32_t>(
|
||||
unicode::CountGraphemeClusters(initialText.Data(),
|
||||
initialText.Length()) +
|
||||
unicode::CountGraphemeClusters(aResult.Data(), aResult.Length()));
|
||||
narrow_cast<int32_t>(unicode::CountGraphemeClusters(initialText) +
|
||||
unicode::CountGraphemeClusters(aResult));
|
||||
if (diff > 0) {
|
||||
auto length = pad.symbol.Length();
|
||||
if (diff > LENGTH_LIMIT || length > LENGTH_LIMIT ||
|
||||
|
||||
Reference in New Issue
Block a user