commit eb94b292ae755ba93c9d065771931379bf792aed parent 50a5799612e6e712d6f20090b2d5ab71a712136e Author: Frédéric Wang <fwang@igalia.com> Date: Thu, 8 Jan 2026 15:24:06 +0000 Bug 2008902 - Convert MathML presentation flags to mozilla::EnumSet. r=emilio,layout-reviewers Differential Revision: https://phabricator.services.mozilla.com/D278091 Diffstat:
18 files changed, 165 insertions(+), 164 deletions(-)
diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp @@ -2441,7 +2441,7 @@ already_AddRefed<gfxTextRun> BuildTextRunsScanner::BuildTextRunForFrames( if (mathFrame) { nsPresentationData presData; mathFrame->GetPresentationData(presData); - if (NS_MATHML_IS_DTLS_SET(presData.flags)) { + if (presData.flags.contains(MathMLPresentationFlag::Dtls)) { mathFlags |= MathMLTextRunFactory::MATH_FONT_FEATURE_DTLS; anyMathMLStyling = true; } diff --git a/layout/mathml/nsIMathMLFrame.h b/layout/mathml/nsIMathMLFrame.h @@ -31,6 +31,37 @@ enum eMathMLFrameType { eMathMLFrameType_COUNT }; +// Bits used for the presentation flags -- these bits are set +// in their relevant situation as they become available +enum class MathMLPresentationFlag : uint8_t { + // This bit is used to emulate TeX rendering. + // Internal use only, cannot be set by the user with an attribute. + Compressed, + + // This bit is set if the frame will fire a vertical stretch + // command on all its (non-empty) children. + // Tags like <mrow> (or an inferred mrow), mpadded, etc, will fire a + // vertical stretch command on all their non-empty children + StretchAllChildrenVertically, + + // This bit is set if the frame will fire a horizontal stretch + // command on all its (non-empty) children. + // Tags like munder, mover, munderover, will fire a + // horizontal stretch command on all their non-empty children + StretchAllChildrenHorizontally, + + // This bit is set if the frame is "space-like", as defined by the spec. + SpaceLike, + + // This bit is set if a token frame should be rendered with the dtls font + // feature setting. + Dtls, + + // a bit used for debug + StretchDone, +}; +using MathMLPresentationFlags = mozilla::EnumSet<MathMLPresentationFlag>; + // Abstract base class that provides additional methods for MathML frames class nsIMathMLFrame { public: @@ -168,7 +199,8 @@ class nsIMathMLFrame { * update some flags in the frame, leaving the other flags unchanged. */ NS_IMETHOD - UpdatePresentationData(uint32_t aFlagsValues, uint32_t aWhichFlags) = 0; + UpdatePresentationData(MathMLPresentationFlags aFlagsValues, + MathMLPresentationFlags aWhichFlags) = 0; /* UpdatePresentationDataFromChildAt : * Sets compression flag on the whole tree. For child frames @@ -193,8 +225,8 @@ class nsIMathMLFrame { */ NS_IMETHOD UpdatePresentationDataFromChildAt(int32_t aFirstIndex, int32_t aLastIndex, - uint32_t aFlagsValues, - uint32_t aWhichFlags) = 0; + MathMLPresentationFlags aFlagsValues, + MathMLPresentationFlags aWhichFlags) = 0; // If aFrame is a child frame, returns the script increment which this frame // imposes on the specified frame, ignoring any artificial adjustments to @@ -242,7 +274,7 @@ struct nsEmbellishData { // descendants that affects us. struct nsPresentationData { // bits for: compressed, etc - uint32_t flags = 0; + MathMLPresentationFlags flags; // handy pointer on our base child (the 'nucleus' in TeX), but it may be // null here (e.g., tags like <mrow>, <mfrac>, <mtable>, etc, won't @@ -251,58 +283,6 @@ struct nsPresentationData { }; // ========================================================================== -// Bits used for the presentation flags -- these bits are set -// in their relevant situation as they become available - -// This bit is used to emulate TeX rendering. -// Internal use only, cannot be set by the user with an attribute. -#define NS_MATHML_COMPRESSED 0x00000002U - -// This bit is set if the frame will fire a vertical stretch -// command on all its (non-empty) children. -// Tags like <mrow> (or an inferred mrow), mpadded, etc, will fire a -// vertical stretch command on all their non-empty children -#define NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY 0x00000004U - -// This bit is set if the frame will fire a horizontal stretch -// command on all its (non-empty) children. -// Tags like munder, mover, munderover, will fire a -// horizontal stretch command on all their non-empty children -#define NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY 0x00000008U - -// This bit is set if the frame is "space-like", as defined by the spec. -#define NS_MATHML_SPACE_LIKE 0x00000040U - -// This bit is set if a token frame should be rendered with the dtls font -// feature setting. -#define NS_MATHML_DTLS 0x00000080U - -// a bit used for debug -#define NS_MATHML_STRETCH_DONE 0x20000000U - -// Macros that retrieve those bits - -#define NS_MATHML_IS_COMPRESSED(_flags) \ - (NS_MATHML_COMPRESSED == ((_flags) & NS_MATHML_COMPRESSED)) - -#define NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY(_flags) \ - (NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY == \ - ((_flags) & NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY)) - -#define NS_MATHML_WILL_STRETCH_ALL_CHILDREN_HORIZONTALLY(_flags) \ - (NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY == \ - ((_flags) & NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY)) - -#define NS_MATHML_IS_SPACE_LIKE(_flags) \ - (NS_MATHML_SPACE_LIKE == ((_flags) & NS_MATHML_SPACE_LIKE)) - -#define NS_MATHML_IS_DTLS_SET(_flags) \ - (NS_MATHML_DTLS == ((_flags) & NS_MATHML_DTLS)) - -#define NS_MATHML_STRETCH_WAS_DONE(_flags) \ - (NS_MATHML_STRETCH_DONE == ((_flags) & NS_MATHML_STRETCH_DONE)) - -// ========================================================================== // Bits used for the embellish flags -- these bits are set // in their relevant situation as they become available diff --git a/layout/mathml/nsMathMLContainerFrame.cpp b/layout/mathml/nsMathMLContainerFrame.cpp @@ -203,11 +203,10 @@ void nsMathMLContainerFrame::GetPreferredStretchSize( } else { // compute a size that includes embellishments iff the container stretches // in the same direction as the embellished operator. - bool stretchAll = aStretchDirection == NS_STRETCH_DIRECTION_VERTICAL - ? NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY( - mPresentationData.flags) - : NS_MATHML_WILL_STRETCH_ALL_CHILDREN_HORIZONTALLY( - mPresentationData.flags); + bool stretchAll = mPresentationData.flags.contains( + aStretchDirection == NS_STRETCH_DIRECTION_VERTICAL + ? MathMLPresentationFlag::StretchAllChildrenVertically + : MathMLPresentationFlag::StretchAllChildrenHorizontally); NS_ASSERTION(aStretchDirection == NS_STRETCH_DIRECTION_HORIZONTAL || aStretchDirection == NS_STRETCH_DIRECTION_VERTICAL, "You must specify a direction in which to stretch"); @@ -294,11 +293,11 @@ nsMathMLContainerFrame::Stretch(DrawTarget* aDrawTarget, nsBoundingMetrics& aContainerSize, ReflowOutput& aDesiredStretchSize) { if (NS_MATHML_IS_EMBELLISH_OPERATOR(mEmbellishData.flags)) { - if (NS_MATHML_STRETCH_WAS_DONE(mPresentationData.flags)) { + if (mPresentationData.flags.contains(MathMLPresentationFlag::StretchDone)) { NS_WARNING("it is wrong to fire stretch more than once on a frame"); return NS_OK; } - mPresentationData.flags |= NS_MATHML_STRETCH_DONE; + mPresentationData.flags += MathMLPresentationFlag::StretchDone; // Pass the stretch to the base child ... @@ -330,11 +329,11 @@ nsMathMLContainerFrame::Stretch(DrawTarget* aDrawTarget, NS_ASSERTION( mEmbellishData.direction != NS_STRETCH_DIRECTION_DEFAULT, "Stretches may have a default direction, operators can not."); - if (mEmbellishData.direction == NS_STRETCH_DIRECTION_VERTICAL - ? NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY( - mPresentationData.flags) - : NS_MATHML_WILL_STRETCH_ALL_CHILDREN_HORIZONTALLY( - mPresentationData.flags)) { + if (mPresentationData.flags.contains( + mEmbellishData.direction == NS_STRETCH_DIRECTION_VERTICAL + ? MathMLPresentationFlag::StretchAllChildrenVertically + : MathMLPresentationFlag:: + StretchAllChildrenHorizontally)) { GetPreferredStretchSize(aDrawTarget, 0, mEmbellishData.direction, containerSize); // Stop further recalculations @@ -357,13 +356,13 @@ nsMathMLContainerFrame::Stretch(DrawTarget* aDrawTarget, // Now that this embellished child may have changed, we need to // fire the stretch on its siblings using our updated size - if (NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY( - mPresentationData.flags) || - NS_MATHML_WILL_STRETCH_ALL_CHILDREN_HORIZONTALLY( - mPresentationData.flags)) { + if (mPresentationData.flags.contains( + MathMLPresentationFlag::StretchAllChildrenVertically) || + mPresentationData.flags.contains( + MathMLPresentationFlag::StretchAllChildrenHorizontally)) { nsStretchDirection stretchDir = - NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY( - mPresentationData.flags) + mPresentationData.flags.contains( + MathMLPresentationFlag::StretchAllChildrenVertically) ? NS_STRETCH_DIRECTION_VERTICAL : NS_STRETCH_DIRECTION_HORIZONTAL; @@ -488,10 +487,10 @@ nsresult nsMathMLContainerFrame::FinalizeReflow(DrawTarget* aDrawTarget, nsPresentationData presentationData; mathMLFrame->GetEmbellishData(embellishData); mathMLFrame->GetPresentationData(presentationData); - if (NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY( - presentationData.flags) || - NS_MATHML_WILL_STRETCH_ALL_CHILDREN_HORIZONTALLY( - presentationData.flags) || + if (presentationData.flags.contains( + MathMLPresentationFlag::StretchAllChildrenVertically) || + presentationData.flags.contains( + MathMLPresentationFlag::StretchAllChildrenHorizontally) || (NS_MATHML_IS_EMBELLISH_OPERATOR(embellishData.flags) && presentationData.baseFrame == this)) { parentWillFireStretch = true; @@ -501,10 +500,10 @@ nsresult nsMathMLContainerFrame::FinalizeReflow(DrawTarget* aDrawTarget, // There is nobody who will fire the stretch for us, we do it ourselves! bool stretchAll = - /* NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY(mPresentationData.flags) + /* mPresentationData.flags.contains(MathMLPresentationFlag::StretchAllChildrenVertically) || */ - NS_MATHML_WILL_STRETCH_ALL_CHILDREN_HORIZONTALLY( - mPresentationData.flags); + mPresentationData.flags.contains( + MathMLPresentationFlag::StretchAllChildrenHorizontally); nsStretchDirection stretchDir; if (mEmbellishData.coreFrame == @@ -551,7 +550,7 @@ nsresult nsMathMLContainerFrame::FinalizeReflow(DrawTarget* aDrawTarget, GatherAndStoreOverflow(&aDesiredSize); } - mPresentationData.flags &= ~NS_MATHML_STRETCH_DONE; + mPresentationData.flags -= MathMLPresentationFlag::StretchDone; return NS_OK; } @@ -566,8 +565,9 @@ nsresult nsMathMLContainerFrame::FinalizeReflow(DrawTarget* aDrawTarget, // a subtree that may contain non-mathml container frames /* static */ void nsMathMLContainerFrame::PropagatePresentationDataFor( - nsIFrame* aFrame, uint32_t aFlagsValues, uint32_t aFlagsToUpdate) { - if (!aFrame || !aFlagsToUpdate) { + nsIFrame* aFrame, MathMLPresentationFlags aFlagsValues, + MathMLPresentationFlags aFlagsToUpdate) { + if (!aFrame || aFlagsToUpdate.isEmpty()) { return; } nsIMathMLFrame* mathMLFrame = do_QueryFrame(aFrame); @@ -589,8 +589,9 @@ void nsMathMLContainerFrame::PropagatePresentationDataFor( /* static */ void nsMathMLContainerFrame::PropagatePresentationDataFromChildAt( nsIFrame* aParentFrame, int32_t aFirstChildIndex, int32_t aLastChildIndex, - uint32_t aFlagsValues, uint32_t aFlagsToUpdate) { - if (!aParentFrame || !aFlagsToUpdate) { + MathMLPresentationFlags aFlagsValues, + MathMLPresentationFlags aFlagsToUpdate) { + if (!aParentFrame || aFlagsToUpdate.isEmpty()) { return; } int32_t index = 0; @@ -862,13 +863,14 @@ void nsMathMLContainerFrame::Reflow(nsPresContext* aPresContext, DrawTarget* drawTarget = aReflowInput.mRenderingContext->GetDrawTarget(); if (!NS_MATHML_IS_EMBELLISH_OPERATOR(mEmbellishData.flags) && - (NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY( - mPresentationData.flags) || - NS_MATHML_WILL_STRETCH_ALL_CHILDREN_HORIZONTALLY( - mPresentationData.flags))) { + (mPresentationData.flags.contains( + MathMLPresentationFlag::StretchAllChildrenVertically) || + mPresentationData.flags.contains( + MathMLPresentationFlag::StretchAllChildrenHorizontally))) { // get the stretchy direction nsStretchDirection stretchDir = - NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY(mPresentationData.flags) + mPresentationData.flags.contains( + MathMLPresentationFlag::StretchAllChildrenVertically) ? NS_STRETCH_DIRECTION_VERTICAL : NS_STRETCH_DIRECTION_HORIZONTAL; @@ -1399,7 +1401,7 @@ nsresult nsMathMLContainerFrame::TransmitAutomaticDataForMrowLikeElement() { // condition 1) or 2) holds. if (!embellishedOpFound) { // the mrow-like element is space-like. - mPresentationData.flags |= NS_MATHML_SPACE_LIKE; + mPresentationData.flags += MathMLPresentationFlag::SpaceLike; } else { // the mrow-like element is an embellished operator. // let the state of the embellished operator found bubble to us. @@ -1420,7 +1422,7 @@ nsresult nsMathMLContainerFrame::TransmitAutomaticDataForMrowLikeElement() { if (childFrame || embellishedOpFound) { // The element is not space-like - mPresentationData.flags &= ~NS_MATHML_SPACE_LIKE; + mPresentationData.flags -= MathMLPresentationFlag::SpaceLike; } return NS_OK; diff --git a/layout/mathml/nsMathMLContainerFrame.h b/layout/mathml/nsMathMLContainerFrame.h @@ -51,9 +51,10 @@ class nsMathMLContainerFrame : public nsContainerFrame, public nsMathMLFrame { ReflowOutput& aDesiredStretchSize) override; NS_IMETHOD - UpdatePresentationDataFromChildAt(int32_t aFirstIndex, int32_t aLastIndex, - uint32_t aFlagsValues, - uint32_t aFlagsToUpdate) override { + UpdatePresentationDataFromChildAt( + int32_t aFirstIndex, int32_t aLastIndex, + MathMLPresentationFlags aFlagsValues, + MathMLPresentationFlags aFlagsToUpdate) override { PropagatePresentationDataFromChildAt(this, aFirstIndex, aLastIndex, aFlagsValues, aFlagsToUpdate); return NS_OK; @@ -299,16 +300,15 @@ class nsMathMLContainerFrame : public nsContainerFrame, public nsMathMLFrame { // helper to let the update of presentation data pass through // a subtree that may contain non-MathML container frames - static void PropagatePresentationDataFor(nsIFrame* aFrame, - uint32_t aFlagsValues, - uint32_t aFlagsToUpdate); + static void PropagatePresentationDataFor( + nsIFrame* aFrame, MathMLPresentationFlags aFlagsValues, + MathMLPresentationFlags aFlagsToUpdate); public: - static void PropagatePresentationDataFromChildAt(nsIFrame* aParentFrame, - int32_t aFirstChildIndex, - int32_t aLastChildIndex, - uint32_t aFlagsValues, - uint32_t aFlagsToUpdate); + static void PropagatePresentationDataFromChildAt( + nsIFrame* aParentFrame, int32_t aFirstChildIndex, int32_t aLastChildIndex, + MathMLPresentationFlags aFlagsValues, + MathMLPresentationFlags aFlagsToUpdate); // Sets flags on aFrame and all descendant frames static void PropagateFrameFlagFor(nsIFrame* aFrame, nsFrameState aFlags); diff --git a/layout/mathml/nsMathMLFrame.cpp b/layout/mathml/nsMathMLFrame.cpp @@ -53,7 +53,7 @@ nsMathMLFrame::InheritAutomaticData(nsIFrame* aParent) { mEmbellishData.leadingSpace = 0; mEmbellishData.trailingSpace = 0; - mPresentationData.flags = 0; + mPresentationData.flags.clear(); mPresentationData.baseFrame = nullptr; // by default, just inherit the display of our parent @@ -64,28 +64,28 @@ nsMathMLFrame::InheritAutomaticData(nsIFrame* aParent) { } NS_IMETHODIMP -nsMathMLFrame::UpdatePresentationData(uint32_t aFlagsValues, - uint32_t aWhichFlags) { - NS_ASSERTION(NS_MATHML_IS_COMPRESSED(aWhichFlags) || - NS_MATHML_IS_DTLS_SET(aWhichFlags), +nsMathMLFrame::UpdatePresentationData(MathMLPresentationFlags aFlagsValues, + MathMLPresentationFlags aWhichFlags) { + NS_ASSERTION(aWhichFlags.contains(MathMLPresentationFlag::Compressed) || + aWhichFlags.contains(MathMLPresentationFlag::Dtls), "aWhichFlags should only be compression or dtls flag"); if (!StaticPrefs::mathml_math_shift_enabled() && - NS_MATHML_IS_COMPRESSED(aWhichFlags)) { + aWhichFlags.contains(MathMLPresentationFlag::Compressed)) { // updating the compression flag is allowed - if (NS_MATHML_IS_COMPRESSED(aFlagsValues)) { + if (aFlagsValues.contains(MathMLPresentationFlag::Compressed)) { // 'compressed' means 'prime' style in App. G, TeXbook - mPresentationData.flags |= NS_MATHML_COMPRESSED; + mPresentationData.flags += MathMLPresentationFlag::Compressed; } // no else. the flag is sticky. it retains its value once it is set } // These flags determine whether the dtls font feature settings should // be applied. - if (NS_MATHML_IS_DTLS_SET(aWhichFlags)) { - if (NS_MATHML_IS_DTLS_SET(aFlagsValues)) { - mPresentationData.flags |= NS_MATHML_DTLS; + if (aWhichFlags.contains(MathMLPresentationFlag::Dtls)) { + if (aFlagsValues.contains(MathMLPresentationFlag::Dtls)) { + mPresentationData.flags += MathMLPresentationFlag::Dtls; } else { - mPresentationData.flags &= ~NS_MATHML_DTLS; + mPresentationData.flags -= MathMLPresentationFlag::Dtls; } } return NS_OK; @@ -115,7 +115,7 @@ void nsMathMLFrame::GetEmbellishDataFrom(nsIFrame* aFrame, void nsMathMLFrame::GetPresentationDataFrom( nsIFrame* aFrame, nsPresentationData& aPresentationData, bool aClimbTree) { // initialize OUT params - aPresentationData.flags = 0; + aPresentationData.flags.clear(); aPresentationData.baseFrame = nullptr; nsIFrame* frame = aFrame; diff --git a/layout/mathml/nsMathMLFrame.h b/layout/mathml/nsMathMLFrame.h @@ -28,7 +28,7 @@ class nsMathMLFrame : public nsIMathMLFrame { // nsIMathMLFrame --- bool IsSpaceLike() override { - return NS_MATHML_IS_SPACE_LIKE(mPresentationData.flags); + return mPresentationData.flags.contains(MathMLPresentationFlag::SpaceLike); } NS_IMETHOD @@ -78,13 +78,14 @@ class nsMathMLFrame : public nsIMathMLFrame { TransmitAutomaticData() override { return NS_OK; } NS_IMETHOD - UpdatePresentationData(uint32_t aFlagsValues, - uint32_t aFlagsToUpdate) override; + UpdatePresentationData(MathMLPresentationFlags aFlagsValues, + MathMLPresentationFlags aFlagsToUpdate) override; NS_IMETHOD - UpdatePresentationDataFromChildAt(int32_t aFirstIndex, int32_t aLastIndex, - uint32_t aFlagsValues, - uint32_t aFlagsToUpdate) override { + UpdatePresentationDataFromChildAt( + int32_t aFirstIndex, int32_t aLastIndex, + MathMLPresentationFlags aFlagsValues, + MathMLPresentationFlags aFlagsToUpdate) override { return NS_OK; } diff --git a/layout/mathml/nsMathMLTokenFrame.h b/layout/mathml/nsMathMLTokenFrame.h @@ -29,7 +29,7 @@ class nsMathMLTokenFrame : public nsMathMLContainerFrame { // The REC defines the following elements to be space-like: // * an mtext, mspace, maligngroup, or malignmark element; if (mContent->IsMathMLElement(nsGkAtoms::mtext)) { - mPresentationData.flags |= NS_MATHML_SPACE_LIKE; + mPresentationData.flags += MathMLPresentationFlag::SpaceLike; } return NS_OK; } diff --git a/layout/mathml/nsMathMLmencloseFrame.cpp b/layout/mathml/nsMathMLmencloseFrame.cpp @@ -177,7 +177,8 @@ nsMathMLmencloseFrame::InheritAutomaticData(nsIFrame* aParent) { // let the base class get the default from our parent nsMathMLContainerFrame::InheritAutomaticData(aParent); - mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY; + mPresentationData.flags += + MathMLPresentationFlag::StretchAllChildrenVertically; InitNotations(); diff --git a/layout/mathml/nsMathMLmfracFrame.cpp b/layout/mathml/nsMathMLmfracFrame.cpp @@ -56,8 +56,8 @@ nsMathMLmfracFrame::TransmitAutomaticData() { // The TeXbook (Ch 17. p.141) says the numerator inherits the compression // while the denominator is compressed if (!StaticPrefs::mathml_math_shift_enabled()) { - UpdatePresentationDataFromChildAt(1, 1, NS_MATHML_COMPRESSED, - NS_MATHML_COMPRESSED); + UpdatePresentationDataFromChildAt(1, 1, MathMLPresentationFlag::Compressed, + MathMLPresentationFlag::Compressed); } // If displaystyle is false, then scriptlevel is incremented, so notify the diff --git a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp @@ -88,8 +88,9 @@ nsMathMLmmultiscriptsFrame::TransmitAutomaticData() { if (!StaticPrefs::mathml_math_shift_enabled()) { for (int32_t i = subScriptFrames.Length() - 1; i >= 0; i--) { childFrame = subScriptFrames[i]; - PropagatePresentationDataFor(childFrame, NS_MATHML_COMPRESSED, - NS_MATHML_COMPRESSED); + PropagatePresentationDataFor(childFrame, + MathMLPresentationFlag::Compressed, + MathMLPresentationFlag::Compressed); } } @@ -215,9 +216,10 @@ void nsMathMLmmultiscriptsFrame::PlaceMultiScript( nscoord supScriptShift; nsPresentationData presentationData; aFrame->GetPresentationData(presentationData); - bool compressed = StaticPrefs::mathml_math_shift_enabled() - ? font->mMathShift == StyleMathShift::Compact - : NS_MATHML_IS_COMPRESSED(presentationData.flags); + bool compressed = + StaticPrefs::mathml_math_shift_enabled() + ? font->mMathShift == StyleMathShift::Compact + : presentationData.flags.contains(MathMLPresentationFlag::Compressed); if (mathFont) { // Try and get the super script shift from the MATH table. Note that // contrary to TeX we only have two parameters. diff --git a/layout/mathml/nsMathMLmoFrame.cpp b/layout/mathml/nsMathMLmoFrame.cpp @@ -603,11 +603,11 @@ nsMathMLmoFrame::Stretch(DrawTarget* aDrawTarget, nsStretchDirection aStretchDirection, nsBoundingMetrics& aContainerSize, ReflowOutput& aDesiredStretchSize) { - if (NS_MATHML_STRETCH_WAS_DONE(mPresentationData.flags)) { + if (mPresentationData.flags.contains(MathMLPresentationFlag::StretchDone)) { NS_WARNING("it is wrong to fire stretch more than once on a frame"); return NS_OK; } - mPresentationData.flags |= NS_MATHML_STRETCH_DONE; + mPresentationData.flags += MathMLPresentationFlag::StretchDone; nsIFrame* firstChild = mFrames.FirstChild(); diff --git a/layout/mathml/nsMathMLmpaddedFrame.cpp b/layout/mathml/nsMathMLmpaddedFrame.cpp @@ -35,7 +35,8 @@ nsMathMLmpaddedFrame::InheritAutomaticData(nsIFrame* aParent) { // let the base class get the default from our parent nsMathMLContainerFrame::InheritAutomaticData(aParent); - mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY; + mPresentationData.flags += + MathMLPresentationFlag::StretchAllChildrenVertically; return NS_OK; } diff --git a/layout/mathml/nsMathMLmrootFrame.cpp b/layout/mathml/nsMathMLmrootFrame.cpp @@ -74,7 +74,8 @@ nsMathMLmrootFrame::InheritAutomaticData(nsIFrame* aParent) { bool isRootWithIndex = GetContent()->IsMathMLElement(nsGkAtoms::mroot); if (!isRootWithIndex) { - mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY; + mPresentationData.flags += + MathMLPresentationFlag::StretchAllChildrenVertically; } return NS_OK; @@ -90,10 +91,12 @@ nsMathMLmrootFrame::TransmitAutomaticData() { // base. // 2. The TeXbook (Ch 17. p.141) says \sqrt is compressed if (!StaticPrefs::mathml_math_shift_enabled()) { - UpdatePresentationDataFromChildAt(1, 1, NS_MATHML_COMPRESSED, - NS_MATHML_COMPRESSED); - UpdatePresentationDataFromChildAt(0, 0, NS_MATHML_COMPRESSED, - NS_MATHML_COMPRESSED); + UpdatePresentationDataFromChildAt(1, 1, + MathMLPresentationFlag::Compressed, + MathMLPresentationFlag::Compressed); + UpdatePresentationDataFromChildAt(0, 0, + MathMLPresentationFlag::Compressed, + MathMLPresentationFlag::Compressed); } PropagateFrameFlagFor(mFrames.LastChild(), @@ -101,8 +104,9 @@ nsMathMLmrootFrame::TransmitAutomaticData() { } else { // The TeXBook (Ch 17. p.141) says that \sqrt is cramped if (!StaticPrefs::mathml_math_shift_enabled()) { - UpdatePresentationDataFromChildAt(0, -1, NS_MATHML_COMPRESSED, - NS_MATHML_COMPRESSED); + UpdatePresentationDataFromChildAt(0, -1, + MathMLPresentationFlag::Compressed, + MathMLPresentationFlag::Compressed); } } diff --git a/layout/mathml/nsMathMLmrowFrame.cpp b/layout/mathml/nsMathMLmrowFrame.cpp @@ -29,7 +29,8 @@ nsMathMLmrowFrame::InheritAutomaticData(nsIFrame* aParent) { // let the base class get the default from our parent nsMathMLContainerFrame::InheritAutomaticData(aParent); - mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY; + mPresentationData.flags += + MathMLPresentationFlag::StretchAllChildrenVertically; return NS_OK; } diff --git a/layout/mathml/nsMathMLmspaceFrame.h b/layout/mathml/nsMathMLmspaceFrame.h @@ -29,7 +29,7 @@ class nsMathMLmspaceFrame final : public nsMathMLContainerFrame { TransmitAutomaticData() override { // The REC defines the following elements to be space-like: // * an mtext, mspace, maligngroup, or malignmark element; - mPresentationData.flags |= NS_MATHML_SPACE_LIKE; + mPresentationData.flags += MathMLPresentationFlag::SpaceLike; return NS_OK; } diff --git a/layout/mathml/nsMathMLmtableFrame.h b/layout/mathml/nsMathMLmtableFrame.h @@ -246,9 +246,10 @@ class nsMathMLmtdInnerFrame final : public nsBlockFrame, public nsMathMLFrame { // Overloaded nsIMathMLFrame methods NS_IMETHOD - UpdatePresentationDataFromChildAt(int32_t aFirstIndex, int32_t aLastIndex, - uint32_t aFlagsValues, - uint32_t aFlagsToUpdate) override { + UpdatePresentationDataFromChildAt( + int32_t aFirstIndex, int32_t aLastIndex, + MathMLPresentationFlags aFlagsValues, + MathMLPresentationFlags aFlagsToUpdate) override { nsMathMLContainerFrame::PropagatePresentationDataFromChildAt( this, aFirstIndex, aLastIndex, aFlagsValues, aFlagsToUpdate); return NS_OK; diff --git a/layout/mathml/nsMathMLmunderoverFrame.cpp b/layout/mathml/nsMathMLmunderoverFrame.cpp @@ -55,16 +55,19 @@ nsresult nsMathMLmunderoverFrame::AttributeChanged(int32_t aNameSpaceID, } NS_IMETHODIMP -nsMathMLmunderoverFrame::UpdatePresentationData(uint32_t aFlagsValues, - uint32_t aFlagsToUpdate) { +nsMathMLmunderoverFrame::UpdatePresentationData( + MathMLPresentationFlags aFlagsValues, + MathMLPresentationFlags aFlagsToUpdate) { nsMathMLContainerFrame::UpdatePresentationData(aFlagsValues, aFlagsToUpdate); // disable the stretch-all flag if we are going to act like a // subscript-superscript pair if (NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) && StyleFont()->mMathStyle == StyleMathStyle::Compact) { - mPresentationData.flags &= ~NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY; + mPresentationData.flags -= + MathMLPresentationFlag::StretchAllChildrenHorizontally; } else { - mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY; + mPresentationData.flags += + MathMLPresentationFlag::StretchAllChildrenHorizontally; } return NS_OK; } @@ -74,7 +77,8 @@ nsMathMLmunderoverFrame::InheritAutomaticData(nsIFrame* aParent) { // let the base class get the default from our parent nsMathMLContainerFrame::InheritAutomaticData(aParent); - mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY; + mPresentationData.flags += + MathMLPresentationFlag::StretchAllChildrenHorizontally; return NS_OK; } @@ -275,7 +279,8 @@ XXX The winner is the outermost setting in conflicting settings like these: // disable the stretch-all flag if we are going to act like a superscript if (subsupDisplay) { - mPresentationData.flags &= ~NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY; + mPresentationData.flags -= + MathMLPresentationFlag::StretchAllChildrenHorizontally; } // Now transmit any change that we want to our children so that they @@ -308,11 +313,11 @@ XXX The winner is the outermost setting in conflicting settings like these: PropagateFrameFlagFor(overscriptFrame, NS_FRAME_MATHML_SCRIPT_DESCENDANT); } if (!StaticPrefs::mathml_math_shift_enabled()) { - uint32_t compress = - NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags) - ? NS_MATHML_COMPRESSED - : 0; - PropagatePresentationDataFor(overscriptFrame, compress, compress); + MathMLPresentationFlags flags; + if (NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags)) { + flags += MathMLPresentationFlag::Compressed; + } + PropagatePresentationDataFor(overscriptFrame, flags, flags); } } /* @@ -330,8 +335,9 @@ XXX The winner is the outermost setting in conflicting settings like these: NS_FRAME_MATHML_SCRIPT_DESCENDANT); } if (!StaticPrefs::mathml_math_shift_enabled()) { - PropagatePresentationDataFor(underscriptFrame, NS_MATHML_COMPRESSED, - NS_MATHML_COMPRESSED); + PropagatePresentationDataFor(underscriptFrame, + MathMLPresentationFlag::Compressed, + MathMLPresentationFlag::Compressed); } } @@ -353,7 +359,8 @@ XXX The winner is the outermost setting in conflicting settings like these: if (overscriptFrame && NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags) && !NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags)) { - PropagatePresentationDataFor(baseFrame, NS_MATHML_DTLS, NS_MATHML_DTLS); + PropagatePresentationDataFor(baseFrame, MathMLPresentationFlag::Dtls, + MathMLPresentationFlag::Dtls); } return NS_OK; diff --git a/layout/mathml/nsMathMLmunderoverFrame.h b/layout/mathml/nsMathMLmunderoverFrame.h @@ -33,8 +33,9 @@ class nsMathMLmunderoverFrame final : public nsMathMLContainerFrame, NS_IMETHOD TransmitAutomaticData() override; - NS_IMETHOD UpdatePresentationData(uint32_t aFlagsValues, - uint32_t aFlagsToUpdate) override; + NS_IMETHOD UpdatePresentationData( + MathMLPresentationFlags aFlagsValues, + MathMLPresentationFlags aFlagsToUpdate) override; void Destroy(DestroyContext&) override;