diff --git a/dom/mathml/MathMLElement.cpp b/dom/mathml/MathMLElement.cpp index 687b461bd862..0ad574089976 100644 --- a/dom/mathml/MathMLElement.cpp +++ b/dom/mathml/MathMLElement.cpp @@ -593,8 +593,8 @@ void MathMLElement::MapMathMLAttributesInto( !aDecls.PropertyIsSet(eCSSProperty_math_style)) { auto str = value->GetStringValue(); static const char displaystyles[][6] = {"false", "true"}; - static const uint8_t mathStyle[MOZ_ARRAY_LENGTH(displaystyles)] = { - NS_STYLE_MATH_STYLE_COMPACT, NS_STYLE_MATH_STYLE_NORMAL}; + static const StyleMathStyle mathStyle[MOZ_ARRAY_LENGTH(displaystyles)] = { + StyleMathStyle::Compact, StyleMathStyle::Normal}; for (uint32_t i = 0; i < ArrayLength(displaystyles); ++i) { if (str.LowerCaseEqualsASCII(displaystyles[i])) { aDecls.SetKeywordValue(eCSSProperty_math_style, mathStyle[i]); diff --git a/layout/mathml/nsMathMLmencloseFrame.cpp b/layout/mathml/nsMathMLmencloseFrame.cpp index b021bd5b7d42..1a907c783a52 100644 --- a/layout/mathml/nsMathMLmencloseFrame.cpp +++ b/layout/mathml/nsMathMLmencloseFrame.cpp @@ -362,8 +362,7 @@ nsresult nsMathMLmencloseFrame::PlaceInternal(DrawTarget* aDrawTarget, if (delta) padding += onePixel - delta; // round up if (IsToDraw(NOTATION_LONGDIV) || IsToDraw(NOTATION_RADICAL)) { - GetRadicalParameters(fm, - StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_NORMAL, + GetRadicalParameters(fm, StyleFont()->mMathStyle == StyleMathStyle::Normal, mRadicalRuleThickness, leading, psi); // make sure that the rule appears on on screen diff --git a/layout/mathml/nsMathMLmfracFrame.cpp b/layout/mathml/nsMathMLmfracFrame.cpp index c5a1b79dc1d4..a7cbde35ba84 100644 --- a/layout/mathml/nsMathMLmfracFrame.cpp +++ b/layout/mathml/nsMathMLmfracFrame.cpp @@ -43,7 +43,7 @@ eMathMLFrameType nsMathMLmfracFrame::GetMathMLFrameType() { } uint8_t nsMathMLmfracFrame::ScriptIncrement(nsIFrame* aFrame) { - if (StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_COMPACT && aFrame && + if (StyleFont()->mMathStyle == StyleMathStyle::Compact && aFrame && (mFrames.FirstChild() == aFrame || mFrames.LastChild() == aFrame)) { return 1; } @@ -59,7 +59,7 @@ nsMathMLmfracFrame::TransmitAutomaticData() { // If displaystyle is false, then scriptlevel is incremented, so notify the // children of this. - if (StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_COMPACT) { + if (StyleFont()->mMathStyle == StyleMathStyle::Compact) { PropagateFrameFlagFor(mFrames.FirstChild(), NS_FRAME_MATHML_SCRIPT_DESCENDANT); PropagateFrameFlagFor(mFrames.LastChild(), @@ -197,7 +197,7 @@ nsresult nsMathMLmfracFrame::PlaceInternal(DrawTarget* aDrawTarget, CalcLineThickness(presContext, mComputedStyle, value, onePixel, defaultRuleThickness, fontSizeInflation); - bool displayStyle = StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_NORMAL; + bool displayStyle = StyleFont()->mMathStyle == StyleMathStyle::Compact; mLineRect.height = mLineThickness; diff --git a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp index 874105b23d10..4c641e65015b 100644 --- a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp +++ b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp @@ -229,8 +229,7 @@ nsresult nsMathMLmmultiscriptsFrame::PlaceMultiScript( // get sup script shift depending on current script level and display style // Rule 18c, App. G, TeXbook - if (font->mMathDepth == 0 && - font->mMathStyle == NS_STYLE_MATH_STYLE_NORMAL && + if (font->mMathDepth == 0 && font->mMathStyle == StyleMathStyle::Normal && !NS_MATHML_IS_COMPRESSED(presentationData.flags)) { // Style D in TeXbook supScriptShift = supScriptShift1; diff --git a/layout/mathml/nsMathMLmoFrame.cpp b/layout/mathml/nsMathMLmoFrame.cpp index 1e5c03e7338e..eccbe1d411e4 100644 --- a/layout/mathml/nsMathMLmoFrame.cpp +++ b/layout/mathml/nsMathMLmoFrame.cpp @@ -553,7 +553,7 @@ static uint32_t GetStretchHint(nsOperatorFlags aFlags, // stretchy are true or false (see bug 69325). // . largeopOnly is taken if largeop=true and stretchy=false // . largeop is taken if largeop=true and stretchy=true - if (aStyleFont->mMathStyle == NS_STYLE_MATH_STYLE_NORMAL && + if (aStyleFont->mMathStyle == StyleMathStyle::Normal && NS_MATHML_OPERATOR_IS_LARGEOP(aFlags)) { stretchHint = NS_STRETCH_LARGEOP; // (largeopOnly, not mask!) if (NS_MATHML_OPERATOR_IS_STRETCHY(aFlags)) { @@ -946,7 +946,7 @@ nsresult nsMathMLmoFrame::Place(DrawTarget* aDrawTarget, bool aPlaceOrigin, Stretch() method. */ - if (!aPlaceOrigin && StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_NORMAL && + if (!aPlaceOrigin && StyleFont()->mMathStyle == StyleMathStyle::Normal && NS_MATHML_OPERATOR_IS_LARGEOP(mFlags) && UseMathMLChar()) { nsBoundingMetrics newMetrics; rv = mMathMLChar.Stretch( diff --git a/layout/mathml/nsMathMLmrootFrame.cpp b/layout/mathml/nsMathMLmrootFrame.cpp index 0c88ecf459bf..77637ffe302f 100644 --- a/layout/mathml/nsMathMLmrootFrame.cpp +++ b/layout/mathml/nsMathMLmrootFrame.cpp @@ -228,8 +228,7 @@ void nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext, nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation); nscoord ruleThickness, leading, psi; - GetRadicalParameters(fm, - StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_NORMAL, + GetRadicalParameters(fm, StyleFont()->mMathStyle == StyleMathStyle::Normal, ruleThickness, leading, psi); // built-in: adjust clearance psi to emulate \mathstrut using '1' (TexBook, diff --git a/layout/mathml/nsMathMLmunderoverFrame.cpp b/layout/mathml/nsMathMLmunderoverFrame.cpp index b36ff1593172..509ae29ed3bd 100644 --- a/layout/mathml/nsMathMLmunderoverFrame.cpp +++ b/layout/mathml/nsMathMLmunderoverFrame.cpp @@ -57,7 +57,7 @@ nsMathMLmunderoverFrame::UpdatePresentationData(uint32_t aFlagsValues, // 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 == NS_STYLE_MATH_STYLE_COMPACT) { + StyleFont()->mMathStyle == StyleMathStyle::Compact) { mPresentationData.flags &= ~NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY; } else { mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY; @@ -257,7 +257,7 @@ XXX The winner is the outermost setting in conflicting settings like these: bool subsupDisplay = NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) && - StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_COMPACT; + StyleFont()->mMathStyle == StyleMathStyle::Compact; // disable the stretch-all flag if we are going to act like a superscript if (subsupDisplay) { @@ -351,7 +351,7 @@ The REC says: i.e.,: if (NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishDataflags) && - StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_COMPACT) { + StyleFont()->mMathStyle == StyleMathStyle::Compact) { // place like subscript-superscript pair } else { @@ -365,7 +365,7 @@ nsresult nsMathMLmunderoverFrame::Place(DrawTarget* aDrawTarget, ReflowOutput& aDesiredSize) { float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this); if (NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) && - StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_COMPACT) { + StyleFont()->mMathStyle == StyleMathStyle::Compact) { // place like sub sup or subsup if (mContent->IsMathMLElement(nsGkAtoms::munderover_)) { return nsMathMLmmultiscriptsFrame::PlaceMultiScript( diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index 4999fcd1db45..939f09e80e87 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -110,6 +110,7 @@ rusty-enums = [ "mozilla::StyleShapeSourceType", "mozilla::StyleVisibility", "mozilla::StyleBasicShapeType", + "mozilla::StyleMathStyle", "nsStyleImageLayers_Size_DimensionType", "mozilla::StyleBorderCollapse", "mozilla::StyleBorderImageRepeat", diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index d8477289bb07..fbc9b25d6aab 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -390,8 +390,7 @@ enum class StyleMathVariant : uint8_t { }; // See nsStyleFont::mMathStyle -#define NS_STYLE_MATH_STYLE_COMPACT 0 -#define NS_STYLE_MATH_STYLE_NORMAL 1 +enum class StyleMathStyle : uint8_t { Compact = 0, Normal = 1 }; // See nsStyleDisplay.mPosition enum class StylePositionProperty : uint8_t { diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 332a2cbcd4b3..ab9080490ae9 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -232,7 +232,7 @@ nsStyleFont::nsStyleFont(const Document& aDocument) mFontPalette(StyleFontPalette::Normal()), mMathDepth(0), mMathVariant(StyleMathVariant::None), - mMathStyle(NS_STYLE_MATH_STYLE_NORMAL), + mMathStyle(StyleMathStyle::Normal), mMinFontSizeRatio(100), // 100% mExplicitLanguage(false), mAllowZoomAndMinSize(true), diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 9324c027f21b..6128a5c9d978 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -140,7 +140,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleFont { // MathML mathvariant support mozilla::StyleMathVariant mMathVariant; // math-style support (used for MathML displaystyle) - uint8_t mMathStyle; + mozilla::StyleMathStyle mMathStyle; // allow different min font-size for certain cases uint8_t mMinFontSizeRatio; // percent * 100 diff --git a/servo/components/style/properties/longhands/font.mako.rs b/servo/components/style/properties/longhands/font.mako.rs index 282750daeea8..aa2dff00a45e 100644 --- a/servo/components/style/properties/longhands/font.mako.rs +++ b/servo/components/style/properties/longhands/font.mako.rs @@ -269,6 +269,7 @@ ${helpers.single_keyword( "math-style", "normal compact", engines="gecko", + gecko_enum_prefix="StyleMathStyle", gecko_pref="layout.css.math-style.enabled", spec="https://mathml-refresh.github.io/mathml-core/#the-math-style-property", has_effect_on_gecko_scrollbars=False,