Move height/width implementation for use element from RenderSVGViewportContainer...
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Jan 2015 19:55:58 +0000 (19:55 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Jan 2015 19:55:58 +0000 (19:55 +0000)
commit5f7424331dc8ee88692b58ff683bd995e1c41c49
tree3a59aac8f32f738b0438de72a99e95b9880f6c50
parenteffe90f942d712c3437b41ee8910490849bf08e3
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179069 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.png
LayoutTests/platform/mac/svg/custom/relative-sized-shadow-tree-content-with-symbol-expected.txt
LayoutTests/svg/animations/use-animate-width-and-height-expected.txt [new file with mode: 0644]
LayoutTests/svg/animations/use-animate-width-and-height.html [new file with mode: 0644]
LayoutTests/svg/custom/use-attribute-invalidations-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/use-attribute-invalidations.html [new file with mode: 0644]
LayoutTests/svg/custom/use-dynamic-attribute-setting-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/use-dynamic-attribute-setting.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp
Source/WebCore/svg/SVGSVGElement.cpp
Source/WebCore/svg/SVGUseElement.cpp