Bug 1388985 - Use GetBBox to calcute the area of frame(s) that clip-path basic-shape should apply to. r?cjku
MozReview-Commit-ID: 4pJnxSy6GQO
--- a/layout/svg/nsCSSClipPathInstance.cpp
+++ b/layout/svg/nsCSSClipPathInstance.cpp
@@ -36,17 +36,17 @@ nsCSSClipPathInstance::ApplyBasicShapeCl
MOZ_ASSERT(type == StyleShapeSourceType::Shape ||
type == StyleShapeSourceType::Box,
"This function is used with basic-shape and geometry-box only.");
#endif
nsCSSClipPathInstance instance(aFrame, clipPathStyle);
aContext.NewPath();
- RefPtr<Path> path = instance.CreateClipPath(aContext.GetDrawTarget());
+ RefPtr<Path> path = instance.CreateClipPath(aContext.GetDrawTarget(), aFrame);
aContext.SetPath(path);
aContext.Clip();
}
/* static*/ bool
nsCSSClipPathInstance::HitTestBasicShapeClip(nsIFrame* aFrame,
const gfxPoint& aPoint)
{
@@ -58,28 +58,37 @@ nsCSSClipPathInstance::HitTestBasicShape
if (type == StyleShapeSourceType::URL) {
return false;
}
nsCSSClipPathInstance instance(aFrame, clipPathStyle);
RefPtr<DrawTarget> drawTarget =
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
- RefPtr<Path> path = instance.CreateClipPath(drawTarget);
+ RefPtr<Path> path = instance.CreateClipPath(drawTarget, aFrame);
float pixelRatio = float(nsPresContext::AppUnitsPerCSSPixel()) /
aFrame->PresContext()->AppUnitsPerDevPixel();
return path->ContainsPoint(ToPoint(aPoint) * pixelRatio, Matrix());
}
already_AddRefed<Path>
-nsCSSClipPathInstance::CreateClipPath(DrawTarget* aDrawTarget)
+nsCSSClipPathInstance::CreateClipPath(DrawTarget* aDrawTarget, nsIFrame* aFrame)
{
+/*
nsRect r =
nsLayoutUtils::ComputeGeometryBox(mTargetFrame,
mClipPathStyle.GetReferenceBox());
+*/
+ uint32_t flags =
+ (aFrame->StyleBorder()->mBoxDecorationBreak == StyleBoxDecorationBreak::Clone)
+ ? nsSVGUtils::eBBoxIncludeFillGeometry |
+ nsSVGUtils::eIncludeOnlyCurrentFrameForNonSVGElement
+ : nsSVGUtils::eBBoxIncludeFillGeometry;
+ gfxRect bbox = nsSVGUtils::GetBBox(aFrame, flags);
+ nsRect r = nsLayoutUtils::RoundGfxRectToAppRect(bbox, AppUnitsPerCSSPixel());
if (mClipPathStyle.GetType() != StyleShapeSourceType::Shape) {
// TODO Clip to border-radius/reference box if no shape
// was specified.
RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
return builder->Finish();
}
--- a/layout/svg/nsCSSClipPathInstance.h
+++ b/layout/svg/nsCSSClipPathInstance.h
@@ -29,17 +29,18 @@ public:
private:
explicit nsCSSClipPathInstance(nsIFrame* aFrame,
const StyleShapeSource aClipPathStyle)
: mTargetFrame(aFrame)
, mClipPathStyle(aClipPathStyle)
{
}
- already_AddRefed<Path> CreateClipPath(DrawTarget* aDrawTarget);
+ already_AddRefed<Path> CreateClipPath(DrawTarget* aDrawTarget,
+ nsIFrame* aFrame);
already_AddRefed<Path> CreateClipPathCircle(DrawTarget* aDrawTarget,
const nsRect& aRefBox);
already_AddRefed<Path> CreateClipPathEllipse(DrawTarget* aDrawTarget,
const nsRect& aRefBox);
already_AddRefed<Path> CreateClipPathPolygon(DrawTarget* aDrawTarget,