tor-browser

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

commit ad2f25ae659bd4bf1af59adb6d26da4357d674b1
parent 291e676b1d581375adbe91ccac5a4ff05d62aa73
Author: Frédéric Wang <fwang@igalia.com>
Date:   Thu,  8 Jan 2026 15:24:07 +0000

Bug 2008902 - Make eMathMLFrameType an enum class. r=emilio,layout-reviewers

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

Diffstat:
Mlayout/mathml/nsIMathMLFrame.h | 22+++++++++++-----------
Mlayout/mathml/nsMathMLContainerFrame.cpp | 101++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mlayout/mathml/nsMathMLContainerFrame.h | 2+-
Mlayout/mathml/nsMathMLFrame.cpp | 4++--
Mlayout/mathml/nsMathMLFrame.h | 6+++---
Mlayout/mathml/nsMathMLTokenFrame.cpp | 8++++----
Mlayout/mathml/nsMathMLTokenFrame.h | 2+-
Mlayout/mathml/nsMathMLmfracFrame.cpp | 4++--
Mlayout/mathml/nsMathMLmfracFrame.h | 2+-
Mlayout/mathml/nsMathMLmoFrame.cpp | 6+++---
Mlayout/mathml/nsMathMLmoFrame.h | 2+-
Mlayout/mathml/nsMathMLmrowFrame.cpp | 2+-
Mlayout/mathml/nsMathMLmrowFrame.h | 2+-
13 files changed, 82 insertions(+), 81 deletions(-)

diff --git a/layout/mathml/nsIMathMLFrame.h b/layout/mathml/nsIMathMLFrame.h @@ -19,16 +19,16 @@ class ReflowOutput; // For MathML, this 'type' will be used to determine the spacing between frames // Subclasses can return a 'type' that will give them a particular spacing -enum eMathMLFrameType { - eMathMLFrameType_UNKNOWN = -1, - eMathMLFrameType_Ordinary, - eMathMLFrameType_OperatorOrdinary, - eMathMLFrameType_OperatorInvisible, - eMathMLFrameType_OperatorUserDefined, - eMathMLFrameType_Inner, - eMathMLFrameType_ItalicIdentifier, - eMathMLFrameType_UprightIdentifier, - eMathMLFrameType_COUNT +enum class MathMLFrameType { + Unknown = -1, + Ordinary, + OperatorOrdinary, + OperatorInvisible, + OperatorUserDefined, + Inner, + ItalicIdentifier, + UprightIdentifier, + Count }; // Bits used for the presentation flags -- these bits are set @@ -120,7 +120,7 @@ class nsIMathMLFrame { NS_IMETHOD SetReference(const nsPoint& aReference) = 0; - virtual eMathMLFrameType GetMathMLFrameType() = 0; + virtual MathMLFrameType GetMathMLFrameType() = 0; /* SUPPORT FOR STRETCHY ELEMENTS */ /*====================================================================*/ diff --git a/layout/mathml/nsMathMLContainerFrame.cpp b/layout/mathml/nsMathMLContainerFrame.cpp @@ -58,7 +58,7 @@ void nsMathMLContainerFrame::SaveReflowAndBoundingMetricsFor( /* static */ void nsMathMLContainerFrame::GetReflowAndBoundingMetricsFor( nsIFrame* aFrame, ReflowOutput& aReflowOutput, - nsBoundingMetrics& aBoundingMetrics, eMathMLFrameType* aMathMLFrameType) { + nsBoundingMetrics& aBoundingMetrics, MathMLFrameType* aMathMLFrameType) { MOZ_ASSERT(aFrame, "null arg"); ReflowOutput* reflowOutput = aFrame->GetProperty(HTMLReflowOutputProperty()); @@ -80,7 +80,7 @@ void nsMathMLContainerFrame::GetReflowAndBoundingMetricsFor( return; } } - *aMathMLFrameType = eMathMLFrameType_UNKNOWN; + *aMathMLFrameType = MathMLFrameType::Unknown; } } @@ -989,31 +989,32 @@ void nsMathMLContainerFrame::GetIntrinsicISizeMetrics( // see spacing table in Chapter 18, TeXBook (p.170) // Our table isn't quite identical to TeX because operators have // built-in values for lspace & rspace in the Operator Dictionary. -static int32_t - kInterFrameSpacingTable[eMathMLFrameType_COUNT][eMathMLFrameType_COUNT] = { - // in units of muspace. - // upper half of the byte is set if the - // spacing is not to be used for scriptlevel > 0 - - /* Ord OpOrd OpInv OpUsr Inner Italic Upright */ - /*Ord */ {0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00}, - /*OpOrd */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - /*OpInv */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - /*OpUsr */ {0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01}, - /*Inner */ {0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01}, - /*Italic */ {0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01}, - /*Upright*/ {0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00}}; - -#define GET_INTERSPACE(scriptlevel_, frametype1_, frametype2_, space_) \ - /* no space if there is a frame that we know nothing about */ \ - if (frametype1_ == eMathMLFrameType_UNKNOWN || \ - frametype2_ == eMathMLFrameType_UNKNOWN) \ - space_ = 0; \ - else { \ - space_ = kInterFrameSpacingTable[frametype1_][frametype2_]; \ - space_ = (scriptlevel_ > 0 && (space_ & 0xF0)) \ - ? 0 /* spacing is disabled */ \ - : space_ & 0x0F; \ +static int32_t kInterFrameSpacingTable[size_t(MathMLFrameType::Count)][size_t( + MathMLFrameType::Count)] = { + // in units of muspace. + // upper half of the byte is set if the + // spacing is not to be used for scriptlevel > 0 + + /* Ord OpOrd OpInv OpUsr Inner Italic Upright */ + /*Ord */ {0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00}, + /*OpOrd */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + /*OpInv */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + /*OpUsr */ {0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01}, + /*Inner */ {0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01}, + /*Italic */ {0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01}, + /*Upright*/ {0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00}}; + +#define GET_INTERSPACE(scriptlevel_, frametype1_, frametype2_, space_) \ + /* no space if there is a frame that we know nothing about */ \ + if (frametype1_ == MathMLFrameType::Unknown || \ + frametype2_ == MathMLFrameType::Unknown) \ + space_ = 0; \ + else { \ + space_ = \ + kInterFrameSpacingTable[size_t(frametype1_)][size_t(frametype2_)]; \ + space_ = (scriptlevel_ > 0 && (space_ & 0xF0)) \ + ? 0 /* spacing is disabled */ \ + : space_ & 0x0F; \ } // This function computes the inter-space between two frames. However, @@ -1027,28 +1028,28 @@ static int32_t // @returns: current inter-space (which is 0 when the true inter-space is // delayed -- and thus has no effect since the frame is invisible anyway). static nscoord GetInterFrameSpacing(int32_t aScriptLevel, - eMathMLFrameType aFirstFrameType, - eMathMLFrameType aSecondFrameType, - eMathMLFrameType* aFromFrameType, // IN/OUT - int32_t* aCarrySpace) // IN/OUT + MathMLFrameType aFirstFrameType, + MathMLFrameType aSecondFrameType, + MathMLFrameType* aFromFrameType, // IN/OUT + int32_t* aCarrySpace) // IN/OUT { - eMathMLFrameType firstType = aFirstFrameType; - eMathMLFrameType secondType = aSecondFrameType; + MathMLFrameType firstType = aFirstFrameType; + MathMLFrameType secondType = aSecondFrameType; int32_t space; GET_INTERSPACE(aScriptLevel, firstType, secondType, space); // feedback control to avoid the inter-space to be added when not necessary - if (secondType == eMathMLFrameType_OperatorInvisible) { + if (secondType == MathMLFrameType::OperatorInvisible) { // see if we should start to carry the space forward until we // encounter a visible frame - if (*aFromFrameType == eMathMLFrameType_UNKNOWN) { + if (*aFromFrameType == MathMLFrameType::Unknown) { *aFromFrameType = firstType; *aCarrySpace = space; } // keep carrying *aCarrySpace forward, while returning 0 for this stage space = 0; - } else if (*aFromFrameType != eMathMLFrameType_UNKNOWN) { + } else if (*aFromFrameType != MathMLFrameType::Unknown) { // no carry-forward anymore, get the real inter-space between // the two frames of interest @@ -1063,10 +1064,10 @@ static nscoord GetInterFrameSpacing(int32_t aScriptLevel, // the trick to get the inter-space in either situation // is to promote "<mi>sin</mi><mo>&ApplyFunction;</mo>" and // "<mo>&InvisibileTime;</mo><mi>sin</mi>" to user-defined operators... - if (firstType == eMathMLFrameType_UprightIdentifier) { - firstType = eMathMLFrameType_OperatorUserDefined; - } else if (secondType == eMathMLFrameType_UprightIdentifier) { - secondType = eMathMLFrameType_OperatorUserDefined; + if (firstType == MathMLFrameType::UprightIdentifier) { + firstType = MathMLFrameType::OperatorUserDefined; + } else if (secondType == MathMLFrameType::UprightIdentifier) { + secondType = MathMLFrameType::OperatorUserDefined; } GET_INTERSPACE(aScriptLevel, firstType, secondType, space); @@ -1076,13 +1077,13 @@ static nscoord GetInterFrameSpacing(int32_t aScriptLevel, // If the second type is an operator (e.g., fence), it already has // built-in lspace & rspace, so we let them win. Otherwise we pick // the max between the two values that we have. - if (secondType != eMathMLFrameType_OperatorOrdinary && + if (secondType != MathMLFrameType::OperatorOrdinary && space < *aCarrySpace) { space = *aCarrySpace; } // reset everything now that the carry-forward is done - *aFromFrameType = eMathMLFrameType_UNKNOWN; + *aFromFrameType = MathMLFrameType::Unknown; *aCarrySpace = 0; } @@ -1101,9 +1102,9 @@ class nsMathMLContainerFrame::RowChildFrameIterator { mReflowOutput(aParentFrame->GetWritingMode()), mX(0), mFlags(aFlags), - mChildFrameType(eMathMLFrameType_UNKNOWN), + mChildFrameType(MathMLFrameType::Unknown), mCarrySpace(0), - mFromFrameType(eMathMLFrameType_UNKNOWN), + mFromFrameType(MathMLFrameType::Unknown), mRTL(aParentFrame->StyleVisibility()->mDirection == StyleDirection::Rtl) { if (!mRTL) { @@ -1134,7 +1135,7 @@ class nsMathMLContainerFrame::RowChildFrameIterator { return *this; } - eMathMLFrameType prevFrameType = mChildFrameType; + MathMLFrameType prevFrameType = mChildFrameType; InitMetricsForChild(); // add inter frame spacing @@ -1167,9 +1168,9 @@ class nsMathMLContainerFrame::RowChildFrameIterator { nsMargin mMargin; nscoord mItalicCorrection; - eMathMLFrameType mChildFrameType; + MathMLFrameType mChildFrameType; int32_t mCarrySpace; - eMathMLFrameType mFromFrameType; + MathMLFrameType mFromFrameType; bool mRTL; @@ -1288,9 +1289,9 @@ static nscoord GetInterFrameSpacingFor(int32_t aScriptLevel, } int32_t carrySpace = 0; - eMathMLFrameType fromFrameType = eMathMLFrameType_UNKNOWN; - eMathMLFrameType prevFrameType = eMathMLFrameType_UNKNOWN; - eMathMLFrameType childFrameType = + MathMLFrameType fromFrameType = MathMLFrameType::Unknown; + MathMLFrameType prevFrameType = MathMLFrameType::Unknown; + MathMLFrameType childFrameType = nsMathMLFrame::GetMathMLFrameTypeFor(childFrame); childFrame = childFrame->GetNextSibling(); while (childFrame) { diff --git a/layout/mathml/nsMathMLContainerFrame.h b/layout/mathml/nsMathMLContainerFrame.h @@ -286,7 +286,7 @@ class nsMathMLContainerFrame : public nsContainerFrame, public nsMathMLFrame { static void GetReflowAndBoundingMetricsFor( nsIFrame* aFrame, ReflowOutput& aReflowOutput, nsBoundingMetrics& aBoundingMetrics, - eMathMLFrameType* aMathMLFrameType = nullptr); + MathMLFrameType* aMathMLFrameType = nullptr); // helper method to clear metrics saved with // SaveReflowAndBoundingMetricsFor() from all child frames. diff --git a/layout/mathml/nsMathMLFrame.cpp b/layout/mathml/nsMathMLFrame.cpp @@ -30,7 +30,7 @@ using namespace mozilla; using namespace mozilla::gfx; -eMathMLFrameType nsMathMLFrame::GetMathMLFrameType() { +MathMLFrameType nsMathMLFrame::GetMathMLFrameType() { // see if it is an embellished operator (mapped to 'Op' in TeX) if (mEmbellishData.coreFrame) { return GetMathMLFrameTypeFor(mEmbellishData.coreFrame); @@ -42,7 +42,7 @@ eMathMLFrameType nsMathMLFrame::GetMathMLFrameType() { } // everything else is treated as ordinary (mapped to 'Ord' in TeX) - return eMathMLFrameType_Ordinary; + return MathMLFrameType::Ordinary; } NS_IMETHODIMP diff --git a/layout/mathml/nsMathMLFrame.h b/layout/mathml/nsMathMLFrame.h @@ -49,7 +49,7 @@ class nsMathMLFrame : public nsIMathMLFrame { return NS_OK; } - eMathMLFrameType GetMathMLFrameType() override; + MathMLFrameType GetMathMLFrameType() override; NS_IMETHOD Stretch(mozilla::gfx::DrawTarget* aDrawTarget, @@ -129,13 +129,13 @@ class nsMathMLFrame : public nsIMathMLFrame { static nscoord CalcLength(const nsCSSValue& aCSSValue, float aFontSizeInflation, nsIFrame* aFrame); - static eMathMLFrameType GetMathMLFrameTypeFor(nsIFrame* aFrame) { + static MathMLFrameType GetMathMLFrameTypeFor(nsIFrame* aFrame) { if (aFrame->IsMathMLFrame()) { if (nsIMathMLFrame* mathMLFrame = do_QueryFrame(aFrame)) { return mathMLFrame->GetMathMLFrameType(); } } - return eMathMLFrameType_UNKNOWN; + return MathMLFrameType::Unknown; } // estimate of the italic correction diff --git a/layout/mathml/nsMathMLTokenFrame.cpp b/layout/mathml/nsMathMLTokenFrame.cpp @@ -34,10 +34,10 @@ nsMathMLTokenFrame::InheritAutomaticData(nsIFrame* aParent) { return NS_OK; } -eMathMLFrameType nsMathMLTokenFrame::GetMathMLFrameType() { +MathMLFrameType nsMathMLTokenFrame::GetMathMLFrameType() { // treat everything other than <mi> as ordinary... if (!mContent->IsMathMLElement(nsGkAtoms::mi)) { - return eMathMLFrameType_Ordinary; + return MathMLFrameType::Ordinary; } StyleMathVariant mathVariant = StyleFont()->mMathVariant; @@ -48,9 +48,9 @@ eMathMLFrameType nsMathMLTokenFrame::GetMathMLFrameType() { mathVariant == StyleMathVariant::BoldItalic || mathVariant == StyleMathVariant::SansSerifItalic || mathVariant == StyleMathVariant::SansSerifBoldItalic) { - return eMathMLFrameType_ItalicIdentifier; + return MathMLFrameType::ItalicIdentifier; } - return eMathMLFrameType_UprightIdentifier; + return MathMLFrameType::UprightIdentifier; } void nsMathMLTokenFrame::MarkTextFramesAsTokenMathML() { diff --git a/layout/mathml/nsMathMLTokenFrame.h b/layout/mathml/nsMathMLTokenFrame.h @@ -37,7 +37,7 @@ class nsMathMLTokenFrame : public nsMathMLContainerFrame { NS_IMETHOD InheritAutomaticData(nsIFrame* aParent) override; - eMathMLFrameType GetMathMLFrameType() override; + MathMLFrameType GetMathMLFrameType() override; void SetInitialChildList(ChildListID aListID, nsFrameList&& aChildList) override; diff --git a/layout/mathml/nsMathMLmfracFrame.cpp b/layout/mathml/nsMathMLmfracFrame.cpp @@ -38,9 +38,9 @@ NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmfracFrame) nsMathMLmfracFrame::~nsMathMLmfracFrame() = default; -eMathMLFrameType nsMathMLmfracFrame::GetMathMLFrameType() { +MathMLFrameType nsMathMLmfracFrame::GetMathMLFrameType() { // frac is "inner" in TeXBook, Appendix G, rule 15e. See also page 170. - return eMathMLFrameType_Inner; + return MathMLFrameType::Inner; } uint8_t nsMathMLmfracFrame::ScriptIncrement(nsIFrame* aFrame) { diff --git a/layout/mathml/nsMathMLmfracFrame.h b/layout/mathml/nsMathMLmfracFrame.h @@ -60,7 +60,7 @@ class nsMathMLmfracFrame final : public nsMathMLContainerFrame { friend nsIFrame* NS_NewMathMLmfracFrame(mozilla::PresShell* aPresShell, ComputedStyle* aStyle); - eMathMLFrameType GetMathMLFrameType() override; + MathMLFrameType GetMathMLFrameType() override; void Place(DrawTarget* aDrawTarget, const PlaceFlags& aFlags, ReflowOutput& aDesiredSize) override; diff --git a/layout/mathml/nsMathMLmoFrame.cpp b/layout/mathml/nsMathMLmoFrame.cpp @@ -39,10 +39,10 @@ static const char16_t kInvisibleTimes = char16_t(0x2062); static const char16_t kInvisibleSeparator = char16_t(0x2063); static const char16_t kInvisiblePlus = char16_t(0x2064); -eMathMLFrameType nsMathMLmoFrame::GetMathMLFrameType() { +MathMLFrameType nsMathMLmoFrame::GetMathMLFrameType() { return NS_MATHML_OPERATOR_IS_INVISIBLE(mFlags) - ? eMathMLFrameType_OperatorInvisible - : eMathMLFrameType_OperatorOrdinary; + ? MathMLFrameType::OperatorInvisible + : MathMLFrameType::OperatorOrdinary; } // since a mouse click implies selection, we cannot just rely on the diff --git a/layout/mathml/nsMathMLmoFrame.h b/layout/mathml/nsMathMLmoFrame.h @@ -25,7 +25,7 @@ class nsMathMLmoFrame final : public nsMathMLTokenFrame { friend nsIFrame* NS_NewMathMLmoFrame(mozilla::PresShell* aPresShell, ComputedStyle* aStyle); - eMathMLFrameType GetMathMLFrameType() override; + MathMLFrameType GetMathMLFrameType() override; void DidSetComputedStyle(ComputedStyle* aOldStyle) override; diff --git a/layout/mathml/nsMathMLmrowFrame.cpp b/layout/mathml/nsMathMLmrowFrame.cpp @@ -57,7 +57,7 @@ nsresult nsMathMLmrowFrame::AttributeChanged(int32_t aNameSpaceID, } /* virtual */ -eMathMLFrameType nsMathMLmrowFrame::GetMathMLFrameType() { +MathMLFrameType nsMathMLmrowFrame::GetMathMLFrameType() { if (!IsMrowLike()) { nsIMathMLFrame* child = do_QueryFrame(mFrames.FirstChild()); if (child) { diff --git a/layout/mathml/nsMathMLmrowFrame.h b/layout/mathml/nsMathMLmrowFrame.h @@ -37,7 +37,7 @@ class nsMathMLmrowFrame final : public nsMathMLContainerFrame { return TransmitAutomaticDataForMrowLikeElement(); } - eMathMLFrameType GetMathMLFrameType() override; + MathMLFrameType GetMathMLFrameType() override; bool IsMrowLike() override { // <mrow> elements with a single child are treated identically to the case