diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /layout/svg/CSSClipPathInstance.cpp | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | layout/svg/CSSClipPathInstance.cpp | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/layout/svg/CSSClipPathInstance.cpp b/layout/svg/CSSClipPathInstance.cpp index 77bde2bb54..a8e0306d3e 100644 --- a/layout/svg/CSSClipPathInstance.cpp +++ b/layout/svg/CSSClipPathInstance.cpp @@ -66,7 +66,7 @@ bool CSSClipPathInstance::HitTestBasicShapeOrPathClip(nsIFrame* aFrame, RefPtr<Path> path = instance.CreateClipPath( drawTarget, SVGUtils::GetCSSPxToDevPxMatrix(aFrame)); float pixelRatio = float(AppUnitsPerCSSPixel()) / - aFrame->PresContext()->AppUnitsPerDevPixel(); + float(aFrame->PresContext()->AppUnitsPerDevPixel()); return path && path->ContainsPoint(ToPoint(aPoint) * pixelRatio, Matrix()); } @@ -121,8 +121,10 @@ already_AddRefed<Path> CSSClipPathInstance::CreateClipPath( return CreateClipPathPolygon(aDrawTarget, r); case StyleBasicShape::Tag::Rect: return CreateClipPathInset(aDrawTarget, r); - case StyleBasicShape::Tag::Path: - return CreateClipPathPath(aDrawTarget, r); + case StyleBasicShape::Tag::PathOrShape: + return basicShape.AsPathOrShape().IsPath() + ? CreateClipPathPath(aDrawTarget, r) + : CreateClipPathShape(aDrawTarget, r); default: MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Unexpected shape type"); } @@ -175,18 +177,41 @@ already_AddRefed<Path> CSSClipPathInstance::CreateClipPathInset( already_AddRefed<Path> CSSClipPathInstance::CreateClipPathPath( DrawTarget* aDrawTarget, const nsRect& aRefBox) { - const auto& path = mClipPathStyle.AsShape()._0->AsPath(); + const auto& path = mClipPathStyle.AsShape()._0->AsPathOrShape().AsPath(); RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder( path.fill == StyleFillRule::Nonzero ? FillRule::FILL_WINDING : FillRule::FILL_EVEN_ODD); - nscoord appUnitsPerDevPixel = + const nscoord appUnitsPerDevPixel = mTargetFrame->PresContext()->AppUnitsPerDevPixel(); - float scale = float(AppUnitsPerCSSPixel()) / appUnitsPerDevPixel; - Point offset = Point(aRefBox.x, aRefBox.y) / appUnitsPerDevPixel; - + const Point offset = + LayoutDevicePoint::FromAppUnits(aRefBox.TopLeft(), appUnitsPerDevPixel) + .ToUnknownPoint(); + const float scale = mTargetFrame->Style()->EffectiveZoom().Zoom( + float(AppUnitsPerCSSPixel()) / float(appUnitsPerDevPixel)); return SVGPathData::BuildPath(path.path._0.AsSpan(), builder, - StyleStrokeLinecap::Butt, 0.0, offset, scale); + StyleStrokeLinecap::Butt, 0.0, {}, offset, + scale); +} + +already_AddRefed<Path> CSSClipPathInstance::CreateClipPathShape( + DrawTarget* aDrawTarget, const nsRect& aRefBox) { + const auto& shape = mClipPathStyle.AsShape()._0->AsPathOrShape().AsShape(); + + RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder( + shape.fill == StyleFillRule::Nonzero ? FillRule::FILL_WINDING + : FillRule::FILL_EVEN_ODD); + const nscoord appUnitsPerDevPixel = + mTargetFrame->PresContext()->AppUnitsPerDevPixel(); + const CSSSize basis = CSSSize::FromAppUnits(aRefBox.Size()); + const Point offset = + LayoutDevicePoint::FromAppUnits(aRefBox.TopLeft(), appUnitsPerDevPixel) + .ToUnknownPoint(); + const float scale = mTargetFrame->Style()->EffectiveZoom().Zoom( + float(AppUnitsPerCSSPixel()) / float(appUnitsPerDevPixel)); + return SVGPathData::BuildPath(shape.commands.AsSpan(), builder, + StyleStrokeLinecap::Butt, 0.0, basis, offset, + scale); } } // namespace mozilla |