mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
style: Move the keyframes property priority stuff outside of animated_properties.
Similarly, no need to be here. Differential Revision: https://phabricator.services.mozilla.com/D10840
This commit is contained in:
parent
282edf1a13
commit
f159c20198
2 changed files with 64 additions and 64 deletions
|
@ -19,7 +19,6 @@ 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;
|
||||
|
@ -3008,66 +3007,3 @@ impl ToAnimatedZero for AnimatedFilter {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 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())
|
||||
})
|
||||
}
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
|
||||
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;
|
||||
|
@ -21,6 +23,68 @@ 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue