Skip to content

Commit

Permalink
Auto merge of #15493 - BorisChiou:animation/get_property, r=Manishearth
Browse files Browse the repository at this point in the history
stylo: Add Servo_AnimationValue_Serialize

This is the servo-side change for [bug 1337313](https://bugzilla.mozilla.org/show_bug.cgi?id=1337313). @Manishearth had already reviewed it there. Please merge this patch until the gecko-side changes for [bug 1337313](https://bugzilla.mozilla.org/show_bug.cgi?id=1337313) is landed.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [bug 1337313](https://bugzilla.mozilla.org/show_bug.cgi?id=1337313).
- [X] These changes do not require tests because there are existing tests for this in mozilla-central

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15493)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Feb 10, 2017
2 parents 2771b24 + fe1c2af commit 401a55e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
13 changes: 9 additions & 4 deletions components/style/gecko_bindings/bindings.rs
Expand Up @@ -1303,13 +1303,18 @@ extern "C" {
-> RawServoDeclarationBlockStrong;
}
extern "C" {
pub fn Servo_AnimationValues_GetOpacity(value:
RawServoAnimationValueBorrowed)
pub fn Servo_AnimationValue_Serialize(value:
RawServoAnimationValueBorrowed,
property: nsCSSPropertyID,
buffer: *mut nsAString_internal);
}
extern "C" {
pub fn Servo_AnimationValue_GetOpacity(value: RawServoAnimationValueBorrowed)
-> f32;
}
extern "C" {
pub fn Servo_AnimationValues_GetTransform(value: RawServoAnimationValueBorrowed,
list: &mut RefPtr<nsCSSValueSharedList>);
pub fn Servo_AnimationValue_GetTransform(value: RawServoAnimationValueBorrowed,
list: &mut RefPtr<nsCSSValueSharedList>);
}
extern "C" {
pub fn Servo_ParseStyleAttribute(data: *const nsACString_internal)
Expand Down
40 changes: 28 additions & 12 deletions ports/geckolib/glue.rs
Expand Up @@ -213,8 +213,33 @@ pub extern "C" fn Servo_AnimationValues_Uncompute(value: RawServoAnimationValueB
})).into_strong()
}

macro_rules! get_property_id_from_nscsspropertyid {
($property_id: ident, $ret: expr) => {{
match PropertyId::from_nscsspropertyid($property_id) {
Ok(property_id) => property_id,
Err(()) => { return $ret; }
}
}}
}

#[no_mangle]
pub extern "C" fn Servo_AnimationValue_Serialize(value: RawServoAnimationValueBorrowed,
property: nsCSSPropertyID,
buffer: *mut nsAString)
{
let uncomputed_value = AnimationValue::as_arc(&value).uncompute();
let mut string = String::new();
let rv = PropertyDeclarationBlock {
declarations: vec![(uncomputed_value, Importance::Normal)],
important_count: 0
}.single_value_to_css(&get_property_id_from_nscsspropertyid!(property, ()), &mut string);
debug_assert!(rv.is_ok());

write!(unsafe { &mut *buffer }, "{}", string).expect("Failed to copy string");
}

#[no_mangle]
pub extern "C" fn Servo_AnimationValues_GetOpacity(value: RawServoAnimationValueBorrowed)
pub extern "C" fn Servo_AnimationValue_GetOpacity(value: RawServoAnimationValueBorrowed)
-> f32
{
let value = AnimationValue::as_arc(&value);
Expand All @@ -226,8 +251,8 @@ 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>)
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 {
Expand Down Expand Up @@ -832,15 +857,6 @@ pub extern "C" fn Servo_DeclarationBlock_GetCssText(declarations: RawServoDeclar
declarations.read().to_css(unsafe { result.as_mut().unwrap() }).unwrap();
}

macro_rules! get_property_id_from_nscsspropertyid {
($property_id: ident, $ret: expr) => {{
match PropertyId::from_nscsspropertyid($property_id) {
Ok(property_id) => property_id,
Err(()) => { return $ret; }
}
}}
}

#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SerializeOneValue(
declarations: RawServoDeclarationBlockBorrowed,
Expand Down

0 comments on commit 401a55e

Please sign in to comment.