Bug 1551991 - Remove usage of nsCSSValue for SpeakAs. r=jwatt
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 16 May 2019 23:06:06 +0000
changeset 474268 56b6c33c74ddcae4905eedd050f598cac8cf558c
parent 474267 80046630ae827214930d393824be223a68fe6805
child 474269 d02c7d06cc798c961d8ee82d490ada2603881fd8
push id36027
push usershindli@mozilla.com
push dateFri, 17 May 2019 16:24:38 +0000
treeherdermozilla-central@c94c54aff466 [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,