mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #14968 - Manishearth:stylo-keyframes, r=heycam,birtles
stylo: Store servo computed values for animation properties Servo counterpart of https://bugzilla.mozilla.org/show_bug.cgi?id=1317208 r=heycam,birtles <!-- 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/14968) <!-- Reviewable:end -->
This commit is contained in:
commit
a46e630b00
7 changed files with 275 additions and 22 deletions
|
@ -108,7 +108,7 @@ mod bindings {
|
|||
trait BuilderExt {
|
||||
fn get_initial_builder(build_type: BuildType) -> Builder;
|
||||
fn include<T: Into<String>>(self, file: T) -> Builder;
|
||||
fn zero_size_type(self, ty: &str) -> Builder;
|
||||
fn zero_size_type(self, ty: &str, structs_list: &[&str]) -> Builder;
|
||||
fn borrowed_type(self, ty: &str) -> Builder;
|
||||
fn mutable_borrowed_type(self, ty: &str) -> Builder;
|
||||
}
|
||||
|
@ -172,10 +172,14 @@ mod bindings {
|
|||
// Not 100% sure of how safe this is, but it's what we're using
|
||||
// in the XPCOM ffi too
|
||||
// https://github.com/nikomatsakis/rust-memory-model/issues/2
|
||||
fn zero_size_type(self, ty: &str) -> Builder {
|
||||
self.hide_type(ty)
|
||||
.raw_line(format!("enum {}Void {{ }}", ty))
|
||||
.raw_line(format!("pub struct {0}({0}Void);", ty))
|
||||
fn zero_size_type(self, ty: &str, structs_list: &[&str]) -> Builder {
|
||||
if !structs_list.contains(&ty) {
|
||||
self.hide_type(ty)
|
||||
.raw_line(format!("enum {}Void {{ }}", ty))
|
||||
.raw_line(format!("pub struct {0}({0}Void);", ty))
|
||||
} else {
|
||||
self
|
||||
}
|
||||
}
|
||||
fn borrowed_type(self, ty: &str) -> Builder {
|
||||
self.hide_type(format!("{}Borrowed", ty))
|
||||
|
@ -222,6 +226,7 @@ mod bindings {
|
|||
..CodegenConfig::nothing()
|
||||
})
|
||||
.header(add_include("nsStyleStruct.h"))
|
||||
.header(add_include("mozilla/StyleAnimationValue.h"))
|
||||
.include(add_include("gfxFontConstants.h"))
|
||||
.include(add_include("nsThemeConstants.h"))
|
||||
.include(add_include("mozilla/dom/AnimationEffectReadOnlyBinding.h"))
|
||||
|
@ -255,6 +260,7 @@ mod bindings {
|
|||
"mozilla::CSSPseudoClassType",
|
||||
"mozilla::css::SheetParsingMode",
|
||||
"mozilla::HalfCorner",
|
||||
"mozilla::PropertyStyleAnimationValuePair",
|
||||
"mozilla::TraversalRootBehavior",
|
||||
"mozilla::DisplayItemClip", // Needed because bindgen generates
|
||||
// specialization tests for this even
|
||||
|
@ -398,7 +404,10 @@ mod bindings {
|
|||
"gfxSize", // <- union { struct { T width; T height; }; T components[2] };
|
||||
"gfxSize_Super", // Ditto.
|
||||
"mozilla::ErrorResult", // Causes JSWhyMagic to be included & handled incorrectly.
|
||||
"mozilla::StyleAnimationValue",
|
||||
"StyleAnimationValue", // pulls in a whole bunch of stuff we don't need in the bindings
|
||||
];
|
||||
|
||||
struct MappedGenericType {
|
||||
generic: bool,
|
||||
gecko: &'static str,
|
||||
|
@ -468,6 +477,8 @@ mod bindings {
|
|||
"RawGeckoDocument",
|
||||
"RawGeckoElement",
|
||||
"RawGeckoNode",
|
||||
"RawGeckoAnimationValueList",
|
||||
"RawServoAnimationValue",
|
||||
"RawGeckoPresContext",
|
||||
"ThreadSafeURIHolder",
|
||||
"ThreadSafePrincipalHolder",
|
||||
|
@ -547,6 +558,7 @@ mod bindings {
|
|||
"RawServoDeclarationBlock",
|
||||
"RawServoStyleRule",
|
||||
"RawServoImportRule",
|
||||
"RawServoAnimationValue",
|
||||
];
|
||||
struct ServoOwnedType {
|
||||
name: &'static str,
|
||||
|
@ -566,6 +578,7 @@ mod bindings {
|
|||
];
|
||||
let servo_borrow_types = [
|
||||
"nsCSSValue",
|
||||
"RawGeckoAnimationValueList",
|
||||
];
|
||||
for &ty in structs_types.iter() {
|
||||
builder = builder.hide_type(ty)
|
||||
|
@ -588,7 +601,7 @@ mod bindings {
|
|||
.hide_type(format!("{}Strong", ty))
|
||||
.raw_line(format!("pub type {0}Strong = ::gecko_bindings::sugar::ownership::Strong<{0}>;", ty))
|
||||
.borrowed_type(ty)
|
||||
.zero_size_type(ty);
|
||||
.zero_size_type(ty, &structs_types);
|
||||
}
|
||||
for &ServoOwnedType { name, opaque } in servo_owned_types.iter() {
|
||||
builder = builder
|
||||
|
@ -599,7 +612,7 @@ mod bindings {
|
|||
name))
|
||||
.mutable_borrowed_type(name);
|
||||
if opaque {
|
||||
builder = builder.zero_size_type(name);
|
||||
builder = builder.zero_size_type(name, &structs_types);
|
||||
}
|
||||
}
|
||||
for &ty in servo_immutable_borrow_types.iter() {
|
||||
|
|
|
@ -6,6 +6,8 @@ type nsAString_internal = nsAString;
|
|||
use gecko_bindings::structs::RawGeckoDocument;
|
||||
use gecko_bindings::structs::RawGeckoElement;
|
||||
use gecko_bindings::structs::RawGeckoNode;
|
||||
use gecko_bindings::structs::RawGeckoAnimationValueList;
|
||||
use gecko_bindings::structs::RawServoAnimationValue;
|
||||
use gecko_bindings::structs::RawGeckoPresContext;
|
||||
use gecko_bindings::structs::ThreadSafeURIHolder;
|
||||
use gecko_bindings::structs::ThreadSafePrincipalHolder;
|
||||
|
@ -177,6 +179,9 @@ pub type RawServoImportRuleBorrowed<'a> = &'a RawServoImportRule;
|
|||
pub type RawServoImportRuleBorrowedOrNull<'a> = Option<&'a RawServoImportRule>;
|
||||
enum RawServoImportRuleVoid { }
|
||||
pub struct RawServoImportRule(RawServoImportRuleVoid);
|
||||
pub type RawServoAnimationValueStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoAnimationValue>;
|
||||
pub type RawServoAnimationValueBorrowed<'a> = &'a RawServoAnimationValue;
|
||||
pub type RawServoAnimationValueBorrowedOrNull<'a> = Option<&'a RawServoAnimationValue>;
|
||||
pub type RawServoStyleSetOwned = ::gecko_bindings::sugar::ownership::Owned<RawServoStyleSet>;
|
||||
pub type RawServoStyleSetOwnedOrNull = ::gecko_bindings::sugar::ownership::OwnedOrNull<RawServoStyleSet>;
|
||||
pub type RawServoStyleSetBorrowed<'a> = &'a RawServoStyleSet;
|
||||
|
@ -213,7 +218,19 @@ pub type nsCSSValueBorrowed<'a> = &'a nsCSSValue;
|
|||
pub type nsCSSValueBorrowedOrNull<'a> = Option<&'a nsCSSValue>;
|
||||
pub type nsCSSValueBorrowedMut<'a> = &'a mut nsCSSValue;
|
||||
pub type nsCSSValueBorrowedMutOrNull<'a> = Option<&'a mut nsCSSValue>;
|
||||
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>;
|
||||
|
||||
extern "C" {
|
||||
pub fn Gecko_EnsureTArrayCapacity(aArray: *mut ::std::os::raw::c_void,
|
||||
aCapacity: usize, aElementSize: usize);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_ClearPODTArray(aArray: *mut ::std::os::raw::c_void,
|
||||
aElementSize: usize, aElementAlign: usize);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_CssRules_AddRef(ptr: ServoCssRulesBorrowed);
|
||||
}
|
||||
|
@ -252,17 +269,15 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Servo_ImportRule_Release(ptr: RawServoImportRuleBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_AnimationValue_AddRef(ptr: RawServoAnimationValueBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_AnimationValue_Release(ptr: RawServoAnimationValueBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSet_Drop(ptr: RawServoStyleSetOwned);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_EnsureTArrayCapacity(aArray: *mut ::std::os::raw::c_void,
|
||||
aCapacity: usize, aElementSize: usize);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_ClearPODTArray(aArray: *mut ::std::os::raw::c_void,
|
||||
aElementSize: usize, aElementAlign: usize);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_AddRefPrincipalArbitraryThread(aPtr:
|
||||
*mut ThreadSafePrincipalHolder);
|
||||
|
@ -1194,6 +1209,16 @@ extern "C" {
|
|||
ServoComputedValuesBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_AnimationValues_Populate(arg1:
|
||||
RawGeckoAnimationValueListBorrowedMut,
|
||||
arg2:
|
||||
RawServoDeclarationBlockBorrowed,
|
||||
arg3: ServoComputedValuesBorrowed,
|
||||
arg4:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
arg5: RawGeckoPresContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ParseStyleAttribute(data: *const nsACString_internal)
|
||||
-> RawServoDeclarationBlockStrong;
|
||||
|
|
|
@ -3047,6 +3047,20 @@ pub mod root {
|
|||
impl Clone for StyleComplexColor {
|
||||
fn clone(&self) -> Self { *self }
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct PropertyStyleAnimationValuePair {
|
||||
pub mProperty: root::nsCSSPropertyID,
|
||||
pub mValue: [u64; 2usize],
|
||||
pub mServoValue: root::RefPtr<root::RawServoAnimationValue>,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_PropertyStyleAnimationValuePair() {
|
||||
assert_eq!(::std::mem::size_of::<PropertyStyleAnimationValuePair>()
|
||||
, 32usize);
|
||||
assert_eq!(::std::mem::align_of::<PropertyStyleAnimationValuePair>()
|
||||
, 8usize);
|
||||
}
|
||||
#[test]
|
||||
fn __bindgen_test_layout_template_1() {
|
||||
assert_eq!(::std::mem::size_of::<root::mozilla::DefaultDelete<root::RawServoStyleSet>>()
|
||||
|
@ -11596,6 +11610,24 @@ pub mod root {
|
|||
assert_eq!(::std::mem::size_of::<nsCSSValueFloatColor>() , 32usize);
|
||||
assert_eq!(::std::mem::align_of::<nsCSSValueFloatColor>() , 8usize);
|
||||
}
|
||||
#[test]
|
||||
fn __bindgen_test_layout_template_8_TEMPORARY() {
|
||||
assert_eq!(::std::mem::size_of::<root::mozilla::UniquePtr<root::nsCSSValueList,
|
||||
root::mozilla::DefaultDelete<root::nsCSSValueList>>>()
|
||||
, 8usize);
|
||||
assert_eq!(::std::mem::align_of::<root::mozilla::UniquePtr<root::nsCSSValueList,
|
||||
root::mozilla::DefaultDelete<root::nsCSSValueList>>>()
|
||||
, 8usize);
|
||||
}
|
||||
#[test]
|
||||
fn __bindgen_test_layout_template_9_TEMPORARY() {
|
||||
assert_eq!(::std::mem::size_of::<root::mozilla::UniquePtr<root::nsCSSValuePairList,
|
||||
root::mozilla::DefaultDelete<root::nsCSSValuePairList>>>()
|
||||
, 8usize);
|
||||
assert_eq!(::std::mem::align_of::<root::mozilla::UniquePtr<root::nsCSSValuePairList,
|
||||
root::mozilla::DefaultDelete<root::nsCSSValuePairList>>>()
|
||||
, 8usize);
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct nsCSSValue {
|
||||
|
@ -11669,6 +11701,14 @@ pub mod root {
|
|||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy)]
|
||||
pub struct RawServoAnimationValue {
|
||||
pub _address: u8,
|
||||
}
|
||||
impl Clone for RawServoAnimationValue {
|
||||
fn clone(&self) -> Self { *self }
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy)]
|
||||
pub struct RawServoStyleSet {
|
||||
pub _address: u8,
|
||||
}
|
||||
|
@ -11679,6 +11719,8 @@ pub mod root {
|
|||
pub type RawGeckoElement = root::mozilla::dom::Element;
|
||||
pub type RawGeckoDocument = root::nsIDocument;
|
||||
pub type RawGeckoPresContext = [u64; 162usize];
|
||||
pub type RawGeckoAnimationValueList =
|
||||
root::nsTArray<root::mozilla::PropertyStyleAnimationValuePair>;
|
||||
pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode;
|
||||
pub type RawGeckoNodeBorrowedOrNull = *const root::RawGeckoNode;
|
||||
pub type RawGeckoElementBorrowed = *const root::RawGeckoElement;
|
||||
|
@ -11686,6 +11728,8 @@ pub mod root {
|
|||
pub type RawGeckoDocumentBorrowed = *const root::RawGeckoDocument;
|
||||
pub type RawGeckoDocumentBorrowedOrNull = *const root::RawGeckoDocument;
|
||||
pub type RawGeckoPresContextBorrowed = *const [u64; 162usize];
|
||||
pub type RawGeckoAnimationValueListBorrowedMut =
|
||||
*mut root::RawGeckoAnimationValueList;
|
||||
#[repr(u32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum nsCSSTokenSerializationType {
|
||||
|
|
|
@ -3029,6 +3029,20 @@ pub mod root {
|
|||
impl Clone for StyleComplexColor {
|
||||
fn clone(&self) -> Self { *self }
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct PropertyStyleAnimationValuePair {
|
||||
pub mProperty: root::nsCSSPropertyID,
|
||||
pub mValue: [u64; 2usize],
|
||||
pub mServoValue: root::RefPtr<root::RawServoAnimationValue>,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_PropertyStyleAnimationValuePair() {
|
||||
assert_eq!(::std::mem::size_of::<PropertyStyleAnimationValuePair>()
|
||||
, 32usize);
|
||||
assert_eq!(::std::mem::align_of::<PropertyStyleAnimationValuePair>()
|
||||
, 8usize);
|
||||
}
|
||||
#[test]
|
||||
fn __bindgen_test_layout_template_1() {
|
||||
assert_eq!(::std::mem::size_of::<root::mozilla::DefaultDelete<root::RawServoStyleSet>>()
|
||||
|
@ -11523,6 +11537,24 @@ pub mod root {
|
|||
assert_eq!(::std::mem::size_of::<nsCSSValueFloatColor>() , 24usize);
|
||||
assert_eq!(::std::mem::align_of::<nsCSSValueFloatColor>() , 8usize);
|
||||
}
|
||||
#[test]
|
||||
fn __bindgen_test_layout_template_8_TEMPORARY() {
|
||||
assert_eq!(::std::mem::size_of::<root::mozilla::UniquePtr<root::nsCSSValueList,
|
||||
root::mozilla::DefaultDelete<root::nsCSSValueList>>>()
|
||||
, 8usize);
|
||||
assert_eq!(::std::mem::align_of::<root::mozilla::UniquePtr<root::nsCSSValueList,
|
||||
root::mozilla::DefaultDelete<root::nsCSSValueList>>>()
|
||||
, 8usize);
|
||||
}
|
||||
#[test]
|
||||
fn __bindgen_test_layout_template_9_TEMPORARY() {
|
||||
assert_eq!(::std::mem::size_of::<root::mozilla::UniquePtr<root::nsCSSValuePairList,
|
||||
root::mozilla::DefaultDelete<root::nsCSSValuePairList>>>()
|
||||
, 8usize);
|
||||
assert_eq!(::std::mem::align_of::<root::mozilla::UniquePtr<root::nsCSSValuePairList,
|
||||
root::mozilla::DefaultDelete<root::nsCSSValuePairList>>>()
|
||||
, 8usize);
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct nsCSSValue {
|
||||
|
@ -11596,6 +11628,14 @@ pub mod root {
|
|||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy)]
|
||||
pub struct RawServoAnimationValue {
|
||||
pub _address: u8,
|
||||
}
|
||||
impl Clone for RawServoAnimationValue {
|
||||
fn clone(&self) -> Self { *self }
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy)]
|
||||
pub struct RawServoStyleSet {
|
||||
pub _address: u8,
|
||||
}
|
||||
|
@ -11606,6 +11646,8 @@ pub mod root {
|
|||
pub type RawGeckoElement = root::mozilla::dom::Element;
|
||||
pub type RawGeckoDocument = root::nsIDocument;
|
||||
pub type RawGeckoPresContext = [u64; 158usize];
|
||||
pub type RawGeckoAnimationValueList =
|
||||
root::nsTArray<root::mozilla::PropertyStyleAnimationValuePair>;
|
||||
pub type RawGeckoNodeBorrowed = *const root::RawGeckoNode;
|
||||
pub type RawGeckoNodeBorrowedOrNull = *const root::RawGeckoNode;
|
||||
pub type RawGeckoElementBorrowed = *const root::RawGeckoElement;
|
||||
|
@ -11613,6 +11655,8 @@ pub mod root {
|
|||
pub type RawGeckoDocumentBorrowed = *const root::RawGeckoDocument;
|
||||
pub type RawGeckoDocumentBorrowedOrNull = *const root::RawGeckoDocument;
|
||||
pub type RawGeckoPresContextBorrowed = *const [u64; 158usize];
|
||||
pub type RawGeckoAnimationValueListBorrowedMut =
|
||||
*mut root::RawGeckoAnimationValueList;
|
||||
#[repr(u32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum nsCSSTokenSerializationType {
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
//! A rust helper to ease the use of Gecko's refcounted types.
|
||||
|
||||
use gecko_bindings::structs;
|
||||
use gecko_bindings::sugar::ownership::HasArcFFI;
|
||||
use heapsize::HeapSizeOf;
|
||||
use std::{mem, ptr};
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Trait for all objects that have Addref() and Release
|
||||
/// methods and can be placed inside RefPtr<T>
|
||||
|
@ -196,6 +198,14 @@ impl<T: RefCounted> structs::RefPtr<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> structs::RefPtr<T> {
|
||||
/// Sets the contents to an Arc<T>
|
||||
/// will leak existing contents
|
||||
pub fn set_arc_leaky<U>(&mut self, other: Arc<U>) where U: HasArcFFI<FFIType = T> {
|
||||
*self = unsafe { mem::transmute(other) }; // Arc::into_raw is unstable :(
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: RefCounted> Drop for RefPtr<T> {
|
||||
fn drop(&mut self) {
|
||||
unsafe { self.release() }
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use app_units::Au;
|
||||
use cssparser::{Color as CSSParserColor, Parser, RGBA};
|
||||
use euclid::{Point2D, Size2D};
|
||||
use properties::PropertyDeclaration;
|
||||
use properties::{DeclaredValue, PropertyDeclaration};
|
||||
use properties::longhands;
|
||||
use properties::longhands::background_position_x::computed_value::T as BackgroundPositionX;
|
||||
use properties::longhands::background_position_y::computed_value::T as BackgroundPositionY;
|
||||
|
@ -26,7 +26,7 @@ use super::ComputedValues;
|
|||
use values::Either;
|
||||
use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
||||
use values::computed::{BorderRadiusSize, LengthOrNone};
|
||||
use values::computed::{CalcLengthOrPercentage, LengthOrPercentage};
|
||||
use values::computed::{CalcLengthOrPercentage, Context, LengthOrPercentage};
|
||||
use values::computed::position::{HorizontalPosition, Position, VerticalPosition};
|
||||
use values::computed::ToComputedValue;
|
||||
|
||||
|
@ -191,6 +191,17 @@ impl AnimatedProperty {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
% if product == "gecko":
|
||||
use gecko_bindings::structs::RawServoAnimationValue;
|
||||
use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI};
|
||||
|
||||
unsafe impl HasFFI for AnimationValue {
|
||||
type FFIType = RawServoAnimationValue;
|
||||
}
|
||||
unsafe impl HasArcFFI for AnimationValue {}
|
||||
% endif
|
||||
|
||||
/// An enum to represent a single computed value belonging to an animated
|
||||
/// property in order to be interpolated with another one. When interpolating,
|
||||
/// both values need to belong to the same property.
|
||||
|
@ -230,6 +241,40 @@ impl AnimationValue {
|
|||
% endfor
|
||||
}
|
||||
}
|
||||
|
||||
/// Construct an AnimationValue from a property declaration
|
||||
pub fn from_declaration(decl: &PropertyDeclaration, context: &Context, initial: &ComputedValues) -> Option<Self> {
|
||||
match *decl {
|
||||
% for prop in data.longhands:
|
||||
% if prop.animatable:
|
||||
PropertyDeclaration::${prop.camel_case}(ref val) => {
|
||||
let computed = match *val {
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1326131
|
||||
DeclaredValue::WithVariables{..} => unimplemented!(),
|
||||
DeclaredValue::Value(ref val) => val.to_computed_value(context),
|
||||
% if not prop.style_struct.inherited:
|
||||
DeclaredValue::Unset |
|
||||
% endif
|
||||
DeclaredValue::Initial => {
|
||||
let initial_struct = initial.get_${prop.style_struct.name_lower}();
|
||||
initial_struct.clone_${prop.ident}()
|
||||
},
|
||||
% if prop.style_struct.inherited:
|
||||
DeclaredValue::Unset |
|
||||
% endif
|
||||
DeclaredValue::Inherit => {
|
||||
let inherit_struct = context.inherited_style
|
||||
.get_${prop.style_struct.name_lower}();
|
||||
inherit_struct.clone_${prop.ident}()
|
||||
},
|
||||
};
|
||||
Some(AnimationValue::${prop.camel_case}(computed))
|
||||
}
|
||||
% endif
|
||||
% endfor
|
||||
_ => None // non animatable properties will get included because of shorthands. ignore.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Interpolate for AnimationValue {
|
||||
|
|
|
@ -13,7 +13,7 @@ use selectors::Element;
|
|||
use servo_url::ServoUrl;
|
||||
use std::borrow::Cow;
|
||||
use std::fmt::Write;
|
||||
use std::mem::transmute;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use style::arc_ptr_eq;
|
||||
|
@ -35,8 +35,10 @@ use style::gecko_bindings::bindings::{RawServoStyleSheetBorrowed, ServoComputedV
|
|||
use style::gecko_bindings::bindings::{RawServoStyleSheetStrong, ServoComputedValuesStrong};
|
||||
use style::gecko_bindings::bindings::{ServoCssRulesBorrowed, ServoCssRulesStrong};
|
||||
use style::gecko_bindings::bindings::{nsACString, nsAString};
|
||||
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::RawServoImportRuleBorrowed;
|
||||
use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
||||
use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t;
|
||||
|
@ -55,6 +57,7 @@ use style::parser::{ParserContext, ParserContextExtraData};
|
|||
use style::properties::{CascadeFlags, ComputedValues, Importance, PropertyDeclaration};
|
||||
use style::properties::{PropertyDeclarationParseResult, PropertyDeclarationBlock, PropertyId};
|
||||
use style::properties::{apply_declarations, parse_one_declaration};
|
||||
use style::properties::animated_properties::AnimationValue;
|
||||
use style::restyle_hints::RestyleHint;
|
||||
use style::selector_parser::PseudoElementCascadeType;
|
||||
use style::sequential;
|
||||
|
@ -155,6 +158,76 @@ pub extern "C" fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
|
|||
behavior == structs::TraversalRootBehavior::UnstyledChildrenOnly);
|
||||
}
|
||||
|
||||
/// Takes a ServoAnimationValues and populates it with the animation values corresponding
|
||||
/// to a given property declaration block
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_AnimationValues_Populate(anim: RawGeckoAnimationValueListBorrowedMut,
|
||||
declarations: RawServoDeclarationBlockBorrowed,
|
||||
style: ServoComputedValuesBorrowed,
|
||||
parent_style: ServoComputedValuesBorrowedOrNull,
|
||||
pres_context: RawGeckoPresContextBorrowed)
|
||||
{
|
||||
use style::properties::declaration_block::Importance;
|
||||
use style::values::computed::Context;
|
||||
|
||||
let parent_style = parent_style.as_ref().map(|r| &**ComputedValues::as_arc(&r));
|
||||
// FIXME this might not be efficient since Populate
|
||||
// is called multiple times. We should precalculate the Context
|
||||
// and share it across Populate calls
|
||||
let style = ComputedValues::as_arc(&style);
|
||||
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||
let guard = declarations.read();
|
||||
|
||||
let init = ComputedValues::default_values(pres_context);
|
||||
|
||||
let context = Context {
|
||||
is_root_element: false,
|
||||
// FIXME (bug 1303229): Use the actual viewport size here
|
||||
viewport_size: Size2D::new(Au(0), Au(0)),
|
||||
inherited_style: parent_style.unwrap_or(&init),
|
||||
style: (**style).clone(),
|
||||
font_metrics_provider: None,
|
||||
};
|
||||
|
||||
let mut iter = guard.declarations
|
||||
.iter()
|
||||
.filter_map(|&(ref decl, imp)| {
|
||||
if imp == Importance::Normal {
|
||||
AnimationValue::from_declaration(decl, &context, &init)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
|
||||
let mut geckoiter = anim.iter_mut();
|
||||
{
|
||||
// we reborrow to scope the consumed mutable borrow
|
||||
// we need to be able to ensure geckoiter is empty later on
|
||||
// and thus can't directly use `geckoiter`
|
||||
let local_geckoiter = &mut geckoiter;
|
||||
for (gecko, servo) in local_geckoiter.zip(&mut iter) {
|
||||
gecko.mServoValue.set_arc_leaky(Arc::new(servo));
|
||||
}
|
||||
}
|
||||
|
||||
// we should have gone through both iterators
|
||||
if iter.next().is_some() || geckoiter.next().is_some() {
|
||||
error!("stylo: Mismatched sizes of Gecko and Servo \
|
||||
array during animation value construction");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_AnimationValue_AddRef(anim: RawServoAnimationValueBorrowed) -> () {
|
||||
unsafe { AnimationValue::addref(anim) };
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_AnimationValue_Release(anim: RawServoAnimationValueBorrowed) -> () {
|
||||
unsafe { AnimationValue::release(anim) };
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_RestyleWithAddedDeclaration(raw_data: RawServoStyleSetBorrowed,
|
||||
declarations: RawServoDeclarationBlockBorrowed,
|
||||
|
@ -226,7 +299,7 @@ pub extern "C" fn Servo_StyleSheet_Empty(mode: SheetParsingMode) -> RawServoStyl
|
|||
"", url, origin, Default::default(), None,
|
||||
Box::new(StdoutErrorReporter), extra_data));
|
||||
unsafe {
|
||||
transmute(sheet)
|
||||
mem::transmute(sheet)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,7 +344,7 @@ pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes(loader: *mut Loader,
|
|||
input, url, origin, Default::default(), loader,
|
||||
Box::new(StdoutErrorReporter), extra_data));
|
||||
unsafe {
|
||||
transmute(sheet)
|
||||
mem::transmute(sheet)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -618,7 +691,6 @@ pub extern "C" fn Servo_StyleSet_Drop(data: RawServoStyleSetOwned) -> () {
|
|||
let _ = data.into_box::<PerDocumentStyleData>();
|
||||
}
|
||||
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ParseProperty(property: *const nsACString, value: *const nsACString,
|
||||
base_url: *const nsACString, base: *mut ThreadSafeURIHolder,
|
||||
|
@ -915,7 +987,7 @@ pub extern "C" fn Servo_ImportRule_GetSheet(import_rule:
|
|||
RawServoImportRuleBorrowed)
|
||||
-> RawServoStyleSheetStrong {
|
||||
let import_rule = RwLock::<ImportRule>::as_arc(&import_rule);
|
||||
unsafe { transmute(import_rule.read().stylesheet.clone()) }
|
||||
unsafe { mem::transmute(import_rule.read().stylesheet.clone()) }
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue