Repaint rect too small on elements with shadows
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Apr 2013 20:52:55 +0000 (20:52 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Apr 2013 20:52:55 +0000 (20:52 +0000)
commit3249e0d64e2de4f38d5c401efedcef6be02c72c8
tree26f36c96ec13511039e75650a2c004558fa34a5b
parent97688e62dbcaf07dfb38e3d92facaed6b27d4e8f
Repaint rect too small on elements with shadows
https://bugs.webkit.org/show_bug.cgi?id=114225

Source/WebCore:

Reviewed by Dain Adler.

We assumed that shadows (box-shadow, text-shadow, svg shadows)
only required inflating the repaint rect by the blur radius of
the shadow. However, this is incorrect; the shadow can extend
further, which resulted in clipped or incorrectly invalidated
shadows.

Fix by disambiguating the blur radius (which is 2x the standard
deviation of the Gaussian distribution used to generate the blur),
from the painting extent, which is how far the shadow visually
projects. Using a 1.4 multiplier of the blur radius is a good
approximation for the painting extent.

Renamed ShadowData::blur() to ShadowData::radius(), and added
ShadowData::paintingExtent(). Use the latter in all places
which relate to invalidation.

Test: fast/box-shadow/shadow-repaint.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::valueForShadow):
* editing/mac/EditorMac.mm:
(WebCore::Editor::fontAttributesForSelectionStart):
* page/animation/CSSPropertyAnimation.cpp:
(WebCore::blendFunc):
* rendering/EllipsisBox.cpp:
(WebCore::EllipsisBox::paint):
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::applyShadowToGraphicsContext):
(WebCore::InlineTextBox::paintDecoration):
* rendering/RenderBoxModelObject.cpp:
(WebCore::applyBoxShadowForBackground):
(WebCore::areaCastingShadowInHole):
(WebCore::RenderBoxModelObject::paintBoxShadow):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::getShadowExtent):
(WebCore::RenderStyle::getShadowInsetExtent):
(WebCore::RenderStyle::getShadowHorizontalExtent):
(WebCore::RenderStyle::getShadowVerticalExtent):
* rendering/style/ShadowData.cpp:
(WebCore::ShadowData::ShadowData):
(WebCore::ShadowData::operator==):
(WebCore::calculateShadowExtent):
* rendering/style/ShadowData.h:
(WebCore::ShadowData::ShadowData):
(WebCore::ShadowData::radius):
(WebCore::ShadowData::paintingExtent):
* rendering/svg/SVGRenderingContext.cpp:
(WebCore::SVGRenderingContext::prepareToRenderSVGContent):

LayoutTests:

Reviewed by Darin Alder.

New test for invalidation with box-shadow. Update test results affected
by shadow extent.

* compositing/geometry/foreground-layer-expected.txt:
* compositing/iframes/composited-parent-iframe-expected.txt:
* compositing/iframes/connect-compositing-iframe-delayed-expected.txt:
* compositing/iframes/connect-compositing-iframe-expected.txt:
* compositing/iframes/connect-compositing-iframe2-expected.txt:
* compositing/iframes/connect-compositing-iframe3-expected.txt:
* compositing/iframes/enter-compositing-iframe-expected.txt:
* compositing/iframes/iframe-resize-expected.txt:
* compositing/iframes/invisible-nested-iframe-show-expected.txt:
* compositing/iframes/overlapped-iframe-expected.txt:
* compositing/iframes/page-cache-layer-tree-expected.txt:
* compositing/iframes/scrolling-iframe-expected.txt:
* compositing/visible-rect/iframe-and-layers-expected.txt:
* fast/box-shadow/shadow-repaint-expected.txt: Added.
* fast/box-shadow/shadow-repaint.html: Added.
* platform/mac/fast/multicol/shadow-breaking-expected.png:
* platform/mac/fast/multicol/shadow-breaking-expected.txt:
* platform/mac/fast/repaint/moving-shadow-on-container-expected.txt:
* platform/mac/fast/repaint/moving-shadow-on-path-expected.png:
* platform/mac/fast/repaint/moving-shadow-on-path-expected.txt:
* platform/mac/svg/css/arrow-with-shadow-expected.png:
* platform/mac/svg/css/circle-in-mask-with-shadow-expected.png:
* platform/mac/svg/css/clippath-with-shadow-expected.png:
* platform/mac/svg/css/composite-shadow-example-expected.png:
* platform/mac/svg/css/composite-shadow-example-expected.txt:
* platform/mac/svg/css/composite-shadow-text-expected.txt:
* platform/mac/svg/css/composite-shadow-with-opacity-expected.png:
* platform/mac/svg/css/composite-shadow-with-opacity-expected.txt:
* platform/mac/svg/css/group-with-shadow-expected.png:
* platform/mac/svg/css/group-with-shadow-expected.txt:
* platform/mac/svg/css/mask-with-shadow-expected.png:
* platform/mac/svg/css/path-with-shadow-expected.png:
* platform/mac/svg/css/path-with-shadow-expected.txt:
* platform/mac/svg/css/shadow-and-opacity-expected.png:
* platform/mac/svg/css/shadow-and-opacity-expected.txt:
* platform/mac/svg/css/shadow-changes-expected.png:
* platform/mac/svg/css/shadow-changes-expected.txt:
* platform/mac/svg/css/shadow-with-large-radius-expected.png:
* platform/mac/svg/css/shadow-with-negative-offset-expected.png:
* platform/mac/svg/css/stars-with-shadow-expected.png:
* platform/mac/svg/css/stars-with-shadow-expected.txt:
* platform/mac/svg/css/text-gradient-shadow-expected.png:
* platform/mac/svg/css/text-gradient-shadow-expected.txt:
* platform/mac/svg/css/text-shadow-multiple-expected.png:
* platform/mac/svg/custom/repaint-shadow-expected.png:
* platform/mac/svg/custom/transform-with-shadow-and-gradient-expected.txt:
* svg/css/arrow-with-shadow-expected.txt:
* svg/css/circle-in-mask-with-shadow-expected.txt:
* svg/css/clippath-with-shadow-expected.txt:
* svg/css/mask-with-shadow-expected.txt:
* svg/css/shadow-with-large-radius-expected.txt:
* svg/css/shadow-with-negative-offset-expected.txt:
* svg/css/text-shadow-multiple-expected.txt:
* svg/custom/repaint-shadow-expected.txt:
* svg/filters/shadow-on-rect-with-filter-expected.txt:
* svg/repaint/repaint-webkit-svg-shadow-container-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@148049 268f45cc-cd09-0410-ab3c-d52691b4dbfc
68 files changed:
LayoutTests/ChangeLog
LayoutTests/compositing/geometry/foreground-layer-expected.txt
LayoutTests/compositing/iframes/composited-parent-iframe-expected.txt
LayoutTests/compositing/iframes/connect-compositing-iframe-delayed-expected.txt
LayoutTests/compositing/iframes/connect-compositing-iframe-expected.txt
LayoutTests/compositing/iframes/connect-compositing-iframe2-expected.txt
LayoutTests/compositing/iframes/connect-compositing-iframe3-expected.txt
LayoutTests/compositing/iframes/enter-compositing-iframe-expected.txt
LayoutTests/compositing/iframes/iframe-resize-expected.txt
LayoutTests/compositing/iframes/invisible-nested-iframe-show-expected.txt
LayoutTests/compositing/iframes/overlapped-iframe-expected.txt
LayoutTests/compositing/iframes/page-cache-layer-tree-expected.txt
LayoutTests/compositing/iframes/scrolling-iframe-expected.txt
LayoutTests/compositing/visible-rect/iframe-and-layers-expected.txt
LayoutTests/fast/box-shadow/shadow-repaint-expected.txt [new file with mode: 0644]
LayoutTests/fast/box-shadow/shadow-repaint.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/multicol/shadow-breaking-expected.png
LayoutTests/platform/mac/fast/multicol/shadow-breaking-expected.txt
LayoutTests/platform/mac/fast/repaint/moving-shadow-on-container-expected.txt
LayoutTests/platform/mac/fast/repaint/moving-shadow-on-path-expected.png
LayoutTests/platform/mac/fast/repaint/moving-shadow-on-path-expected.txt
LayoutTests/platform/mac/svg/css/arrow-with-shadow-expected.png
LayoutTests/platform/mac/svg/css/circle-in-mask-with-shadow-expected.png
LayoutTests/platform/mac/svg/css/clippath-with-shadow-expected.png
LayoutTests/platform/mac/svg/css/composite-shadow-example-expected.png
LayoutTests/platform/mac/svg/css/composite-shadow-example-expected.txt
LayoutTests/platform/mac/svg/css/composite-shadow-text-expected.txt
LayoutTests/platform/mac/svg/css/composite-shadow-with-opacity-expected.png
LayoutTests/platform/mac/svg/css/composite-shadow-with-opacity-expected.txt
LayoutTests/platform/mac/svg/css/group-with-shadow-expected.png
LayoutTests/platform/mac/svg/css/group-with-shadow-expected.txt
LayoutTests/platform/mac/svg/css/mask-with-shadow-expected.png
LayoutTests/platform/mac/svg/css/path-with-shadow-expected.png
LayoutTests/platform/mac/svg/css/path-with-shadow-expected.txt
LayoutTests/platform/mac/svg/css/shadow-and-opacity-expected.png
LayoutTests/platform/mac/svg/css/shadow-and-opacity-expected.txt
LayoutTests/platform/mac/svg/css/shadow-changes-expected.png
LayoutTests/platform/mac/svg/css/shadow-changes-expected.txt
LayoutTests/platform/mac/svg/css/shadow-with-large-radius-expected.png
LayoutTests/platform/mac/svg/css/shadow-with-negative-offset-expected.png
LayoutTests/platform/mac/svg/css/stars-with-shadow-expected.png
LayoutTests/platform/mac/svg/css/stars-with-shadow-expected.txt
LayoutTests/platform/mac/svg/css/text-gradient-shadow-expected.png
LayoutTests/platform/mac/svg/css/text-gradient-shadow-expected.txt
LayoutTests/platform/mac/svg/css/text-shadow-multiple-expected.png
LayoutTests/platform/mac/svg/custom/repaint-shadow-expected.png
LayoutTests/platform/mac/svg/custom/transform-with-shadow-and-gradient-expected.txt
LayoutTests/svg/css/arrow-with-shadow-expected.txt
LayoutTests/svg/css/circle-in-mask-with-shadow-expected.txt
LayoutTests/svg/css/clippath-with-shadow-expected.txt
LayoutTests/svg/css/mask-with-shadow-expected.txt
LayoutTests/svg/css/shadow-with-large-radius-expected.txt
LayoutTests/svg/css/shadow-with-negative-offset-expected.txt
LayoutTests/svg/css/text-shadow-multiple-expected.txt
LayoutTests/svg/custom/repaint-shadow-expected.txt
LayoutTests/svg/filters/shadow-on-rect-with-filter-expected.txt
LayoutTests/svg/repaint/repaint-webkit-svg-shadow-container-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/editing/mac/EditorMac.mm
Source/WebCore/page/animation/CSSPropertyAnimation.cpp
Source/WebCore/rendering/EllipsisBox.cpp
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/ShadowData.cpp
Source/WebCore/rendering/style/ShadowData.h
Source/WebCore/rendering/svg/SVGRenderingContext.cpp