From 5eeefa16c75ad95b3c2f3478a9f04170d8ab4c05 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Thu, 28 May 2015 15:51:58 -0400 Subject: [PATCH] Bug 1153845 - For CSS filters, make the primitive subregions big enough to contain the whole pre-filter visual overflow rect. r=roc The BBox of the SVG element only includes its contents, not the SVG element's background color. --- layout/reftests/bugs/1153845-1-ref.html | 16 ++++++++++++++++ layout/reftests/bugs/1153845-1.html | 17 +++++++++++++++++ layout/reftests/bugs/reftest.list | 1 + layout/svg/nsCSSFilterInstance.cpp | 6 +++--- layout/svg/nsCSSFilterInstance.h | 12 ++++++------ layout/svg/nsFilterInstance.cpp | 22 +++++++++++----------- 6 files changed, 54 insertions(+), 20 deletions(-) create mode 100644 layout/reftests/bugs/1153845-1-ref.html create mode 100644 layout/reftests/bugs/1153845-1.html diff --git a/layout/reftests/bugs/1153845-1-ref.html b/layout/reftests/bugs/1153845-1-ref.html new file mode 100644 index 000000000000..fcf6221c95fe --- /dev/null +++ b/layout/reftests/bugs/1153845-1-ref.html @@ -0,0 +1,16 @@ + + + +There should be a 200x200 lime square on this page. + + + + diff --git a/layout/reftests/bugs/1153845-1.html b/layout/reftests/bugs/1153845-1.html new file mode 100644 index 000000000000..aeacbe08fc6e --- /dev/null +++ b/layout/reftests/bugs/1153845-1.html @@ -0,0 +1,17 @@ + + + +There should be a 200x200 lime square on this page. + + + + diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index 96b8fe638fd0..d5e4badb8264 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1923,4 +1923,5 @@ skip-if(!asyncPanZoom) fuzzy-if(B2G,101,887) == 1133905-6-vh-rtl.html 1133905-re skip-if(B2G||Mulet) == 1150021-1.xul 1150021-1-ref.xul == 1151145-1.html 1151145-1-ref.html == 1151306-1.html 1151306-1-ref.html +== 1153845-1.html 1153845-1-ref.html == 1156129-1.html 1156129-1-ref.html diff --git a/layout/svg/nsCSSFilterInstance.cpp b/layout/svg/nsCSSFilterInstance.cpp index 37c3ef238133..f118264f56b5 100644 --- a/layout/svg/nsCSSFilterInstance.cpp +++ b/layout/svg/nsCSSFilterInstance.cpp @@ -30,11 +30,11 @@ static float ClampFactor(float aFactor) nsCSSFilterInstance::nsCSSFilterInstance(const nsStyleFilter& aFilter, nscolor aShadowFallbackColor, - const nsIntRect& aTargetBBoxInFilterSpace, + const nsIntRect& aTargetBoundsInFilterSpace, const gfxMatrix& aFrameSpaceInCSSPxToFilterSpaceTransform) : mFilter(aFilter) , mShadowFallbackColor(aShadowFallbackColor) - , mTargetBBoxInFilterSpace(aTargetBBoxInFilterSpace) + , mTargetBoundsInFilterSpace(aTargetBoundsInFilterSpace) , mFrameSpaceInCSSPxToFilterSpaceTransform(aFrameSpaceInCSSPxToFilterSpaceTransform) { } @@ -385,7 +385,7 @@ nsCSSFilterInstance::SetBounds(FilterPrimitiveDescription& aDescr, { int32_t inputIndex = GetLastResultIndex(aPrimitiveDescrs); nsIntRect inputBounds = (inputIndex < 0) ? - mTargetBBoxInFilterSpace : aPrimitiveDescrs[inputIndex].PrimitiveSubregion(); + mTargetBoundsInFilterSpace : aPrimitiveDescrs[inputIndex].PrimitiveSubregion(); nsTArray inputExtents; inputExtents.AppendElement(inputBounds); diff --git a/layout/svg/nsCSSFilterInstance.h b/layout/svg/nsCSSFilterInstance.h index 5d60eb3e77ae..3f139fbf8d0f 100644 --- a/layout/svg/nsCSSFilterInstance.h +++ b/layout/svg/nsCSSFilterInstance.h @@ -36,14 +36,14 @@ public: * aFilter during the lifetime of nsCSSFilterInstance. * @param aShadowFallbackColor The color that should be used for * drop-shadow() filters that don't specify a shadow color. - * @param aTargetBBoxInFilterSpace The frame of element being filtered, in - * filter space. + * @param aTargetBoundsInFilterSpace The pre-filter visual overflow rect of + * the frame being filtered, in filter space. * @param aFrameSpaceInCSSPxToFilterSpaceTransform The transformation from * the filtered element's frame space in CSS pixels to filter space. */ nsCSSFilterInstance(const nsStyleFilter& aFilter, nscolor aShadowFallbackColor, - const nsIntRect& aTargetBBoxInFilterSpace, + const nsIntRect& aTargetBoundsInFilterSpace, const gfxMatrix& aFrameSpaceInCSSPxToFilterSpaceTransform); /** @@ -119,10 +119,10 @@ private: nscolor mShadowFallbackColor; /** - * The bounding box of the element being filtered, in filter space. Used for - * input bounds if this CSS filter is the first in the filter chain. + * The pre-filter overflow rect of the frame being filtered, in filter space. + * Used for input bounds if this CSS filter is the first in the filter chain. */ - nsIntRect mTargetBBoxInFilterSpace; + nsIntRect mTargetBoundsInFilterSpace; /** * The transformation from the filtered element's frame space in CSS pixels to diff --git a/layout/svg/nsFilterInstance.cpp b/layout/svg/nsFilterInstance.cpp index ede860b8a487..d276816b1f31 100644 --- a/layout/svg/nsFilterInstance.cpp +++ b/layout/svg/nsFilterInstance.cpp @@ -202,6 +202,16 @@ nsFilterInstance::nsFilterInstance(nsIFrame *aTargetFrame, mFilterSpaceToFrameSpaceInCSSPxTransform; mFrameSpaceInCSSPxToFilterSpaceTransform.Invert(); + nsIntRect targetBounds; + if (aPreFilterVisualOverflowRectOverride) { + targetBounds = + FrameSpaceToFilterSpace(aPreFilterVisualOverflowRectOverride); + } else if (mTargetFrame) { + nsRect preFilterVOR = mTargetFrame->GetPreEffectsVisualOverflowRect(); + targetBounds = FrameSpaceToFilterSpace(&preFilterVOR); + } + mTargetBounds.UnionRect(mTargetBBoxInFilterSpace, targetBounds); + // Build the filter graph. rv = BuildPrimitives(aFilterChain); if (NS_FAILED(rv)) { @@ -217,16 +227,6 @@ nsFilterInstance::nsFilterInstance(nsIFrame *aTargetFrame, mPostFilterDirtyRegion = FrameSpaceToFilterSpace(aPostFilterDirtyRegion); mPreFilterDirtyRegion = FrameSpaceToFilterSpace(aPreFilterDirtyRegion); - nsIntRect targetBounds; - if (aPreFilterVisualOverflowRectOverride) { - targetBounds = - FrameSpaceToFilterSpace(aPreFilterVisualOverflowRectOverride); - } else if (mTargetFrame) { - nsRect preFilterVOR = mTargetFrame->GetPreEffectsVisualOverflowRect(); - targetBounds = FrameSpaceToFilterSpace(&preFilterVOR); - } - mTargetBounds.UnionRect(mTargetBBoxInFilterSpace, targetBounds); - mInitialized = true; } @@ -318,7 +318,7 @@ nsFilterInstance::BuildPrimitivesForFilter(const nsStyleFilter& aFilter) mTargetFrame ? mTargetFrame->StyleColor()->mColor : NS_RGB(0,0,0); nsCSSFilterInstance cssFilterInstance(aFilter, shadowFallbackColor, - mTargetBBoxInFilterSpace, + mTargetBounds, mFrameSpaceInCSSPxToFilterSpaceTransform); return cssFilterInstance.BuildPrimitives(mPrimitiveDescriptions); }