diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index c014e90bbe66..305f34147833 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -3006,12 +3006,13 @@ nsRect nsCSSRendering::GetBackgroundLayerRect(nsPresContext* aPresContext, nsIFrame* aForFrame, const nsRect& aBorderArea, + const nsRect& aClipRect, const nsStyleBackground& aBackground, const nsStyleBackground::Layer& aLayer) { nsBackgroundLayerState state = PrepareBackgroundLayer(aPresContext, aForFrame, 0, aBorderArea, - aBorderArea, aBackground, aLayer); + aClipRect, aBackground, aLayer); return state.mFillArea; } diff --git a/layout/base/nsCSSRendering.h b/layout/base/nsCSSRendering.h index 568e41e43a30..2059b128afd4 100644 --- a/layout/base/nsCSSRendering.h +++ b/layout/base/nsCSSRendering.h @@ -390,6 +390,7 @@ struct nsCSSRendering { static nsRect GetBackgroundLayerRect(nsPresContext* aPresContext, nsIFrame* aForFrame, const nsRect& aBorderArea, + const nsRect& aClipRect, const nsStyleBackground& aBackground, const nsStyleBackground::Layer& aLayer); diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 6e4d05c67885..066c0c6107f4 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -2010,11 +2010,8 @@ nsDisplayBackgroundImage::GetOpaqueRegion(nsDisplayListBuilder* aBuilder, (!mFrame->GetPrevContinuation() && !mFrame->GetNextContinuation())) { const nsStyleBackground::Layer& layer = mBackgroundStyle->mLayers[mLayer]; if (layer.mImage.IsOpaque()) { - nsRect borderBox = nsRect(ToReferenceFrame(), mFrame->GetSize()); nsPresContext* presContext = mFrame->PresContext(); - nsRect r = nsCSSRendering::GetBackgroundLayerRect(presContext, mFrame, - borderBox, *mBackgroundStyle, layer); - result = GetInsideClipRegion(this, presContext, layer.mClip, r, aSnap); + result = GetInsideClipRegion(this, presContext, layer.mClip, mBounds, aSnap); } } @@ -2193,9 +2190,14 @@ nsDisplayBackgroundImage::GetBoundsInternal() { } nsRect borderBox = nsRect(ToReferenceFrame(), mFrame->GetSize()); + nsRect clipRect = borderBox; + if (mFrame->GetType() == nsGkAtoms::canvasFrame) { + nsCanvasFrame* frame = static_cast(mFrame); + clipRect = frame->CanvasArea() + ToReferenceFrame(); + } const nsStyleBackground::Layer& layer = mBackgroundStyle->mLayers[mLayer]; return nsCSSRendering::GetBackgroundLayerRect(presContext, mFrame, - borderBox, *mBackgroundStyle, layer); + borderBox, clipRect, *mBackgroundStyle, layer); } uint32_t diff --git a/layout/reftests/bugs/836844-1-ref.html b/layout/reftests/bugs/836844-1-ref.html new file mode 100644 index 000000000000..bd3c54ee0149 --- /dev/null +++ b/layout/reftests/bugs/836844-1-ref.html @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/layout/reftests/bugs/836844-1.html b/layout/reftests/bugs/836844-1.html new file mode 100644 index 000000000000..28ed17c628b7 --- /dev/null +++ b/layout/reftests/bugs/836844-1.html @@ -0,0 +1,22 @@ + + + + + + + +
+ + + diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index 97747f3e4d2f..9ead44bc9520 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1743,3 +1743,4 @@ skip-if(B2G) == 818276-1.html 818276-1-ref.html == 827577-1a.html 827577-1-ref.html == 827577-1b.html 827577-1-ref.html == 827799-1.html about:blank +== 836844-1.html 836844-1-ref.html