Bug 1504536 - Move the keyframes property priority stuff outside of animated_properties. r=hiro
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 04 Nov 2018 23:12:24 +0000
changeset 503578 0f270a54b160bcf54351a62aee72fca909409e18
parent 503577 df3738e12c6124de78c6870df5a009a8faf462ce
child 503579 2d0e45f37f451874bbe6834d865c0e864a35b7a6
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro
bugs1504536
milestone65.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 1504536 - Move the keyframes property priority stuff outside of animated_properties. r=hiro Similarly, no need to be here. Differential Revision: https://phabricator.services.mozilla.com/D10840
servo/components/style/properties/helpers/animated_properties.mako.rs
servo/components/style/values/animated/mod.rs
servo/ports/geckolib/glue.rs
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -14,17 +14,16 @@
 #[cfg(feature = "gecko")] use gecko_bindings::structs::nsCSSPropertyID;
 #[cfg(feature = "gecko")] use gecko_bindings::sugar::ownership::{HasFFI, HasSimpleFFI};
 use itertools::{EitherOrBoth, Itertools};
 use num_traits::Zero;
 use properties::{CSSWideKeyword, PropertyDeclaration};
 use properties::longhands;
 use properties::longhands::font_weight::computed_value::T as FontWeight;
 use properties::longhands::visibility::computed_value::T as Visibility;
-use properties::PropertyId;
 use properties::{LonghandId, ShorthandId};
 use servo_arc::Arc;
 use smallvec::SmallVec;
 use std::{cmp, ptr};
 use std::mem::{self, ManuallyDrop};
 use hash::FxHashMap;
 use super::ComputedValues;
 use values::CSSFloat;
@@ -3003,71 +3002,8 @@ impl ToAnimatedZero for AnimatedFilter {
             % endfor
             % if product == "gecko":
             Filter::DropShadow(ref this) => Ok(Filter::DropShadow(this.to_animated_zero()?)),
             % endif
             _ => Err(()),
         }
     }
 }
-
-/// The category a property falls into for ordering purposes.
-///
-/// https://drafts.csswg.org/web-animations/#calculating-computed-keyframes
-///
-#[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)]
-enum PropertyCategory {
-    Custom,
-    PhysicalLonghand,
-    LogicalLonghand,
-    Shorthand,
-}
-
-impl PropertyCategory {
-    fn of(id: &PropertyId) -> Self {
-        match *id {
-            PropertyId::Shorthand(..) |
-            PropertyId::ShorthandAlias(..) => PropertyCategory::Shorthand,
-            PropertyId::Longhand(id) |
-            PropertyId::LonghandAlias(id, ..) => {
-                if id.is_logical() {
-                    PropertyCategory::LogicalLonghand
-                } else {
-                    PropertyCategory::PhysicalLonghand
-                }
-            }
-            PropertyId::Custom(..) => PropertyCategory::Custom,
-        }
-    }
-}
-
-/// A comparator to sort PropertyIds such that physical longhands are sorted
-/// before logical longhands and shorthands, shorthands with fewer components
-/// are sorted before shorthands with more components, and otherwise shorthands
-/// are sorted by IDL name as defined by [Web Animations][property-order].
-///
-/// Using this allows us to prioritize values specified by longhands (or smaller
-/// shorthand subsets) when longhands and shorthands are both specified on the
-/// one keyframe.
-///
-/// [property-order] https://drafts.csswg.org/web-animations/#calculating-computed-keyframes
-pub fn compare_property_priority(a: &PropertyId, b: &PropertyId) -> cmp::Ordering {
-    let a_category = PropertyCategory::of(a);
-    let b_category = PropertyCategory::of(b);
-
-    if a_category != b_category {
-        return a_category.cmp(&b_category);
-    }
-
-    if a_category != PropertyCategory::Shorthand {
-        return cmp::Ordering::Equal;
-    }
-
-    let a = a.as_shorthand().unwrap();
-    let b = b.as_shorthand().unwrap();
-    // Within shorthands, sort by the number of subproperties, then by IDL
-    // name.
-    let subprop_count_a = a.longhands().count();
-    let subprop_count_b = b.longhands().count();
-    subprop_count_a.cmp(&subprop_count_b).then_with(|| {
-        a.idl_name_sort_order().cmp(&b.idl_name_sort_order())
-    })
-}
--- a/servo/components/style/values/animated/mod.rs
+++ b/servo/components/style/values/animated/mod.rs
@@ -5,27 +5,91 @@
 //! Animated values.
 //!
 //! Some values, notably colors, cannot be interpolated directly with their
 //! computed values and need yet another intermediate representation. This
 //! module's raison d'ĂȘtre is to ultimately contain all these types.
 
 use app_units::Au;
 use euclid::{Point2D, Size2D};
+use properties::PropertyId;
 use smallvec::SmallVec;
+use std::cmp;
 use values::computed::Angle as ComputedAngle;
 use values::computed::BorderCornerRadius as ComputedBorderCornerRadius;
 use values::computed::MaxLength as ComputedMaxLength;
 use values::computed::MozLength as ComputedMozLength;
 use values::computed::length::CalcLengthOrPercentage;
 use values::computed::url::ComputedUrl;
 
 pub mod color;
 pub mod effects;
 
+/// The category a property falls into for ordering purposes.
+///
+/// https://drafts.csswg.org/web-animations/#calculating-computed-keyframes
+#[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)]
+enum PropertyCategory {
+    Custom,
+    PhysicalLonghand,
+    LogicalLonghand,
+    Shorthand,
+}
+
+impl PropertyCategory {
+    fn of(id: &PropertyId) -> Self {
+        match *id {
+            PropertyId::Shorthand(..) |
+            PropertyId::ShorthandAlias(..) => PropertyCategory::Shorthand,
+            PropertyId::Longhand(id) |
+            PropertyId::LonghandAlias(id, ..) => {
+                if id.is_logical() {
+                    PropertyCategory::LogicalLonghand
+                } else {
+                    PropertyCategory::PhysicalLonghand
+                }
+            }
+            PropertyId::Custom(..) => PropertyCategory::Custom,
+        }
+    }
+}
+
+/// A comparator to sort PropertyIds such that physical longhands are sorted
+/// before logical longhands and shorthands, shorthands with fewer components
+/// are sorted before shorthands with more components, and otherwise shorthands
+/// are sorted by IDL name as defined by [Web Animations][property-order].
+///
+/// Using this allows us to prioritize values specified by longhands (or smaller
+/// shorthand subsets) when longhands and shorthands are both specified on the
+/// one keyframe.
+///
+/// [property-order] https://drafts.csswg.org/web-animations/#calculating-computed-keyframes
+pub fn compare_property_priority(a: &PropertyId, b: &PropertyId) -> cmp::Ordering {
+    let a_category = PropertyCategory::of(a);
+    let b_category = PropertyCategory::of(b);
+
+    if a_category != b_category {
+        return a_category.cmp(&b_category);
+    }
+
+    if a_category != PropertyCategory::Shorthand {
+        return cmp::Ordering::Equal;
+    }
+
+    let a = a.as_shorthand().unwrap();
+    let b = b.as_shorthand().unwrap();
+    // Within shorthands, sort by the number of subproperties, then by IDL
+    // name.
+    let subprop_count_a = a.longhands().count();
+    let subprop_count_b = b.longhands().count();
+    subprop_count_a.cmp(&subprop_count_b).then_with(|| {
+        a.idl_name_sort_order().cmp(&b.idl_name_sort_order())
+    })
+}
+
 /// Animate from one value to another.
 ///
 /// This trait is derivable with `#[derive(Animate)]`. The derived
 /// implementation uses a `match` expression with identical patterns for both
 /// `self` and `other`, calling `Animate::animate` on each fields of the values.
 /// If a field is annotated with `#[animation(constant)]`, the two values should
 /// be equal or an error is returned.
 ///
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -131,17 +131,16 @@ use style::invalidation::element::restyl
 use style::media_queries::MediaList;
 use style::parser::{Parse, ParserContext, self};
 use style::properties::{ComputedValues, Importance};
 use style::properties::{LonghandId, LonghandIdSet, PropertyDeclarationBlock, PropertyId};
 use style::properties::{PropertyDeclarationId, ShorthandId};
 use style::properties::{SourcePropertyDeclaration, StyleBuilder};
 use style::properties::{parse_one_declaration_into, parse_style_attribute};
 use style::properties::animated_properties::AnimationValue;
-use style::properties::animated_properties::compare_property_priority;
 use style::rule_cache::RuleCacheConditions;
 use style::rule_tree::{CascadeLevel, StrongRuleNode};
 use style::selector_parser::{PseudoElementCascadeType, SelectorImpl};
 use style::shared_lock::{SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard, Locked};
 use style::string_cache::{Atom, WeakAtom};
 use style::style_adjuster::StyleAdjuster;
 use style::stylesheets::{CssRule, CssRules, CssRuleType, CssRulesHelpers, CounterStyleRule};
 use style::stylesheets::{DocumentRule, FontFaceRule, FontFeatureValuesRule, ImportRule};
@@ -4732,16 +4731,18 @@ struct PropertyAndIndex {
 struct PrioritizedPropertyIter<'a> {
     properties: &'a [PropertyValuePair],
     sorted_property_indices: Vec<PropertyAndIndex>,
     curr: usize,
 }
 
 impl<'a> PrioritizedPropertyIter<'a> {
     fn new(properties: &'a [PropertyValuePair]) -> PrioritizedPropertyIter {
+        use style::values::animated::compare_property_priority;
+
         // If we fail to convert a nsCSSPropertyID into a PropertyId we
         // shouldn't fail outright but instead by treating that property as the
         // 'all' property we make it sort last.
         let mut sorted_property_indices: Vec<PropertyAndIndex> =
             properties.iter().enumerate().map(|(index, pair)| {
                 let property =
                     PropertyId::from_nscsspropertyid(pair.mProperty)
                         .unwrap_or(PropertyId::Shorthand(ShorthandId::All));