Differentiate between SVG/CSS width/height attributes/properties
authorzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2012 15:30:17 +0000 (15:30 +0000)
committerzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2012 15:30:17 +0000 (15:30 +0000)
commita14b7ff846b273c15c97cdf2d95f2957ec45b1c3
treeee77fb1e45384c684e54e0ba1b6eebb26d93962c
parent319f78bc1af02f8ff74633d9bd94deb71b863f82
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: https://svn.webkit.org/repository/webkit/trunk@105513 268f45cc-cd09-0410-ab3c-d52691b4dbfc
58 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/mac/svg/custom/dynamic-empty-path-expected.png
LayoutTests/platform/mac/svg/custom/fractional-rects-expected.png
LayoutTests/platform/mac/svg/custom/js-update-container-expected.png
LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.png
LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.txt
LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.png
LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.txt
LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.png
LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.txt
LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.png
LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.txt
LayoutTests/platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.png
LayoutTests/platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.txt
LayoutTests/platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.png
LayoutTests/platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.txt
LayoutTests/platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.png
LayoutTests/platform/mac/svg/custom/viewBox-hit-expected.png
LayoutTests/platform/mac/svg/zoom/page/absolute-sized-document-no-scrollbars-expected.png
LayoutTests/platform/mac/svg/zoom/page/zoom-background-image-tiled-expected.png
LayoutTests/platform/mac/svg/zoom/page/zoom-background-images-expected.png
LayoutTests/platform/mac/svg/zoom/page/zoom-hixie-mixed-009-expected.png
LayoutTests/platform/mac/svg/zoom/page/zoom-img-preserveAspectRatio-support-1-expected.png
LayoutTests/platform/mac/svg/zoom/page/zoom-replaced-intrinsic-ratio-001-expected.png
LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.png
LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.png
LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.png
LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-huge-size-expected.png
LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-override-size-expected.png
LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-percentage-size-expected.png
LayoutTests/platform/mac/tables/mozilla/bugs/bug101674-expected.png
LayoutTests/platform/mac/tables/mozilla/bugs/bug101674-expected.txt
LayoutTests/platform/mac/tables/mozilla/bugs/bug86708-expected.png
LayoutTests/platform/mac/tables/mozilla/bugs/bug86708-expected.txt
LayoutTests/platform/mac/tables/mozilla_expected_failures/bugs/97619-expected.png
LayoutTests/platform/mac/tables/mozilla_expected_failures/bugs/97619-expected.txt
LayoutTests/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute.xhtml
LayoutTests/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute.xhtml
LayoutTests/svg/custom/object-sizing-width-50p-on-target-svg-absolute.xhtml
LayoutTests/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute.xhtml
LayoutTests/svg/foreignObject/text-tref-02-b-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/css/svg.css
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/RenderImage.h
Source/WebCore/rendering/RenderReplaced.cpp
Source/WebCore/rendering/RenderReplaced.h
Source/WebCore/rendering/svg/RenderSVGRoot.cpp
Source/WebCore/rendering/svg/RenderSVGRoot.h
Source/WebCore/rendering/svg/RenderSVGViewportContainer.h
Source/WebCore/svg/SVGLengthContext.cpp
Source/WebCore/svg/SVGSVGElement.cpp
Source/WebCore/svg/SVGSVGElement.h
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebCore/svg/graphics/SVGImage.h