Bug 1551991 - Remove nsCSSValue usage from GetPad. r=jwatt
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 16 May 2019 23:05:10 +0000
changeset 474263 336a076368ebcebbde75f4e6e468ebfe2b50ec94
parent 474262 5bac84efbf6d16393e61789c8fb183fb7410a0a0
child 474264 76ba2ec949d32634e2dd9ea5ba0a91170bda89a5
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 from GetPad. r=jwatt Depends on D31315 Differential Revision: https://phabricator.services.mozilla.com/D31316
layout/style/CounterStyleManager.cpp
servo/ports/geckolib/glue.rs
--- a/layout/style/CounterStyleManager.cpp
+++ b/layout/style/CounterStyleManager.cpp
@@ -1237,26 +1237,23 @@ bool CustomCounterStyle::IsOrdinalInAuto
       return false;
   }
 }
 
 /* virtual */
 void CustomCounterStyle::GetPad(PadType& aResult) {
   if (!(mFlags & FLAG_PAD_INITED)) {
     mFlags |= FLAG_PAD_INITED;
-    nsCSSValue value = GetDesc(eCSSCounterDesc_Pad);
-    if (value.GetUnit() == eCSSUnit_Pair) {
-      const nsCSSValuePair& pair = value.GetPairValue();
-      mPad.width = pair.mXValue.GetIntValue();
-      pair.mYValue.GetStringValue(mPad.symbol);
-    } else if (IsExtendsSystem()) {
-      GetExtends()->GetPad(mPad);
-    } else {
-      mPad.width = 0;
-      mPad.symbol.Truncate();
+    if (!Servo_CounterStyleRule_GetPad(mRule, &mPad.width, &mPad.symbol)) {
+      if (IsExtendsSystem()) {
+        GetExtends()->GetPad(mPad);
+      } else {
+        mPad.width = 0;
+        mPad.symbol.Truncate();
+      }
     }
   }
   aResult = mPad;
 }
 
 /* virtual */
 CounterStyle* CustomCounterStyle::GetFallback() {
   if (!mFallback) {
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -2954,16 +2954,40 @@ pub unsafe extern "C" fn Servo_CounterSt
 
 #[no_mangle]
 pub unsafe extern "C" fn Servo_CounterStyleRule_GetGeneration(
     rule: &RawServoCounterStyleRule,
 ) -> u32 {
     read_locked_arc(rule, |rule: &CounterStyleRule| rule.generation())
 }
 
+fn symbol_to_string(s: &counter_style::Symbol) -> nsString {
+    match *s {
+        counter_style::Symbol::String(ref s) => nsString::from(&**s),
+        counter_style::Symbol::Ident(ref i) => nsString::from(i.0.as_slice())
+    }
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn Servo_CounterStyleRule_GetPad(
+    rule: &RawServoCounterStyleRule,
+    width: &mut i32,
+    symbol: &mut nsString,
+) -> bool {
+    read_locked_arc(rule, |rule: &CounterStyleRule| {
+        let pad = match rule.pad() {
+            Some(pad) => pad,
+            None => return false,
+        };
+        *width = pad.0.value();
+        *symbol = symbol_to_string(&pad.1);
+        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,