From def92d1b8e9d373e2f6f27c366d578d97d8960c6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:50 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- layout/base/MotionPathUtils.cpp | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'layout/base/MotionPathUtils.cpp') diff --git a/layout/base/MotionPathUtils.cpp b/layout/base/MotionPathUtils.cpp index 4045f2304a..d620064b73 100644 --- a/layout/base/MotionPathUtils.cpp +++ b/layout/base/MotionPathUtils.cpp @@ -434,7 +434,7 @@ Maybe MotionPathUtils::ResolveMotionPath( static inline bool IsClosedLoop(const StyleSVGPathData& aPathData) { return !aPathData._0.AsSpan().empty() && - aPathData._0.AsSpan().rbegin()->IsClosePath(); + aPathData._0.AsSpan().rbegin()->IsClose(); } // Create a path for "inset(0 round X)", where X is the value of border-radius @@ -466,8 +466,8 @@ static already_AddRefed BuildDefaultPathForURL( return nullptr; } - Array array(StylePathCommand::MoveTo( - StyleCoordPair(gfx::Point{0.0, 0.0}), StyleIsAbsolute::No)); + Array array(StylePathCommand::Move( + StyleByTo::By, StyleCoordinatePair{0.0, 0.0})); return SVGPathData::BuildPath(array, aBuilder, StyleStrokeLinecap::Butt, 0.0); } @@ -695,6 +695,21 @@ already_AddRefed MotionPathUtils::BuildSVGPath( 0.0); } +static already_AddRefed BuildShape( + const Span& aShape, gfx::PathBuilder* aPathBuilder, + const nsRect& aCoordBox) { + if (!aPathBuilder) { + return nullptr; + } + + // For motion path, we always use CSSPixel unit to compute the offset + // transform (i.e. motion path transform). + const auto rect = CSSRect::FromAppUnits(aCoordBox); + return SVGPathData::BuildPath(aShape, aPathBuilder, StyleStrokeLinecap::Butt, + 0.0, rect.Size(), + rect.TopLeft().ToUnknownPoint()); +} + /* static */ already_AddRefed MotionPathUtils::BuildPath( const StyleBasicShape& aBasicShape, @@ -725,12 +740,22 @@ already_AddRefed MotionPathUtils::BuildPath( case StyleBasicShape::Tag::Polygon: return ShapeUtils::BuildPolygonPath(aBasicShape, aCoordBox, AppUnitsPerCSSPixel(), aPathBuilder); - case StyleBasicShape::Tag::Path: + case StyleBasicShape::Tag::PathOrShape: { // FIXME: Bug 1836847. Once we support "at " for path(), we have // to also check its containing block as well. For now, we are still // building its gfx::Path directly by its SVGPathData without other // reference. https://github.com/w3c/fxtf-drafts/issues/504 - return BuildSVGPath(aBasicShape.AsPath().path, aPathBuilder); + const auto& pathOrShape = aBasicShape.AsPathOrShape(); + if (pathOrShape.IsPath()) { + return BuildSVGPath(pathOrShape.AsPath().path, aPathBuilder); + } + + // Note that shape() always defines the initial position, i.e. "from x y", + // by its first move command, so |aOffsetPosition|, i.e. offset-position + // property, is ignored. + return BuildShape(pathOrShape.AsShape().commands.AsSpan(), aPathBuilder, + aCoordBox); + } } return nullptr; -- cgit v1.2.3