haikuwebkit/LayoutTests/svg/custom/use-attribute-invalidations...

18 lines
515 B
HTML
Raw Permalink Normal View History

Move height/width implementation for use element from RenderSVGViewportContainer to SVGUseElement https://bugs.webkit.org/show_bug.cgi?id=140826 Reviewed by Anders Carlsson. Source/WebCore: Tests: svg/animations/use-animate-width-and-height.html svg/custom/use-attribute-invalidations.html svg/custom/use-dynamic-attribute-setting.html This is an adaptation of work Rob Buis did in Blink: http://src.chromium.org/viewvc/blink?view=revision&revision=173258 The goal here is to reduce use of SVGElementInstance since we are going to remove it. The tests Rob added to Blink (which I believe I improved a bit here) meant we had to fix quite a few bugs in the implementation of the width/height logic rather than just moving it. Even so, this could use even more test coverage since there is separate logic for <symbol> and <svg>, three different code paths (animation/attribute setting, initial creation, and one other), and also distinct issues for attributes not set at all, attributes set to values that can't be parsed, and attributes set with different units. * rendering/svg/RenderSVGViewportContainer.cpp: (WebCore::RenderSVGViewportContainer::calcViewport): Removed the old logic. * svg/SVGSVGElement.cpp: (WebCore::SVGSVGElement::SVGSVGElement): Use ASCIILiteral to more efficiently create strings from ASCII literals here. (WebCore::SVGSVGElement::parseAttribute): Default to 100%, not 0, when the width or height property are either not set or not successfully parsed. Without this change, one of the SVG tests starts failing. * svg/SVGUseElement.cpp: (WebCore::updateWidthAndHeight): Added. The tricky part here is that we have to copy width and height attributes only if they were successfully parsed, and also we need to copy the current animating values, not the original attribute strings. Kind of messy, but I wanted to adapt Rob's solution for the time being, rather than inventing something new. (WebCore::SVGUseElement::svgAttributeChanged): Call updateWidthAndHeight. This is used both when actual attribute changes occur and also when animation changes the current value. (WebCore::SVGUseElement::buildShadowAndInstanceTree): Call updateWidthAndHeight. This is used when the shadow elements are first created. (WebCore::SVGUseElement::expandUseElementsInShadowTree): Call updateWidthAndHeight. This was in Rob's patch, but I am not sure we have sufficient test coverage. LayoutTests: * platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.png: Old test result was expecting failure. New one expects success. * platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.txt: Ditto. * svg/animations/use-animate-width-and-height-expected.txt: Added. * svg/animations/use-animate-width-and-height.html: Added. * svg/custom/use-attribute-invalidations-expected.html: Added. * svg/custom/use-attribute-invalidations.html: Added. * svg/custom/use-dynamic-attribute-setting-expected.html: Added. * svg/custom/use-dynamic-attribute-setting.html: Added. Canonical link: https://commits.webkit.org/158845@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179069 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-24 19:55:58 +00:00
<!DOCTYPE HTML>
<html>
<body>
<p>This test passes if there are three 100x100px green squares in a diagonal line below:</p>
<svg width="300" height="300">
<svg width="100" height="100">
<rect width="100%" height="100%" fill="green"/>
</svg>
<svg x="100" y="100" width="100" height="100">
<rect width="100%" height="100%" fill="green"/>
</svg>
<svg x="200" y="200" width="100" height="100">
<rect width="100%" height="100%" fill="green"/>
</svg>
</svg>
</body>
</html>