forked from mirrors/gecko-dev
Bug 1864039 - clip-path path reference box is incorrect with stroke r=boris
Differential Revision: https://phabricator.services.mozilla.com/D193643
This commit is contained in:
parent
6e4a680240
commit
1b18e7f21f
5 changed files with 19 additions and 19 deletions
|
|
@ -582,7 +582,8 @@ already_AddRefed<Path> SVGPathData::BuildPathForMeasuring(
|
||||||
/* static */
|
/* static */
|
||||||
already_AddRefed<Path> SVGPathData::BuildPath(
|
already_AddRefed<Path> SVGPathData::BuildPath(
|
||||||
Span<const StylePathCommand> aPath, PathBuilder* aBuilder,
|
Span<const StylePathCommand> aPath, PathBuilder* aBuilder,
|
||||||
StyleStrokeLinecap aStrokeLineCap, Float aStrokeWidth, float aZoomFactor) {
|
StyleStrokeLinecap aStrokeLineCap, Float aStrokeWidth, const Point& aOffset,
|
||||||
|
float aZoomFactor) {
|
||||||
if (aPath.IsEmpty() || !aPath[0].IsMoveTo()) {
|
if (aPath.IsEmpty() || !aPath[0].IsMoveTo()) {
|
||||||
return nullptr; // paths without an initial moveto are invalid
|
return nullptr; // paths without an initial moveto are invalid
|
||||||
}
|
}
|
||||||
|
|
@ -599,8 +600,8 @@ already_AddRefed<Path> SVGPathData::BuildPath(
|
||||||
Point cp1, cp2; // previous bezier's control points
|
Point cp1, cp2; // previous bezier's control points
|
||||||
Point tcp1, tcp2; // temporaries
|
Point tcp1, tcp2; // temporaries
|
||||||
|
|
||||||
auto scale = [aZoomFactor](const Point& p) {
|
auto scale = [aOffset, aZoomFactor](const Point& p) {
|
||||||
return Point(p.x * aZoomFactor, p.y * aZoomFactor);
|
return Point(p.x * aZoomFactor, p.y * aZoomFactor) + aOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Regarding cp1 and cp2: If the previous segment was a cubic bezier curve,
|
// Regarding cp1 and cp2: If the previous segment was a cubic bezier curve,
|
||||||
|
|
|
||||||
|
|
@ -194,11 +194,10 @@ class SVGPathData {
|
||||||
* which is generated by cbindgen from Rust (see ServoStyleConsts.h).
|
* which is generated by cbindgen from Rust (see ServoStyleConsts.h).
|
||||||
* Basically, this is a variant of the above BuildPath() functions.
|
* Basically, this is a variant of the above BuildPath() functions.
|
||||||
*/
|
*/
|
||||||
static already_AddRefed<Path> BuildPath(Span<const StylePathCommand> aPath,
|
static already_AddRefed<Path> BuildPath(
|
||||||
PathBuilder* aBuilder,
|
Span<const StylePathCommand> aPath, PathBuilder* aBuilder,
|
||||||
StyleStrokeLinecap aStrokeLineCap,
|
StyleStrokeLinecap aStrokeLineCap, Float aStrokeWidth,
|
||||||
Float aStrokeWidth,
|
const gfx::Point& aOffset = gfx::Point(), float aZoomFactor = 1.0);
|
||||||
float aZoomFactor = 1.0);
|
|
||||||
|
|
||||||
const_iterator begin() const { return mData.Elements(); }
|
const_iterator begin() const { return mData.Elements(); }
|
||||||
const_iterator end() const { return mData.Elements() + mData.Length(); }
|
const_iterator end() const { return mData.Elements() + mData.Length(); }
|
||||||
|
|
|
||||||
|
|
@ -86,10 +86,6 @@ Maybe<Rect> CSSClipPathInstance::GetBoundingRectForBasicShapeOrPathClip(
|
||||||
|
|
||||||
already_AddRefed<Path> CSSClipPathInstance::CreateClipPath(
|
already_AddRefed<Path> CSSClipPathInstance::CreateClipPath(
|
||||||
DrawTarget* aDrawTarget, const gfxMatrix& aTransform) {
|
DrawTarget* aDrawTarget, const gfxMatrix& aTransform) {
|
||||||
if (mClipPathStyle.IsShape() && mClipPathStyle.AsShape()._0->IsPath()) {
|
|
||||||
return CreateClipPathPath(aDrawTarget);
|
|
||||||
}
|
|
||||||
|
|
||||||
nscoord appUnitsPerDevPixel =
|
nscoord appUnitsPerDevPixel =
|
||||||
mTargetFrame->PresContext()->AppUnitsPerDevPixel();
|
mTargetFrame->PresContext()->AppUnitsPerDevPixel();
|
||||||
|
|
||||||
|
|
@ -125,6 +121,8 @@ already_AddRefed<Path> CSSClipPathInstance::CreateClipPath(
|
||||||
return CreateClipPathPolygon(aDrawTarget, r);
|
return CreateClipPathPolygon(aDrawTarget, r);
|
||||||
case StyleBasicShape::Tag::Rect:
|
case StyleBasicShape::Tag::Rect:
|
||||||
return CreateClipPathInset(aDrawTarget, r);
|
return CreateClipPathInset(aDrawTarget, r);
|
||||||
|
case StyleBasicShape::Tag::Path:
|
||||||
|
return CreateClipPathPath(aDrawTarget, r);
|
||||||
default:
|
default:
|
||||||
MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Unexpected shape type");
|
MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Unexpected shape type");
|
||||||
}
|
}
|
||||||
|
|
@ -176,16 +174,19 @@ already_AddRefed<Path> CSSClipPathInstance::CreateClipPathInset(
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<Path> CSSClipPathInstance::CreateClipPathPath(
|
already_AddRefed<Path> CSSClipPathInstance::CreateClipPathPath(
|
||||||
DrawTarget* aDrawTarget) {
|
DrawTarget* aDrawTarget, const nsRect& aRefBox) {
|
||||||
const auto& path = mClipPathStyle.AsShape()._0->AsPath();
|
const auto& path = mClipPathStyle.AsShape()._0->AsPath();
|
||||||
|
|
||||||
RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder(
|
RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder(
|
||||||
path.fill == StyleFillRule::Nonzero ? FillRule::FILL_WINDING
|
path.fill == StyleFillRule::Nonzero ? FillRule::FILL_WINDING
|
||||||
: FillRule::FILL_EVEN_ODD);
|
: FillRule::FILL_EVEN_ODD);
|
||||||
float scale = float(AppUnitsPerCSSPixel()) /
|
nscoord appUnitsPerDevPixel =
|
||||||
mTargetFrame->PresContext()->AppUnitsPerDevPixel();
|
mTargetFrame->PresContext()->AppUnitsPerDevPixel();
|
||||||
|
float scale = float(AppUnitsPerCSSPixel()) / appUnitsPerDevPixel;
|
||||||
|
Point offset = Point(aRefBox.x, aRefBox.y) / appUnitsPerDevPixel;
|
||||||
|
|
||||||
return SVGPathData::BuildPath(path.path._0.AsSpan(), builder,
|
return SVGPathData::BuildPath(path.path._0.AsSpan(), builder,
|
||||||
StyleStrokeLinecap::Butt, 0.0, scale);
|
StyleStrokeLinecap::Butt, 0.0, offset, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,8 @@ class MOZ_STACK_CLASS CSSClipPathInstance {
|
||||||
already_AddRefed<Path> CreateClipPathInset(DrawTarget* aDrawTarget,
|
already_AddRefed<Path> CreateClipPathInset(DrawTarget* aDrawTarget,
|
||||||
const nsRect& aRefBox);
|
const nsRect& aRefBox);
|
||||||
|
|
||||||
already_AddRefed<Path> CreateClipPathPath(DrawTarget* aDrawTarget);
|
already_AddRefed<Path> CreateClipPathPath(DrawTarget* aDrawTarget,
|
||||||
|
const nsRect& aRefBox);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The frame for the element that is currently being clipped.
|
* The frame for the element that is currently being clipped.
|
||||||
|
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
[clip-path-path-003.html]
|
|
||||||
expected: FAIL
|
|
||||||
Loading…
Reference in a new issue