diff options
author | Boris Chiou <boris.chiou@gmail.com> | 2017-02-08 11:36:51 +0800 |
---|---|---|
committer | Boris Chiou <boris.chiou@gmail.com> | 2017-02-08 12:32:25 +0800 |
commit | 873cb98302176987920855f64499ab435b10bf27 (patch) | |
tree | b886da20329b71a504dbf80101006243acc8cb58 | |
parent | 22d04e1a167f8def6c04d8fe36b9f35c98cda0a5 (diff) | |
download | servo-873cb98302176987920855f64499ab435b10bf27.tar.gz servo-873cb98302176987920855f64499ab435b10bf27.zip |
Bug 1335942 - Part 3: Support GetTransform FFI. r=manishearth
-rw-r--r-- | components/style/build_gecko.rs | 1 | ||||
-rw-r--r-- | components/style/gecko_bindings/bindings.rs | 5 | ||||
-rw-r--r-- | components/style/properties/gecko.mako.rs | 33 | ||||
-rw-r--r-- | ports/geckolib/glue.rs | 14 |
4 files changed, 39 insertions, 14 deletions
diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index f9e8da7c49e..2714a54bfc3 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -505,6 +505,7 @@ mod bindings { "RawServoDeclarationBlock", "RawGeckoPresContext", "RawGeckoPresContextOwned", + "RefPtr", "ThreadSafeURIHolder", "ThreadSafePrincipalHolder", "CSSPseudoClassType", diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 034992d1b21..579e82f0d8e 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -156,6 +156,7 @@ use gecko_bindings::structs::Loader; use gecko_bindings::structs::ServoStyleSheet; use gecko_bindings::structs::EffectCompositor_CascadeLevel; use gecko_bindings::structs::RawServoAnimationValueBorrowedListBorrowed; +use gecko_bindings::structs::RefPtr; pub type nsTArrayBorrowed_uintptr_t<'a> = &'a mut ::gecko_bindings::structs::nsTArray<usize>; pub type ServoComputedValuesStrong = ::gecko_bindings::sugar::ownership::Strong<ServoComputedValues>; pub type ServoComputedValuesBorrowed<'a> = &'a ServoComputedValues; @@ -1307,6 +1308,10 @@ extern "C" { -> f32; } extern "C" { + pub fn Servo_AnimationValues_GetTransform(value: RawServoAnimationValueBorrowed, + list: &mut RefPtr<nsCSSValueSharedList>); +} +extern "C" { pub fn Servo_ParseStyleAttribute(data: *const nsACString_internal) -> RawServoDeclarationBlockStrong; } diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 40ee0b2b2b7..ef02e3b3fbf 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1322,7 +1322,7 @@ fn static_assert() { "number" : "bindings::Gecko_CSSValue_SetNumber(%s, %s)", } %> - ComputedOperation::${name.title()}(${pattern}) => { + longhands::transform::computed_value::ComputedOperation::${name.title()}(${pattern}) => { bindings::Gecko_CSSValue_SetFunction(gecko_value, ${len(items) + 1}); bindings::Gecko_CSSValue_SetKeyword( bindings::Gecko_CSSValue_GetArrayItem(gecko_value, 0), @@ -1336,27 +1336,20 @@ fn static_assert() { % endfor } </%def> - pub fn set_transform(&mut self, other: longhands::transform::computed_value::T) { + pub fn convert_transform(input: Vec<longhands::transform::computed_value::ComputedOperation>, + output: &mut structs::root::RefPtr<structs::root::nsCSSValueSharedList>) { use gecko_bindings::structs::nsCSSKeyword::*; use gecko_bindings::sugar::refptr::RefPtr; use properties::longhands::transform::computed_value::ComputedMatrix; - use properties::longhands::transform::computed_value::ComputedOperation; - let vec = if let Some(v) = other.0 { - v - } else { - unsafe { - self.gecko.mSpecifiedTransform.clear(); - } - return; - }; + unsafe { output.clear() }; let list = unsafe { - RefPtr::from_addrefed(bindings::Gecko_NewCSSValueSharedList(vec.len() as u32)) + RefPtr::from_addrefed(bindings::Gecko_NewCSSValueSharedList(input.len() as u32)) }; let mut cur = list.mHead; - let mut iter = vec.into_iter(); + let mut iter = input.into_iter(); while !cur.is_null() { let gecko_value = unsafe { &mut (*cur).mValue }; let servo = iter.next().expect("Gecko_NewCSSValueSharedList should create a shared \ @@ -1374,7 +1367,19 @@ fn static_assert() { } } debug_assert!(iter.next().is_none()); - unsafe { self.gecko.mSpecifiedTransform.set_move(list) }; + unsafe { output.set_move(list) }; + } + + pub fn set_transform(&mut self, other: longhands::transform::computed_value::T) { + let vec = if let Some(v) = other.0 { + v + } else { + unsafe { + self.gecko.mSpecifiedTransform.clear(); + } + return; + }; + Self::convert_transform(vec, &mut self.gecko.mSpecifiedTransform); } pub fn copy_transform_from(&mut self, other: &Self) { diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index bee77e36b9f..6ba9b8148de 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -53,11 +53,13 @@ use style::gecko_bindings::structs::Loader; use style::gecko_bindings::structs::RawGeckoPresContextOwned; use style::gecko_bindings::structs::RawServoAnimationValueBorrowedListBorrowed; use style::gecko_bindings::structs::ServoStyleSheet; +use style::gecko_bindings::structs::nsCSSValueSharedList; use style::gecko_bindings::structs::nsTimingFunction; use style::gecko_bindings::structs::nsresult; use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, HasBoxFFI}; use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong}; use style::gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI}; +use style::gecko_properties::style_structs; use style::keyframes::KeyframesStepValue; use style::parallel; use style::parser::{ParserContext, ParserContextExtraData}; @@ -217,6 +219,18 @@ pub extern "C" fn Servo_AnimationValues_GetOpacity(value: RawServoAnimationValue } } +#[no_mangle] +pub extern "C" fn Servo_AnimationValues_GetTransform(value: RawServoAnimationValueBorrowed, + list: &mut structs::RefPtr<nsCSSValueSharedList>) +{ + let value = AnimationValue::as_arc(&value); + if let AnimationValue::Transform(ref servo_list) = **value { + style_structs::Box::convert_transform(servo_list.0.clone().unwrap(), list); + } else { + panic!("The AnimationValue should be transform"); + } +} + /// Takes a ServoAnimationValues and populates it with the animation values corresponding /// to a given property declaration block #[no_mangle] |