REGRESSION(58212): html foreignObjects with positions other than static not hidden...
authorzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Feb 2012 14:49:46 +0000 (14:49 +0000)
committerzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Feb 2012 14:49:46 +0000 (14:49 +0000)
commitb3b75625ed612add8b898a66c5c27f9ebc6c2839
treee2349544a1e5b79618845df229398d315965d45f
parent7c3a90a4ffa29eeca7ce19cea4f4a092e30aaffe
REGRESSION(58212): html foreignObjects with positions other than static not hidden correctly when parent has display:none
https://bugs.webkit.org/show_bug.cgi?id=41386

Reviewed by Zoltan Herczeg.

Source/WebCore:

r58212 gave SVGGElements a renderer, regardless if "display: none" was set or not, for various reasons (see change set).
The <g> renderer for such cases is a RenderSVGHiddenContainer. We make sure in SVG that such subtrees are never used
for painting & hittesting - they only exist for the purpose of SVG DOM (query getCTM, etc..) and to create renderers
for child resources, like <g display="none"><linearGradient>.

This concept still works fine for: <g display="none"><foreignObject><body>Foobar</body></foreignObject></g>, as
RenderSVGForeignObject::paint is never called thus we never paint the subtree of the <fO>. If the <body> elements
contains "position: relative" a new layer is created for the <body>. When the document paints we have two seperated
layers, and the <body> layer doesn't know that it's actually inside a "SVG hidden subtree", and gets painted, where it
shouldn't. HTML doesn't have this problems, as a display: none object, never creates a renderer.

The fix is to disallow layer creation in hidden SVG subtrees, to mimic what would happen if we'd follow HTML rules
to not create renderers for display: none objects. This avoids any indirections - as no layers are created anymore.

Tests: svg/foreignObject/fO-display-none-with-relative-pos-content.svg
       svg/foreignObject/fO-display-none.svg
       svg/foreignObject/fO-parent-display-changes.svg
       svg/foreignObject/fO-parent-display-none-with-relative-pos-content.svg
       svg/foreignObject/fO-parent-display-none.svg
       svg/foreignObject/fO-parent-of-parent-display-none-with-relative-pos-content.svg
       svg/foreignObject/fO-parent-of-parent-display-none.svg

* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::styleDidChange): Only create layers, if its allowed -- layerCreationAllowedForSubtree() will always return true for HTML, and only false for layers inside a hidden SVG subtree.
* rendering/RenderObject.cpp:
(WebCore::RenderObject::addChild): Only create layers, if its allowed.
* rendering/RenderObject.h: Add inline layerCreationAllowedForSubtree() helper, that craws the tree to find a RenderSVGHiddenContainer ancestor, if not present, return true.

LayoutTests:

Add new tests covering <foreignObject> content inside a <g display="none">.

* platform/chromium/test_expectations.txt:
* platform/mac/svg/foreignObject/fO-display-none-expected.png: Added.
* platform/mac/svg/foreignObject/fO-display-none-expected.txt: Added.
* platform/mac/svg/foreignObject/fO-display-none-with-relative-pos-content-expected.png: Added.
* platform/mac/svg/foreignObject/fO-display-none-with-relative-pos-content-expected.txt: Added.
* platform/mac/svg/foreignObject/fO-parent-display-changes-expected.png: Added.
* platform/mac/svg/foreignObject/fO-parent-display-changes-expected.txt: Added.
* platform/mac/svg/foreignObject/fO-parent-display-none-expected.png: Added.
* platform/mac/svg/foreignObject/fO-parent-display-none-expected.txt: Added.
* platform/mac/svg/foreignObject/fO-parent-display-none-with-relative-pos-content-expected.png: Added.
* platform/mac/svg/foreignObject/fO-parent-display-none-with-relative-pos-content-expected.txt: Added.
* platform/mac/svg/foreignObject/fO-parent-of-parent-display-none-expected.png: Added.
* platform/mac/svg/foreignObject/fO-parent-of-parent-display-none-expected.txt: Added.
* platform/mac/svg/foreignObject/fO-parent-of-parent-display-none-with-relative-pos-content-expected.png: Added.
* platform/mac/svg/foreignObject/fO-parent-of-parent-display-none-with-relative-pos-content-expected.txt: Added.
* svg/foreignObject/fO-display-none-with-relative-pos-content.svg: Added.
* svg/foreignObject/fO-display-none.svg: Added.
* svg/foreignObject/fO-parent-display-changes.svg: Added.
* svg/foreignObject/fO-parent-display-none-with-relative-pos-content.svg: Added.
* svg/foreignObject/fO-parent-display-none.svg: Added.
* svg/foreignObject/fO-parent-of-parent-display-none-with-relative-pos-content.svg: Added.
* svg/foreignObject/fO-parent-of-parent-display-none.svg: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108494 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/mac/svg/foreignObject/fO-display-none-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/foreignObject/fO-display-none-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/foreignObject/fO-display-none-with-relative-pos-content-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/foreignObject/fO-display-none-with-relative-pos-content-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/foreignObject/fO-parent-display-changes-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/foreignObject/fO-parent-display-changes-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/foreignObject/fO-parent-display-none-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/foreignObject/fO-parent-display-none-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/foreignObject/fO-parent-display-none-with-relative-pos-content-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/foreignObject/fO-parent-display-none-with-relative-pos-content-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/foreignObject/fO-parent-of-parent-display-none-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/foreignObject/fO-parent-of-parent-display-none-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/foreignObject/fO-parent-of-parent-display-none-with-relative-pos-content-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/foreignObject/fO-parent-of-parent-display-none-with-relative-pos-content-expected.txt [new file with mode: 0644]
LayoutTests/svg/foreignObject/fO-display-none-with-relative-pos-content.svg [new file with mode: 0644]
LayoutTests/svg/foreignObject/fO-display-none.svg [new file with mode: 0644]
LayoutTests/svg/foreignObject/fO-parent-display-changes.svg [new file with mode: 0644]
LayoutTests/svg/foreignObject/fO-parent-display-none-with-relative-pos-content.svg [new file with mode: 0644]
LayoutTests/svg/foreignObject/fO-parent-display-none.svg [new file with mode: 0644]
LayoutTests/svg/foreignObject/fO-parent-of-parent-display-none-with-relative-pos-content.svg [new file with mode: 0644]
LayoutTests/svg/foreignObject/fO-parent-of-parent-display-none.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderObject.h