Auto merge of #15287 - hiikezoe:css-animation, r=heycam

Counter part of bug 1328787 - Stylo: Convert Servo's animation keyframes and store them into Gecko's keyframes

<!-- Please describe your changes on the following line: -->
Reviewed by @heycam, An exception is auto-generated bindgen stuff, I did not include it in patches on bugzilla.  The bindgen diff included in this PR was generated with  b5c94bad37.  It might be bit-rotted.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because gecko has test cases.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/15287)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-01-28 21:24:04 -08:00 committed by GitHub
commit 0459e1a6dd
13 changed files with 7228 additions and 9083 deletions

View file

@ -5,9 +5,11 @@ type nsACString_internal = nsACString;
type nsAString_internal = nsAString;
use gecko_bindings::structs::RawGeckoDocument;
use gecko_bindings::structs::RawGeckoElement;
use gecko_bindings::structs::RawGeckoKeyframeList;
use gecko_bindings::structs::RawGeckoNode;
use gecko_bindings::structs::RawGeckoAnimationValueList;
use gecko_bindings::structs::RawServoAnimationValue;
use gecko_bindings::structs::RawServoDeclarationBlock;
use gecko_bindings::structs::RawGeckoPresContext;
use gecko_bindings::structs::RawGeckoPresContextOwned;
use gecko_bindings::structs::ThreadSafeURIHolder;
@ -16,6 +18,7 @@ use gecko_bindings::structs::CSSPseudoClassType;
use gecko_bindings::structs::TraversalRootBehavior;
use gecko_bindings::structs::FontFamilyList;
use gecko_bindings::structs::FontFamilyType;
use gecko_bindings::structs::Keyframe;
use gecko_bindings::structs::ServoElementSnapshot;
use gecko_bindings::structs::SheetParsingMode;
use gecko_bindings::structs::StyleBasicShape;
@ -146,6 +149,7 @@ unsafe impl Sync for nsStyleVisibility {}
use gecko_bindings::structs::nsStyleXUL;
unsafe impl Send for nsStyleXUL {}
unsafe impl Sync for nsStyleXUL {}
use gecko_bindings::structs::nsTimingFunction;
use gecko_bindings::structs::nscoord;
use gecko_bindings::structs::nsresult;
use gecko_bindings::structs::Loader;
@ -171,8 +175,6 @@ pub struct RawServoStyleSheet(RawServoStyleSheetVoid);
pub type RawServoDeclarationBlockStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoDeclarationBlock>;
pub type RawServoDeclarationBlockBorrowed<'a> = &'a RawServoDeclarationBlock;
pub type RawServoDeclarationBlockBorrowedOrNull<'a> = Option<&'a RawServoDeclarationBlock>;
enum RawServoDeclarationBlockVoid { }
pub struct RawServoDeclarationBlock(RawServoDeclarationBlockVoid);
pub type RawServoStyleRuleStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoStyleRule>;
pub type RawServoStyleRuleBorrowed<'a> = &'a RawServoStyleRule;
pub type RawServoStyleRuleBorrowedOrNull<'a> = Option<&'a RawServoStyleRule>;
@ -226,6 +228,10 @@ 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 RawGeckoKeyframeListBorrowed<'a> = &'a RawGeckoKeyframeList;
pub type RawGeckoKeyframeListBorrowedOrNull<'a> = Option<&'a RawGeckoKeyframeList>;
pub type RawGeckoKeyframeListBorrowedMut<'a> = &'a mut RawGeckoKeyframeList;
pub type RawGeckoKeyframeListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoKeyframeList>;
extern "C" {
pub fn Gecko_EnsureTArrayCapacity(aArray: *mut ::std::os::raw::c_void,
@ -662,6 +668,14 @@ extern "C" {
*mut ::std::os::raw::c_void,
len: usize);
}
extern "C" {
pub fn Gecko_AnimationAppendKeyframe(keyframes:
RawGeckoKeyframeListBorrowedMut,
offset: f32,
timingFunction:
*const nsTimingFunction)
-> *mut Keyframe;
}
extern "C" {
pub fn Gecko_ResetStyleCoord(unit: *mut nsStyleUnit,
value: *mut nsStyleUnion);
@ -1169,6 +1183,18 @@ extern "C" {
pub fn Servo_StyleSet_NoteStyleSheetsChanged(set:
RawServoStyleSetBorrowed);
}
extern "C" {
pub fn Servo_StyleSet_FillKeyframesForName(set: RawServoStyleSetBorrowed,
property:
*const nsACString_internal,
timing_function:
*const nsTimingFunction,
computed_values:
ServoComputedValuesBorrowed,
keyframe_list:
RawGeckoKeyframeListBorrowedMut)
-> bool;
}
extern "C" {
pub fn Servo_CssRules_ListTypes(rules: ServoCssRulesBorrowed,
result: nsTArrayBorrowed_uintptr_t);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -2,64 +2,109 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use euclid::point::TypedPoint2D;
use euclid::point::{Point2D, TypedPoint2D};
use gecko_bindings::structs::{nsTimingFunction, nsTimingFunction_Type};
use properties::longhands::transition_timing_function::single_value::FunctionKeyword;
use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction;
use properties::longhands::transition_timing_function::single_value::computed_value::StartEnd;
use properties::longhands::transition_timing_function::single_value::computed_value::T as TransitionTimingFunction;
use properties::longhands::transition_timing_function::single_value::computed_value::T as ComputedTimingFunction;
use std::mem;
impl From<TransitionTimingFunction> for nsTimingFunction {
fn from(function: TransitionTimingFunction) -> nsTimingFunction {
impl nsTimingFunction {
fn set_as_step(&mut self, function_type: nsTimingFunction_Type, steps: u32) {
debug_assert!(function_type == nsTimingFunction_Type::StepStart ||
function_type == nsTimingFunction_Type::StepEnd,
"function_type should be step-start or step-end");
self.mType = function_type;
unsafe {
self.__bindgen_anon_1.__bindgen_anon_1.as_mut().mSteps = steps;
}
}
fn set_as_cubic_bezier(&mut self, p1: Point2D<f32>, p2: Point2D<f32>) {
self.mType = nsTimingFunction_Type::CubicBezier;
unsafe {
let ref mut gecko_cubic_bezier =
unsafe { self.__bindgen_anon_1.mFunc.as_mut() };
gecko_cubic_bezier.mX1 = p1.x;
gecko_cubic_bezier.mY1 = p1.y;
gecko_cubic_bezier.mX2 = p2.x;
gecko_cubic_bezier.mY2 = p2.y;
}
}
}
impl From<ComputedTimingFunction> for nsTimingFunction {
fn from(function: ComputedTimingFunction) -> nsTimingFunction {
let mut tf: nsTimingFunction = unsafe { mem::zeroed() };
match function {
TransitionTimingFunction::Steps(steps, StartEnd::Start) => {
tf.mType = nsTimingFunction_Type::StepStart;
unsafe {
tf.__bindgen_anon_1.__bindgen_anon_1.as_mut().mSteps = steps;
}
ComputedTimingFunction::Steps(steps, StartEnd::Start) => {
tf.set_as_step(nsTimingFunction_Type::StepStart, steps);
},
TransitionTimingFunction::Steps(steps, StartEnd::End) => {
tf.mType = nsTimingFunction_Type::StepEnd;
unsafe {
tf.__bindgen_anon_1.__bindgen_anon_1.as_mut().mSteps = steps;
}
ComputedTimingFunction::Steps(steps, StartEnd::End) => {
tf.set_as_step(nsTimingFunction_Type::StepEnd, steps);
},
TransitionTimingFunction::CubicBezier(p1, p2) => {
tf.mType = nsTimingFunction_Type::CubicBezier;
let ref mut gecko_cubic_bezier =
unsafe { tf.__bindgen_anon_1.mFunc.as_mut() };
gecko_cubic_bezier.mX1 = p1.x;
gecko_cubic_bezier.mY1 = p1.y;
gecko_cubic_bezier.mX2 = p2.x;
gecko_cubic_bezier.mY2 = p2.y;
ComputedTimingFunction::CubicBezier(p1, p2) => {
tf.set_as_cubic_bezier(p1, p2);
},
// FIXME: we need to add more types once TransitionTimingFunction
// has more types.
}
tf
}
}
impl From<nsTimingFunction> for TransitionTimingFunction {
fn from(function: nsTimingFunction) -> TransitionTimingFunction {
impl From<SpecifiedTimingFunction> for nsTimingFunction {
fn from(function: SpecifiedTimingFunction) -> nsTimingFunction {
let mut tf: nsTimingFunction = unsafe { mem::zeroed() };
match function {
SpecifiedTimingFunction::Steps(steps, StartEnd::Start) => {
tf.set_as_step(nsTimingFunction_Type::StepStart, steps);
},
SpecifiedTimingFunction::Steps(steps, StartEnd::End) => {
tf.set_as_step(nsTimingFunction_Type::StepEnd, steps);
},
SpecifiedTimingFunction::CubicBezier(p1, p2) => {
tf.set_as_cubic_bezier(p1, p2);
},
SpecifiedTimingFunction::Keyword(keyword) => {
match keyword {
FunctionKeyword::Ease => tf.mType = nsTimingFunction_Type::Ease,
FunctionKeyword::Linear => tf.mType = nsTimingFunction_Type::Linear,
FunctionKeyword::EaseIn => tf.mType = nsTimingFunction_Type::EaseIn,
FunctionKeyword::EaseOut => tf.mType = nsTimingFunction_Type::EaseOut,
FunctionKeyword::EaseInOut => tf.mType = nsTimingFunction_Type::EaseInOut,
FunctionKeyword::StepStart => {
tf.set_as_step(nsTimingFunction_Type::StepStart, 1);
},
FunctionKeyword::StepEnd => {
tf.set_as_step(nsTimingFunction_Type::StepEnd, 1);
},
}
},
}
tf
}
}
impl From<nsTimingFunction> for ComputedTimingFunction {
fn from(function: nsTimingFunction) -> ComputedTimingFunction {
match function.mType {
nsTimingFunction_Type::StepStart => {
TransitionTimingFunction::Steps(unsafe { function.__bindgen_anon_1.__bindgen_anon_1.as_ref().mSteps },
StartEnd::Start)
ComputedTimingFunction::Steps(unsafe { function.__bindgen_anon_1.__bindgen_anon_1.as_ref().mSteps },
StartEnd::Start)
},
nsTimingFunction_Type::StepEnd => {
TransitionTimingFunction::Steps(unsafe { function.__bindgen_anon_1.__bindgen_anon_1.as_ref().mSteps },
StartEnd::End)
ComputedTimingFunction::Steps(unsafe { function.__bindgen_anon_1.__bindgen_anon_1.as_ref().mSteps },
StartEnd::End)
},
// FIXME: As above, we need to fix here.
nsTimingFunction_Type::Ease |
nsTimingFunction_Type::Linear |
nsTimingFunction_Type::EaseIn |
nsTimingFunction_Type::EaseOut |
nsTimingFunction_Type::EaseInOut |
nsTimingFunction_Type::CubicBezier => {
TransitionTimingFunction::CubicBezier(
ComputedTimingFunction::CubicBezier(
TypedPoint2D::new(unsafe { function.__bindgen_anon_1.mFunc.as_ref().mX1 },
unsafe { function.__bindgen_anon_1.mFunc.as_ref().mY1 }),
TypedPoint2D::new(unsafe { function.__bindgen_anon_1.mFunc.as_ref().mX2 },