Skip to content
Snippets Groups Projects
Commit 81d930a5 authored by Jonathan Kew's avatar Jonathan Kew
Browse files

Bug 1819025 - Don't consider following join-controls when determining whether...

Bug 1819025 - Don't consider following join-controls when determining whether a space is collapsible. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D171061
parent 86bab383
No related branches found
No related tags found
No related merge requests found
...@@ -167,6 +167,15 @@ bool IsClusterExtender(uint32_t aCh, uint8_t aCategory) { ...@@ -167,6 +167,15 @@ bool IsClusterExtender(uint32_t aCh, uint8_t aCategory) {
(aCh >= 0xe0020 && aCh <= 0xe007f)); // emoji (flag) tag characters (aCh >= 0xe0020 && aCh <= 0xe007f)); // emoji (flag) tag characters
} }
bool IsClusterExtenderExcludingJoiners(uint32_t aCh, uint8_t aCategory) {
return (
(aCategory >= HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK &&
aCategory <= HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) ||
(aCh >= 0xff9e && aCh <= 0xff9f) || // katakana sound marks
(aCh >= 0x1F3FB && aCh <= 0x1F3FF) || // fitzpatrick skin tone modifiers
(aCh >= 0xe0020 && aCh <= 0xe007f)); // emoji (flag) tag characters
}
uint32_t CountGraphemeClusters(Span<const char16_t> aText) { uint32_t CountGraphemeClusters(Span<const char16_t> aText) {
intl::GraphemeClusterBreakIteratorUtf16 iter(aText); intl::GraphemeClusterBreakIteratorUtf16 iter(aText);
uint32_t result = 0; uint32_t result = 0;
......
...@@ -159,6 +159,12 @@ inline bool IsClusterExtender(uint32_t aCh) { ...@@ -159,6 +159,12 @@ inline bool IsClusterExtender(uint32_t aCh) {
return IsClusterExtender(aCh, GetGeneralCategory(aCh)); return IsClusterExtender(aCh, GetGeneralCategory(aCh));
} }
bool IsClusterExtenderExcludingJoiners(uint32_t aCh, uint8_t aCategory);
inline bool IsClusterExtenderExcludingJoiners(uint32_t aCh) {
return IsClusterExtenderExcludingJoiners(aCh, GetGeneralCategory(aCh));
}
// Count the number of grapheme clusters in the given string // Count the number of grapheme clusters in the given string
uint32_t CountGraphemeClusters(Span<const char16_t> aText); uint32_t CountGraphemeClusters(Span<const char16_t> aText);
......
...@@ -23,7 +23,7 @@ using namespace mozilla::dom; ...@@ -23,7 +23,7 @@ using namespace mozilla::dom;
bool nsTextFrameUtils::IsSpaceCombiningSequenceTail(const char16_t* aChars, bool nsTextFrameUtils::IsSpaceCombiningSequenceTail(const char16_t* aChars,
int32_t aLength) { int32_t aLength) {
return aLength > 0 && return aLength > 0 &&
(mozilla::unicode::IsClusterExtender(aChars[0]) || (mozilla::unicode::IsClusterExtenderExcludingJoiners(aChars[0]) ||
(IsBidiControl(aChars[0]) && (IsBidiControl(aChars[0]) &&
IsSpaceCombiningSequenceTail(aChars + 1, aLength - 1))); IsSpaceCombiningSequenceTail(aChars + 1, aLength - 1)));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment