mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #15442 - BorisChiou:animation/opacity_transform, r=Manishearth
Retrieve the opacity and the transform list from RawServoAnimationValue These are the servo-side changes for [bug 1335942](https://bugzilla.mozilla.org/show_bug.cgi?id=1335942). @Manishearth had already reviewed them there. Please merge these patches until the gecko-side changes for [bug 1335942](https://bugzilla.mozilla.org/show_bug.cgi?id=1335942) 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 1335942](https://bugzilla.mozilla.org/show_bug.cgi?id=1335942). - [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/15442) <!-- Reviewable:end -->
This commit is contained in:
commit
11c86b82f6
6 changed files with 71 additions and 19 deletions
|
@ -505,6 +505,7 @@ mod bindings {
|
||||||
"RawServoDeclarationBlock",
|
"RawServoDeclarationBlock",
|
||||||
"RawGeckoPresContext",
|
"RawGeckoPresContext",
|
||||||
"RawGeckoPresContextOwned",
|
"RawGeckoPresContextOwned",
|
||||||
|
"RefPtr",
|
||||||
"ThreadSafeURIHolder",
|
"ThreadSafeURIHolder",
|
||||||
"ThreadSafePrincipalHolder",
|
"ThreadSafePrincipalHolder",
|
||||||
"CSSPseudoClassType",
|
"CSSPseudoClassType",
|
||||||
|
|
|
@ -156,6 +156,7 @@ use gecko_bindings::structs::Loader;
|
||||||
use gecko_bindings::structs::ServoStyleSheet;
|
use gecko_bindings::structs::ServoStyleSheet;
|
||||||
use gecko_bindings::structs::EffectCompositor_CascadeLevel;
|
use gecko_bindings::structs::EffectCompositor_CascadeLevel;
|
||||||
use gecko_bindings::structs::RawServoAnimationValueBorrowedListBorrowed;
|
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 nsTArrayBorrowed_uintptr_t<'a> = &'a mut ::gecko_bindings::structs::nsTArray<usize>;
|
||||||
pub type ServoComputedValuesStrong = ::gecko_bindings::sugar::ownership::Strong<ServoComputedValues>;
|
pub type ServoComputedValuesStrong = ::gecko_bindings::sugar::ownership::Strong<ServoComputedValues>;
|
||||||
pub type ServoComputedValuesBorrowed<'a> = &'a ServoComputedValues;
|
pub type ServoComputedValuesBorrowed<'a> = &'a ServoComputedValues;
|
||||||
|
@ -1301,6 +1302,15 @@ extern "C" {
|
||||||
RawServoAnimationValueBorrowedListBorrowed)
|
RawServoAnimationValueBorrowedListBorrowed)
|
||||||
-> RawServoDeclarationBlockStrong;
|
-> RawServoDeclarationBlockStrong;
|
||||||
}
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Servo_AnimationValues_GetOpacity(value:
|
||||||
|
RawServoAnimationValueBorrowed)
|
||||||
|
-> f32;
|
||||||
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Servo_AnimationValues_GetTransform(value: RawServoAnimationValueBorrowed,
|
||||||
|
list: &mut RefPtr<nsCSSValueSharedList>);
|
||||||
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_ParseStyleAttribute(data: *const nsACString_internal)
|
pub fn Servo_ParseStyleAttribute(data: *const nsACString_internal)
|
||||||
-> RawServoDeclarationBlockStrong;
|
-> RawServoDeclarationBlockStrong;
|
||||||
|
|
|
@ -5152,10 +5152,15 @@ pub mod root {
|
||||||
pub struct ContainerLayerParameters([u8; 0]);
|
pub struct ContainerLayerParameters([u8; 0]);
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
pub struct AnimationValue {
|
||||||
|
pub mGecko: root::mozilla::StyleAnimationValue,
|
||||||
|
pub mServo: root::RefPtr<root::RawServoAnimationValue>,
|
||||||
|
}
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct PropertyStyleAnimationValuePair {
|
pub struct PropertyStyleAnimationValuePair {
|
||||||
pub mProperty: root::nsCSSPropertyID,
|
pub mProperty: root::nsCSSPropertyID,
|
||||||
pub mValue: root::mozilla::StyleAnimationValue,
|
pub mValue: root::mozilla::AnimationValue,
|
||||||
pub mServoValue: root::RefPtr<root::RawServoAnimationValue>,
|
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn bindgen_test_layout_PropertyStyleAnimationValuePair() {
|
fn bindgen_test_layout_PropertyStyleAnimationValuePair() {
|
||||||
|
|
|
@ -5068,10 +5068,15 @@ pub mod root {
|
||||||
pub struct ContainerLayerParameters([u8; 0]);
|
pub struct ContainerLayerParameters([u8; 0]);
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
pub struct AnimationValue {
|
||||||
|
pub mGecko: root::mozilla::StyleAnimationValue,
|
||||||
|
pub mServo: root::RefPtr<root::RawServoAnimationValue>,
|
||||||
|
}
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct PropertyStyleAnimationValuePair {
|
pub struct PropertyStyleAnimationValuePair {
|
||||||
pub mProperty: root::nsCSSPropertyID,
|
pub mProperty: root::nsCSSPropertyID,
|
||||||
pub mValue: root::mozilla::StyleAnimationValue,
|
pub mValue: root::mozilla::AnimationValue,
|
||||||
pub mServoValue: root::RefPtr<root::RawServoAnimationValue>,
|
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn bindgen_test_layout_PropertyStyleAnimationValuePair() {
|
fn bindgen_test_layout_PropertyStyleAnimationValuePair() {
|
||||||
|
|
|
@ -1322,7 +1322,7 @@ fn static_assert() {
|
||||||
"number" : "bindings::Gecko_CSSValue_SetNumber(%s, %s)",
|
"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_SetFunction(gecko_value, ${len(items) + 1});
|
||||||
bindings::Gecko_CSSValue_SetKeyword(
|
bindings::Gecko_CSSValue_SetKeyword(
|
||||||
bindings::Gecko_CSSValue_GetArrayItem(gecko_value, 0),
|
bindings::Gecko_CSSValue_GetArrayItem(gecko_value, 0),
|
||||||
|
@ -1336,27 +1336,20 @@ fn static_assert() {
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
</%def>
|
</%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::structs::nsCSSKeyword::*;
|
||||||
use gecko_bindings::sugar::refptr::RefPtr;
|
use gecko_bindings::sugar::refptr::RefPtr;
|
||||||
use properties::longhands::transform::computed_value::ComputedMatrix;
|
use properties::longhands::transform::computed_value::ComputedMatrix;
|
||||||
use properties::longhands::transform::computed_value::ComputedOperation;
|
|
||||||
|
|
||||||
let vec = if let Some(v) = other.0 {
|
unsafe { output.clear() };
|
||||||
v
|
|
||||||
} else {
|
|
||||||
unsafe {
|
|
||||||
self.gecko.mSpecifiedTransform.clear();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
let list = unsafe {
|
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 cur = list.mHead;
|
||||||
let mut iter = vec.into_iter();
|
let mut iter = input.into_iter();
|
||||||
while !cur.is_null() {
|
while !cur.is_null() {
|
||||||
let gecko_value = unsafe { &mut (*cur).mValue };
|
let gecko_value = unsafe { &mut (*cur).mValue };
|
||||||
let servo = iter.next().expect("Gecko_NewCSSValueSharedList should create a shared \
|
let servo = iter.next().expect("Gecko_NewCSSValueSharedList should create a shared \
|
||||||
|
@ -1374,7 +1367,19 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug_assert!(iter.next().is_none());
|
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) {
|
pub fn copy_transform_from(&mut self, other: &Self) {
|
||||||
|
|
|
@ -53,11 +53,13 @@ use style::gecko_bindings::structs::Loader;
|
||||||
use style::gecko_bindings::structs::RawGeckoPresContextOwned;
|
use style::gecko_bindings::structs::RawGeckoPresContextOwned;
|
||||||
use style::gecko_bindings::structs::RawServoAnimationValueBorrowedListBorrowed;
|
use style::gecko_bindings::structs::RawServoAnimationValueBorrowedListBorrowed;
|
||||||
use style::gecko_bindings::structs::ServoStyleSheet;
|
use style::gecko_bindings::structs::ServoStyleSheet;
|
||||||
|
use style::gecko_bindings::structs::nsCSSValueSharedList;
|
||||||
use style::gecko_bindings::structs::nsTimingFunction;
|
use style::gecko_bindings::structs::nsTimingFunction;
|
||||||
use style::gecko_bindings::structs::nsresult;
|
use style::gecko_bindings::structs::nsresult;
|
||||||
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, HasBoxFFI};
|
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, HasBoxFFI};
|
||||||
use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
|
use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
|
||||||
use style::gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
|
use style::gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
|
||||||
|
use style::gecko_properties::style_structs;
|
||||||
use style::keyframes::KeyframesStepValue;
|
use style::keyframes::KeyframesStepValue;
|
||||||
use style::parallel;
|
use style::parallel;
|
||||||
use style::parser::{ParserContext, ParserContextExtraData};
|
use style::parser::{ParserContext, ParserContextExtraData};
|
||||||
|
@ -205,6 +207,30 @@ pub extern "C" fn Servo_AnimationValues_Uncompute(value: RawServoAnimationValueB
|
||||||
})).into_strong()
|
})).into_strong()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Servo_AnimationValues_GetOpacity(value: RawServoAnimationValueBorrowed)
|
||||||
|
-> f32
|
||||||
|
{
|
||||||
|
let value = AnimationValue::as_arc(&value);
|
||||||
|
if let AnimationValue::Opacity(opacity) = **value {
|
||||||
|
opacity
|
||||||
|
} else {
|
||||||
|
panic!("The AnimationValue should be Opacity");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[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
|
/// Takes a ServoAnimationValues and populates it with the animation values corresponding
|
||||||
/// to a given property declaration block
|
/// to a given property declaration block
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -253,7 +279,7 @@ pub extern "C" fn Servo_AnimationValues_Populate(anim: RawGeckoAnimationValueLis
|
||||||
// and thus can't directly use `geckoiter`
|
// and thus can't directly use `geckoiter`
|
||||||
let local_geckoiter = &mut geckoiter;
|
let local_geckoiter = &mut geckoiter;
|
||||||
for (gecko, servo) in local_geckoiter.zip(&mut iter) {
|
for (gecko, servo) in local_geckoiter.zip(&mut iter) {
|
||||||
gecko.mServoValue.set_arc_leaky(Arc::new(servo));
|
gecko.mValue.mServo.set_arc_leaky(Arc::new(servo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue