diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index 15a9d06dc02..6cb3c77a8a6 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -691,6 +691,7 @@ mod bindings { ]; let servo_borrow_types = [ "nsCSSValue", + "nsTimingFunction", "RawGeckoAnimationValueList", "RawGeckoKeyframeList", "RawGeckoComputedKeyframeValuesList", diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index a5addcee8d3..c84ca64587d 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -263,6 +263,10 @@ 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 nsTimingFunctionBorrowed<'a> = &'a nsTimingFunction; +pub type nsTimingFunctionBorrowedOrNull<'a> = Option<&'a nsTimingFunction>; +pub type nsTimingFunctionBorrowedMut<'a> = &'a mut nsTimingFunction; +pub type nsTimingFunctionBorrowedMutOrNull<'a> = Option<&'a mut nsTimingFunction>; pub type RawGeckoAnimationValueListBorrowed<'a> = &'a RawGeckoAnimationValueList; pub type RawGeckoAnimationValueListBorrowedOrNull<'a> = Option<&'a RawGeckoAnimationValueList>; pub type RawGeckoAnimationValueListBorrowedMut<'a> = &'a mut RawGeckoAnimationValueList; @@ -1487,6 +1491,12 @@ extern "C" { data: *const GeckoParserExtraData) -> RawServoDeclarationBlockStrong; } +extern "C" { + pub fn Servo_ParseEasing(easing: *const nsAString, + base: *const nsACString, + data: *const GeckoParserExtraData, + output: nsTimingFunctionBorrowedMut) -> bool; +} extern "C" { pub fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeListBorrowed, diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 253e724a363..b36d5fc67eb 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -48,6 +48,7 @@ use style::gecko_bindings::bindings::RawServoAnimationValueStrong; use style::gecko_bindings::bindings::RawServoImportRuleBorrowed; use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull; use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t; +use style::gecko_bindings::bindings::nsTimingFunctionBorrowedMut; use style::gecko_bindings::structs; use style::gecko_bindings::structs::{SheetParsingMode, nsIAtom, nsCSSPropertyID}; use style::gecko_bindings::structs::{ThreadSafePrincipalHolder, ThreadSafeURIHolder}; @@ -790,6 +791,27 @@ pub extern "C" fn Servo_ParseProperty(property: *const nsACString, value: *const } } +#[no_mangle] +pub extern "C" fn Servo_ParseEasing(easing: *const nsAString, + base: *const nsACString, + data: *const structs::GeckoParserExtraData, + output: nsTimingFunctionBorrowedMut) + -> bool { + use style::properties::longhands::transition_timing_function; + + make_context!((base, data) => (base_url, extra_data)); + let reporter = StdoutErrorReporter; + let context = ParserContext::new_with_extra_data(Origin::Author, &base_url, &reporter, extra_data); + let easing = unsafe { (*easing).to_string() }; + match transition_timing_function::single_value::parse(&context, &mut Parser::new(&easing)) { + Ok(parsed_easing) => { + *output = parsed_easing.into(); + true + }, + Err(_) => false + } +} + #[no_mangle] pub extern "C" fn Servo_ParseStyleAttribute(data: *const nsACString, base: *const nsACString,