Bug 1339711 - Part 1: stylo: Support -moz-script-size-multiplier, -moz-script-level, -moz-math-display; r=emilio
authorManish Goregaokar <manishearth@gmail.com>
Mon, 10 Apr 2017 15:28:48 +0800
changeset 403168 70023ccd2733d8f3d59977340a8025d0f41afdc7
parent 403167 946b403ea75b0bb72b80cc25cc2417b2c72049d7
child 403169 888ef3f2eb92406c3cca19fd9be08172b32d08fd
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1339711
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1339711 - Part 1: stylo: Support -moz-script-size-multiplier, -moz-script-level, -moz-math-display; r=emilio MozReview-Commit-ID: KzBDsmZK5w0
dom/mathml/nsMathMLElement.cpp
layout/style/GenericSpecifiedValues.h
layout/style/GenericSpecifiedValuesInlines.h
layout/style/ServoBindingList.h
layout/style/ServoSpecifiedValues.cpp
layout/style/ServoSpecifiedValues.h
layout/style/nsRuleData.h
--- a/dom/mathml/nsMathMLElement.cpp
+++ b/dom/mathml/nsMathMLElement.cpp
@@ -503,29 +503,27 @@ nsMathMLElement::MapMathMLAttributesInto
     // "Specifies the multiplier to be used to adjust font size due to changes
     // in scriptlevel.
     //
     // values: number
     // default: 0.71
     //
     const nsAttrValue* value =
       aAttributes->GetAttr(nsGkAtoms::scriptsizemultiplier_);
-    nsCSSValue* scriptSizeMultiplier =
-      aData->ValueForScriptSizeMultiplier();
     if (value && value->Type() == nsAttrValue::eString &&
-        scriptSizeMultiplier->GetUnit() == eCSSUnit_Null) {
+        !aData->PropertyIsSet(eCSSProperty__moz_script_size_multiplier)) {
       nsAutoString str(value->GetStringValue());
       str.CompressWhitespace();
       // MathML numbers can't have leading '+'
       if (str.Length() > 0 && str.CharAt(0) != '+') {
         nsresult errorCode;
         float floatValue = str.ToFloat(&errorCode);
         // Negative scriptsizemultipliers are not parsed
         if (NS_SUCCEEDED(errorCode) && floatValue >= 0.0f) {
-          scriptSizeMultiplier->SetFloatValue(floatValue, eCSSUnit_Number);
+          aData->SetNumberValue(eCSSProperty__moz_script_size_multiplier, floatValue);
         } else {
           ReportParseErrorNoTag(str,
                                 nsGkAtoms::scriptsizemultiplier_,
                                 aData->mPresContext->Document());
         }
       }
     }
 
@@ -561,34 +559,33 @@ nsMathMLElement::MapMathMLAttributesInto
     // sign is given, it increments ("+") or decrements ("-") the current
     // value. (Note that large decrements can result in negative values of
     // scriptlevel, but these values are considered legal.)"
     //
     // values: ( "+" | "-" )? unsigned-integer
     // default: inherited
     //
     value = aAttributes->GetAttr(nsGkAtoms::scriptlevel_);
-    nsCSSValue* scriptLevel = aData->ValueForScriptLevel();
     if (value && value->Type() == nsAttrValue::eString &&
-        scriptLevel->GetUnit() == eCSSUnit_Null) {
+        !aData->PropertyIsSet(eCSSProperty__moz_script_level)) {
       nsAutoString str(value->GetStringValue());
       str.CompressWhitespace();
       if (str.Length() > 0) {
         nsresult errorCode;
         int32_t intValue = str.ToInteger(&errorCode);
         if (NS_SUCCEEDED(errorCode)) {
           // This is kind of cheesy ... if the scriptlevel has a sign,
           // then it's a relative value and we store the nsCSSValue as an
           // Integer to indicate that. Otherwise we store it as a Number
           // to indicate that the scriptlevel is absolute.
           char16_t ch = str.CharAt(0);
           if (ch == '+' || ch == '-') {
-            scriptLevel->SetIntValue(intValue, eCSSUnit_Integer);
+            aData->SetIntValue(eCSSProperty__moz_script_level, intValue);
           } else {
-            scriptLevel->SetFloatValue(intValue, eCSSUnit_Number);
+            aData->SetNumberValue(eCSSProperty__moz_script_level, intValue);
           }
         } else {
           ReportParseErrorNoTag(str,
                                 nsGkAtoms::scriptlevel_,
                                 aData->mPresContext->Document());
         }
       }
     }
@@ -736,20 +733,19 @@ nsMathMLElement::MapMathMLAttributesInto
     // than styling, it typically conveys semantic intent;"
     //
     // values: "normal" | "bold" | "italic" | "bold-italic" | "double-struck" |
     // "bold-fraktur" | "script" | "bold-script" | "fraktur" | "sans-serif" |
     // "bold-sans-serif" | "sans-serif-italic" | "sans-serif-bold-italic" |
     // "monospace" | "initial" | "tailed" | "looped" | "stretched"
     // default: normal (except on <mi>)
     //
-    nsCSSValue* mathVariant = aData->ValueForMathVariant();
     value = aAttributes->GetAttr(nsGkAtoms::mathvariant_);
     if (value && value->Type() == nsAttrValue::eString &&
-        mathVariant->GetUnit() == eCSSUnit_Null) {
+        !aData->PropertyIsSet(eCSSProperty__moz_math_variant)) {
       nsAutoString str(value->GetStringValue());
       str.CompressWhitespace();
       static const char sizes[19][23] = {
         "normal", "bold", "italic", "bold-italic", "script", "bold-script",
         "fraktur", "double-struck", "bold-fraktur", "sans-serif",
         "bold-sans-serif", "sans-serif-italic", "sans-serif-bold-italic",
         "monospace", "initial", "tailed", "looped", "stretched"
       };
@@ -763,17 +759,17 @@ nsMathMLElement::MapMathMLAttributesInto
         NS_MATHML_MATHVARIANT_SANS_SERIF_ITALIC,
         NS_MATHML_MATHVARIANT_SANS_SERIF_BOLD_ITALIC,
         NS_MATHML_MATHVARIANT_MONOSPACE, NS_MATHML_MATHVARIANT_INITIAL,
         NS_MATHML_MATHVARIANT_TAILED, NS_MATHML_MATHVARIANT_LOOPED,
         NS_MATHML_MATHVARIANT_STRETCHED
       };
       for (uint32_t i = 0; i < ArrayLength(sizes); ++i) {
         if (str.EqualsASCII(sizes[i])) {
-          mathVariant->SetIntValue(values[i], eCSSUnit_Enumerated);
+          aData->SetKeywordValue(eCSSProperty__moz_math_variant, values[i]);
           break;
         }
       }
     }
   }
 
   // mathbackground
   // 
--- a/layout/style/GenericSpecifiedValues.h
+++ b/layout/style/GenericSpecifiedValues.h
@@ -73,16 +73,19 @@ public:
     }
 
     // Set a property to an integer value
     inline void SetIntValue(nsCSSPropertyID aId, int32_t aValue);
     // Set a property to a pixel value
     inline void SetPixelValue(nsCSSPropertyID aId, float aValue);
     inline void SetPixelValueIfUnset(nsCSSPropertyID aId, float aValue);
 
+    // Set a property to a number value
+    inline void SetNumberValue(nsCSSPropertyID aId, float aValue);
+
     // Set a property to a percent value
     inline void SetPercentValue(nsCSSPropertyID aId, float aValue);
     inline void SetPercentValueIfUnset(nsCSSPropertyID aId, float aValue);
 
     // Set a property to `auto`
     inline void SetAutoValue(nsCSSPropertyID aId);
     inline void SetAutoValueIfUnset(nsCSSPropertyID aId);
 
--- a/layout/style/GenericSpecifiedValuesInlines.h
+++ b/layout/style/GenericSpecifiedValuesInlines.h
@@ -94,16 +94,22 @@ GenericSpecifiedValues::SetPixelValue(ns
 
 void
 GenericSpecifiedValues::SetPixelValueIfUnset(nsCSSPropertyID aId, float aValue)
 {
   MOZ_STYLO_FORWARD(SetPixelValueIfUnset, (aId, aValue))
 }
 
 void
+GenericSpecifiedValues::SetNumberValue(nsCSSPropertyID aId, float aValue)
+{
+  MOZ_STYLO_FORWARD(SetNumberValue, (aId, aValue))
+}
+
+void
 GenericSpecifiedValues::SetPercentValue(nsCSSPropertyID aId, float aValue)
 {
   MOZ_STYLO_FORWARD(SetPercentValue, (aId, aValue))
 }
 
 void
 GenericSpecifiedValues::SetPercentValueIfUnset(nsCSSPropertyID aId, float aValue)
 {
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -245,16 +245,20 @@ SERVO_BINDING_FUNC(Servo_DeclarationBloc
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetIntValue, void,
                    RawServoDeclarationBlockBorrowed declarations,
                    nsCSSPropertyID property,
                    int32_t value)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetPixelValue, void,
                    RawServoDeclarationBlockBorrowed declarations,
                    nsCSSPropertyID property,
                    float value)
+SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetNumberValue, void,
+                   RawServoDeclarationBlockBorrowed declarations,
+                   nsCSSPropertyID property,
+                   float value)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetPercentValue, void,
                    RawServoDeclarationBlockBorrowed declarations,
                    nsCSSPropertyID property,
                    float value)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetAutoValue, void,
                    RawServoDeclarationBlockBorrowed declarations,
                    nsCSSPropertyID property)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetCurrentColor, void,
--- a/layout/style/ServoSpecifiedValues.cpp
+++ b/layout/style/ServoSpecifiedValues.cpp
@@ -64,16 +64,22 @@ ServoSpecifiedValues::SetIntValue(nsCSSP
 
 void
 ServoSpecifiedValues::SetPixelValue(nsCSSPropertyID aId, float aValue)
 {
   Servo_DeclarationBlock_SetPixelValue(mDecl, aId, aValue);
 }
 
 void
+ServoSpecifiedValues::SetNumberValue(nsCSSPropertyID aId, float aValue)
+{
+  Servo_DeclarationBlock_SetNumberValue(mDecl, aId, aValue);
+}
+
+void
 ServoSpecifiedValues::SetPercentValue(nsCSSPropertyID aId, float aValue)
 {
   Servo_DeclarationBlock_SetPercentValue(mDecl, aId, aValue);
 }
 
 void
 ServoSpecifiedValues::SetAutoValue(nsCSSPropertyID aId)
 {
--- a/layout/style/ServoSpecifiedValues.h
+++ b/layout/style/ServoSpecifiedValues.h
@@ -55,16 +55,19 @@ public:
 
   void SetPixelValueIfUnset(nsCSSPropertyID aId,
                             float aValue) {
     if (!PropertyIsSet(aId)) {
       SetPixelValue(aId, aValue);
     }
   }
 
+  void SetNumberValue(nsCSSPropertyID aId,
+                     float aValue);
+
   void SetPercentValue(nsCSSPropertyID aId,
                        float aValue);
 
   void SetAutoValue(nsCSSPropertyID aId);
 
   void SetAutoValueIfUnset(nsCSSPropertyID aId) {
     if (!PropertyIsSet(aId)) {
       SetAutoValue(aId);
--- a/layout/style/nsRuleData.h
+++ b/layout/style/nsRuleData.h
@@ -161,16 +161,21 @@ struct nsRuleData final: mozilla::Generi
 
   void SetPixelValueIfUnset(nsCSSPropertyID aId,
                             float aValue) {
     if (!PropertyIsSet(aId)) {
       SetPixelValue(aId, aValue);
     }
   }
 
+  void SetNumberValue(nsCSSPropertyID aId,
+                     float aValue) {
+    ValueFor(aId)->SetFloatValue(aValue, eCSSUnit_Number);
+  }
+
   void SetPercentValue(nsCSSPropertyID aId,
                        float aValue) {
     ValueFor(aId)->SetPercentValue(aValue);
   }
 
   void SetAutoValue(nsCSSPropertyID aId) {
     ValueFor(aId)->SetAutoValue();
   }