Bug 1551991 - Remove nsCSSValue usage for negative / suffix / prefix. r=jwatt
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 16 May 2019 23:05:25 +0000
changeset 474264 76ba2ec949d32634e2dd9ea5ba0a91170bda89a5
parent 474263 336a076368ebcebbde75f4e6e468ebfe2b50ec94
child 474265 f06a39190b3d96439f9a1bd4e340f360244a4711
push id113144
push usershindli@mozilla.com
push dateFri, 17 May 2019 16:44:55 +0000
treeherdermozilla-inbound@f4c4b796f845 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1551991
milestone68.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 1551991 - Remove nsCSSValue usage for negative / suffix / prefix. r=jwatt Depends on D31316 Differential Revision: https://phabricator.services.mozilla.com/D31317
layout/style/CounterStyleManager.cpp
servo/ports/geckolib/glue.rs
--- a/layout/style/CounterStyleManager.cpp
+++ b/layout/style/CounterStyleManager.cpp
@@ -1097,40 +1097,38 @@ void CustomCounterStyle::ResetDependentD
   }
 }
 
 /* virtual */
 void CustomCounterStyle::GetPrefix(nsAString& aResult) {
   if (!(mFlags & FLAG_PREFIX_INITED)) {
     mFlags |= FLAG_PREFIX_INITED;
 
-    nsCSSValue value = GetDesc(eCSSCounterDesc_Prefix);
-    if (value.UnitHasStringValue()) {
-      value.GetStringValue(mPrefix);
-    } else if (IsExtendsSystem()) {
-      GetExtends()->GetPrefix(mPrefix);
-    } else {
-      mPrefix.Truncate();
+    if (!Servo_CounterStyleRule_GetPrefix(mRule, &mPrefix)) {
+      if (IsExtendsSystem()) {
+        GetExtends()->GetPrefix(mPrefix);
+      } else {
+        mPrefix.Truncate();
+      }
     }
   }
   aResult = mPrefix;
 }
 
 /* virtual */
 void CustomCounterStyle::GetSuffix(nsAString& aResult) {
   if (!(mFlags & FLAG_SUFFIX_INITED)) {
     mFlags |= FLAG_SUFFIX_INITED;
 
-    nsCSSValue value = GetDesc(eCSSCounterDesc_Suffix);
-    if (value.UnitHasStringValue()) {
-      value.GetStringValue(mSuffix);
-    } else if (IsExtendsSystem()) {
-      GetExtends()->GetSuffix(mSuffix);
-    } else {
-      mSuffix.AssignLiteral(u". ");
+    if (!Servo_CounterStyleRule_GetSuffix(mRule, &mSuffix)) {
+      if (IsExtendsSystem()) {
+        GetExtends()->GetSuffix(mSuffix);
+      } else {
+        mSuffix.AssignLiteral(u". ");
+      }
     }
   }
   aResult = mSuffix;
 }
 
 /* virtual */
 void CustomCounterStyle::GetSpokenCounterText(CounterValue aOrdinal,
                                               WritingMode aWritingMode,
@@ -1159,36 +1157,24 @@ bool CustomCounterStyle::IsBullet() {
       return false;
   }
 }
 
 /* virtual */
 void CustomCounterStyle::GetNegative(NegativeType& aResult) {
   if (!(mFlags & FLAG_NEGATIVE_INITED)) {
     mFlags |= FLAG_NEGATIVE_INITED;
-    nsCSSValue value = GetDesc(eCSSCounterDesc_Negative);
-    switch (value.GetUnit()) {
-      case eCSSUnit_Ident:
-      case eCSSUnit_String:
-        value.GetStringValue(mNegative.before);
+    if (!Servo_CounterStyleRule_GetNegative(mRule,
+                                            &mNegative.before,
+                                            &mNegative.after)) {
+      if (IsExtendsSystem()) {
+        GetExtends()->GetNegative(mNegative);
+      } else {
+        mNegative.before.AssignLiteral(u"-");
         mNegative.after.Truncate();
-        break;
-      case eCSSUnit_Pair: {
-        const nsCSSValuePair& pair = value.GetPairValue();
-        pair.mXValue.GetStringValue(mNegative.before);
-        pair.mYValue.GetStringValue(mNegative.after);
-        break;
-      }
-      default: {
-        if (IsExtendsSystem()) {
-          GetExtends()->GetNegative(mNegative);
-        } else {
-          mNegative.before.AssignLiteral(u"-");
-          mNegative.after.Truncate();
-        }
       }
     }
   }
   aResult = mNegative;
 }
 
 static inline bool IsRangeValueInfinite(const nsCSSValue& aValue) {
   return aValue.GetUnit() == eCSSUnit_Enumerated &&
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -2978,16 +2978,65 @@ pub unsafe extern "C" fn Servo_CounterSt
             None => return false,
         };
         *width = pad.0.value();
         *symbol = symbol_to_string(&pad.1);
         true
     })
 }
 
+fn get_symbol(s: Option<&counter_style::Symbol>, out: &mut nsString) -> bool {
+    let s = match s {
+        Some(s) => s,
+        None => return false,
+    };
+    *out = symbol_to_string(s);
+    true
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn Servo_CounterStyleRule_GetPrefix(
+    rule: &RawServoCounterStyleRule,
+    out: &mut nsString,
+) -> bool {
+    read_locked_arc(rule, |rule: &CounterStyleRule| {
+        get_symbol(rule.prefix(), out)
+    })
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn Servo_CounterStyleRule_GetSuffix(
+    rule: &RawServoCounterStyleRule,
+    out: &mut nsString,
+) -> bool {
+    read_locked_arc(rule, |rule: &CounterStyleRule| {
+        get_symbol(rule.suffix(), out)
+    })
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn Servo_CounterStyleRule_GetNegative(
+    rule: &RawServoCounterStyleRule,
+    prefix: &mut nsString,
+    suffix: &mut nsString,
+) -> bool {
+    read_locked_arc(rule, |rule: &CounterStyleRule| {
+        let negative = match rule.negative() {
+            Some(n) => n,
+            None => return false,
+        };
+        *prefix = symbol_to_string(&negative.0);
+        *suffix = match negative.1 {
+            Some(ref s) => symbol_to_string(s),
+            None => nsString::new(),
+        };
+        true
+    })
+}
+
 #[no_mangle]
 pub unsafe extern "C" fn Servo_CounterStyleRule_GetSystem(
     rule: &RawServoCounterStyleRule,
 ) -> u8 {
     use style::counter_style::System;
     read_locked_arc(rule, |rule: &CounterStyleRule| {
         match *rule.resolved_system() {
             System::Cyclic => structs::NS_STYLE_COUNTER_SYSTEM_CYCLIC,