tor-browser

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

commit 7a3c4b556acb00cc3a6f067e0a394d3a7ad898eb
parent 2e216f0f8869446dee03f3d12f233dfdbbe5cfb8
Author: Frédéric Wang <fwang@igalia.com>
Date:   Mon,  5 Jan 2026 18:19:15 +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; @@ -171,6 +172,8 @@ class nsUnicodeTable final : public nsGlyphTable { MOZ_COUNTED_DTOR(nsUnicodeTable) + bool IsUnicodeTable() const final { return true; }; + const nsCString& FontNameFor(const nsGlyphCode& aGlyphCode) const override { MOZ_ASSERT_UNREACHABLE(); return VoidCString(); @@ -661,7 +664,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; } @@ -937,7 +940,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]) { @@ -1105,6 +1108,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. @@ -1118,7 +1122,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)) ||