bug 1389862 - created enum class stylefont draft
☠☠ backed out by b4ee742a8f2b ☠ ☠
authorruby <akriti.v10@gmail.com>
Thu, 17 Aug 2017 21:50:06 +0530
changeset 648349 5339fae295d7423116f33822ca037cb1b470e858
parent 648260 04bee69b3274bd8d5cf52d54a0a5cc14dbe8693a
child 649944 b4ee742a8f2b62550273d7eec5ce1682ccfa0330
push id74720
push userbmo:akriti.v10@gmail.com
push dateThu, 17 Aug 2017 16:21:07 +0000
bugs1389862
milestone57.0a1
bug 1389862 - created enum class stylefont MozReview-Commit-ID: 7ZPGuVWGBjI
dom/mathml/nsMathMLElement.cpp
layout/style/nsCSSProps.cpp
layout/style/nsRuleNode.cpp
layout/style/nsStyleConsts.h
--- a/dom/mathml/nsMathMLElement.cpp
+++ b/dom/mathml/nsMathMLElement.cpp
@@ -633,18 +633,18 @@ nsMathMLElement::MapMathMLAttributesInto
       nsAutoString str(value->GetStringValue());
       nsCSSValue fontSize;
       if (!ParseNumericValue(str, fontSize, PARSE_SUPPRESS_WARNINGS |
                              PARSE_ALLOW_UNITLESS | CONVERT_UNITLESS_TO_PERCENT,
                              nullptr)
           && parseSizeKeywords) {
         static const char sizes[3][7] = { "small", "normal", "big" };
         static const int32_t values[MOZ_ARRAY_LENGTH(sizes)] = {
-          NS_STYLE_FONT_SIZE_SMALL, NS_STYLE_FONT_SIZE_MEDIUM,
-          NS_STYLE_FONT_SIZE_LARGE
+          uint8_t(StyleFont::FontSizeSmall), uint8_t(StyleFont::FontSizeMedium),
+          uint8_t(StyleFont::FontSizeLarge)
         };
         str.CompressWhitespace();
         for (uint32_t i = 0; i < ArrayLength(sizes); ++i) {
           if (str.EqualsASCII(sizes[i])) {
             aData->SetKeywordValue(eCSSProperty_font_size, values[i]);
             break;
           }
         }
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -1532,25 +1532,25 @@ const KTableEntry nsCSSProps::kFontKTabl
 const KTableEntry nsCSSProps::kFontKerningKTable[] = {
   { eCSSKeyword_auto, NS_FONT_KERNING_AUTO },
   { eCSSKeyword_none, NS_FONT_KERNING_NONE },
   { eCSSKeyword_normal, NS_FONT_KERNING_NORMAL },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
 const KTableEntry nsCSSProps::kFontSizeKTable[] = {
-  { eCSSKeyword_xx_small, NS_STYLE_FONT_SIZE_XXSMALL },
-  { eCSSKeyword_x_small, NS_STYLE_FONT_SIZE_XSMALL },
-  { eCSSKeyword_small, NS_STYLE_FONT_SIZE_SMALL },
-  { eCSSKeyword_medium, NS_STYLE_FONT_SIZE_MEDIUM },
-  { eCSSKeyword_large, NS_STYLE_FONT_SIZE_LARGE },
-  { eCSSKeyword_x_large, NS_STYLE_FONT_SIZE_XLARGE },
-  { eCSSKeyword_xx_large, NS_STYLE_FONT_SIZE_XXLARGE },
-  { eCSSKeyword_larger, NS_STYLE_FONT_SIZE_LARGER },
-  { eCSSKeyword_smaller, NS_STYLE_FONT_SIZE_SMALLER },
+  { eCSSKeyword_xx_small, uint8_t(StyleFont::FontSizeXXSmall) },
+  { eCSSKeyword_x_small, uint8_t(StyleFont::FontSizeXSmall) },
+  { eCSSKeyword_small, uint8_t(StyleFont::FontSizeSmall) },
+  { eCSSKeyword_medium, uint8_t(StyleFont::FontSizeMedium) },
+  { eCSSKeyword_large, uint8_t(StyleFont::FontSizeLarge) },
+  { eCSSKeyword_x_large, uint8_t(StyleFont::FontSizeXLarge) },
+  { eCSSKeyword_xx_large, uint8_t(StyleFont::FontSizeXXLarge) },
+  { eCSSKeyword_larger, uint8_t(StyleFont::FontSizeLarger) },
+  { eCSSKeyword_smaller, uint8_t(StyleFont::FontSizeSmaller) },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
 const KTableEntry nsCSSProps::kFontSmoothingKTable[] = {
   { eCSSKeyword_auto, NS_FONT_SMOOTHING_AUTO },
   { eCSSKeyword_grayscale, NS_FONT_SMOOTHING_GRAYSCALE },
   { eCSSKeyword_UNKNOWN, -1 }
 };
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -2112,18 +2112,18 @@ CheckFontCallback(const nsRuleData* aRul
   // on the parent context's font-size
   // Likewise, 'lighter' and 'bolder' values of 'font-weight', and 'wider'
   // and 'narrower' values of 'font-stretch' depend on the parent.
   const nsCSSValue& size = *aRuleData->ValueForFontSize();
   const nsCSSValue& weight = *aRuleData->ValueForFontWeight();
   if ((size.IsRelativeLengthUnit() && size.GetUnit() != eCSSUnit_RootEM) ||
       size.GetUnit() == eCSSUnit_Percent ||
       (size.GetUnit() == eCSSUnit_Enumerated &&
-       (size.GetIntValue() == NS_STYLE_FONT_SIZE_SMALLER ||
-        size.GetIntValue() == NS_STYLE_FONT_SIZE_LARGER)) ||
+       (size.GetIntValue() == int32_t(StyleFont::FontSizeSmaller) ||
+        size.GetIntValue() == int32_t(StyleFont::FontSizeLarger))) ||
       aRuleData->ValueForScriptLevel()->GetUnit() == eCSSUnit_Integer ||
       (weight.GetUnit() == eCSSUnit_Enumerated &&
        (weight.GetIntValue() == NS_STYLE_FONT_WEIGHT_BOLDER ||
         weight.GetIntValue() == NS_STYLE_FONT_WEIGHT_LIGHTER))) {
     NS_ASSERTION(aResult == nsRuleNode::eRulePartialReset ||
                  aResult == nsRuleNode::eRuleFullReset ||
                  aResult == nsRuleNode::eRulePartialMixed ||
                  aResult == nsRuleNode::eRuleFullMixed,
@@ -3471,30 +3471,30 @@ nsRuleNode::SetFontSize(nsPresContext* a
   bool sizeIsZoomedAccordingToParent = false;
 
   int32_t baseSize = (int32_t) aPresContext->
     GetDefaultFont(aFont->mGenericID, aFont->mLanguage)->size;
   const nsCSSValue* sizeValue = aRuleData->ValueForFontSize();
   if (eCSSUnit_Enumerated == sizeValue->GetUnit()) {
     int32_t value = sizeValue->GetIntValue();
 
-    if ((NS_STYLE_FONT_SIZE_XXSMALL <= value) &&
-        (value <= NS_STYLE_FONT_SIZE_XXLARGE)) {
+    if ((int32_t(StyleFont::FontSizeXXSmall) <= value) &&
+        (value <= int32_t(StyleFont::FontSizeXXLarge))) {
       *aSize = CalcFontPointSize(value, baseSize,
                        aPresContext, eFontSize_CSS);
     }
-    else if (NS_STYLE_FONT_SIZE_XXXLARGE == value) {
+    else if (int32_t(StyleFont::FontSizeXXXLarge) == value) {
       // <font size="7"> is not specified in CSS, so we don't use eFontSize_CSS.
       *aSize = CalcFontPointSize(value, baseSize, aPresContext);
     }
-    else if (NS_STYLE_FONT_SIZE_LARGER  == value ||
-             NS_STYLE_FONT_SIZE_SMALLER == value) {
+    else if (int32_t(StyleFont::FontSizeLarger)  == value ||
+    int32_t(StyleFont::FontSizeSmaller) == value) {
       aConditions.SetUncacheable();
 
-      float factor = (NS_STYLE_FONT_SIZE_LARGER == value) ? 1.2f : (1.0f / 1.2f);
+      float factor = (int32_t(StyleFont::FontSizeLarger) == value) ? 1.2f : (1.0f / 1.2f);
 
       *aSize = NSToCoordFloorClamped(aParentSize * factor);
 
       sizeIsZoomedAccordingToParent = true;
 
     } else {
       NS_NOTREACHED("unexpected value");
     }
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -634,26 +634,28 @@ enum class StyleDisplay : uint8_t {
 // We should eventually stop using the NS_STYLE_* variants here.
 #define NS_STYLE_FONT_WEIGHT_NORMAL             NS_FONT_WEIGHT_NORMAL
 #define NS_STYLE_FONT_WEIGHT_BOLD               NS_FONT_WEIGHT_BOLD
 // The constants below appear only in style sheets and not computed style.
 #define NS_STYLE_FONT_WEIGHT_BOLDER             (-1)
 #define NS_STYLE_FONT_WEIGHT_LIGHTER            (-2)
 
 // See nsStyleFont
-#define NS_STYLE_FONT_SIZE_XXSMALL              0
-#define NS_STYLE_FONT_SIZE_XSMALL               1
-#define NS_STYLE_FONT_SIZE_SMALL                2
-#define NS_STYLE_FONT_SIZE_MEDIUM               3
-#define NS_STYLE_FONT_SIZE_LARGE                4
-#define NS_STYLE_FONT_SIZE_XLARGE               5
-#define NS_STYLE_FONT_SIZE_XXLARGE              6
-#define NS_STYLE_FONT_SIZE_XXXLARGE             7  // Only used by <font size="7">. Not specifiable in CSS.
-#define NS_STYLE_FONT_SIZE_LARGER               8
-#define NS_STYLE_FONT_SIZE_SMALLER              9
+enum class StyleFont : uint8_t {
+  FontSizeXXSmall,
+  FontSizeXSmall,
+  FontSizeSmall,
+  FontSizeMedium,
+  FontSizeLarge,
+  FontSizeXLarge,
+  FontSizeXXLarge,
+  FontSizeXXXLarge,  // Only used by <font size="7">. Not specifiable in CSS.
+  FontSizeLarger,
+  FontSizeSmaller,
+};
 
 // See nsStyleFont
 // We should eventually stop using the NS_STYLE_* variants here.
 #define NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED   NS_FONT_STRETCH_ULTRA_CONDENSED
 #define NS_STYLE_FONT_STRETCH_EXTRA_CONDENSED   NS_FONT_STRETCH_EXTRA_CONDENSED
 #define NS_STYLE_FONT_STRETCH_CONDENSED         NS_FONT_STRETCH_CONDENSED
 #define NS_STYLE_FONT_STRETCH_SEMI_CONDENSED    NS_FONT_STRETCH_SEMI_CONDENSED
 #define NS_STYLE_FONT_STRETCH_NORMAL            NS_FONT_STRETCH_NORMAL