viewBox on nested SVG causes wrong content size for relative values
authorkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 19:19:03 +0000 (19:19 +0000)
committerkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 19:19:03 +0000 (19:19 +0000)
commita9b203ca98914e351b01f88eb6f227b29e55916d
tree37a1bf697b48a5cae8eddec7f56d96684a590755
parent6ea606cdccf176124e2981d290f796fd990e869b
viewBox on nested SVG causes wrong content size for relative values
https://bugs.webkit.org/show_bug.cgi?id=69459

Reviewed by Nikolas.

Source/WebCore:

In the past we just checked the change of the viewport size of the root SVG element. If the size changed, all childs
with relative length values needed a relayout. We did not consider that we might have other viewports in the document.
Childs with relative lengths had a strange zooming, if just the viewport size of an inner SVG element changed.

With this patch we check if the size of the nearest viewport changes. Is this the case, childs with relative lengths
need a relayout.

Test: inner-svg-change-viewBox.svg

* rendering/svg/RenderSVGContainer.cpp:
(WebCore::RenderSVGContainer::layout):
* rendering/svg/RenderSVGContainer.h:
(RenderSVGContainer):
(WebCore::RenderSVGContainer::determineIfLayoutSizeChanged): Check if we need layout and have relative length values.
* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::layout): Remove resetting 'viewport size changed' flag for code operability. No influence on the layout.
* rendering/svg/RenderSVGViewportContainer.cpp:
(WebCore::RenderSVGViewportContainer::RenderSVGViewportContainer): Add a flag that indicates that the viewport size changes.
(WebCore::RenderSVGViewportContainer::determineIfLayoutSizeChanged): The flag gets set during the layout phase of the SVG element if the size changes.
(WebCore):
* rendering/svg/RenderSVGViewportContainer.h:
(WebCore::RenderSVGViewportContainer::isLayoutSizeChanged): Added getter to get flag status.
(RenderSVGViewportContainer):
(WebCore::toRenderSVGViewportContainer): Added casting function for constant RenderObjects.
(WebCore):
* rendering/svg/SVGRenderSupport.cpp:
(WebCore::layoutSizeOfNearestViewportChanged): Search the nearest viewport and check if the size changed.
(WebCore):
(WebCore::SVGRenderSupport::layoutChildren): Don't check the roots viewport for size changes, but the nearest viewport.
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::svgAttributeChanged): Added viewBoxAttr to the list of attributes that cause relayout.

LayoutTests:

Test relayout of content of inner SVG on change of relative length values.

* svg/repaint/inner-svg-change-viewBox-expected.png: Added.
* svg/repaint/inner-svg-change-viewBox-expected.txt: Added.
* svg/repaint/inner-svg-change-viewBox.svg: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@107108 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/svg/repaint/inner-svg-change-viewBox-expected.png [new file with mode: 0644]
LayoutTests/svg/repaint/inner-svg-change-viewBox-expected.txt [new file with mode: 0644]
LayoutTests/svg/repaint/inner-svg-change-viewBox.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGContainer.cpp
Source/WebCore/rendering/svg/RenderSVGContainer.h
Source/WebCore/rendering/svg/RenderSVGRoot.cpp
Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp
Source/WebCore/rendering/svg/RenderSVGViewportContainer.h
Source/WebCore/rendering/svg/SVGRenderSupport.cpp
Source/WebCore/svg/SVGSVGElement.cpp