Pass AnimationValueMap raw pointer instead of Arc to Gecko_GetAnimationRule()

This commit is contained in:
Hiroyuki Ikezoe 2017-05-01 18:11:33 +09:00
parent ecc818165f
commit 83a4935b60
6 changed files with 27 additions and 29 deletions

View file

@ -466,7 +466,6 @@ mod bindings {
"mozilla::DefaultDelete",
"mozilla::Side",
"mozilla::binding_danger::AssertAndSuppressCleanupPolicy",
"RawServoAnimationValueMapBorrowed",
"mozilla::LengthParsingMode",
"mozilla::InheritTarget",
];
@ -636,7 +635,6 @@ mod bindings {
"RawGeckoNode",
"RawGeckoAnimationValueList",
"RawServoAnimationValue",
"RawServoAnimationValueMap",
"RawServoDeclarationBlock",
"RawServoStyleRule",
"RawGeckoPresContext",
@ -743,6 +741,7 @@ mod bindings {
ServoOwnedType { name: "RawServoStyleSet", opaque: true },
ServoOwnedType { name: "StyleChildrenIterator", opaque: true },
ServoOwnedType { name: "ServoElementSnapshot", opaque: false },
ServoOwnedType { name: "RawServoAnimationValueMap", opaque: true },
];
let servo_immutable_borrow_types = [
"RawGeckoNode",

View file

@ -11,13 +11,12 @@
use gecko_bindings::bindings::{RawServoMediaList, RawServoMediaRule, RawServoNamespaceRule, RawServoPageRule};
use gecko_bindings::bindings::{RawServoStyleSheet, RawServoImportRule, RawServoSupportsRule};
use gecko_bindings::bindings::{ServoComputedValues, ServoCssRules};
use gecko_bindings::structs::{RawServoAnimationValue, RawServoAnimationValueMap};
use gecko_bindings::structs::{RawServoDeclarationBlock, RawServoStyleRule};
use gecko_bindings::structs::RawServoAnimationValue;
use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI};
use media_queries::MediaList;
use parking_lot::RwLock;
use properties::{ComputedValues, PropertyDeclarationBlock};
use properties::animated_properties::{AnimationValue, AnimationValueMap};
use properties::animated_properties::AnimationValue;
use shared_lock::Locked;
use stylesheets::{CssRules, Stylesheet, StyleRule, ImportRule, MediaRule};
use stylesheets::{NamespaceRule, PageRule, SupportsRule};
@ -62,9 +61,6 @@ impl_arc_ffi!(Locked<ImportRule> => RawServoImportRule
impl_arc_ffi!(AnimationValue => RawServoAnimationValue
[Servo_AnimationValue_AddRef, Servo_AnimationValue_Release]);
impl_arc_ffi!(RwLock<AnimationValueMap> => RawServoAnimationValueMap
[Servo_AnimationValueMap_AddRef, Servo_AnimationValueMap_Release]);
impl_arc_ffi!(Locked<MediaList> => RawServoMediaList
[Servo_MediaList_AddRef, Servo_MediaList_Release]);

View file

@ -55,7 +55,6 @@ use gecko_bindings::structs::NODE_IS_NATIVE_ANONYMOUS;
use gecko_bindings::sugar::ownership::HasArcFFI;
use logical_geometry::WritingMode;
use media_queries::Device;
use parking_lot::RwLock;
use properties::{ComputedValues, parse_style_attribute};
use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock};
use properties::animated_properties::{AnimationValue, AnimationValueMap, TransitionProperty};
@ -423,17 +422,15 @@ fn selector_flags_to_node_flags(flags: ElementSelectorFlags) -> u32 {
fn get_animation_rule(element: &GeckoElement,
cascade_level: CascadeLevel)
-> Option<Arc<Locked<PropertyDeclarationBlock>>> {
// FIXME(emilio): This is quite dumb, why an RwLock, it's local to this
// function?
//
use gecko_bindings::sugar::ownership::HasSimpleFFI;
// Also, we should try to reuse the PDB, to avoid creating extra rule nodes.
let animation_values = Arc::new(RwLock::new(AnimationValueMap::new()));
let mut animation_values = AnimationValueMap::new();
if unsafe { Gecko_GetAnimationRule(element.0,
cascade_level,
HasArcFFI::arc_as_borrowed(&animation_values)) } {
AnimationValueMap::as_ffi_mut(&mut animation_values)) } {
let shared_lock = &GLOBAL_STYLE_DATA.shared_lock;
Some(Arc::new(shared_lock.wrap(
PropertyDeclarationBlock::from_animation_value_map(&animation_values.read()))))
PropertyDeclarationBlock::from_animation_value_map(&animation_values))))
} else {
None
}

View file

@ -9,7 +9,9 @@
use app_units::Au;
use cssparser::{Color as CSSParserColor, Parser, RGBA, serialize_identifier};
use euclid::{Point2D, Size2D};
#[cfg(feature = "gecko")] use gecko_bindings::bindings::RawServoAnimationValueMap;
#[cfg(feature = "gecko")] use gecko_bindings::structs::nsCSSPropertyID;
#[cfg(feature = "gecko")] use gecko_bindings::sugar::ownership::{HasFFI, HasSimpleFFI};
#[cfg(feature = "gecko")] use gecko_string_cache::Atom;
use properties::{CSSWideKeyword, PropertyDeclaration};
use properties::longhands;
@ -388,6 +390,12 @@ impl AnimatedProperty {
/// composed for each TransitionProperty.
#[cfg(feature = "gecko")]
pub type AnimationValueMap = HashMap<TransitionProperty, AnimationValue>;
#[cfg(feature = "gecko")]
unsafe impl HasFFI for AnimationValueMap {
type FFIType = RawServoAnimationValueMap;
}
#[cfg(feature = "gecko")]
unsafe impl HasSimpleFFI for AnimationValueMap {}
/// An enum to represent a single computed value belonging to an animated
/// property in order to be interpolated with another one. When interpolating,