mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Drop frames() timing function.
frames() timing function was removed from the spec, so we drop it. Besides, some devtool tests are removed because they use frame(). I will add them back by using new step function later. Differential Revision: https://phabricator.services.mozilla.com/D9309
This commit is contained in:
parent
990f2c6bb9
commit
3a536f463c
4 changed files with 4 additions and 71 deletions
|
@ -369,22 +369,6 @@ impl PropertyAnimation {
|
||||||
GenericTimingFunction::Steps(steps, StepPosition::End) => {
|
GenericTimingFunction::Steps(steps, StepPosition::End) => {
|
||||||
(time * (steps as f64)).floor() / (steps as f64)
|
(time * (steps as f64)).floor() / (steps as f64)
|
||||||
},
|
},
|
||||||
GenericTimingFunction::Frames(frames) => {
|
|
||||||
// https://drafts.csswg.org/css-timing/#frames-timing-functions
|
|
||||||
let mut out = (time * (frames as f64)).floor() / ((frames - 1) as f64);
|
|
||||||
if out > 1.0 {
|
|
||||||
// FIXME: Basically, during the animation sampling process, the input progress
|
|
||||||
// should be in the range of [0, 1]. However, |time| is not accurate enough
|
|
||||||
// here, which means |time| could be larger than 1.0 in the last animation
|
|
||||||
// frame. (It should be equal to 1.0 exactly.) This makes the output of frames
|
|
||||||
// timing function jumps to the next frame/level.
|
|
||||||
// However, this solution is still not correct because |time| is possible
|
|
||||||
// outside the range of [0, 1] after introducing Web Animations. We should fix
|
|
||||||
// this problem when implementing web animations.
|
|
||||||
out = 1.0;
|
|
||||||
}
|
|
||||||
out
|
|
||||||
},
|
|
||||||
GenericTimingFunction::Keyword(keyword) => {
|
GenericTimingFunction::Keyword(keyword) => {
|
||||||
let (x1, x2, y1, y2) = keyword.to_bezier();
|
let (x1, x2, y1, y2) = keyword.to_bezier();
|
||||||
Bezier::new(x1, x2, y1, y2).solve(time, epsilon)
|
Bezier::new(x1, x2, y1, y2).solve(time, epsilon)
|
||||||
|
|
|
@ -22,17 +22,7 @@ impl nsTimingFunction {
|
||||||
self.__bindgen_anon_1
|
self.__bindgen_anon_1
|
||||||
.__bindgen_anon_1
|
.__bindgen_anon_1
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.mStepsOrFrames = steps;
|
.mSteps = steps;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_as_frames(&mut self, frames: u32) {
|
|
||||||
self.mType = nsTimingFunction_Type::Frames;
|
|
||||||
unsafe {
|
|
||||||
self.__bindgen_anon_1
|
|
||||||
.__bindgen_anon_1
|
|
||||||
.as_mut()
|
|
||||||
.mStepsOrFrames = frames;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,10 +64,6 @@ impl From<TimingFunction> for nsTimingFunction {
|
||||||
debug_assert!(steps.value() >= 0);
|
debug_assert!(steps.value() >= 0);
|
||||||
tf.set_as_step(nsTimingFunction_Type::StepEnd, steps.value() as u32);
|
tf.set_as_step(nsTimingFunction_Type::StepEnd, steps.value() as u32);
|
||||||
},
|
},
|
||||||
GenericTimingFunction::Frames(frames) => {
|
|
||||||
debug_assert!(frames.value() >= 2);
|
|
||||||
tf.set_as_frames(frames.value() as u32);
|
|
||||||
},
|
|
||||||
GenericTimingFunction::CubicBezier { x1, y1, x2, y2 } => {
|
GenericTimingFunction::CubicBezier { x1, y1, x2, y2 } => {
|
||||||
tf.set_as_bezier(
|
tf.set_as_bezier(
|
||||||
nsTimingFunction_Type::CubicBezier,
|
nsTimingFunction_Type::CubicBezier,
|
||||||
|
@ -105,7 +91,7 @@ impl From<nsTimingFunction> for ComputedTimingFunction {
|
||||||
.__bindgen_anon_1
|
.__bindgen_anon_1
|
||||||
.__bindgen_anon_1
|
.__bindgen_anon_1
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.mStepsOrFrames
|
.mSteps
|
||||||
},
|
},
|
||||||
StepPosition::Start,
|
StepPosition::Start,
|
||||||
),
|
),
|
||||||
|
@ -115,17 +101,10 @@ impl From<nsTimingFunction> for ComputedTimingFunction {
|
||||||
.__bindgen_anon_1
|
.__bindgen_anon_1
|
||||||
.__bindgen_anon_1
|
.__bindgen_anon_1
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.mStepsOrFrames
|
.mSteps
|
||||||
},
|
},
|
||||||
StepPosition::End,
|
StepPosition::End,
|
||||||
),
|
),
|
||||||
nsTimingFunction_Type::Frames => GenericTimingFunction::Frames(unsafe {
|
|
||||||
function
|
|
||||||
.__bindgen_anon_1
|
|
||||||
.__bindgen_anon_1
|
|
||||||
.as_ref()
|
|
||||||
.mStepsOrFrames
|
|
||||||
}),
|
|
||||||
nsTimingFunction_Type::Ease => GenericTimingFunction::Keyword(TimingKeyword::Ease),
|
nsTimingFunction_Type::Ease => GenericTimingFunction::Keyword(TimingKeyword::Ease),
|
||||||
nsTimingFunction_Type::Linear => GenericTimingFunction::Keyword(TimingKeyword::Linear),
|
nsTimingFunction_Type::Linear => GenericTimingFunction::Keyword(TimingKeyword::Linear),
|
||||||
nsTimingFunction_Type::EaseIn => GenericTimingFunction::Keyword(TimingKeyword::EaseIn),
|
nsTimingFunction_Type::EaseIn => GenericTimingFunction::Keyword(TimingKeyword::EaseIn),
|
||||||
|
|
|
@ -92,7 +92,7 @@ pub struct TransformOrigin<H, V, Depth> {
|
||||||
|
|
||||||
/// A generic timing function.
|
/// A generic timing function.
|
||||||
///
|
///
|
||||||
/// <https://drafts.csswg.org/css-timing-1/#single-timing-function-production>
|
/// https://drafts.csswg.org/css-easing-1/#timing-functions
|
||||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss)]
|
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss)]
|
||||||
#[value_info(ty = "TIMING_FUNCTION")]
|
#[value_info(ty = "TIMING_FUNCTION")]
|
||||||
pub enum TimingFunction<Integer, Number> {
|
pub enum TimingFunction<Integer, Number> {
|
||||||
|
@ -111,9 +111,6 @@ pub enum TimingFunction<Integer, Number> {
|
||||||
#[css(comma, function)]
|
#[css(comma, function)]
|
||||||
#[value_info(other_values = "step-start,step-end")]
|
#[value_info(other_values = "step-start,step-end")]
|
||||||
Steps(Integer, #[css(skip_if = "is_end")] StepPosition),
|
Steps(Integer, #[css(skip_if = "is_end")] StepPosition),
|
||||||
/// `frames(<integer>)`
|
|
||||||
#[css(comma, function)]
|
|
||||||
Frames(Integer),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
|
|
|
@ -350,19 +350,6 @@ impl<S> OriginComponent<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
#[inline]
|
|
||||||
fn allow_frames_timing() -> bool {
|
|
||||||
use gecko_bindings::structs::mozilla;
|
|
||||||
unsafe { mozilla::StaticPrefs_sVarCache_layout_css_frames_timing_enabled }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
#[inline]
|
|
||||||
fn allow_frames_timing() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for TimingFunction {
|
impl Parse for TimingFunction {
|
||||||
fn parse<'i, 't>(
|
fn parse<'i, 't>(
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
|
@ -406,14 +393,6 @@ impl Parse for TimingFunction {
|
||||||
}).unwrap_or(StepPosition::End);
|
}).unwrap_or(StepPosition::End);
|
||||||
Ok(generic::TimingFunction::Steps(steps, position))
|
Ok(generic::TimingFunction::Steps(steps, position))
|
||||||
},
|
},
|
||||||
"frames" => {
|
|
||||||
if allow_frames_timing() {
|
|
||||||
let frames = Integer::parse_with_minimum(context, i, 2)?;
|
|
||||||
Ok(generic::TimingFunction::Frames(frames))
|
|
||||||
} else {
|
|
||||||
Err(())
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
}).map_err(|()| {
|
}).map_err(|()| {
|
||||||
location.new_custom_error(StyleParseErrorKind::UnexpectedFunction(function.clone()))
|
location.new_custom_error(StyleParseErrorKind::UnexpectedFunction(function.clone()))
|
||||||
|
@ -440,9 +419,6 @@ impl ToComputedValue for TimingFunction {
|
||||||
generic::TimingFunction::Steps(steps, position) => {
|
generic::TimingFunction::Steps(steps, position) => {
|
||||||
generic::TimingFunction::Steps(steps.to_computed_value(context) as u32, position)
|
generic::TimingFunction::Steps(steps.to_computed_value(context) as u32, position)
|
||||||
},
|
},
|
||||||
generic::TimingFunction::Frames(frames) => {
|
|
||||||
generic::TimingFunction::Frames(frames.to_computed_value(context) as u32)
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,9 +441,6 @@ impl ToComputedValue for TimingFunction {
|
||||||
Integer::from_computed_value(&(steps as i32)),
|
Integer::from_computed_value(&(steps as i32)),
|
||||||
position,
|
position,
|
||||||
),
|
),
|
||||||
generic::TimingFunction::Frames(frames) => {
|
|
||||||
generic::TimingFunction::Frames(Integer::from_computed_value(&(frames as i32)))
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue