Bug 1551991 - Remove usage of nsCSSValue for SpeakAs. r=jwatt
☠☠ backed out by 283b94c196a1 ☠ ☠
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 16 May 2019 14:31:50 +0000
changeset 474085 e12a979de502bf14147c43b34d437449bbd74552
parent 474084 d81e4aa6bf0c5701bf5369b4f764caa09cf803ea
child 474086 3bb3fafa62e2eea4b96404a1954f822fdaecbfd5
push id36022
push userncsoregi@mozilla.com
push dateThu, 16 May 2019 21:55:16 +0000
treeherdermozilla-central@96802be91766 [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 usage of nsCSSValue for SpeakAs. r=jwatt Depends on D31319 Differential Revision: https://phabricator.services.mozilla.com/D31320
layout/style/CounterStyleManager.cpp
servo/ports/geckolib/glue.rs
--- a/layout/style/CounterStyleManager.cpp
+++ b/layout/style/CounterStyleManager.cpp
@@ -1339,29 +1339,35 @@ uint8_t CustomCounterStyle::GetSpeakAsAu
 // out the raw value. To keep things clear, this method is designed to
 // have no side effects (but functions it calls may still affect other
 // fields in the style.)
 void CustomCounterStyle::ComputeRawSpeakAs(uint8_t& aSpeakAs,
                                            CounterStyle*& aSpeakAsCounter) {
   NS_ASSERTION(!(mFlags & FLAG_SPEAKAS_INITED),
                "ComputeRawSpeakAs is called with speak-as inited.");
 
-  nsCSSValue value = GetDesc(eCSSCounterDesc_SpeakAs);
-  switch (value.GetUnit()) {
-    case eCSSUnit_Auto:
+  auto speakAs = Servo_CounterStyleRule_GetSpeakAs(mRule);
+  switch (speakAs.tag) {
+    case StyleCounterSpeakAs::Tag::Auto:
       aSpeakAs = GetSpeakAsAutoValue();
       break;
-    case eCSSUnit_Enumerated:
-      aSpeakAs = value.GetIntValue();
+    case StyleCounterSpeakAs::Tag::Bullets:
+      aSpeakAs = NS_STYLE_COUNTER_SPEAKAS_BULLETS;
+      break;
+    case StyleCounterSpeakAs::Tag::Numbers:
+      aSpeakAs = NS_STYLE_COUNTER_SPEAKAS_NUMBERS;
       break;
-    case eCSSUnit_AtomIdent:
+    case StyleCounterSpeakAs::Tag::Words:
+      aSpeakAs = NS_STYLE_COUNTER_SPEAKAS_WORDS;
+      break;
+    case StyleCounterSpeakAs::Tag::Ident:
       aSpeakAs = NS_STYLE_COUNTER_SPEAKAS_OTHER;
-      aSpeakAsCounter = mManager->ResolveCounterStyle(value.GetAtomValue());
+      aSpeakAsCounter = mManager->ResolveCounterStyle(speakAs.AsIdent());
       break;
-    case eCSSUnit_Null: {
+    case StyleCounterSpeakAs::Tag::None: {
       if (!IsExtendsSystem()) {
         aSpeakAs = GetSpeakAsAutoValue();
       } else {
         CounterStyle* extended = GetExtends();
         if (!extended->IsCustomStyle()) {
           // It is safe to call GetSpeakAs on non-custom style.
           aSpeakAs = extended->GetSpeakAs();
         } else {
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -3113,16 +3113,46 @@ pub unsafe extern "C" fn Servo_CounterSt
                     symbol: symbol_to_string(&s.symbol),
                 }
             }).collect(),
             None => style::OwnedSlice::default(),
         };
     })
 }
 
+#[repr(C, u8)]
+pub enum CounterSpeakAs {
+    None,
+    Auto,
+    Bullets,
+    Numbers,
+    Words,
+    Ident(*mut nsAtom),
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn Servo_CounterStyleRule_GetSpeakAs(
+    rule: &RawServoCounterStyleRule,
+) -> CounterSpeakAs {
+    use style::counter_style::SpeakAs;
+    read_locked_arc(rule, |rule: &CounterStyleRule| {
+        let speak_as = match rule.speak_as() {
+            Some(s) => s,
+            None => return CounterSpeakAs::None,
+        };
+        match *speak_as {
+            SpeakAs::Auto => CounterSpeakAs::Auto,
+            SpeakAs::Bullets => CounterSpeakAs::Bullets,
+            SpeakAs::Numbers => CounterSpeakAs::Numbers,
+            SpeakAs::Words => CounterSpeakAs::Words,
+            SpeakAs::Other(ref other) => CounterSpeakAs::Ident(other.0.as_ptr()),
+        }
+    })
+}
+
 #[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,