Bug 1342302 - Part 2. Implement ImageLayerClipState::IsValid.
MozReview-Commit-ID: 2Axr7buX1c4
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -1984,25 +1984,42 @@ ComputeBoxValue(nsIFrame* aForFrame, Sty
if (IsHTMLStyleGeometryBox(aBox)) {
return StyleGeometryBox::Fill;
}
}
return aBox;
}
+bool
+nsCSSRendering::ImageLayerClipState::IsValid() const
+{
+ // mDirtyRectGfx comes from mDirtyRect. If mDirtyRectGfx is not empty,
+ // mDirtyRect can never be empty.
+ if (!mDirtyRectGfx.IsEmpty() && mDirtyRect.IsEmpty()) {
+ return false;
+ }
+
+ if (mHasRoundedCorners == mClippedRadii.IsEmpty()) {
+ return false;
+ }
+
+ return true;
+}
+
/* static */ void
nsCSSRendering::GetImageLayerClip(const nsStyleImageLayers::Layer& aLayer,
nsIFrame* aForFrame, const nsStyleBorder& aBorder,
const nsRect& aBorderArea, const nsRect& aCallerDirtyRect,
bool aWillPaintBorder, nscoord aAppUnitsPerPixel,
/* out */ ImageLayerClipState* aClipState)
{
aClipState->mHasRoundedCorners = false;
aClipState->mHasAdditionalBGClipArea = false;
+ aClipState->mAdditionalBGClipArea.SetEmpty();
aClipState->mCustomClip = false;
StyleGeometryBox layerClip = ComputeBoxValue(aForFrame, aLayer.mClip);
if (IsSVGStyleGeometryBox(layerClip)) {
MOZ_ASSERT(aForFrame->IsFrameOfType(nsIFrame::eSVG) &&
(aForFrame->GetType() != nsGkAtoms::svgOuterSVGFrame));
// The coordinate space of clipArea is svg user space.
@@ -2023,25 +2040,27 @@ nsCSSRendering::GetImageLayerClip(const
// coordiante space with aBorderArea. So we evaluate the position of clip
// area base on the position of aBorderArea here.
aClipState->mBGClipArea =
clipAreaRelativeToStrokeBox + aBorderArea.TopLeft();
SetupDirtyRects(aClipState->mBGClipArea, aCallerDirtyRect,
aAppUnitsPerPixel, &aClipState->mDirtyRect,
&aClipState->mDirtyRectGfx);
+ MOZ_ASSERT(aClipState->IsValid());
return;
}
if (layerClip == StyleGeometryBox::NoClip) {
aClipState->mBGClipArea = aCallerDirtyRect;
SetupDirtyRects(aClipState->mBGClipArea, aCallerDirtyRect,
aAppUnitsPerPixel, &aClipState->mDirtyRect,
&aClipState->mDirtyRectGfx);
+ MOZ_ASSERT(aClipState->IsValid());
return;
}
MOZ_ASSERT(!aForFrame->IsFrameOfType(nsIFrame::eSVG) ||
aForFrame->GetType() == nsGkAtoms::svgOuterSVGFrame);
// Compute the outermost boundary of the area that might be painted.
// Same coordinate space as aBorderArea.
@@ -2140,16 +2159,18 @@ nsCSSRendering::GetImageLayerClip(const
// Do the intersection here to account for the fast path(?) below.
aClipState->mBGClipArea =
aClipState->mBGClipArea.Intersect(aClipState->mAdditionalBGClipArea);
aClipState->mHasAdditionalBGClipArea = false;
}
SetupDirtyRects(aClipState->mBGClipArea, aCallerDirtyRect, aAppUnitsPerPixel,
&aClipState->mDirtyRect, &aClipState->mDirtyRectGfx);
+
+ MOZ_ASSERT(aClipState->IsValid());
}
static void
SetupImageLayerClip(nsCSSRendering::ImageLayerClipState& aClipState,
gfxContext *aCtx, nscoord aAppUnitsPerPixel,
gfxContextAutoSaveRestore* aAutoSR)
{
if (aClipState.mDirtyRectGfx.IsEmpty()) {
--- a/layout/painting/nsCSSRendering.h
+++ b/layout/painting/nsCSSRendering.h
@@ -612,16 +612,18 @@ struct nsCSSRendering {
ImageLayerClipState()
: mHasRoundedCorners(false),
mHasAdditionalBGClipArea(false),
mCustomClip(false)
{
memset(mRadii, 0, sizeof(nscoord) * 8);
}
+
+ bool IsValid() const;
};
static void
GetImageLayerClip(const nsStyleImageLayers::Layer& aLayer,
nsIFrame* aForFrame, const nsStyleBorder& aBorder,
const nsRect& aBorderArea, const nsRect& aCallerDirtyRect,
bool aWillPaintBorder, nscoord aAppUnitsPerPixel,
/* out */ ImageLayerClipState* aClipState);