From d3a62b73f78f0cdc2a61c062ee7ca99909d0a33b Mon Sep 17 00:00:00 2001 From: roytam1 Date: Thu, 8 Jan 2026 00:11:19 +0800 Subject: [PATCH] import from UXP: Issue #2871 - Restructure `GetEmojiPresentation()` for `Extended_Pictographic` clusters (f13f1bd9) --- gfx/thebes/gfxPlatformGtk.cpp | 2 +- gfx/thebes/gfxPlatformMac.cpp | 2 +- gfx/thebes/gfxWindowsPlatform.cpp | 2 +- intl/unicharutil/util/nsUnicodeProperties.cpp | 10 +++++----- intl/unicharutil/util/nsUnicodeProperties.h | 14 ++++++++------ 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index e8048ca46..391b3676e 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -212,7 +212,7 @@ gfxPlatformGtk::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh, nsTArray& aFontList) { EmojiPresentation emoji = GetEmojiPresentation(aCh); - EmojiPresentation eNext = GetEmojiPresentation(aNextCh); + EmojiPresentation eNext = GetEmojiPresentation(aNextCh, true); if (aNextCh != kVariationSelector15 && emoji != EmojiPresentation::TextOnly && (emoji != EmojiPresentation::TextDefault || diff --git a/gfx/thebes/gfxPlatformMac.cpp b/gfx/thebes/gfxPlatformMac.cpp index 6137b6fd8..6aa2d901a 100644 --- a/gfx/thebes/gfxPlatformMac.cpp +++ b/gfx/thebes/gfxPlatformMac.cpp @@ -201,7 +201,7 @@ gfxPlatformMac::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh, nsTArray& aFontList) { EmojiPresentation emoji = GetEmojiPresentation(aCh); - EmojiPresentation eNext = GetEmojiPresentation(aNextCh); + EmojiPresentation eNext = GetEmojiPresentation(aNextCh, true); if (aNextCh != kVariationSelector15 && emoji != EmojiPresentation::TextOnly && (emoji != EmojiPresentation::TextDefault || diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index be51fc797..f4b03123e 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -647,7 +647,7 @@ gfxWindowsPlatform::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh, nsTArray& aFontList) { EmojiPresentation emoji = GetEmojiPresentation(aCh); - EmojiPresentation eNext = GetEmojiPresentation(aNextCh); + EmojiPresentation eNext = GetEmojiPresentation(aNextCh, true); if (aNextCh != kVariationSelector15 && emoji != EmojiPresentation::TextOnly && (emoji != EmojiPresentation::TextDefault || diff --git a/intl/unicharutil/util/nsUnicodeProperties.cpp b/intl/unicharutil/util/nsUnicodeProperties.cpp index 5b9f5b905..47d54d6ba 100644 --- a/intl/unicharutil/util/nsUnicodeProperties.cpp +++ b/intl/unicharutil/util/nsUnicodeProperties.cpp @@ -275,10 +275,10 @@ ClusterIterator::Next() IsClusterExtender(ch) || IsEmojiClusterExtender(ch) || (baseIsEmoji && prevWasZwj && - ((GetEmojiPresentation(ch) == EmojiDefault) || - (GetEmojiPresentation(ch) == EmojiComponent) || - (GetEmojiPresentation(ch) == TextDefault && - GetEmojiPresentation(aExtCh) == EmojiComponent))); + ((GetEmojiPresentation(ch, true) == EmojiDefault) || + (GetEmojiPresentation(ch, true) == EmojiComponent) || + (GetEmojiPresentation(ch, true) == TextDefault && + GetEmojiPresentation(aExtCh, true) == EmojiComponent))); if (!extendCluster) { break; } @@ -346,7 +346,7 @@ ClusterReverseIterator::Next() } break; } - nextWasComponent = (GetEmojiPresentation(ch) == EmojiComponent); + nextWasComponent = (GetEmojiPresentation(ch, true) == EmojiComponent); } while ((mPos - tRel) > mLimit); mPos -= tPos; diff --git a/intl/unicharutil/util/nsUnicodeProperties.h b/intl/unicharutil/util/nsUnicodeProperties.h index 3b7b54ed8..fe60ffe50 100644 --- a/intl/unicharutil/util/nsUnicodeProperties.h +++ b/intl/unicharutil/util/nsUnicodeProperties.h @@ -184,19 +184,21 @@ IsDefaultIgnorable(uint32_t aCh) } inline EmojiPresentation -GetEmojiPresentation(uint32_t aCh) +GetEmojiPresentation(uint32_t aCh, bool bExt = false) { if (u_hasBinaryProperty(aCh, UCHAR_EMOJI_COMPONENT)) { return EmojiComponent; } - if (u_hasBinaryProperty(aCh, UCHAR_EMOJI) && - !u_hasBinaryProperty(aCh, UCHAR_EMOJI_PRESENTATION)) { - return TextDefault; + if (!u_hasBinaryProperty(aCh, UCHAR_EMOJI)) { + return TextOnly; } - if (u_hasBinaryProperty(aCh, UCHAR_EXTENDED_PICTOGRAPHIC)) { + if (u_hasBinaryProperty(aCh, UCHAR_EMOJI_PRESENTATION)) { return EmojiDefault; } - return TextOnly; + if (bExt && u_hasBinaryProperty(aCh, UCHAR_EXTENDED_PICTOGRAPHIC)) { + return EmojiDefault; + } + return TextDefault; } // returns the simplified Gen Category as defined in nsIUGenCategory