tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 2da44da5de3ba36feece11f887ee6180a38f1cbe
parent 97881a44751d12ebf8e6fbfdf5dbeb9c70428069
Author: Frédéric Wang <fwang@igalia.com>
Date:   Tue,  6 Jan 2026 05:35:36 +0000

Bug 2008530 - Part 2 - Use `nsGlyphTable::IsUnicodeTable()` instead of raw pointer comparison. r=layout-reviewers,dshin,sergesanspaille

`glyph table == &gUnicodeTable` is used in three places with the glyph
table nullptr in `nsMathMLChar::SetFontFamily` when called from
https://searchfox.org/firefox-main/rev/e61d59b5c9a651fd7bf28043f87c0dc669833496/layout/mathml/nsMathMLChar.cpp#1279

Differential Revision: https://phabricator.services.mozilla.com/D277860

Diffstat:
Mlayout/mathml/nsMathMLChar.cpp | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/layout/mathml/nsMathMLChar.cpp b/layout/mathml/nsMathMLChar.cpp @@ -73,6 +73,7 @@ static const nsGlyphCode kNullGlyph = {{0}, false}; class nsGlyphTable { public: virtual ~nsGlyphTable() = default; + virtual bool IsUnicodeTable() const { return false; } virtual const nsCString& FontNameFor(const nsGlyphCode& aGlyphCode) const = 0; @@ -169,6 +170,8 @@ class nsUnicodeTable final : public nsGlyphTable { public: constexpr nsUnicodeTable() = default; + bool IsUnicodeTable() const final { return true; }; + const nsCString& FontNameFor(const nsGlyphCode& aGlyphCode) const override { MOZ_ASSERT_UNREACHABLE(); return VoidCString(); @@ -663,7 +666,7 @@ bool nsMathMLChar::SetFontFamily(nsPresContext* aPresContext, // Set the font if it is an unicode table or if the same family name has // been found. const bool shouldSetFont = [&] { - if (aGlyphTable == &gUnicodeTable) { + if (aGlyphTable && aGlyphTable->IsUnicodeTable()) { return true; } @@ -939,7 +942,7 @@ bool nsMathMLChar::StretchEnumContext::TryParts( // For the Unicode table, we check that all the glyphs are actually found and // come from the same font. - if (aGlyphTable == &gUnicodeTable) { + if (aGlyphTable->IsUnicodeTable()) { gfxFont* unicodeFont = nullptr; for (int32_t i = 0; i < 4; i++) { if (!textRun[i]) { @@ -1107,6 +1110,7 @@ bool nsMathMLChar::StretchEnumContext::EnumCallback( // Fallback to the Unicode table. return &gUnicodeTable; }(); + MOZ_ASSERT(glyphTable); if (!openTypeTable) { // Make sure we only try the UnicodeTable once. @@ -1120,7 +1124,7 @@ bool nsMathMLChar::StretchEnumContext::EnumCallback( // special table is being used then the font in this family should have the // specified glyphs. const StyleFontFamilyList& familyList = - glyphTable == &gUnicodeTable ? context->mFamilyList : family; + glyphTable->IsUnicodeTable() ? context->mFamilyList : family; return (context->mTryVariants && context->TryVariants(glyphTable, &fontGroup, familyList, aRtl)) ||