Filters need to affect visual overflow
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Dec 2011 18:01:09 +0000 (18:01 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Dec 2011 18:01:09 +0000 (18:01 +0000)
commit60a913b52d66936521f68d049b65c73bbb76ca94
tree86e4ce7c45a410c96565f70641be911cd797f54b
parent92f91e2f0c5a1d6a8ab701d0e6b3eed00e5315b0
Filters need to affect visual overflow
https://bugs.webkit.org/show_bug.cgi?id=71930

Source/WebCore:

Reviewed by Simon Fraser.

Make sure filters are included in visual overflow.
Add a new method to calculate the expansion of overflow
region given a list of FilterOperations. This is a slight
duplication of code from the rendering path, but is needed
because overflow is calculated before the FilterEffect
chain is built.

Also, filters were always rendered into their
input rectangle which was wrong for any effect
that produced a different sized result - drop-shadow
and blur. This required two changes. First, FilterEffect
needed a flag to decide whether or not to clip
output to primitive regions (as required by SVG but not
what we want here). Second, the rendering operation
draws into the rectangle the filter claims is its painting
rectangle.

Test: css3/filters/regions-expanding.html

* platform/graphics/filters/FEDropShadow.cpp:
(WebCore::FEDropShadow::determineAbsolutePaintRect): Only
clipToBounds if necessary.
* platform/graphics/filters/FEGaussianBlur.cpp:
(WebCore::FEGaussianBlur::calculateUnscaledKernelSize): CSS filters
ask for the kernel size before the Filter object is created, so
add a new method to return an unscaled kernel.
(WebCore::FEGaussianBlur::calculateKernelSize):
(WebCore::FEGaussianBlur::determineAbsolutePaintRect): Only
clipToBounds if necessary.
* platform/graphics/filters/FEGaussianBlur.h:
* platform/graphics/filters/FEMorphology.cpp:
(WebCore::FEMorphology::determineAbsolutePaintRect): Only
clipToBounds if necessary.
* platform/graphics/filters/FEOffset.cpp:
(WebCore::FEOffset::determineAbsolutePaintRect): Only
clipToBounds if necessary.
* platform/graphics/filters/FilterEffect.cpp:
(WebCore::FilterEffect::FilterEffect): Initialize clipToBounds
as false so SVG remains unchanged.
(WebCore::FilterEffect::determineAbsolutePaintRect): Only
clipToBounds if necessary.
* platform/graphics/filters/FilterEffect.h:
(WebCore::FilterEffect::clipsToBounds):
(WebCore::FilterEffect::setClipsToBounds):
* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::build): Make sure we set our
filters here to NOT clip to bounds.
* rendering/FilterEffectRenderer.h:
(WebCore::FilterEffectRenderer::outputRect): Asks the filter
operation for the size of the result image.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::computeOverflow):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::addVisualEffectOverflow): Change the name
from addBoxShadowAndBorderOverflow().
* rendering/RenderBox.h:
* rendering/RenderEmbeddedObject.cpp:
(WebCore::RenderEmbeddedObject::layout):
* rendering/RenderIFrame.cpp:
(WebCore::RenderIFrame::layout):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::paintLayer):
* rendering/RenderLayerBacking.cpp:
(WebCore::hasBoxDecorations): Change name from
hasBorderOutlineOrShadow().
(WebCore::hasBoxDecorationsOrBackground):
(WebCore::hasBoxDecorationsOrBackgroundImage):
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::layout):
* rendering/style/FilterOperations.cpp:
(WebCore::outsetSizeForBlur): Return an IntSize that is the amount
of offset.
(WebCore::FilterOperations::hasOutsets):
(WebCore::FilterOperations::getOutsets):
* rendering/style/FilterOperations.h:
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::getFilterOutsets):
(WebCore::InheritedFlags::hasFilterOutsets):
* svg/graphics/filters/SVGFEImage.cpp:
(WebCore::FEImage::determineAbsolutePaintRect): Only
clipToBounds if necessary.

LayoutTests:

Previously, filters that expanded their input
region (drop-shadow and blur) were being squished
when rendered back into the document. This is now
fixed, so the expected.png images from tests including
such filters needed updating. I also turned off
dumpAsText() in order to enable pixel tests, and added
some margin between the elements in effects which have
overflow (so that blurs don't overlap, for example).

There is one new test which exercises the case
of expanding filters at various stages in a list
of operations.

Reviewed by Simon Fraser.

* css3/filters/crash-filter-change-expected.png:
* css3/filters/effect-blur-expected.png:
* css3/filters/effect-blur-expected.txt:
* css3/filters/effect-blur.html:
* css3/filters/effect-combined-expected.png:
* css3/filters/effect-combined-expected.txt:
* css3/filters/effect-combined.html:
* css3/filters/effect-drop-shadow-expected.png:
* css3/filters/effect-drop-shadow-expected.txt:
* css3/filters/effect-drop-shadow.html:
* css3/filters/effect-gamma-expected.txt:
* css3/filters/effect-gamma.html:
* css3/filters/effect-grayscale-expected.txt:
* css3/filters/effect-grayscale.html:
* css3/filters/effect-hue-rotate-expected.txt:
* css3/filters/effect-hue-rotate.html:
* css3/filters/effect-invert-expected.png:
* css3/filters/effect-invert-expected.txt:
* css3/filters/effect-invert.html:
* css3/filters/effect-opacity-expected.txt:
* css3/filters/effect-opacity.html:
* css3/filters/effect-saturate-expected.txt:
* css3/filters/effect-saturate.html:
* css3/filters/effect-sepia-expected.txt:
* css3/filters/effect-sepia.html:
* css3/filters/regions-expanding-expected.png: Added.
* css3/filters/regions-expanding-expected.txt: Added.
* css3/filters/regions-expanding.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@103076 268f45cc-cd09-0410-ab3c-d52691b4dbfc
52 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/filters/crash-filter-change-expected.png
LayoutTests/css3/filters/effect-blur-expected.png
LayoutTests/css3/filters/effect-blur-expected.txt
LayoutTests/css3/filters/effect-blur.html
LayoutTests/css3/filters/effect-combined-expected.png
LayoutTests/css3/filters/effect-combined-expected.txt
LayoutTests/css3/filters/effect-combined.html
LayoutTests/css3/filters/effect-drop-shadow-expected.png
LayoutTests/css3/filters/effect-drop-shadow-expected.txt
LayoutTests/css3/filters/effect-drop-shadow.html
LayoutTests/css3/filters/effect-gamma-expected.txt
LayoutTests/css3/filters/effect-gamma.html
LayoutTests/css3/filters/effect-grayscale-expected.txt
LayoutTests/css3/filters/effect-grayscale.html
LayoutTests/css3/filters/effect-hue-rotate-expected.txt
LayoutTests/css3/filters/effect-hue-rotate.html
LayoutTests/css3/filters/effect-invert-expected.png
LayoutTests/css3/filters/effect-invert-expected.txt
LayoutTests/css3/filters/effect-invert.html
LayoutTests/css3/filters/effect-opacity-expected.txt
LayoutTests/css3/filters/effect-opacity.html
LayoutTests/css3/filters/effect-saturate-expected.txt
LayoutTests/css3/filters/effect-saturate.html
LayoutTests/css3/filters/effect-sepia-expected.txt
LayoutTests/css3/filters/effect-sepia.html
LayoutTests/css3/filters/regions-expanding-expected.png [new file with mode: 0644]
LayoutTests/css3/filters/regions-expanding-expected.txt [new file with mode: 0644]
LayoutTests/css3/filters/regions-expanding.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/filters/FEDropShadow.cpp
Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
Source/WebCore/platform/graphics/filters/FEGaussianBlur.h
Source/WebCore/platform/graphics/filters/FEMorphology.cpp
Source/WebCore/platform/graphics/filters/FEOffset.cpp
Source/WebCore/platform/graphics/filters/FilterEffect.cpp
Source/WebCore/platform/graphics/filters/FilterEffect.h
Source/WebCore/platform/graphics/filters/FilterOperations.cpp
Source/WebCore/platform/graphics/filters/FilterOperations.h
Source/WebCore/rendering/FilterEffectRenderer.cpp
Source/WebCore/rendering/FilterEffectRenderer.h
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderEmbeddedObject.cpp
Source/WebCore/rendering/RenderIFrame.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderReplaced.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleFilterData.cpp
Source/WebCore/svg/graphics/filters/SVGFEImage.cpp