Skip to content

Commit

Permalink
Bug 1317209 - Part 1: Implement uncompute FFI. r=manishearth
Browse files Browse the repository at this point in the history
  • Loading branch information
BorisChiou committed Jan 24, 2017
1 parent 2314815 commit 4f0791a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions components/style/build_gecko.rs
Expand Up @@ -501,6 +501,7 @@ mod bindings {
"RawGeckoNode",
"RawGeckoAnimationValueList",
"RawServoAnimationValue",
"RawServoAnimationValueList",
"RawGeckoPresContext",
"RawGeckoPresContextOwned",
"ThreadSafeURIHolder",
Expand Down Expand Up @@ -603,6 +604,7 @@ mod bindings {
let servo_borrow_types = [
"nsCSSValue",
"RawGeckoAnimationValueList",
"RawServoAnimationValueList",
];
for &ty in structs_types.iter() {
builder = builder.hide_type(ty)
Expand Down
7 changes: 7 additions & 0 deletions components/style/gecko_bindings/bindings.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions components/style/gecko_bindings/structs_debug.rs
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions components/style/gecko_bindings/structs_release.rs
Expand Up @@ -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 {
Expand Down
19 changes: 19 additions & 0 deletions ports/geckolib/glue.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 4f0791a

Please sign in to comment.