servo: Merge #12263 - Make geckolib possible to build on stable Rust (from servo:stable-geckolib); r=nox
authorSimon Sapin <simon.sapin@exyr.org>
Tue, 05 Jul 2016 15:04:42 -0700
changeset 339215 0563b21dfecef0e2f3f04f56f4f108a5dcbe85ec
parent 339214 71c5a69870bcac681dd6ecb31f131118138ad51f
child 339216 35df17e12eb15665b4b9822417d3b5457982f947
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnox
servo: Merge #12263 - Make geckolib possible to build on stable Rust (from servo:stable-geckolib); r=nox <!-- Please describe your changes on the following line: --> More for https://github.com/servo/servo/issues/11815 r? @nox --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 3d557b6f25eb9dbd084cb53bbc9a9cf93bad825b
servo/components/style/keyframes.rs
servo/components/style/properties/helpers.mako.rs
servo/components/style/properties/helpers/animated_properties.mako.rs
servo/components/style/properties/longhand/box.mako.rs
servo/components/style/stylesheets.rs
servo/ports/geckolib/Cargo.toml
--- a/servo/components/style/keyframes.rs
+++ b/servo/components/style/keyframes.rs
@@ -5,17 +5,18 @@
 use cssparser::{AtRuleParser, Delimiter, Parser, QualifiedRuleParser, RuleListParser};
 use parser::{ParserContext, log_css_error};
 use properties::animated_properties::TransitionProperty;
 use properties::{PropertyDeclaration, parse_property_declaration_list};
 use std::sync::Arc;
 
 /// A number from 1 to 100, indicating the percentage of the animation where
 /// this keyframe should run.
-#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, HeapSizeOf)]
+#[derive(Debug, Copy, Clone, PartialEq, PartialOrd)]
+#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 pub struct KeyframePercentage(pub f32);
 
 impl ::std::cmp::Ord for KeyframePercentage {
     #[inline]
     fn cmp(&self, other: &Self) -> ::std::cmp::Ordering {
         // We know we have a number from 0 to 1, so unwrap() here is safe.
         self.0.partial_cmp(&other.0).unwrap()
     }
@@ -44,32 +45,34 @@ impl KeyframePercentage {
         };
 
         Ok(percentage)
     }
 }
 
 /// A keyframes selector is a list of percentages or from/to symbols, which are
 /// converted at parse time to percentages.
-#[derive(Debug, Clone, PartialEq, HeapSizeOf)]
+#[derive(Debug, Clone, PartialEq)]
+#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 pub struct KeyframeSelector(Vec<KeyframePercentage>);
 impl KeyframeSelector {
     #[inline]
     pub fn percentages(&self) -> &[KeyframePercentage] {
         &self.0
     }
 
     /// A dummy public function so we can write a unit test for this.
     pub fn new_for_unit_testing(percentages: Vec<KeyframePercentage>) -> KeyframeSelector {
         KeyframeSelector(percentages)
     }
 }
 
 /// A keyframe.
-#[derive(Debug, Clone, PartialEq, HeapSizeOf)]
+#[derive(Debug, Clone, PartialEq)]
+#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 pub struct Keyframe {
     pub selector: KeyframeSelector,
     pub declarations: Arc<Vec<PropertyDeclaration>>,
 }
 
 impl Keyframe {
     pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<Keyframe, ()> {
         let percentages = try!(input.parse_until_before(Delimiter::CurlyBracketBlock, |input| {
@@ -90,24 +93,26 @@ impl Keyframe {
         })
     }
 }
 
 /// A keyframes step value. This can be a synthetised keyframes animation, that
 /// is, one autogenerated from the current computed values, or a list of
 /// declarations to apply.
 // TODO: Find a better name for this?
-#[derive(Debug, Clone, PartialEq, HeapSizeOf)]
+#[derive(Debug, Clone, PartialEq)]
+#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 pub enum KeyframesStepValue {
     Declarations(Arc<Vec<PropertyDeclaration>>),
     ComputedValues,
 }
 
 /// A single step from a keyframe animation.
-#[derive(Debug, Clone, PartialEq, HeapSizeOf)]
+#[derive(Debug, Clone, PartialEq)]
+#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 pub struct KeyframesStep {
     /// The percentage of the animation duration when this step starts.
     pub start_percentage: KeyframePercentage,
     /// Declarations that will determine the final style during the step, or
     /// `ComputedValues` if this is an autogenerated step.
     pub value: KeyframesStepValue,
 }
 
@@ -121,17 +126,18 @@ impl KeyframesStep {
         }
     }
 }
 
 /// This structure represents a list of animation steps computed from the list
 /// of keyframes, in order.
 ///
 /// It only takes into account animable properties.
-#[derive(Debug, Clone, PartialEq, HeapSizeOf)]
+#[derive(Debug, Clone, PartialEq)]
+#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 pub struct KeyframesAnimation {
     pub steps: Vec<KeyframesStep>,
     /// The properties that change in this animation.
     pub properties_changed: Vec<TransitionProperty>,
 }
 
 /// Get all the animated properties in a keyframes animation. Note that it's not
 /// defined what happens when a property is not on a keyframe, so we only peek
--- a/servo/components/style/properties/helpers.mako.rs
+++ b/servo/components/style/properties/helpers.mako.rs
@@ -201,17 +201,18 @@
     %>
     <%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
         use values::computed::ComputedValueAsSpecified;
         pub use self::computed_value::T as SpecifiedValue;
         pub mod computed_value {
             use cssparser::ToCss;
             use std::fmt;
 
-            #[derive(Debug, Clone, PartialEq, HeapSizeOf)]
+            #[derive(Debug, Clone, PartialEq)]
+            #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
             pub struct T(pub Vec<${to_camel_case(name)}>);
 
             impl ToCss for T {
                 fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
                     debug_assert!(!self.0.is_empty(), "Always parses at least one");
 
                     for (index, item) in self.0.iter().enumerate() {
                         if index != 0 {
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -29,17 +29,18 @@ use std::cmp;
 use std::fmt;
 use super::ComputedValues;
 use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
 use values::computed::{BorderRadiusSize, LengthOrNone};
 use values::computed::{CalcLengthOrPercentage, LengthOrPercentage};
 
 // NB: This needs to be here because it needs all the longhands generated
 // beforehand.
-#[derive(Copy, Clone, Debug, PartialEq, HeapSizeOf)]
+#[derive(Copy, Clone, Debug, PartialEq)]
+#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 pub enum TransitionProperty {
     All,
     % for prop in data.longhands:
         % if prop.animatable:
             ${prop.camel_case},
         % endif
     % endfor
 }
@@ -87,17 +88,18 @@ impl ToCss for TransitionProperty {
                 % if prop.animatable:
                     TransitionProperty::${prop.camel_case} => dest.write_str("${prop.name}"),
                 % endif
             % endfor
         }
     }
 }
 
-#[derive(Clone, Debug, PartialEq, HeapSizeOf)]
+#[derive(Clone, Debug, PartialEq)]
+#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 pub enum AnimatedProperty {
     % for prop in data.longhands:
         % if prop.animatable:
             ${prop.camel_case}(longhands::${prop.ident}::computed_value::T,
                                longhands::${prop.ident}::computed_value::T),
         % endif
     % endfor
 }
--- a/servo/components/style/properties/longhand/box.mako.rs
+++ b/servo/components/style/properties/longhand/box.mako.rs
@@ -613,17 +613,18 @@
 
     pub mod computed_value {
         use cssparser::ToCss;
         use std::fmt;
         use string_cache::Atom;
 
         pub use string_cache::Atom as SingleComputedValue;
 
-        #[derive(Debug, Clone, PartialEq, HeapSizeOf)]
+        #[derive(Debug, Clone, PartialEq)]
+        #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
         pub struct T(pub Vec<Atom>);
 
         impl ToCss for T {
             fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
                 if self.0.is_empty() {
                     return dest.write_str("none")
                 }
 
@@ -678,32 +679,34 @@
     use values::computed::ComputedValueAsSpecified;
 
     pub mod computed_value {
         use cssparser::ToCss;
         use std::fmt;
 
         pub use self::AnimationIterationCount as SingleComputedValue;
 
-        #[derive(Debug, Clone, PartialEq, HeapSizeOf)]
+        #[derive(Debug, Clone, PartialEq)]
+        #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
         pub enum AnimationIterationCount {
             Number(u32),
             Infinite,
         }
 
         impl ToCss for AnimationIterationCount {
             fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
                 match *self {
                     AnimationIterationCount::Number(n) => write!(dest, "{}", n),
                     AnimationIterationCount::Infinite => dest.write_str("infinite"),
                 }
             }
         }
 
-        #[derive(Debug, Clone, PartialEq, HeapSizeOf)]
+        #[derive(Debug, Clone, PartialEq)]
+        #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
         pub struct T(pub Vec<AnimationIterationCount>);
 
         impl ToCss for T {
             fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
                 if self.0.is_empty() {
                     return dest.write_str("none")
                 }
                 for (i, value) in self.0.iter().enumerate() {
--- a/servo/components/style/stylesheets.rs
+++ b/servo/components/style/stylesheets.rs
@@ -62,17 +62,18 @@ pub enum CSSRule<Impl: SelectorImpl> {
     Style(StyleRule<Impl>),
     Media(MediaRule<Impl>),
     FontFace(FontFaceRule),
     Viewport(ViewportRule),
     Keyframes(KeyframesRule),
 }
 
 
-#[derive(Debug, HeapSizeOf, PartialEq)]
+#[derive(Debug, PartialEq)]
+#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 pub struct KeyframesRule {
     pub name: Atom,
     pub keyframes: Vec<Keyframe>,
 }
 
 #[derive(Debug, PartialEq)]
 #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 pub struct MediaRule<Impl: SelectorImpl> {
--- a/servo/ports/geckolib/Cargo.toml
+++ b/servo/ports/geckolib/Cargo.toml
@@ -13,16 +13,17 @@ crate-type = ["staticlib"]
 [features]
 default = ["servo_features"]
 
 # Features that aren't actually required for geckolib, but match the ones used
 # in the full Servo build.  Enabling this reduces the number of things
 # recompiled when building both Servo and geckolib in the same source tree.
 servo_features = [
   "heapsize",
+  "selectors/unstable",
   "style/servo",
   "time",
   "url/query_encoding",
   "url/rustc-serialize",
   "uuid",
 ]
 
 [dependencies]
@@ -31,17 +32,17 @@ cssparser = "0.5.4"
 env_logger = "0.3"
 euclid = "0.7.1"
 gecko_bindings = {version = "0.0.1", path = "gecko_bindings"}
 heapsize = {version = "0.3.0", optional = true}
 lazy_static = "0.2"
 libc = "0.2"
 log = {version = "0.3.5", features = ["release_max_level_info"]}
 num_cpus = "0.2.2"
-selectors = {version = "0.6", features = ["unstable"]}
+selectors = "0.6"
 smallvec = "0.1"
 string_cache = {version = "0.2.20", features = ["unstable"]}
 style = {path = "../../components/style", features = ["gecko"]}
 style_traits = {path = "../../components/style_traits"}
 time = {version = "0.1", optional = true, features = ["rustc-serialize"]}
 url = "1.0.0"
 util = {path = "../../components/util"}
 uuid = {version = "0.2", optional = true, features = ["v4", "serde"]}