aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-04-02 20:12:09 -0500
committerGitHub <noreply@github.com>2017-04-02 20:12:09 -0500
commita31271b07ff1372e48d8b363a1f4a16b8ff6f98d (patch)
tree88508be58bd11af059e58b75ef81f689fc749942
parenteb1865070a8324016c369104afa159fdec345bea (diff)
parentf36199201c498db8e4e7a23e1f24a9c421b3bb83 (diff)
downloadservo-a31271b07ff1372e48d8b363a1f4a16b8ff6f98d.tar.gz
servo-a31271b07ff1372e48d8b363a1f4a16b8ff6f98d.zip
Auto merge of #16233 - hiikezoe:timing-function-fix, r=emilio
Set each control points when converting specified keyworded timing fu… …nction to nsTimingFunction. Gecko's timing function (nsTimingFunction) needs to be specified each control points if timing function can be represented as cubic-bezier function. To avoid scattering control points values (e.g. 0.25, 0.1, ...) we convert specified value to computed value and then use control points values of the computed value. <!-- Please describe your changes on the following line: --> This is a PR of https://bugzilla.mozilla.org/show_bug.cgi?id=1352891 --- <!-- 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 it's for stylo. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- 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/16233) <!-- Reviewable:end -->
-rw-r--r--components/style/gecko_bindings/sugar/ns_timing_function.rs51
-rw-r--r--components/style/properties/longhand/box.mako.rs27
2 files changed, 52 insertions, 26 deletions
diff --git a/components/style/gecko_bindings/sugar/ns_timing_function.rs b/components/style/gecko_bindings/sugar/ns_timing_function.rs
index 840879b4d08..53c0d468523 100644
--- a/components/style/gecko_bindings/sugar/ns_timing_function.rs
+++ b/components/style/gecko_bindings/sugar/ns_timing_function.rs
@@ -21,8 +21,11 @@ impl nsTimingFunction {
}
}
- fn set_as_cubic_bezier(&mut self, p1: Point2D<f32>, p2: Point2D<f32>) {
- self.mType = nsTimingFunction_Type::CubicBezier;
+ fn set_as_bezier(&mut self,
+ function_type: nsTimingFunction_Type,
+ p1: Point2D<f32>,
+ p2: Point2D<f32>) {
+ self.mType = function_type;
unsafe {
let ref mut gecko_cubic_bezier =
unsafe { self.__bindgen_anon_1.mFunc.as_mut() };
@@ -46,7 +49,7 @@ impl From<ComputedTimingFunction> for nsTimingFunction {
tf.set_as_step(nsTimingFunction_Type::StepEnd, steps);
},
ComputedTimingFunction::CubicBezier(p1, p2) => {
- tf.set_as_cubic_bezier(p1, p2);
+ tf.set_as_bezier(nsTimingFunction_Type::CubicBezier, p1, p2);
},
}
tf
@@ -67,21 +70,39 @@ impl From<SpecifiedTimingFunction> for nsTimingFunction {
tf.set_as_step(nsTimingFunction_Type::StepEnd, steps.value() as u32);
},
SpecifiedTimingFunction::CubicBezier(p1, p2) => {
- tf.set_as_cubic_bezier(Point2D::new(p1.x.value, p1.y.value),
- Point2D::new(p2.x.value, p2.y.value));
+ tf.set_as_bezier(nsTimingFunction_Type::CubicBezier,
+ Point2D::new(p1.x.value, p1.y.value),
+ Point2D::new(p2.x.value, p2.y.value));
},
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);
+ match keyword.to_computed_value() {
+ ComputedTimingFunction::CubicBezier(p1, p2) => {
+ match keyword {
+ FunctionKeyword::Ease => {
+ tf.set_as_bezier(nsTimingFunction_Type::Ease, p1, p2);
+ },
+ FunctionKeyword::Linear => {
+ tf.set_as_bezier(nsTimingFunction_Type::Linear, p1, p2);
+ },
+ FunctionKeyword::EaseIn => {
+ tf.set_as_bezier(nsTimingFunction_Type::EaseIn, p1, p2);
+ },
+ FunctionKeyword::EaseOut => {
+ tf.set_as_bezier(nsTimingFunction_Type::EaseOut, p1, p2);
+ },
+ FunctionKeyword::EaseInOut => {
+ tf.set_as_bezier(nsTimingFunction_Type::EaseInOut, p1, p2);
+ },
+ _ => unreachable!("Unexpected bezier function type"),
+ }
+ },
+ ComputedTimingFunction::Steps(steps, StartEnd::Start) => {
+ debug_assert!(keyword == FunctionKeyword::StepStart && steps == 1);
+ tf.set_as_step(nsTimingFunction_Type::StepStart, steps);
},
- FunctionKeyword::StepEnd => {
- tf.set_as_step(nsTimingFunction_Type::StepEnd, 1);
+ ComputedTimingFunction::Steps(steps, StartEnd::End) => {
+ debug_assert!(keyword == FunctionKeyword::StepEnd && steps == 1);
+ tf.set_as_step(nsTimingFunction_Type::StepEnd, steps);
},
}
},
diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs
index 363964be74c..d05a5ed4a1e 100644
--- a/components/style/properties/longhand/box.mako.rs
+++ b/components/style/properties/longhand/box.mako.rs
@@ -671,17 +671,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
SpecifiedValue::Steps(count, start_end) => {
computed_value::T::Steps(count.to_computed_value(context) as u32, start_end)
},
- SpecifiedValue::Keyword(keyword) => {
- match keyword {
- FunctionKeyword::Ease => ease(),
- FunctionKeyword::Linear => linear(),
- FunctionKeyword::EaseIn => ease_in(),
- FunctionKeyword::EaseOut => ease_out(),
- FunctionKeyword::EaseInOut => ease_in_out(),
- FunctionKeyword::StepStart => STEP_START,
- FunctionKeyword::StepEnd => STEP_END,
- }
- },
+ SpecifiedValue::Keyword(keyword) => keyword.to_computed_value(),
}
}
#[inline]
@@ -702,6 +692,21 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
}
}
+ impl FunctionKeyword {
+ #[inline]
+ pub fn to_computed_value(&self) -> computed_value::T {
+ match *self {
+ FunctionKeyword::Ease => ease(),
+ FunctionKeyword::Linear => linear(),
+ FunctionKeyword::EaseIn => ease_in(),
+ FunctionKeyword::EaseOut => ease_out(),
+ FunctionKeyword::EaseInOut => ease_in_out(),
+ FunctionKeyword::StepStart => STEP_START,
+ FunctionKeyword::StepEnd => STEP_END,
+ }
+ }
+ }
+
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue);