Bug 1551991 - Remove nsCSSValue usage for negative / suffix / prefix. r=jwatt
☠☠ backed out by 283b94c196a1 ☠ ☠
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 16 May 2019 14:31:22 +0000
changeset 532924 37fd602bebc2f47062f1b8b22b3b71574aa4f072
parent 532923 6c1f00cc30ca74cf5db1463da06b0c2772e9737a
child 532925 c354e61f2a347779dbc2f31ca384046f8a85953a
push id11276
push userrgurzau@mozilla.com
push dateMon, 20 May 2019 13:11:24 +0000
treeherdermozilla-beta@847755a7c325 [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,