Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 15eb00a

Browse files
committed
Bug 1797012 - Change NS_STYLE_MATH_STYLE_* macros to enum StyleMathStyle. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D160016
1 parent 5bc9f5b commit 15eb00a

File tree

12 files changed

+19
-21
lines changed

12 files changed

+19
-21
lines changed

dom/mathml/MathMLElement.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,8 @@ void MathMLElement::MapMathMLAttributesInto(
593593
!aDecls.PropertyIsSet(eCSSProperty_math_style)) {
594594
auto str = value->GetStringValue();
595595
static const char displaystyles[][6] = {"false", "true"};
596-
static const uint8_t mathStyle[MOZ_ARRAY_LENGTH(displaystyles)] = {
597-
NS_STYLE_MATH_STYLE_COMPACT, NS_STYLE_MATH_STYLE_NORMAL};
596+
static const StyleMathStyle mathStyle[MOZ_ARRAY_LENGTH(displaystyles)] = {
597+
StyleMathStyle::Compact, StyleMathStyle::Normal};
598598
for (uint32_t i = 0; i < ArrayLength(displaystyles); ++i) {
599599
if (str.LowerCaseEqualsASCII(displaystyles[i])) {
600600
aDecls.SetKeywordValue(eCSSProperty_math_style, mathStyle[i]);

layout/mathml/nsMathMLmencloseFrame.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ nsresult nsMathMLmencloseFrame::PlaceInternal(DrawTarget* aDrawTarget,
362362
if (delta) padding += onePixel - delta; // round up
363363

364364
if (IsToDraw(NOTATION_LONGDIV) || IsToDraw(NOTATION_RADICAL)) {
365-
GetRadicalParameters(fm,
366-
StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_NORMAL,
365+
GetRadicalParameters(fm, StyleFont()->mMathStyle == StyleMathStyle::Normal,
367366
mRadicalRuleThickness, leading, psi);
368367

369368
// make sure that the rule appears on on screen

layout/mathml/nsMathMLmfracFrame.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ eMathMLFrameType nsMathMLmfracFrame::GetMathMLFrameType() {
4343
}
4444

4545
uint8_t nsMathMLmfracFrame::ScriptIncrement(nsIFrame* aFrame) {
46-
if (StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_COMPACT && aFrame &&
46+
if (StyleFont()->mMathStyle == StyleMathStyle::Compact && aFrame &&
4747
(mFrames.FirstChild() == aFrame || mFrames.LastChild() == aFrame)) {
4848
return 1;
4949
}
@@ -59,7 +59,7 @@ nsMathMLmfracFrame::TransmitAutomaticData() {
5959

6060
// If displaystyle is false, then scriptlevel is incremented, so notify the
6161
// children of this.
62-
if (StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_COMPACT) {
62+
if (StyleFont()->mMathStyle == StyleMathStyle::Compact) {
6363
PropagateFrameFlagFor(mFrames.FirstChild(),
6464
NS_FRAME_MATHML_SCRIPT_DESCENDANT);
6565
PropagateFrameFlagFor(mFrames.LastChild(),
@@ -197,7 +197,7 @@ nsresult nsMathMLmfracFrame::PlaceInternal(DrawTarget* aDrawTarget,
197197
CalcLineThickness(presContext, mComputedStyle, value, onePixel,
198198
defaultRuleThickness, fontSizeInflation);
199199

200-
bool displayStyle = StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_NORMAL;
200+
bool displayStyle = StyleFont()->mMathStyle == StyleMathStyle::Compact;
201201

202202
mLineRect.height = mLineThickness;
203203

layout/mathml/nsMathMLmmultiscriptsFrame.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ nsresult nsMathMLmmultiscriptsFrame::PlaceMultiScript(
229229

230230
// get sup script shift depending on current script level and display style
231231
// Rule 18c, App. G, TeXbook
232-
if (font->mMathDepth == 0 &&
233-
font->mMathStyle == NS_STYLE_MATH_STYLE_NORMAL &&
232+
if (font->mMathDepth == 0 && font->mMathStyle == StyleMathStyle::Normal &&
234233
!NS_MATHML_IS_COMPRESSED(presentationData.flags)) {
235234
// Style D in TeXbook
236235
supScriptShift = supScriptShift1;

layout/mathml/nsMathMLmoFrame.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ static uint32_t GetStretchHint(nsOperatorFlags aFlags,
553553
// stretchy are true or false (see bug 69325).
554554
// . largeopOnly is taken if largeop=true and stretchy=false
555555
// . largeop is taken if largeop=true and stretchy=true
556-
if (aStyleFont->mMathStyle == NS_STYLE_MATH_STYLE_NORMAL &&
556+
if (aStyleFont->mMathStyle == StyleMathStyle::Normal &&
557557
NS_MATHML_OPERATOR_IS_LARGEOP(aFlags)) {
558558
stretchHint = NS_STRETCH_LARGEOP; // (largeopOnly, not mask!)
559559
if (NS_MATHML_OPERATOR_IS_STRETCHY(aFlags)) {
@@ -946,7 +946,7 @@ nsresult nsMathMLmoFrame::Place(DrawTarget* aDrawTarget, bool aPlaceOrigin,
946946
Stretch() method.
947947
*/
948948

949-
if (!aPlaceOrigin && StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_NORMAL &&
949+
if (!aPlaceOrigin && StyleFont()->mMathStyle == StyleMathStyle::Normal &&
950950
NS_MATHML_OPERATOR_IS_LARGEOP(mFlags) && UseMathMLChar()) {
951951
nsBoundingMetrics newMetrics;
952952
rv = mMathMLChar.Stretch(

layout/mathml/nsMathMLmrootFrame.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ void nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
228228
nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation);
229229

230230
nscoord ruleThickness, leading, psi;
231-
GetRadicalParameters(fm,
232-
StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_NORMAL,
231+
GetRadicalParameters(fm, StyleFont()->mMathStyle == StyleMathStyle::Normal,
233232
ruleThickness, leading, psi);
234233

235234
// built-in: adjust clearance psi to emulate \mathstrut using '1' (TexBook,

layout/mathml/nsMathMLmunderoverFrame.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ nsMathMLmunderoverFrame::UpdatePresentationData(uint32_t aFlagsValues,
5757
// disable the stretch-all flag if we are going to act like a
5858
// subscript-superscript pair
5959
if (NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) &&
60-
StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_COMPACT) {
60+
StyleFont()->mMathStyle == StyleMathStyle::Compact) {
6161
mPresentationData.flags &= ~NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY;
6262
} else {
6363
mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY;
@@ -257,7 +257,7 @@ XXX The winner is the outermost setting in conflicting settings like these:
257257

258258
bool subsupDisplay =
259259
NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) &&
260-
StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_COMPACT;
260+
StyleFont()->mMathStyle == StyleMathStyle::Compact;
261261

262262
// disable the stretch-all flag if we are going to act like a superscript
263263
if (subsupDisplay) {
@@ -351,7 +351,7 @@ The REC says:
351351
352352
i.e.,:
353353
if (NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishDataflags) &&
354-
StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_COMPACT) {
354+
StyleFont()->mMathStyle == StyleMathStyle::Compact) {
355355
// place like subscript-superscript pair
356356
}
357357
else {
@@ -365,7 +365,7 @@ nsresult nsMathMLmunderoverFrame::Place(DrawTarget* aDrawTarget,
365365
ReflowOutput& aDesiredSize) {
366366
float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this);
367367
if (NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) &&
368-
StyleFont()->mMathStyle == NS_STYLE_MATH_STYLE_COMPACT) {
368+
StyleFont()->mMathStyle == StyleMathStyle::Compact) {
369369
// place like sub sup or subsup
370370
if (mContent->IsMathMLElement(nsGkAtoms::munderover_)) {
371371
return nsMathMLmmultiscriptsFrame::PlaceMultiScript(

layout/style/ServoBindings.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ rusty-enums = [
110110
"mozilla::StyleShapeSourceType",
111111
"mozilla::StyleVisibility",
112112
"mozilla::StyleBasicShapeType",
113+
"mozilla::StyleMathStyle",
113114
"nsStyleImageLayers_Size_DimensionType",
114115
"mozilla::StyleBorderCollapse",
115116
"mozilla::StyleBorderImageRepeat",

layout/style/nsStyleConsts.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,7 @@ enum class StyleMathVariant : uint8_t {
390390
};
391391

392392
// See nsStyleFont::mMathStyle
393-
#define NS_STYLE_MATH_STYLE_COMPACT 0
394-
#define NS_STYLE_MATH_STYLE_NORMAL 1
393+
enum class StyleMathStyle : uint8_t { Compact = 0, Normal = 1 };
395394

396395
// See nsStyleDisplay.mPosition
397396
enum class StylePositionProperty : uint8_t {

layout/style/nsStyleStruct.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ nsStyleFont::nsStyleFont(const Document& aDocument)
232232
mFontPalette(StyleFontPalette::Normal()),
233233
mMathDepth(0),
234234
mMathVariant(StyleMathVariant::None),
235-
mMathStyle(NS_STYLE_MATH_STYLE_NORMAL),
235+
mMathStyle(StyleMathStyle::Normal),
236236
mMinFontSizeRatio(100), // 100%
237237
mExplicitLanguage(false),
238238
mAllowZoomAndMinSize(true),

0 commit comments

Comments
 (0)