[SVG] Suppress painting when an empty viewBox is specified
authorfmalita@chromium.org <fmalita@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2013 19:14:00 +0000 (19:14 +0000)
committerfmalita@chromium.org <fmalita@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2013 19:14:00 +0000 (19:14 +0000)
commit85d40664f576940b98b59a12222758ab3e8bfb14
tree8f13a7415e0cb0c3e47846480cb1280e0308e1c4
parentd69ebfa2fe3ebffc4d01e5013f621a0baa87ef19
[SVG] Suppress painting when an empty viewBox is specified
https://bugs.webkit.org/show_bug.cgi?id=112623

Reviewed by Philip Rogers.

Source/WebCore:

Per spec, elements with an empty viewBox should not be rendered:
http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute.

This patch adds the missing viewBox checks to RenderSVGRoot, RenderSVGViewPortContainer,
RenderSVGResourceMarker and RenderSVGResourceMarker's paint methods.

In order to detect the case of "viewBox present but invalid", the patch also introduces
SVGAnimatedProperty plumbing for tracking property validity: the baseVal setter now takes
an additional optional 'validValue' boolean parameter, which can later be queried via a
macroed getter (LowerProperty##IsValid()).

Test: svg/custom/viewBox-empty.html

* rendering/svg/RenderSVGResourceMarker.cpp:
(WebCore::RenderSVGResourceMarker::draw):
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::buildPattern):
* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::paintReplaced):
* rendering/svg/RenderSVGViewportContainer.cpp:
(WebCore::RenderSVGViewportContainer::paint):
(WebCore):
* rendering/svg/RenderSVGViewportContainer.h:
(RenderSVGViewportContainer):
* svg/SVGPatternElement.cpp:
(WebCore::SVGPatternElement::collectPatternAttributes):
* svg/SVGSVGElement.h:
(WebCore::SVGSVGElement::hasEmptyViewBox):
(SVGSVGElement):
Suppress painting if a valid empty viewBox is found.

* svg/SVGFitToViewBox.h:
(WebCore::SVGFitToViewBox::parseAttribute):
Mark the viewBox property as invalid if not successfully parsed.

* svg/SVGExternalResourcesRequired.h:
(SVGExternalResourcesRequired):
* svg/SVGURIReference.h:
(SVGURIReference):
* svg/properties/SVGAnimatedPropertyMacros.h:
(WebCore::SVGSynchronizableAnimatedProperty::SVGSynchronizableAnimatedProperty):
(SVGSynchronizableAnimatedProperty):
(WebCore):
Plumbing for tracking property value validation.

LayoutTests:

* svg/custom/script-tests/svg-viewBox-dynamic.js:
* svg/custom/svg-viewBox-dynamic-expected.txt:
* svg/custom/viewBox-empty-expected.html: Added.
* svg/custom/viewBox-empty.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@146495 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/svg/custom/script-tests/svg-viewBox-dynamic.js
LayoutTests/svg/custom/svg-viewBox-dynamic-expected.txt
LayoutTests/svg/custom/viewBox-empty-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/viewBox-empty.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGResourceMarker.cpp
Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp
Source/WebCore/rendering/svg/RenderSVGRoot.cpp
Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp
Source/WebCore/rendering/svg/RenderSVGViewportContainer.h
Source/WebCore/svg/SVGExternalResourcesRequired.h
Source/WebCore/svg/SVGFitToViewBox.h
Source/WebCore/svg/SVGPatternElement.cpp
Source/WebCore/svg/SVGSVGElement.h
Source/WebCore/svg/SVGURIReference.h
Source/WebCore/svg/properties/SVGAnimatedPropertyMacros.h