summaryrefslogtreecommitdiffstats
path: root/layout/base/MotionPathUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'layout/base/MotionPathUtils.cpp')
-rw-r--r--layout/base/MotionPathUtils.cpp35
1 files changed, 30 insertions, 5 deletions
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<ResolvedMotionPathData> 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<gfx::Path> BuildDefaultPathForURL(
return nullptr;
}
- Array<const StylePathCommand, 1> array(StylePathCommand::MoveTo(
- StyleCoordPair(gfx::Point{0.0, 0.0}), StyleIsAbsolute::No));
+ Array<const StylePathCommand, 1> array(StylePathCommand::Move(
+ StyleByTo::By, StyleCoordinatePair<StyleCSSFloat>{0.0, 0.0}));
return SVGPathData::BuildPath(array, aBuilder, StyleStrokeLinecap::Butt, 0.0);
}
@@ -695,6 +695,21 @@ already_AddRefed<gfx::Path> MotionPathUtils::BuildSVGPath(
0.0);
}
+static already_AddRefed<gfx::Path> BuildShape(
+ const Span<const StyleShapeCommand>& 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<gfx::Path> MotionPathUtils::BuildPath(
const StyleBasicShape& aBasicShape,
@@ -725,12 +740,22 @@ already_AddRefed<gfx::Path> 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 <position>" 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;