Bug 1317209 - Part 1: Implement uncompute FFI. r=manishearth

This commit is contained in:
Boris Chiou 2017-01-24 15:20:44 +08:00
parent 231481570e
commit 4f0791a94b
5 changed files with 36 additions and 0 deletions

View file

@ -501,6 +501,7 @@ mod bindings {
"RawGeckoNode",
"RawGeckoAnimationValueList",
"RawServoAnimationValue",
"RawServoAnimationValueList",
"RawGeckoPresContext",
"RawGeckoPresContextOwned",
"ThreadSafeURIHolder",
@ -603,6 +604,7 @@ mod bindings {
let servo_borrow_types = [
"nsCSSValue",
"RawGeckoAnimationValueList",
"RawServoAnimationValueList",
];
for &ty in structs_types.iter() {
builder = builder.hide_type(ty)

View file

@ -8,6 +8,7 @@ use gecko_bindings::structs::RawGeckoElement;
use gecko_bindings::structs::RawGeckoNode;
use gecko_bindings::structs::RawGeckoAnimationValueList;
use gecko_bindings::structs::RawServoAnimationValue;
use gecko_bindings::structs::RawServoAnimationValueBorrowedList;
use gecko_bindings::structs::RawGeckoPresContext;
use gecko_bindings::structs::RawGeckoPresContextOwned;
use gecko_bindings::structs::ThreadSafeURIHolder;
@ -224,6 +225,8 @@ pub type RawGeckoAnimationValueListBorrowed<'a> = &'a RawGeckoAnimationValueList
pub type RawGeckoAnimationValueListBorrowedOrNull<'a> = Option<&'a RawGeckoAnimationValueList>;
pub type RawGeckoAnimationValueListBorrowedMut<'a> = &'a mut RawGeckoAnimationValueList;
pub type RawGeckoAnimationValueListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoAnimationValueList>;
pub type RawServoAnimationValueBorrowedListBorrowed<'a> = &'a RawServoAnimationValueBorrowedList;
pub type RawServoAnimationValueBorrowedListBorrowedOrNull<'a> = Option<&'a RawServoAnimationValueBorrowedList>;
extern "C" {
pub fn Gecko_EnsureTArrayCapacity(aArray: *mut ::std::os::raw::c_void,
@ -1217,6 +1220,10 @@ extern "C" {
ServoComputedValuesBorrowed)
-> ServoComputedValuesStrong;
}
extern "C" {
pub fn Servo_AnimationValues_Uncompute(value: RawServoAnimationValueBorrowedListBorrowed)
-> RawServoDeclarationBlockStrong;
}
extern "C" {
pub fn Servo_AnimationValues_Populate(arg1:
RawGeckoAnimationValueListBorrowedMut,

View file

@ -13810,6 +13810,10 @@ pub mod root {
pub type RawGeckoPresContextBorrowedMut = *mut root::RawGeckoPresContext;
pub type RawGeckoAnimationValueListBorrowedMut =
*mut root::RawGeckoAnimationValueList;
pub type RawServoAnimationValueBorrowedList =
root::nsTArray<*const root::RawServoAnimationValue>;
pub type RawServoAnimationValueBorrowedListBorrowed =
*const root::RawServoAnimationValueBorrowedList;
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum nsCSSTokenSerializationType {

View file

@ -13725,6 +13725,10 @@ pub mod root {
pub type RawGeckoPresContextBorrowedMut = *mut root::RawGeckoPresContext;
pub type RawGeckoAnimationValueListBorrowedMut =
*mut root::RawGeckoAnimationValueList;
pub type RawServoAnimationValueBorrowedList =
root::nsTArray<*const root::RawServoAnimationValue>;
pub type RawServoAnimationValueBorrowedListBorrowed =
*const root::RawServoAnimationValueBorrowedList;
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum nsCSSTokenSerializationType {

View file

@ -39,6 +39,7 @@ use style::gecko_bindings::bindings::RawGeckoAnimationValueListBorrowedMut;
use style::gecko_bindings::bindings::RawGeckoElementBorrowed;
use style::gecko_bindings::bindings::RawGeckoPresContextBorrowed;
use style::gecko_bindings::bindings::RawServoAnimationValueBorrowed;
use style::gecko_bindings::bindings::RawServoAnimationValueBorrowedListBorrowed;
use style::gecko_bindings::bindings::RawServoImportRuleBorrowed;
use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t;
@ -160,6 +161,24 @@ pub extern "C" fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
behavior == structs::TraversalRootBehavior::UnstyledChildrenOnly);
}
#[no_mangle]
pub extern "C" fn Servo_AnimationValues_Uncompute(value: RawServoAnimationValueBorrowedListBorrowed)
-> RawServoDeclarationBlockStrong
{
let uncomputed_values = value.into_iter()
.map(|v| {
let raw_anim = unsafe { v.as_ref().unwrap() };
let anim = AnimationValue::as_arc(&raw_anim);
(anim.uncompute(), Importance::Normal)
})
.collect();
Arc::new(RwLock::new(PropertyDeclarationBlock {
declarations: uncomputed_values,
important_count: 0,
})).into_strong()
}
/// Takes a ServoAnimationValues and populates it with the animation values corresponding
/// to a given property declaration block
#[no_mangle]