--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -660,23 +660,20 @@ ValidateSVGFrame(nsIFrame* aFrame)
* aClipCtx, this function may clip that context by the visual overflow area
* of aFrame.
*
* @param aFrame is the target frame.
* @param aOffsetToBoundingBox returns the offset between the reference frame
* and the bounding box of aFrame.
* @oaram aOffsetToUserSpace returns the offset between the reference frame and
* the user space coordinate of aFrame.
- * @param aClipCtx indicate whether clip aParams.ctx by visual overflow rect of
- * aFrame or not.
*/
static void
SetupContextMatrix(nsIFrame* aFrame, const PaintFramesParams& aParams,
- nsPoint& aOffsetToBoundingBox, nsPoint& aOffsetToUserSpace,
- bool aClipCtx)
+ nsPoint& aOffsetToBoundingBox, nsPoint& aOffsetToUserSpace)
{
aOffsetToBoundingBox = aParams.builder->ToReferenceFrame(aFrame) -
nsSVGIntegrationUtils::GetOffsetToBoundingBox(aFrame);
if (!aFrame->IsFrameOfType(nsIFrame::eSVG)) {
/* Snap the offset if the reference frame is not a SVG frame,
* since other frames will be snapped to pixel when rendering. */
aOffsetToBoundingBox = nsPoint(
aFrame->PresContext()->RoundAppUnitsToNearestDevPixels(aOffsetToBoundingBox.x),
@@ -686,17 +683,17 @@ SetupContextMatrix(nsIFrame* aFrame, con
// After applying only "aOffsetToBoundingBox", aParams.ctx would have its
// origin at the top left corner of frame's bounding box (over all
// continuations).
// However, SVG painting needs the origin to be located at the origin of the
// SVG frame's "user space", i.e. the space in which, for example, the
// frame's BBox lives.
// SVG geometry frames and foreignObject frames apply their own offsets, so
// their position is relative to their user space. So for these frame types,
- // if we want aCtx to be in user space, we first need to subtract the
+ // if we want aParams.ctx to be in user space, we first need to subtract the
// frame's position so that SVG painting can later add it again and the
// frame is painted in the right place.
gfxPoint toUserSpaceGfx = nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(aFrame);
nsPoint toUserSpace =
nsPoint(nsPresContext::CSSPixelsToAppUnits(float(toUserSpaceGfx.x)),
nsPresContext::CSSPixelsToAppUnits(float(toUserSpaceGfx.y)));
@@ -708,24 +705,16 @@ SetupContextMatrix(nsIFrame* aFrame, con
"For non-SVG frames there shouldn't be any additional offset");
#endif
gfxPoint devPixelOffsetToUserSpace =
nsLayoutUtils::PointToGfxPoint(aOffsetToUserSpace,
aFrame->PresContext()->AppUnitsPerDevPixel());
gfxContext& context = aParams.ctx;
context.SetMatrix(context.CurrentMatrix().Translate(devPixelOffsetToUserSpace));
-
- if (aClipCtx) {
- nsRect clipRect =
- aParams.frame->GetVisualOverflowRectRelativeToSelf() + toUserSpace;
- context.Clip(NSRectToSnappedRect(clipRect,
- aFrame->PresContext()->AppUnitsPerDevPixel(),
- *context.GetDrawTarget()));
- }
}
bool
nsSVGIntegrationUtils::IsMaskResourceReady(nsIFrame* aFrame)
{
nsIFrame* firstFrame =
nsLayoutUtils::FirstContinuationOrIBSplitSibling(aFrame);
nsSVGEffects::EffectProperties effectProperties =
@@ -791,17 +780,17 @@ nsSVGIntegrationUtils::PaintMask(const P
SurfaceFormat::A8);
}
// Paint mask onto ctx.
if (maskUsage.shouldGenerateMaskLayer) {
matSR.SetContext(&ctx);
SetupContextMatrix(frame, aParams, offsetToBoundingBox,
- offsetToUserSpace, false);
+ offsetToUserSpace);
nsTArray<nsSVGMaskFrame *> maskFrames = effectProperties.GetMaskFrames();
bool opacityApplied = !HasNonSVGMask(maskFrames);
result = PaintMaskSurface(aParams, maskTarget,
opacityApplied ? maskUsage.opacity : 1.0,
firstFrame->StyleContext(), maskFrames,
ctx.CurrentMatrix(), offsetToUserSpace);
if (result != DrawResult::SUCCESS) {
return result;
@@ -809,17 +798,17 @@ nsSVGIntegrationUtils::PaintMask(const P
}
// Paint clip-path onto ctx.
if (maskUsage.shouldGenerateClipMaskLayer) {
matSR.Restore();
matSR.SetContext(&ctx);
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
- offsetToUserSpace, false);
+ offsetToUserSpace);
Matrix clipMaskTransform;
gfxMatrix cssPxToDevPxMatrix = GetCSSPxToDevPxMatrix(frame);
nsSVGClipPathFrame *clipPathFrame = effectProperties.GetClipPathFrame();
RefPtr<SourceSurface> maskSurface =
maskUsage.shouldGenerateMaskLayer ? maskTarget->Snapshot() : nullptr;
result =
clipPathFrame->PaintClipMask(ctx, frame, cssPxToDevPxMatrix,
@@ -898,17 +887,17 @@ nsSVGIntegrationUtils::PaintMaskAndClipP
if (maskUsage.shouldGenerateMaskLayer) {
matSR.SetContext(&context);
// For css-mask, we want to generate a mask for each continuation frame,
// so we setup context matrix by the position of the current frame,
// instead of the first continuation frame.
SetupContextMatrix(frame, aParams, offsetToBoundingBox,
- offsetToUserSpace, false);
+ offsetToUserSpace);
MaskPaintResult paintResult =
CreateAndPaintMaskSurface(aParams, maskUsage.opacity,
firstFrame->StyleContext(),
maskFrames, offsetToUserSpace);
if (paintResult.transparentBlackMask) {
return paintResult.result;
}
@@ -923,17 +912,17 @@ nsSVGIntegrationUtils::PaintMaskAndClipP
}
}
if (maskUsage.shouldGenerateClipMaskLayer) {
matSR.Restore();
matSR.SetContext(&context);
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
- offsetToUserSpace, false);
+ offsetToUserSpace);
Matrix clipMaskTransform;
DrawResult clipMaskResult;
RefPtr<SourceSurface> clipMaskSurface;
Tie(clipMaskResult, clipMaskSurface) =
clipPathFrame->GetClipMask(context, frame, cssPxToDevPxMatrix,
&clipMaskTransform, maskSurface,
maskTransform);
@@ -951,17 +940,17 @@ nsSVGIntegrationUtils::PaintMaskAndClipP
// opacity != 1.0f.
if (!maskUsage.shouldGenerateClipMaskLayer &&
!maskUsage.shouldGenerateMaskLayer) {
MOZ_ASSERT(maskUsage.opacity != 1.0f);
matSR.SetContext(&context);
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
- offsetToUserSpace, false);
+ offsetToUserSpace);
shouldPushMask = true;
}
if (shouldPushMask) {
if (aParams.layerManager->GetRoot()->GetContentFlags() &
Layer::CONTENT_COMPONENT_ALPHA) {
context.PushGroupAndCopyBackground(gfxContentType::COLOR_ALPHA,
opacityApplied
@@ -978,17 +967,17 @@ nsSVGIntegrationUtils::PaintMaskAndClipP
/* If this frame has only a trivial clipPath, set up cairo's clipping now so
* we can just do normal painting and get it clipped appropriately.
*/
if (maskUsage.shouldApplyClipPath || maskUsage.shouldApplyBasicShape) {
gfxContextMatrixAutoSaveRestore matSR(&context);
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
- offsetToUserSpace, false);
+ offsetToUserSpace);
MOZ_ASSERT(!maskUsage.shouldApplyClipPath ||
!maskUsage.shouldApplyBasicShape);
if (maskUsage.shouldApplyClipPath) {
clipPathFrame->ApplyClipPath(context, frame, cssPxToDevPxMatrix);
} else {
nsCSSClipPathInstance::ApplyBasicShapeClip(context, frame);
}
@@ -1056,17 +1045,17 @@ nsSVGIntegrationUtils::PaintFilter(const
}
gfxContext& context = aParams.ctx;
nsPoint offsetToBoundingBox;
nsPoint offsetToUserSpace;
gfxContextAutoSaveRestore autoSR(&context);
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
- offsetToUserSpace, true);
+ offsetToUserSpace);
if (opacity != 1.0f) {
context.PushGroupForBlendBack(gfxContentType::COLOR_ALPHA, opacity,
nullptr, Matrix());
}
/* Paint the child and apply filters */
RegularFramePaintCallback callback(aParams.builder, aParams.layerManager,