haikuwebkit/LayoutTests/svg/custom/viewBox-empty.html

37 lines
1.2 KiB
HTML
Raw Permalink Normal View History

[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. Canonical link: https://commits.webkit.org/131276@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@146495 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-03-21 19:14:00 +00:00
<!DOCTYPE html>
<html>
<body>
<!-- Test for https://bugs.webkit.org/show_bug.cgi?id=112623.
Empty-viewBox elements should not be rendered. -->
<svg width="600px" height="100px" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="pattern" viewBox="10 10 0 0" width="100" height="100">
<rect width="100" height="100" fill="red"/>
</pattern>
<marker id="marker" viewBox="0 0 0 0" markerWidth="100" markerHeight="100">
<rect width="100" height="100" fill="red"/>
</marker>
</defs>
<rect width="100" height="100" fill="green"/>
<svg width="100px" height="100px" viewBox="0 0 0 0">
<rect width="100" height="100" fill="red"/>
</svg>
<rect x="120" width="100" height="100" fill="green"/>
<rect x="120" width="100" height="100" fill="url(#pattern)"/>
<rect x="240" width="100" height="100" fill="green"/>
<line x1="240" x2="340" marker-start="url(#marker)"/>
</svg>
<div style="width: 100px; height: 100px; background-color: green;">
<svg width="100px" height="100px" viewBox="0 0 0 0" xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="red"/>
</svg>
</div>
</body>
</html>