Differentiate between SVG/CSS width/height attributes/properties
https://bugs.webkit.org/show_bug.cgi?id=76447

Reviewed by Antti Koivisto.

Source/WebCore:

Remove a gazillion of hacks out of our SVG implementation, by correctly differentiating between the
SVG width/height attributes and the CSS width/height properties. They need to be treated independently
when handling the intrinsic size negotiation, according to both CSS 2.1 & SVG 1.1 2nd Edition specs.

Fixes several bugs in the LayoutTests/svg/custom/*object*sizing tests, we now match Opera perfectly. FF still has some bugs, and IE9 as well.

* css/svg.css: Remove hardcoded, width/height: 100% on <svg>.
* rendering/RenderBox.h:
(WebCore::RenderBox::computeIntrinsicRatioInformation): Make 'intrinsicRatio' a float, and add 'intrinsicSize' as seperated FloatSize, to avoid confusion.
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions): Add forgotton case for percentage intrinsic sizes, that lead to workarounds in other places, that can now be removed.
* rendering/RenderImage.cpp:
(WebCore::RenderImage::computeReplacedLogicalWidth): Directly use imageHasRelativeWidth/Height(), it does differentiate between SVG/CSS width/height attributes/properties now.
(WebCore::RenderImage::computeIntrinsicRatioInformation): Adapt to 'intrinsicRatio' argument change.
* rendering/RenderImage.h: Ditto.
* rendering/RenderReplaced.cpp: Refactor existing code, break out firstContainingBlockWithLogicalWidth/hasReplacedLogicalWidth/hasReplacedLogicalHeight/hasAutoHeightOrContainingBlockWithAutoHeight.
(WebCore::firstContainingBlockWithLogicalWidth): Refactored.
(WebCore::RenderReplaced::hasReplacedLogicalWidth): Refactored, and exported, so SVGSVGElement::widthAttributeEstablishesViewport() can use it.
(WebCore::hasAutoHeightOrContainingBlockWithAutoHeight): Refactored.
(WebCore::RenderReplaced::hasReplacedLogicalHeight): Refactored, and exported, so SVGSVGElement::heightAttributeEstablishesViewport() can use it.
(WebCore::RenderReplaced::computeReplacedLogicalWidth): Adapt to 'intrinsicRatio' changes ('intrinsicSize' is now decoupled from it). Refactor so that RenderSVGRoot can directly use it as well!
(WebCore::RenderReplaced::computeReplacedLogicalHeight): Ditto.
* rendering/RenderReplaced.h:
* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::computeIntrinsicRatioInformation): Only determine the intrinsic size & ratio using the SVG width/height attributes, not the CSS width/height properties, as it's specified.
(WebCore::resolveLengthAttributeForSVG): Helper function for computeReplacedLogicalWidth/Height, that scales Length values that come from SVG width/height attributes.
(WebCore::RenderSVGRoot::computeReplacedLogicalWidth): Finally remove home-brewn size computation logic - it can be fully shared with RenderReplaced now that we inherit from it.
(WebCore::RenderSVGRoot::computeReplacedLogicalHeight): Ditto.
* rendering/svg/RenderSVGRoot.h:
* rendering/svg/RenderSVGViewportContainer.h:
(WebCore::RenderSVGViewportContainer::viewport): Export viewport() for easier length resolution.
* svg/SVGLengthContext.cpp:
(WebCore::SVGLengthContext::determineViewport): Finally clean up this hell, and make it easy to understand. Only need to resolve lengths against either RenderSVGRoot or RenderSVGViewportContainer now.
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::viewport): Remove wrong code and disable this. Its not used, and we have no test coverage for it. Its current implementation didn't make any sense.
(WebCore::SVGSVGElement::parseMappedAttribute): Remove hacks mapping SVG width/height attributes to CSS properties.
(WebCore::SVGSVGElement::svgAttributeChanged): Ditto.
(WebCore::SVGSVGElement::localCoordinateSpaceTransform): Refactored.
(WebCore::SVGSVGElement::currentViewBoxRect): Ditto.
(WebCore::SVGSVGElement::currentViewportSize): Ditto.
(WebCore::SVGSVGElement::widthAttributeEstablishesViewport): Main logic determining if the SVG or CSS properties establish the viewport -  a direct transliteration from the spec.
(WebCore::SVGSVGElement::heightAttributeEstablishesViewport): Ditto.
(WebCore::SVGSVGElement::intrinsicWidth): Helper.
(WebCore::SVGSVGElement::intrinsicHeight): Ditto.
* svg/SVGSVGElement.h:
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::size): Cleanup code.
(WebCore::SVGImage::hasRelativeWidth): Added, avoids hacks in RenderBoxModelObject.
(WebCore::SVGImage::hasRelativeHeight): Ditto.
(WebCore::SVGImage::computeIntrinsicDimensions): Make use of new SVGSVGElement::computeIntrinsicDimensions.
* svg/graphics/SVGImage.h:

LayoutTests:

Update SVG pixel test baseline.

* platform/mac/svg/custom/dynamic-empty-path-expected.png: Marginal changes.
* platform/mac/svg/custom/fractional-rects-expected.png: Ditto.
* platform/mac/svg/custom/js-update-container-expected.png: Ditto.
* platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.png: Align with Opera, gives same result now. All *object*sizing* tests are passing now.
* platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.txt: Ditto.
* platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.png: Ditto.
* platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.txt: Ditto.
* platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.png: Ditto.
* platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.txt: Ditto.
* platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.png: Ditto.
* platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.txt: Ditto.
* platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.png: Ditto.
* platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.txt: Ditto.
* platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.png: Ditto.
* platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.txt: Ditto.
* platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.png: Marginal changes.
* platform/mac/svg/custom/viewBox-hit-expected.png: Ditto.
* platform/mac/svg/zoom/page/absolute-sized-document-no-scrollbars-expected.png: Ditto.
* platform/mac/svg/zoom/page/zoom-background-image-tiled-expected.png: Ditto.
* platform/mac/svg/zoom/page/zoom-background-images-expected.png: Ditto.
* platform/mac/svg/zoom/page/zoom-hixie-mixed-009-expected.png: Ditto.
* platform/mac/svg/zoom/page/zoom-img-preserveAspectRatio-support-1-expected.png: Ditto.
* platform/mac/svg/zoom/page/zoom-replaced-intrinsic-ratio-001-expected.png: Ditto.
* platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.png: Ditto.
* platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.txt: Ditto.
* platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.png: Ditto.
* platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.png: Ditto.
* platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.txt: Ditto.
* platform/mac/svg/zoom/page/zoom-svg-through-object-with-huge-size-expected.png: Ditto.
* platform/mac/svg/zoom/page/zoom-svg-through-object-with-override-size-expected.png: Ditto.
* platform/mac/svg/zoom/page/zoom-svg-through-object-with-percentage-size-expected.png: Ditto.
* platform/mac/tables/mozilla/bugs/bug101674-expected.png: Ditto.
* platform/mac/tables/mozilla/bugs/bug101674-expected.txt: Ditto.
* platform/mac/tables/mozilla/bugs/bug86708-expected.png: Ditto.
* platform/mac/tables/mozilla/bugs/bug86708-expected.txt: Ditto.
* platform/mac/tables/mozilla_expected_failures/bugs/97619-expected.png: Ditto.
* platform/mac/tables/mozilla_expected_failures/bugs/97619-expected.txt: Ditto.
* svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute.xhtml: Fix test, now that our bug is fixed.
* svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute.xhtml: Ditto.
* svg/custom/object-sizing-width-50p-on-target-svg-absolute.xhtml: Ditto.
* svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute.xhtml: Ditto.
* svg/foreignObject/text-tref-02-b-expected.txt: Size is not reported anymore.

git-svn-id: svn://svn.chromium.org/blink/trunk@105513 bbb929c8-8fbe-4397-9dbb-9b2b20218538
58 files changed