From 52bee9a4cfd2752d2c18b06399d765b5b34a431b Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Fri, 17 Mar 2017 12:29:08 +0900 Subject: [PATCH] Add AnimationValueMap and expose it in FFI. Current Gecko composes all of effects in the composite order at once. We can put each computed value into this AnimationValueMap every time composing an effect. --- components/style/build_gecko.rs | 2 ++ components/style/gecko/arc_types.rs | 7 +++++-- components/style/gecko_bindings/bindings.rs | 12 ++++++++++++ components/style/gecko_bindings/structs_debug.rs | 5 +++++ components/style/gecko_bindings/structs_release.rs | 5 +++++ .../properties/helpers/animated_properties.mako.rs | 7 +++++++ 6 files changed, 36 insertions(+), 2 deletions(-) diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index 8dbbc7f749b..88916c3f886 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -421,6 +421,7 @@ mod bindings { "mozilla::Side", "mozilla::binding_danger::AssertAndSuppressCleanupPolicy", "RawServoAnimationValueBorrowedListBorrowed", + "RawServoAnimationValueMapBorrowed", ]; let opaque_types = [ "std::pair__PCCP", @@ -541,6 +542,7 @@ mod bindings { "RawGeckoNode", "RawGeckoAnimationValueList", "RawServoAnimationValue", + "RawServoAnimationValueMap", "RawServoDeclarationBlock", "RawGeckoPresContext", "RawGeckoPresContextOwned", diff --git a/components/style/gecko/arc_types.rs b/components/style/gecko/arc_types.rs index 43a87f6b35f..d822857a9e6 100644 --- a/components/style/gecko/arc_types.rs +++ b/components/style/gecko/arc_types.rs @@ -11,12 +11,12 @@ use gecko_bindings::bindings::{RawServoMediaList, RawServoMediaRule, RawServoNamespaceRule}; use gecko_bindings::bindings::{RawServoStyleSheet, RawServoStyleRule, RawServoImportRule}; use gecko_bindings::bindings::{ServoComputedValues, ServoCssRules}; -use gecko_bindings::structs::{RawServoAnimationValue, RawServoDeclarationBlock}; +use gecko_bindings::structs::{RawServoAnimationValue, RawServoAnimationValueMap, RawServoDeclarationBlock}; use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI}; use media_queries::MediaList; use parking_lot::RwLock; use properties::{ComputedValues, PropertyDeclarationBlock}; -use properties::animated_properties::AnimationValue; +use properties::animated_properties::{AnimationValue, AnimationValueMap}; use stylesheets::{CssRules, Stylesheet, StyleRule, ImportRule, MediaRule, NamespaceRule}; macro_rules! impl_arc_ffi { @@ -59,6 +59,9 @@ impl_arc_ffi!(RwLock => RawServoImportRule impl_arc_ffi!(AnimationValue => RawServoAnimationValue [Servo_AnimationValue_AddRef, Servo_AnimationValue_Release]); +impl_arc_ffi!(RwLock => RawServoAnimationValueMap + [Servo_AnimationValueMap_AddRef, Servo_AnimationValueMap_Release]); + impl_arc_ffi!(RwLock => RawServoMediaList [Servo_MediaList_AddRef, Servo_MediaList_Release]); diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 1c0114737e7..81d8b2f3ca1 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -11,6 +11,7 @@ use gecko_bindings::structs::RawGeckoComputedKeyframeValuesList; use gecko_bindings::structs::RawGeckoNode; use gecko_bindings::structs::RawGeckoAnimationValueList; use gecko_bindings::structs::RawServoAnimationValue; +use gecko_bindings::structs::RawServoAnimationValueMap; use gecko_bindings::structs::RawServoDeclarationBlock; use gecko_bindings::structs::RawGeckoPresContext; use gecko_bindings::structs::RawGeckoPresContextOwned; @@ -207,6 +208,9 @@ pub struct RawServoImportRule(RawServoImportRuleVoid); pub type RawServoAnimationValueStrong = ::gecko_bindings::sugar::ownership::Strong; pub type RawServoAnimationValueBorrowed<'a> = &'a RawServoAnimationValue; pub type RawServoAnimationValueBorrowedOrNull<'a> = Option<&'a RawServoAnimationValue>; +pub type RawServoAnimationValueMapStrong = ::gecko_bindings::sugar::ownership::Strong; +pub type RawServoAnimationValueMapBorrowed<'a> = &'a RawServoAnimationValueMap; +pub type RawServoAnimationValueMapBorrowedOrNull<'a> = Option<&'a RawServoAnimationValueMap>; pub type RawServoMediaListStrong = ::gecko_bindings::sugar::ownership::Strong; pub type RawServoMediaListBorrowed<'a> = &'a RawServoMediaList; pub type RawServoMediaListBorrowedOrNull<'a> = Option<&'a RawServoMediaList>; @@ -325,6 +329,14 @@ extern "C" { extern "C" { pub fn Servo_AnimationValue_Release(ptr: RawServoAnimationValueBorrowed); } +extern "C" { + pub fn Servo_AnimationValueMap_AddRef(ptr: + RawServoAnimationValueMapBorrowed); +} +extern "C" { + pub fn Servo_AnimationValueMap_Release(ptr: + RawServoAnimationValueMapBorrowed); +} extern "C" { pub fn Servo_MediaList_AddRef(ptr: RawServoMediaListBorrowed); } diff --git a/components/style/gecko_bindings/structs_debug.rs b/components/style/gecko_bindings/structs_debug.rs index b7441315898..b7631880641 100644 --- a/components/style/gecko_bindings/structs_debug.rs +++ b/components/style/gecko_bindings/structs_debug.rs @@ -25843,6 +25843,9 @@ pub mod root { #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct RawServoStyleSet([u8; 0]); + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct RawServoAnimationValueMap([u8; 0]); pub type RawGeckoNode = root::nsINode; pub type RawGeckoElement = root::mozilla::dom::Element; pub type RawGeckoDocument = root::nsIDocument; @@ -25856,6 +25859,8 @@ pub mod root { root::nsTArray<*const root::RawServoAnimationValue>; pub type RawGeckoStyleAnimationList = root::nsStyleAutoArray; + pub type RawServoAnimationValueMapBorrowed = + *const root::RawServoAnimationValueMap; pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode; pub type RawGeckoNodeBorrowedOrNull = *const root::RawGeckoNode; pub type RawGeckoElementBorrowed = *const root::RawGeckoElement; diff --git a/components/style/gecko_bindings/structs_release.rs b/components/style/gecko_bindings/structs_release.rs index 606330565b4..afe41ab3238 100644 --- a/components/style/gecko_bindings/structs_release.rs +++ b/components/style/gecko_bindings/structs_release.rs @@ -25201,6 +25201,9 @@ pub mod root { #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct RawServoStyleSet([u8; 0]); + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct RawServoAnimationValueMap([u8; 0]); pub type RawGeckoNode = root::nsINode; pub type RawGeckoElement = root::mozilla::dom::Element; pub type RawGeckoDocument = root::nsIDocument; @@ -25214,6 +25217,8 @@ pub mod root { root::nsTArray<*const root::RawServoAnimationValue>; pub type RawGeckoStyleAnimationList = root::nsStyleAutoArray; + pub type RawServoAnimationValueMapBorrowed = + *const root::RawServoAnimationValueMap; pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode; pub type RawGeckoNodeBorrowedOrNull = *const root::RawGeckoNode; pub type RawGeckoElementBorrowed = *const root::RawGeckoElement; diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 83c3f26c4ce..37dbd3e0da0 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -25,6 +25,7 @@ use properties::longhands::visibility::computed_value::T as Visibility; use properties::longhands::z_index::computed_value::T as ZIndex; #[cfg(feature = "gecko")] use properties::{PropertyDeclarationId, LonghandId}; use std::cmp; +#[cfg(feature = "gecko")] use std::collections::HashMap; use std::fmt; use style_traits::ToCss; use super::ComputedValues; @@ -252,6 +253,12 @@ impl AnimatedProperty { } } +/// A collection of AnimationValue that were composed on an element. +/// This HashMap stores the values that are the last AnimationValue to be +/// composed for each TransitionProperty. +#[cfg(feature = "gecko")] +pub type AnimationValueMap = HashMap; + /// An enum to represent a single computed value belonging to an animated /// property in order to be interpolated with another one. When interpolating, /// both values need to belong to the same property.