diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 360483c85475..e95dbdc04183 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -1570,13 +1570,13 @@ struct CSSMaskLayerUserData : public LayerUserData : mImageLayers(nsStyleImageLayers::LayerType::Mask) { } - CSSMaskLayerUserData(nsIFrame* aFrame, const nsRect& aBound) + CSSMaskLayerUserData(nsIFrame* aFrame, const nsIntRect& aBounds) : mImageLayers(aFrame->StyleSVGReset()->mMask), mContentRect(aFrame->GetContentRectRelativeToSelf()), mPaddingRect(aFrame->GetPaddingRectRelativeToSelf()), mBorderRect(aFrame->GetRectRelativeToSelf()), mMarginRect(aFrame->GetMarginRectRelativeToSelf()), - mBounds(aBound) + mBounds(aBounds) { Hash(aFrame); } @@ -1650,7 +1650,7 @@ private: nsRect mBorderRect; nsRect mMarginRect; - nsRect mBounds; + nsIntRect mBounds; uint32_t mHash; }; @@ -3914,26 +3914,22 @@ ContainerState::SetupMaskLayerForCSSMask(Layer* aLayer, bool snap; nsRect bounds = aMaskItem->GetBounds(mBuilder, &snap); - CSSMaskLayerUserData newUserData(aMaskItem->Frame(), bounds); + nsIntRect itemRect = ScaleToOutsidePixels(bounds, snap); + CSSMaskLayerUserData newUserData(aMaskItem->Frame(), itemRect); if (*oldUserData == newUserData) { aLayer->SetMaskLayer(maskLayer); return; } - const nsIFrame* frame = aMaskItem->Frame(); - int32_t A2D = frame->PresContext()->AppUnitsPerDevPixel(); - Rect devBounds = NSRectToRect(bounds, A2D); - uint32_t maxSize = mManager->GetMaxTextureSize(); - gfx::Size surfaceSize(std::min(devBounds.Width(), maxSize), - std::min(devBounds.Height(), maxSize)); - IntSize surfaceSizeInt(NSToIntCeil(surfaceSize.width), - NSToIntCeil(surfaceSize.height)); + int32_t maxSize = mManager->GetMaxTextureSize(); + IntSize surfaceSize(std::min(itemRect.width, maxSize), + std::min(itemRect.height, maxSize)); - if (surfaceSizeInt.IsEmpty()) { + if (surfaceSize.IsEmpty()) { return; } - MaskImageData imageData(surfaceSizeInt, mManager); + MaskImageData imageData(surfaceSize, mManager); RefPtr dt = imageData.CreateDrawTarget(); if (!dt || !dt->IsValid()) { NS_WARNING("Could not create DrawTarget for mask layer."); @@ -3941,8 +3937,8 @@ ContainerState::SetupMaskLayerForCSSMask(Layer* aLayer, } RefPtr maskCtx = gfxContext::CreateOrNull(dt); - gfxPoint offset = nsLayoutUtils::PointToGfxPoint(bounds.TopLeft(), A2D); - maskCtx->SetMatrix(gfxMatrix::Translation(-offset)); + maskCtx->SetMatrix(gfxMatrix::Translation(-itemRect.TopLeft())); + maskCtx->Multiply(gfxMatrix::Scaling(mParameters.mXScale, mParameters.mYScale)); if (!aMaskItem->PaintMask(mBuilder, maskCtx)) { // Mostly because of mask resource is not ready. @@ -3951,9 +3947,8 @@ ContainerState::SetupMaskLayerForCSSMask(Layer* aLayer, // Setup mask layer offset. Matrix4x4 matrix; - matrix.PreTranslate(offset.x, offset.y, 0); + matrix.PreTranslate(itemRect.x, itemRect.y, 0); matrix.PreTranslate(mParameters.mOffset.x, mParameters.mOffset.y, 0); - matrix.PreScale(mParameters.mXScale, mParameters.mYScale, 1.0); maskLayer->SetBaseTransform(matrix); diff --git a/layout/reftests/bugs/1316719-1-ref.html b/layout/reftests/bugs/1316719-1-ref.html new file mode 100644 index 000000000000..13078e112a98 --- /dev/null +++ b/layout/reftests/bugs/1316719-1-ref.html @@ -0,0 +1,19 @@ + + +reference: 0.8 opacity green circle + + +
diff --git a/layout/reftests/bugs/1316719-1a.html b/layout/reftests/bugs/1316719-1a.html new file mode 100644 index 000000000000..eaefed654ab7 --- /dev/null +++ b/layout/reftests/bugs/1316719-1a.html @@ -0,0 +1,42 @@ + + +mask-image with scale transform + + +
+
+
+
+
+
+
diff --git a/layout/reftests/bugs/1316719-1b.html b/layout/reftests/bugs/1316719-1b.html new file mode 100644 index 000000000000..b6e056e86bde --- /dev/null +++ b/layout/reftests/bugs/1316719-1b.html @@ -0,0 +1,35 @@ + + +mask-image with scale transform + + +
+
+
+
+
diff --git a/layout/reftests/bugs/1316719-1c.html b/layout/reftests/bugs/1316719-1c.html new file mode 100644 index 000000000000..32d00265e1f1 --- /dev/null +++ b/layout/reftests/bugs/1316719-1c.html @@ -0,0 +1,29 @@ + + +mask-image with scale transform + + +
+
+
diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index cefd3b22b4e4..fdf408f8d97a 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1974,6 +1974,9 @@ fuzzy(8,1900) == 1291528.html 1291528-ref.html # background color. fuzzy(255,1000) skip-if(!cocoaWidget) == 1294102-1.html 1294102-1-ref.html == 1315632-1.html 1315632-1-ref.html +fuzzy(2,40000) == 1316719-1a.html 1316719-1-ref.html +fuzzy(2,40000) == 1316719-1b.html 1316719-1-ref.html +fuzzy(2,40000) == 1316719-1c.html 1316719-1-ref.html HTTP == 652991-1a.html 652991-1-ref.html HTTP == 652991-1b.html 652991-1-ref.html