Skip to content

Commit

Permalink
Add Servo_AnimationValue_Transform which creates an AnimationValue of…
Browse files Browse the repository at this point in the history
… transform.
  • Loading branch information
BorisChiou committed Oct 27, 2017
1 parent f02bd01 commit 1f5551c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 12 deletions.
4 changes: 4 additions & 0 deletions components/style/gecko/generated/bindings.rs
Expand Up @@ -2628,6 +2628,10 @@ extern "C" {
list:
*mut RefPtr<nsCSSValueSharedList>);
}
extern "C" {
pub fn Servo_AnimationValue_Transform(list: *const nsCSSValueSharedList)
-> RawServoAnimationValueStrong;
}
extern "C" {
pub fn Servo_AnimationValue_DeepEqual(arg1:
RawServoAnimationValueBorrowed,
Expand Down
6 changes: 6 additions & 0 deletions components/style/gecko_bindings/sugar/ns_css_value.rs
Expand Up @@ -23,6 +23,12 @@ impl nsCSSValue {
unsafe { mem::zeroed() }
}

/// Returns true if this nsCSSValue is none.
#[inline]
pub fn is_none(&self) -> bool {
self.mUnit == nsCSSUnit::eCSSUnit_None
}

/// Returns this nsCSSValue value as an integer, unchecked in release
/// builds.
pub fn integer_unchecked(&self) -> i32 {
Expand Down
32 changes: 23 additions & 9 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -3097,18 +3097,32 @@ fn static_assert() {
}
}
pub fn clone_transform(&self) -> longhands::transform::computed_value::T {
use properties::longhands::transform::computed_value;

if self.gecko.mSpecifiedTransform.mRawPtr.is_null() {
return computed_value::T(None);
return longhands::transform::computed_value::T(None);
}
let list = unsafe { (*self.gecko.mSpecifiedTransform.to_safe().get()).mHead.as_ref() };
let result = list.map(|list| {
list.into_iter()
.map(|value| Self::clone_single_transform_function(value))
.collect()
});
computed_value::T(result)
Self::clone_transform_from_list(list)
}
pub fn clone_transform_from_list(list: Option< &structs::root::nsCSSValueList>)
-> longhands::transform::computed_value::T {
let result = match list {
Some(list) => {
let vec: Vec<_> = list
.into_iter()
.filter_map(|value| {
// Handle none transform.
if value.is_none() {
None
} else {
Some(Self::clone_single_transform_function(value))
}
})
.collect();
if !vec.is_empty() { Some(vec) } else { None }
},
_ => None,
};
longhands::transform::computed_value::T(result)
}

${impl_transition_time_value('delay', 'Delay')}
Expand Down
16 changes: 13 additions & 3 deletions ports/geckolib/glue.rs
Expand Up @@ -653,9 +653,10 @@ pub extern "C" fn Servo_AnimationValue_Opacity(
}

#[no_mangle]
pub extern "C" fn Servo_AnimationValue_GetTransform(value: RawServoAnimationValueBorrowed,
list: *mut structs::RefPtr<nsCSSValueSharedList>)
{
pub extern "C" fn Servo_AnimationValue_GetTransform(
value: RawServoAnimationValueBorrowed,
list: *mut structs::RefPtr<nsCSSValueSharedList>
) {
let value = AnimationValue::as_arc(&value);
if let AnimationValue::Transform(ref servo_list) = **value {
let list = unsafe { &mut *list };
Expand All @@ -672,6 +673,15 @@ pub extern "C" fn Servo_AnimationValue_GetTransform(value: RawServoAnimationValu
}
}

#[no_mangle]
pub extern "C" fn Servo_AnimationValue_Transform(
list: *const nsCSSValueSharedList
) -> RawServoAnimationValueStrong {
let list = unsafe { (&*list).mHead.as_ref() };
let transform = style_structs::Box::clone_transform_from_list(list);
Arc::new(AnimationValue::Transform(transform)).into_strong()
}

#[no_mangle]
pub extern "C" fn Servo_AnimationValue_DeepEqual(this: RawServoAnimationValueBorrowed,
other: RawServoAnimationValueBorrowed)
Expand Down

0 comments on commit 1f5551c

Please sign in to comment.