From 9735c2e9729266e2a8ed2a4da58157423faacc21 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Wed, 22 Jan 2020 18:40:09 +0000 Subject: [PATCH] Bug 1592822 - Use Serde for Transform. r=emilio Though this may make us use more space when serializing StyleTransform, but we don't have to do extra conversion on the compostior side, and this makes us easier to maintain the Rust type. Differential Revision: https://phabricator.services.mozilla.com/D60045 --HG-- extra : moz-landing-system : lando --- gfx/layers/ipc/LayersMessageUtils.h | 1 + gfx/layers/ipc/LayersMessages.ipdlh | 43 +--- layout/painting/nsDisplayList.cpp | 211 +++++------------- layout/style/ServoBindings.h | 1 + layout/style/ServoStyleConstsForwards.h | 1 + layout/style/ServoStyleConstsInlines.h | 17 ++ layout/style/StyleAnimationValue.cpp | 104 +-------- .../style/values/generics/transform.rs | 8 + servo/components/style_traits/owned_slice.rs | 21 ++ servo/ports/geckolib/cbindgen.toml | 1 + servo/ports/geckolib/glue.rs | 17 +- 11 files changed, 126 insertions(+), 299 deletions(-) diff --git a/gfx/layers/ipc/LayersMessageUtils.h b/gfx/layers/ipc/LayersMessageUtils.h index 49497f442505..c94373b3822f 100644 --- a/gfx/layers/ipc/LayersMessageUtils.h +++ b/gfx/layers/ipc/LayersMessageUtils.h @@ -877,6 +877,7 @@ IMPL_PARAMTRAITS_BY_SERDE(RayFunction) IMPL_PARAMTRAITS_BY_SERDE(StyleRotate) IMPL_PARAMTRAITS_BY_SERDE(StyleScale) IMPL_PARAMTRAITS_BY_SERDE(StyleTranslate) +IMPL_PARAMTRAITS_BY_SERDE(StyleTransform) } /* namespace IPC */ diff --git a/gfx/layers/ipc/LayersMessages.ipdlh b/gfx/layers/ipc/LayersMessages.ipdlh index 66684fb3c85a..a8b3764dd37e 100644 --- a/gfx/layers/ipc/LayersMessages.ipdlh +++ b/gfx/layers/ipc/LayersMessages.ipdlh @@ -64,6 +64,7 @@ using mozilla::RayReferenceData from "mozilla/MotionPathUtils.h"; using mozilla::StyleRotate from "mozilla/ServoStyleConsts.h"; using mozilla::StyleScale from "mozilla/ServoStyleConsts.h"; using mozilla::StyleTranslate from "mozilla/ServoStyleConsts.h"; +using mozilla::StyleTransform from "mozilla/ServoStyleConsts.h"; namespace mozilla { namespace layers { @@ -124,46 +125,6 @@ struct CSSAngle { }; struct LayerColor { Color value; }; -struct Perspective { float value; }; -struct RotationX { CSSAngle angle; }; -struct RotationY { CSSAngle angle; }; -struct RotationZ { CSSAngle angle; }; -struct Rotation { CSSAngle angle; }; -struct Rotation3D { - float x; - float y; - float z; - CSSAngle angle; -}; -struct Scale { - float x; - float y; - float z; -}; -struct Skew { CSSAngle x; CSSAngle y; }; -struct SkewX { CSSAngle x; }; -struct SkewY { CSSAngle y; }; -struct TransformMatrix { Matrix4x4 value; }; -struct Translation { - float x; - float y; - float z; -}; - -union TransformFunction { - Perspective; - RotationX; - RotationY; - RotationZ; - Rotation; - Rotation3D; - Scale; - Skew; - SkewX; - SkewY; - Translation; - TransformMatrix; -}; struct MoveTo { Point point; }; struct LineTo { Point point; }; @@ -232,7 +193,7 @@ union Animatable { StyleRotate; StyleScale; StyleTranslate; - TransformFunction[]; + StyleTransform; OffsetPath; LengthPercentage; OffsetRotate; diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index a26802076174..c30011006e09 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -207,17 +207,16 @@ static inline CSSAngle MakeCSSAngle(const StyleAngle& aValue) { return CSSAngle(aValue.ToDegrees(), eCSSUnit_Degree); } -static Translation GetTranslate( +static StyleTransformOperation ResolveTranslate( TransformReferenceBox& aRefBox, const LengthPercentage& aX, const LengthPercentage& aY = LengthPercentage::Zero(), const Length& aZ = Length{0}) { - Translation result(0, 0, 0); - result.x() = nsStyleTransformMatrix::ProcessTranslatePart( + float x = nsStyleTransformMatrix::ProcessTranslatePart( aX, &aRefBox, &TransformReferenceBox::Width); - result.y() = nsStyleTransformMatrix::ProcessTranslatePart( + float y = nsStyleTransformMatrix::ProcessTranslatePart( aY, &aRefBox, &TransformReferenceBox::Height); - result.z() = aZ.ToCSSPixels(); - return result; + return StyleTransformOperation::Translate3D( + LengthPercentage::FromPixels(x), LengthPercentage::FromPixels(y), aZ); } static StyleTranslate ResolveTranslate(const StyleTranslate& aValue, @@ -236,169 +235,85 @@ static StyleTranslate ResolveTranslate(const StyleTranslate& aValue, return StyleTranslate::None(); } -static void AddTransformFunctions(const StyleTransform& aTransform, - TransformReferenceBox& aRefBox, - nsTArray& aFunctions) { +static StyleTransform ResolveTransformOperations( + const StyleTransform& aTransform, TransformReferenceBox& aRefBox) { + auto convertMatrix = [](const Matrix4x4& aM) { + return StyleTransformOperation::Matrix3D(StyleGenericMatrix3D{ + aM._11, aM._12, aM._13, aM._14, aM._21, aM._22, aM._23, aM._24, aM._31, + aM._32, aM._33, aM._34, aM._41, aM._42, aM._43, aM._44}); + }; + + Vector result; + MOZ_RELEASE_ASSERT( + result.initCapacity(aTransform.Operations().Length()), + "Allocating vector of transform operations should be successful."); + for (const StyleTransformOperation& op : aTransform.Operations()) { switch (op.tag) { - case StyleTransformOperation::Tag::RotateX: { - CSSAngle theta = MakeCSSAngle(op.AsRotateX()); - aFunctions.AppendElement(RotationX(theta)); + case StyleTransformOperation::Tag::TranslateX: + result.infallibleAppend(ResolveTranslate(aRefBox, op.AsTranslateX())); break; - } - case StyleTransformOperation::Tag::RotateY: { - CSSAngle theta = MakeCSSAngle(op.AsRotateY()); - aFunctions.AppendElement(RotationY(theta)); + case StyleTransformOperation::Tag::TranslateY: + result.infallibleAppend(ResolveTranslate( + aRefBox, LengthPercentage::Zero(), op.AsTranslateY())); break; - } - case StyleTransformOperation::Tag::RotateZ: { - CSSAngle theta = MakeCSSAngle(op.AsRotateZ()); - aFunctions.AppendElement(RotationZ(theta)); + case StyleTransformOperation::Tag::TranslateZ: + result.infallibleAppend( + ResolveTranslate(aRefBox, LengthPercentage::Zero(), + LengthPercentage::Zero(), op.AsTranslateZ())); break; - } - case StyleTransformOperation::Tag::Rotate: { - CSSAngle theta = MakeCSSAngle(op.AsRotate()); - aFunctions.AppendElement(Rotation(theta)); - break; - } - case StyleTransformOperation::Tag::Rotate3D: { - const auto& rotate = op.AsRotate3D(); - CSSAngle theta = MakeCSSAngle(rotate._3); - aFunctions.AppendElement( - Rotation3D(rotate._0, rotate._1, rotate._2, theta)); - break; - } - case StyleTransformOperation::Tag::ScaleX: { - aFunctions.AppendElement(Scale(op.AsScaleX(), 1., 1.)); - break; - } - case StyleTransformOperation::Tag::ScaleY: { - aFunctions.AppendElement(Scale(1., op.AsScaleY(), 1.)); - break; - } - case StyleTransformOperation::Tag::ScaleZ: { - aFunctions.AppendElement(Scale(1., 1., op.AsScaleZ())); - break; - } - case StyleTransformOperation::Tag::Scale: { - const auto& scale = op.AsScale(); - aFunctions.AppendElement(Scale(scale._0, scale._1, 1.)); - break; - } - case StyleTransformOperation::Tag::Scale3D: { - const auto& scale = op.AsScale3D(); - aFunctions.AppendElement(Scale(scale._0, scale._1, scale._2)); - break; - } - case StyleTransformOperation::Tag::TranslateX: { - aFunctions.AppendElement(GetTranslate(aRefBox, op.AsTranslateX())); - break; - } - case StyleTransformOperation::Tag::TranslateY: { - aFunctions.AppendElement( - GetTranslate(aRefBox, LengthPercentage::Zero(), op.AsTranslateY())); - break; - } - case StyleTransformOperation::Tag::TranslateZ: { - aFunctions.AppendElement(GetTranslate(aRefBox, LengthPercentage::Zero(), - LengthPercentage::Zero(), - op.AsTranslateZ())); - break; - } case StyleTransformOperation::Tag::Translate: { const auto& translate = op.AsTranslate(); - aFunctions.AppendElement( - GetTranslate(aRefBox, translate._0, translate._1)); + result.infallibleAppend( + ResolveTranslate(aRefBox, translate._0, translate._1)); break; } case StyleTransformOperation::Tag::Translate3D: { const auto& translate = op.AsTranslate3D(); - aFunctions.AppendElement( - GetTranslate(aRefBox, translate._0, translate._1, translate._2)); - break; - } - case StyleTransformOperation::Tag::SkewX: { - CSSAngle x = MakeCSSAngle(op.AsSkewX()); - aFunctions.AppendElement(SkewX(x)); - break; - } - case StyleTransformOperation::Tag::SkewY: { - CSSAngle y = MakeCSSAngle(op.AsSkewY()); - aFunctions.AppendElement(SkewY(y)); - break; - } - case StyleTransformOperation::Tag::Skew: { - const auto& skew = op.AsSkew(); - aFunctions.AppendElement( - Skew(MakeCSSAngle(skew._0), MakeCSSAngle(skew._1))); - break; - } - case StyleTransformOperation::Tag::Matrix: { - gfx::Matrix4x4 matrix; - const auto& m = op.AsMatrix(); - matrix._11 = m.a; - matrix._12 = m.b; - matrix._13 = 0; - matrix._14 = 0; - matrix._21 = m.c; - matrix._22 = m.d; - matrix._23 = 0; - matrix._24 = 0; - matrix._31 = 0; - matrix._32 = 0; - matrix._33 = 1; - matrix._34 = 0; - matrix._41 = m.e; - matrix._42 = m.f; - matrix._43 = 0; - matrix._44 = 1; - aFunctions.AppendElement(TransformMatrix(matrix)); - break; - } - case StyleTransformOperation::Tag::Matrix3D: { - const auto& m = op.AsMatrix3D(); - gfx::Matrix4x4 matrix; - - matrix._11 = m.m11; - matrix._12 = m.m12; - matrix._13 = m.m13; - matrix._14 = m.m14; - matrix._21 = m.m21; - matrix._22 = m.m22; - matrix._23 = m.m23; - matrix._24 = m.m24; - matrix._31 = m.m31; - matrix._32 = m.m32; - matrix._33 = m.m33; - matrix._34 = m.m34; - - matrix._41 = m.m41; - matrix._42 = m.m42; - matrix._43 = m.m43; - matrix._44 = m.m44; - aFunctions.AppendElement(TransformMatrix(matrix)); + result.infallibleAppend(ResolveTranslate(aRefBox, translate._0, + translate._1, translate._2)); break; } case StyleTransformOperation::Tag::InterpolateMatrix: { Matrix4x4 matrix; nsStyleTransformMatrix::ProcessInterpolateMatrix(matrix, op, aRefBox); - aFunctions.AppendElement(TransformMatrix(matrix)); + result.infallibleAppend(convertMatrix(matrix)); break; } case StyleTransformOperation::Tag::AccumulateMatrix: { Matrix4x4 matrix; nsStyleTransformMatrix::ProcessAccumulateMatrix(matrix, op, aRefBox); - aFunctions.AppendElement(TransformMatrix(matrix)); + result.infallibleAppend(convertMatrix(matrix)); break; } - case StyleTransformOperation::Tag::Perspective: { - aFunctions.AppendElement(Perspective(op.AsPerspective().ToCSSPixels())); + case StyleTransformOperation::Tag::RotateX: + case StyleTransformOperation::Tag::RotateY: + case StyleTransformOperation::Tag::RotateZ: + case StyleTransformOperation::Tag::Rotate: + case StyleTransformOperation::Tag::Rotate3D: + case StyleTransformOperation::Tag::ScaleX: + case StyleTransformOperation::Tag::ScaleY: + case StyleTransformOperation::Tag::ScaleZ: + case StyleTransformOperation::Tag::Scale: + case StyleTransformOperation::Tag::Scale3D: + case StyleTransformOperation::Tag::SkewX: + case StyleTransformOperation::Tag::SkewY: + case StyleTransformOperation::Tag::Skew: + case StyleTransformOperation::Tag::Matrix: + case StyleTransformOperation::Tag::Matrix3D: + case StyleTransformOperation::Tag::Perspective: + result.infallibleAppend(op); break; - } default: MOZ_ASSERT_UNREACHABLE("Function not handled yet!"); } } + + auto transform = StyleTransform{StyleOwnedSlice(std::move(result))}; + MOZ_ASSERT(!transform.HasPercent()); + MOZ_ASSERT(transform.Operations().Length() == + aTransform.Operations().Length()); + return transform; } static TimingFunction ToTimingFunction( @@ -467,12 +382,10 @@ static void SetAnimatable(nsCSSPropertyID aProperty, aAnimatable = ResolveTranslate(aAnimationValue.GetTranslateProperty(), aRefBox); break; - case eCSSProperty_transform: { - aAnimatable = nsTArray(); - AddTransformFunctions(aAnimationValue.GetTransformProperty(), aRefBox, - aAnimatable.get_ArrayOfTransformFunction()); + case eCSSProperty_transform: + aAnimatable = ResolveTransformOperations( + aAnimationValue.GetTransformProperty(), aRefBox); break; - } case eCSSProperty_offset_path: aAnimatable = GetOffsetPath(aAnimationValue.GetOffsetPathProperty()); break; @@ -838,10 +751,8 @@ static void AddNonAnimatingTransformLikePropertiesStyles( case eCSSProperty_transform: if (!display->mTransform.IsNone()) { TransformReferenceBox refBox(aFrame); - nsTArray transformFunctions; - AddTransformFunctions(display->mTransform, refBox, - transformFunctions); - appendFakeAnimation(id, Animatable(std::move(transformFunctions))); + appendFakeAnimation( + id, ResolveTransformOperations(display->mTransform, refBox)); } break; case eCSSProperty_translate: diff --git a/layout/style/ServoBindings.h b/layout/style/ServoBindings.h index 43715bc312dc..53e8fa20affc 100644 --- a/layout/style/ServoBindings.h +++ b/layout/style/ServoBindings.h @@ -69,6 +69,7 @@ BASIC_SERDE_FUNCS(RayFunction) BASIC_SERDE_FUNCS(StyleRotate) BASIC_SERDE_FUNCS(StyleScale) BASIC_SERDE_FUNCS(StyleTranslate) +BASIC_SERDE_FUNCS(StyleTransform) #undef BASIC_SERDE_FUNCS diff --git a/layout/style/ServoStyleConstsForwards.h b/layout/style/ServoStyleConstsForwards.h index da926b353a97..8d4b49737939 100644 --- a/layout/style/ServoStyleConstsForwards.h +++ b/layout/style/ServoStyleConstsForwards.h @@ -26,6 +26,7 @@ # include "mozilla/MemoryReporting.h" # include "mozilla/ServoTypes.h" # include "mozilla/ServoBindingTypes.h" +# include "mozilla/Vector.h" # include "nsCSSPropertyID.h" # include "nsCompatibility.h" # include "nsIURI.h" diff --git a/layout/style/ServoStyleConstsInlines.h b/layout/style/ServoStyleConstsInlines.h index 2b7de00ee4bb..6b5a140cd9d8 100644 --- a/layout/style/ServoStyleConstsInlines.h +++ b/layout/style/ServoStyleConstsInlines.h @@ -68,6 +68,23 @@ inline StyleOwnedSlice::StyleOwnedSlice(StyleOwnedSlice&& aOther) SwapElements(aOther); } +template +inline StyleOwnedSlice::StyleOwnedSlice(Vector&& aVector) + : StyleOwnedSlice() { + if (!aVector.length()) { + return; + } + + // We could handle this if Vector provided the relevant APIs, see bug 1610702. + MOZ_DIAGNOSTIC_ASSERT(aVector.length() == aVector.capacity(), + "Shouldn't over-allocate"); + len = aVector.length(); + ptr = aVector.extractRawBuffer(); + MOZ_ASSERT(ptr, + "How did extractRawBuffer return null if we're not using inline " + "capacity?"); +} + template inline StyleOwnedSlice& StyleOwnedSlice::operator=( const StyleOwnedSlice& aOther) { diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp index 481c12627162..8263fa51c476 100644 --- a/layout/style/StyleAnimationValue.cpp +++ b/layout/style/StyleAnimationValue.cpp @@ -51,100 +51,6 @@ static inline StyleAngle GetCSSAngle(const layers::CSSAngle& aAngle) { return StyleAngle{aAngle.value()}; } -static StyleTransformOperation OperationFromLayers( - const layers::TransformFunction& aFunction) { - switch (aFunction.type()) { - case layers::TransformFunction::TRotationX: { - const layers::CSSAngle& angle = aFunction.get_RotationX().angle(); - return StyleTransformOperation::RotateX(GetCSSAngle(angle)); - } - case layers::TransformFunction::TRotationY: { - const layers::CSSAngle& angle = aFunction.get_RotationY().angle(); - return StyleTransformOperation::RotateY(GetCSSAngle(angle)); - } - case layers::TransformFunction::TRotationZ: { - const layers::CSSAngle& angle = aFunction.get_RotationZ().angle(); - return StyleTransformOperation::RotateZ(GetCSSAngle(angle)); - } - case layers::TransformFunction::TRotation: { - const layers::CSSAngle& angle = aFunction.get_Rotation().angle(); - return StyleTransformOperation::Rotate(GetCSSAngle(angle)); - } - case layers::TransformFunction::TRotation3D: { - float x = aFunction.get_Rotation3D().x(); - float y = aFunction.get_Rotation3D().y(); - float z = aFunction.get_Rotation3D().z(); - const layers::CSSAngle& angle = aFunction.get_Rotation3D().angle(); - return StyleTransformOperation::Rotate3D(x, y, z, GetCSSAngle(angle)); - } - case layers::TransformFunction::TScale: { - float x = aFunction.get_Scale().x(); - float y = aFunction.get_Scale().y(); - float z = aFunction.get_Scale().z(); - return StyleTransformOperation::Scale3D(x, y, z); - } - case layers::TransformFunction::TTranslation: { - float x = aFunction.get_Translation().x(); - float y = aFunction.get_Translation().y(); - float z = aFunction.get_Translation().z(); - return StyleTransformOperation::Translate3D( - LengthPercentage::FromPixels(x), LengthPercentage::FromPixels(y), - Length{z}); - } - case layers::TransformFunction::TSkewX: { - const layers::CSSAngle& x = aFunction.get_SkewX().x(); - return StyleTransformOperation::SkewX(GetCSSAngle(x)); - } - case layers::TransformFunction::TSkewY: { - const layers::CSSAngle& y = aFunction.get_SkewY().y(); - return StyleTransformOperation::SkewY(GetCSSAngle(y)); - } - case layers::TransformFunction::TSkew: { - const layers::CSSAngle& x = aFunction.get_Skew().x(); - const layers::CSSAngle& y = aFunction.get_Skew().y(); - return StyleTransformOperation::Skew(GetCSSAngle(x), GetCSSAngle(y)); - } - case layers::TransformFunction::TTransformMatrix: { - const gfx::Matrix4x4& matrix = aFunction.get_TransformMatrix().value(); - return StyleTransformOperation::Matrix3D({ - matrix._11, - matrix._12, - matrix._13, - matrix._14, - matrix._21, - matrix._22, - matrix._23, - matrix._24, - matrix._31, - matrix._32, - matrix._33, - matrix._34, - matrix._41, - matrix._42, - matrix._43, - matrix._44, - }); - } - case layers::TransformFunction::TPerspective: { - float perspective = aFunction.get_Perspective().value(); - return StyleTransformOperation::Perspective(Length{perspective}); - } - default: - MOZ_ASSERT_UNREACHABLE("All functions should be implemented?"); - return StyleTransformOperation::TranslateX(LengthPercentage::Zero()); - } -} - -static nsTArray CreateTransformList( - const nsTArray& aFunctions) { - nsTArray result; - result.SetCapacity(aFunctions.Length()); - for (const layers::TransformFunction& function : aFunctions) { - result.AppendElement(OperationFromLayers(function)); - } - return result; -} - static StylePathCommand CommandFromLayers(const layers::PathCommand& aCommand) { switch (aCommand.type()) { case layers::PathCommand::TMoveTo: @@ -388,11 +294,11 @@ already_AddRefed AnimationValue::FromAnimatable( switch (aAnimatable.type()) { case layers::Animatable::Tnull_t: break; - case layers::Animatable::TArrayOfTransformFunction: { - nsTArray ops = - CreateTransformList(aAnimatable.get_ArrayOfTransformFunction()); - return Servo_AnimationValue_Transform(ops.Elements(), ops.Length()) - .Consume(); + case layers::Animatable::TStyleTransform: { + const StyleTransform& transform = aAnimatable.get_StyleTransform(); + MOZ_ASSERT(!transform.HasPercent(), + "Received transform operations should have been resolved."); + return Servo_AnimationValue_Transform(&transform).Consume(); } case layers::Animatable::Tfloat: return Servo_AnimationValue_Opacity(aAnimatable.get_float()).Consume(); diff --git a/servo/components/style/values/generics/transform.rs b/servo/components/style/values/generics/transform.rs index d452b215c6a5..42a5197311f9 100644 --- a/servo/components/style/values/generics/transform.rs +++ b/servo/components/style/values/generics/transform.rs @@ -23,8 +23,10 @@ use style_traits::{CssWriter, ToCss}; Clone, Copy, Debug, + Deserialize, MallocSizeOf, PartialEq, + Serialize, SpecifiedValueInfo, ToComputedValue, ToCss, @@ -51,8 +53,10 @@ pub use self::GenericMatrix as Matrix; Clone, Copy, Debug, + Deserialize, MallocSizeOf, PartialEq, + Serialize, SpecifiedValueInfo, ToComputedValue, ToCss, @@ -141,8 +145,10 @@ fn is_same(x: &N, y: &N) -> bool { #[derive( Clone, Debug, + Deserialize, MallocSizeOf, PartialEq, + Serialize, SpecifiedValueInfo, ToComputedValue, ToCss, @@ -267,8 +273,10 @@ pub use self::GenericTransformOperation as TransformOperation; #[derive( Clone, Debug, + Deserialize, MallocSizeOf, PartialEq, + Serialize, SpecifiedValueInfo, ToComputedValue, ToCss, diff --git a/servo/components/style_traits/owned_slice.rs b/servo/components/style_traits/owned_slice.rs index 33d3ac1c2ab4..bbce70651969 100644 --- a/servo/components/style_traits/owned_slice.rs +++ b/servo/components/style_traits/owned_slice.rs @@ -7,6 +7,8 @@ //! A replacement for `Box<[T]>` that cbindgen can understand. use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf, MallocSizeOfOps}; +use serde::de::{Deserialize, Deserializer}; +use serde::ser::{Serialize, Serializer}; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use std::ptr::NonNull; @@ -171,3 +173,22 @@ impl iter::FromIterator for OwnedSlice { Vec::from_iter(iter).into() } } + +impl Serialize for OwnedSlice { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + self.deref().serialize(serializer) + } +} + +impl<'de, T: Deserialize<'de>> Deserialize<'de> for OwnedSlice { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let r = Box::<[T]>::deserialize(deserializer)?; + Ok(r.into()) + } +} diff --git a/servo/ports/geckolib/cbindgen.toml b/servo/ports/geckolib/cbindgen.toml index 303cb8312560..5ccfea6817c5 100644 --- a/servo/ports/geckolib/cbindgen.toml +++ b/servo/ports/geckolib/cbindgen.toml @@ -467,6 +467,7 @@ renaming_overrides_prefixing = true inline StyleOwnedSlice(const StyleOwnedSlice&); inline StyleOwnedSlice(StyleOwnedSlice&&); + inline explicit StyleOwnedSlice(Vector&&); inline ~StyleOwnedSlice(); diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs index 026c8bbe181d..ec12942d4882 100644 --- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -909,16 +909,9 @@ pub unsafe extern "C" fn Servo_AnimationValue_Scale( #[no_mangle] pub unsafe extern "C" fn Servo_AnimationValue_Transform( - list: *const computed::TransformOperation, - len: usize, + transform: &computed::Transform, ) -> Strong { - use style::values::generics::transform::Transform; - - let slice = std::slice::from_raw_parts(list, len); - Arc::new(AnimationValue::Transform(Transform( - slice.iter().cloned().collect(), - ))) - .into_strong() + Arc::new(AnimationValue::Transform(transform.clone())).into_strong() } #[no_mangle] @@ -1097,6 +1090,12 @@ impl_basic_serde_funcs!( computed::transform::Translate ); +impl_basic_serde_funcs!( + Servo_StyleTransform_Serialize, + Servo_StyleTransform_Deserialize, + computed::transform::Transform +); + #[no_mangle] pub extern "C" fn Servo_SVGPathData_Normalize( input: &specified::SVGPathData,