Skip to content

Commit

Permalink
Check Gecko pref before parsing frames() timing function
Browse files Browse the repository at this point in the history
  • Loading branch information
birtles committed Jul 11, 2017
1 parent 6320702 commit 8daeeb1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions components/style/gecko/generated/bindings.rs
Expand Up @@ -803,6 +803,9 @@ extern "C" {
ComputedTimingFunction_BeforeFlag)
-> f64;
}
extern "C" {
pub fn Gecko_IsFramesTimingEnabled() -> bool;
}
extern "C" {
pub fn Gecko_AnimationGetBaseStyle(aBaseStyles:
*mut ::std::os::raw::c_void,
Expand Down
19 changes: 17 additions & 2 deletions components/style/values/specified/transform.rs
Expand Up @@ -131,6 +131,17 @@ impl<S> OriginComponent<S> {
}
}

#[cfg(feature = "gecko")]
#[inline]
fn allow_frames_timing() -> bool {
use gecko_bindings::bindings;
unsafe { bindings::Gecko_IsFramesTimingEnabled() }
}

#[cfg(feature = "servo")]
#[inline]
fn allow_frames_timing() -> bool { true }

impl Parse for TimingFunction {
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
if let Ok(keyword) = input.try(TimingKeyword::parse) {
Expand Down Expand Up @@ -172,8 +183,12 @@ impl Parse for TimingFunction {
Ok(GenericTimingFunction::Steps(steps, position))
},
"frames" => {
let frames = Integer::parse_with_minimum(context, i, 2)?;
Ok(GenericTimingFunction::Frames(frames))
if allow_frames_timing() {
let frames = Integer::parse_with_minimum(context, i, 2)?;
Ok(GenericTimingFunction::Frames(frames))
} else {
Err(())
}
},
_ => Err(()),
}).map_err(|()| StyleParseError::UnexpectedFunction(function).into())
Expand Down

0 comments on commit 8daeeb1

Please sign in to comment.