Bug 1542178 - Use ToResolvedValue for computed style serialization. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 10 Apr 2019 12:10:40 +0000
changeset 468799 11dcdb94e2faab73048c25a0802105d8e97d0f14
parent 468798 79752758fc82bda5a89bd3a3860fc20aea10d72f
child 468800 5ce09292f6bfd580d4a641ed8c00651dc0c7691e
push id112755
push userdvarga@mozilla.com
push dateWed, 10 Apr 2019 22:06:41 +0000
treeherdermozilla-inbound@606f85641d0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1542178
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 1542178 - Use ToResolvedValue for computed style serialization. r=heycam Differential Revision: https://phabricator.services.mozilla.com/D26784
servo/components/style/properties/properties.mako.rs
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -34,17 +34,17 @@ use crate::properties::longhands::system
 use crate::selector_parser::PseudoElement;
 use selectors::parser::SelectorParseErrorKind;
 #[cfg(feature = "servo")] use servo_config::prefs;
 use style_traits::{CssWriter, KeywordsCollectFn, ParseError, ParsingMode};
 use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss};
 use to_shmem::impl_trivial_to_shmem;
 use crate::stylesheets::{CssRuleType, Origin, UrlExtraData};
 use crate::values::generics::text::LineHeight;
-use crate::values::computed;
+use crate::values::{computed, resolved};
 use crate::values::computed::NonNegativeLength;
 use crate::values::serialize_atom_name;
 use crate::rule_tree::StrongRuleNode;
 use crate::Zero;
 use self::computed_value_flags::*;
 use crate::str::{CssString, CssStringBorrow, CssStringWriter};
 use std::cell::Cell;
 
@@ -2807,29 +2807,29 @@ impl ComputedValues {
     pub fn get_longhand_property_value<W>(
         &self,
         property_id: LonghandId,
         dest: &mut CssWriter<W>
     ) -> fmt::Result
     where
         W: Write,
     {
+        use crate::values::resolved::ToResolvedValue;
+
+        let context = resolved::Context {
+            style: self,
+        };
+
         // TODO(emilio): Is it worth to merge branches here just like
         // PropertyDeclaration::to_css does?
-        //
-        // We'd need to get a concept of ~resolved value, which may not be worth
-        // it.
         match property_id {
             % for prop in data.longhands:
             LonghandId::${prop.camel_case} => {
                 let value = self.clone_${prop.ident}();
-                % if prop.predefined_type == "Color":
-                let value = self.resolve_color(value);
-                % endif
-                value.to_css(dest)
+                value.to_resolved_value(&context).to_css(dest)
             }
             % endfor
         }
     }
 
     /// Resolves the currentColor keyword.
     ///
     /// Any color value from computed values (except for the 'color' property