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)
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

index 5586b40..bd7c658 100644 (file)
@@ -1,3 +1,55 @@
+2012-01-20  Nikolas Zimmermann  <nzimmermann@rim.com>
+
+        Differentiate between SVG/CSS width/height attributes/properties
+        https://bugs.webkit.org/show_bug.cgi?id=76447
+
+        Reviewed by Antti Koivisto.
+
+        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.
+
 2012-01-20  Sami Kyostila  <skyostil@chromium.org>
 
         window.innerWidth/Height should not include page scale
index ca9adf0..01970fc 100644 (file)
@@ -3909,6 +3909,18 @@ BUGWK76446 : svg/custom/pointer-events-text.svg = TEXT
 // RenderSVGRoot now reports a correct size.
 BUGWK76646 : svg/foreignObject/text-tref-02-b.svg = TEXT
 
+// Slight changes in RenderReplaced extents.
+BUGWK76647 : svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute.xhtml = IMAGE+TEXT
+BUGWK76647 : svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute.xhtml = IMAGE+TEXT
+BUGWK76647 : svg/custom/object-sizing-width-50p-height-75p-on-target-svg.xhtml = IMAGE+TEXT
+BUGWK76647 : svg/custom/object-sizing-width-50p-on-target-svg-absolute.xhtml = IMAGE+TEXT
+BUGWK76647 : svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute.xhtml = IMAGE+TEXT
+BUGWK76647 : svg/custom/object-sizing-width-75p-height-50p-on-target-svg.xhtml = IMAGE+TEXT
+BUGWK76647 : tables/mozilla/bugs/bug101674.html = IMAGE+TEXT
+BUGWK76647 : tables/mozilla/bugs/bug86708.html = IMAGE+TEXT
+BUGWK76647 : tables/mozilla_expected_failures/bugs/97619.html = IMAGE+TEXT
+BUGWK76647 : svg/zoom/page/zoom-background-images.html = IMAGE
+
 // Change error (misspelling) underlines from Windows look to Mac look.
 BUG_CARYCLARK MAC : editing/deleting/delete-3928305-fix.html = IMAGE
 BUG_CARYCLARK MAC : editing/deleting/delete-3959464-fix.html = IMAGE
index 84bae18..7ec45bd 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/dynamic-empty-path-expected.png and b/LayoutTests/platform/mac/svg/custom/dynamic-empty-path-expected.png differ
index 32a2108..a82a9f6 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/fractional-rects-expected.png and b/LayoutTests/platform/mac/svg/custom/fractional-rects-expected.png differ
index ee2e5fd..c3d9985 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/js-update-container-expected.png and b/LayoutTests/platform/mac/svg/custom/js-update-container-expected.png differ
index 05629b6..04dee40 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.png and b/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.png differ
index 3439750..b1df108 100644 (file)
@@ -1,8 +1,8 @@
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 500x154 layerType: background only
-layer at (0,0) size 125x75
-  RenderBlock (positioned) zI: -1 {div} at (0,0) size 125x75 [bgcolor=#FF0000]
+layer at (0,0) size 250x75
+  RenderBlock (positioned) zI: -1 {div} at (0,0) size 250x75 [bgcolor=#FF0000]
 layer at (0,0) size 500x154 layerType: foreground only
   RenderBlock {html} at (0,0) size 500x154
     RenderBody {body} at (0,0) size 500x154
@@ -11,10 +11,10 @@ layer at (0,0) size 500x154 layerType: foreground only
           layer at (0,0) size 250x150
             RenderView at (0,0) size 250x150
           layer at (0,0) size 250x75
-            RenderSVGRoot {svg} at (0,0) size 125x75
-              RenderSVGRect {rect} at (0,0) size 125x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=125.00] [height=75.00]
-              RenderSVGRect {rect} at (6,3) size 113x69 [fill={[type=SOLID] [color=#008000]}] [x=6.25] [y=3.75] [width=112.50] [height=67.50]
-layer at (0,80) size 125x75
-  RenderSVGRoot {svg} at (0,80) size 125x75
-    RenderSVGRect {rect} at (0,80) size 125x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
-    RenderSVGRect {rect} at (6,83) size 113x69 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
+            RenderSVGRoot {svg} at (0,0) size 250x75
+              RenderSVGRect {rect} at (0,0) size 250x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=250.00] [height=75.00]
+              RenderSVGRect {rect} at (12,3) size 226x69 [fill={[type=SOLID] [color=#008000]}] [x=12.50] [y=3.75] [width=225.00] [height=67.50]
+layer at (0,80) size 250x75
+  RenderSVGRoot {svg} at (0,80) size 250x75
+    RenderSVGRect {rect} at (0,80) size 250x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
+    RenderSVGRect {rect} at (12,83) size 226x69 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
index 55f9239..935c23b 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.png and b/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.png differ
index 740c798..1d95558 100644 (file)
@@ -1,8 +1,8 @@
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 500x154 layerType: background only
-layer at (0,0) size 125x112
-  RenderBlock (positioned) zI: -1 {div} at (0,0) size 125x112 [bgcolor=#FF0000]
+layer at (0,0) size 250x112
+  RenderBlock (positioned) zI: -1 {div} at (0,0) size 250x112 [bgcolor=#FF0000]
 layer at (0,0) size 500x154 layerType: foreground only
   RenderBlock {html} at (0,0) size 500x154
     RenderBody {body} at (0,0) size 500x154
@@ -11,10 +11,10 @@ layer at (0,0) size 500x154 layerType: foreground only
           layer at (0,0) size 250x150
             RenderView at (0,0) size 250x150
           layer at (0,0) size 250x112
-            RenderSVGRoot {svg} at (0,0) size 125x112
-              RenderSVGRect {rect} at (0,0) size 125x112 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=125.00] [height=112.50]
-              RenderSVGRect {rect} at (6,5) size 113x102 [fill={[type=SOLID] [color=#008000]}] [x=6.25] [y=5.63] [width=112.50] [height=101.25]
-layer at (0,117) size 125x112
-  RenderSVGRoot {svg} at (0,117) size 125x112
-    RenderSVGRect {rect} at (0,117) size 125x112 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
-    RenderSVGRect {rect} at (6,122) size 113x102 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
+            RenderSVGRoot {svg} at (0,0) size 250x112
+              RenderSVGRect {rect} at (0,0) size 250x112 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=250.00] [height=112.00]
+              RenderSVGRect {rect} at (12,5) size 226x102 [fill={[type=SOLID] [color=#008000]}] [x=12.50] [y=5.60] [width=225.00] [height=100.80]
+layer at (0,117) size 250x112
+  RenderSVGRoot {svg} at (0,117) size 250x112
+    RenderSVGRect {rect} at (0,117) size 250x112 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
+    RenderSVGRect {rect} at (12,122) size 226x102 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
index 55f9239..5af33ab 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.png and b/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.png differ
index 15a8f30..1ca4f00 100644 (file)
@@ -12,8 +12,8 @@ layer at (0,0) size 500x154 layerType: foreground only
             RenderView at (0,0) size 250x150
           layer at (0,0) size 125x112
             RenderSVGRoot {svg} at (0,0) size 125x112
-              RenderSVGRect {rect} at (0,0) size 125x112 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=125.00] [height=112.50]
-              RenderSVGRect {rect} at (6,5) size 113x102 [fill={[type=SOLID] [color=#008000]}] [x=6.25] [y=5.63] [width=112.50] [height=101.25]
+              RenderSVGRect {rect} at (0,0) size 125x112 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=125.00] [height=112.00]
+              RenderSVGRect {rect} at (6,5) size 113x102 [fill={[type=SOLID] [color=#008000]}] [x=6.25] [y=5.60] [width=112.50] [height=100.80]
 layer at (0,117) size 125x112
   RenderSVGRoot {svg} at (0,117) size 125x112
     RenderSVGRect {rect} at (0,117) size 125x112 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
index d25ef7e..5a12a2f 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.png and b/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.png differ
index b06945d..31fb450 100644 (file)
@@ -1,8 +1,8 @@
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 500x154 layerType: background only
-layer at (0,0) size 125x150
-  RenderBlock (positioned) zI: -1 {div} at (0,0) size 125x150 [bgcolor=#FF0000]
+layer at (0,0) size 250x150
+  RenderBlock (positioned) zI: -1 {div} at (0,0) size 250x150 [bgcolor=#FF0000]
 layer at (0,0) size 500x154 layerType: foreground only
   RenderBlock {html} at (0,0) size 500x154
     RenderBody {body} at (0,0) size 500x154
@@ -11,10 +11,10 @@ layer at (0,0) size 500x154 layerType: foreground only
           layer at (0,0) size 250x150
             RenderView at (0,0) size 250x150
           layer at (0,0) size 250x150
-            RenderSVGRoot {svg} at (0,0) size 125x150
-              RenderSVGRect {rect} at (0,0) size 125x150 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=125.00] [height=150.00]
-              RenderSVGRect {rect} at (6,7) size 113x136 [fill={[type=SOLID] [color=#008000]}] [x=6.25] [y=7.50] [width=112.50] [height=135.00]
-layer at (0,155) size 125x150
-  RenderSVGRoot {svg} at (0,155) size 125x150
-    RenderSVGRect {rect} at (0,155) size 125x150 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
-    RenderSVGRect {rect} at (6,162) size 113x136 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
+            RenderSVGRoot {svg} at (0,0) size 250x150
+              RenderSVGRect {rect} at (0,0) size 250x150 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=250.00] [height=150.00]
+              RenderSVGRect {rect} at (12,7) size 226x136 [fill={[type=SOLID] [color=#008000]}] [x=12.50] [y=7.50] [width=225.00] [height=135.00]
+layer at (0,155) size 250x150
+  RenderSVGRoot {svg} at (0,155) size 250x150
+    RenderSVGRect {rect} at (0,155) size 250x150 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
+    RenderSVGRect {rect} at (12,162) size 226x136 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
index 964d5d4..29d7df7 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.png and b/LayoutTests/platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.png differ
index f85259d..b4e24e7 100644 (file)
@@ -1,8 +1,8 @@
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 500x154 layerType: background only
-layer at (0,0) size 281x75
-  RenderBlock (positioned) zI: -1 {div} at (0,0) size 281x75 [bgcolor=#FF0000]
+layer at (0,0) size 375x75
+  RenderBlock (positioned) zI: -1 {div} at (0,0) size 375x75 [bgcolor=#FF0000]
 layer at (0,0) size 500x154 layerType: foreground only
   RenderBlock {html} at (0,0) size 500x154
     RenderBody {body} at (0,0) size 500x154
@@ -11,10 +11,10 @@ layer at (0,0) size 500x154 layerType: foreground only
           layer at (0,0) size 375x150
             RenderView at (0,0) size 375x150
           layer at (0,0) size 375x75
-            RenderSVGRoot {svg} at (0,0) size 282x75
-              RenderSVGRect {rect} at (0,0) size 282x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=281.25] [height=75.00]
-              RenderSVGRect {rect} at (14,3) size 254x69 [fill={[type=SOLID] [color=#008000]}] [x=14.06] [y=3.75] [width=253.13] [height=67.50]
-layer at (0,80) size 281x75
-  RenderSVGRoot {svg} at (0,80) size 281x75
-    RenderSVGRect {rect} at (0,80) size 281x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
-    RenderSVGRect {rect} at (14,83) size 253x69 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
+            RenderSVGRoot {svg} at (0,0) size 375x75
+              RenderSVGRect {rect} at (0,0) size 375x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=375.00] [height=75.00]
+              RenderSVGRect {rect} at (18,3) size 339x69 [fill={[type=SOLID] [color=#008000]}] [x=18.75] [y=3.75] [width=337.50] [height=67.50]
+layer at (0,80) size 375x75
+  RenderSVGRoot {svg} at (0,80) size 375x75
+    RenderSVGRect {rect} at (0,80) size 375x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
+    RenderSVGRect {rect} at (18,83) size 339x69 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
index c865135..5d9d9dd 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.png and b/LayoutTests/platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.png differ
index 315de26..d73815a 100644 (file)
@@ -12,8 +12,8 @@ layer at (0,0) size 500x154 layerType: foreground only
             RenderView at (0,0) size 375x150
           layer at (0,0) size 281x75
             RenderSVGRoot {svg} at (0,0) size 281x75
-              RenderSVGRect {rect} at (0,0) size 281x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=281.25] [height=75.00]
-              RenderSVGRect {rect} at (14,3) size 254x69 [fill={[type=SOLID] [color=#008000]}] [x=14.06] [y=3.75] [width=253.13] [height=67.50]
+              RenderSVGRect {rect} at (0,0) size 281x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=281.00] [height=75.00]
+              RenderSVGRect {rect} at (14,3) size 253x69 [fill={[type=SOLID] [color=#008000]}] [x=14.05] [y=3.75] [width=252.90] [height=67.50]
 layer at (0,80) size 281x75
   RenderSVGRoot {svg} at (0,80) size 281x75
     RenderSVGRect {rect} at (0,80) size 281x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
index 8e05233..c5dec13 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.png and b/LayoutTests/platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.png differ
index 0d3ac26..359dbbe 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/viewBox-hit-expected.png and b/LayoutTests/platform/mac/svg/custom/viewBox-hit-expected.png differ
index d8e3bce..849ce47 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/zoom/page/absolute-sized-document-no-scrollbars-expected.png and b/LayoutTests/platform/mac/svg/zoom/page/absolute-sized-document-no-scrollbars-expected.png differ
index 0a6f398..f8089f3 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/zoom/page/zoom-background-image-tiled-expected.png and b/LayoutTests/platform/mac/svg/zoom/page/zoom-background-image-tiled-expected.png differ
index a1b8c25..08dc25f 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/zoom/page/zoom-background-images-expected.png and b/LayoutTests/platform/mac/svg/zoom/page/zoom-background-images-expected.png differ
index ceed694..8ee5f9d 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/zoom/page/zoom-hixie-mixed-009-expected.png and b/LayoutTests/platform/mac/svg/zoom/page/zoom-hixie-mixed-009-expected.png differ
index 3ade1c6..780d27d 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/zoom/page/zoom-img-preserveAspectRatio-support-1-expected.png and b/LayoutTests/platform/mac/svg/zoom/page/zoom-img-preserveAspectRatio-support-1-expected.png differ
index a812bd6..4c42c09 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/zoom/page/zoom-replaced-intrinsic-ratio-001-expected.png and b/LayoutTests/platform/mac/svg/zoom/page/zoom-replaced-intrinsic-ratio-001-expected.png differ
index d4b0c3d..aa6226d 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.png and b/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.png differ
index d4b0c3d..aa6226d 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.png and b/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.png differ
index 1a9757a..31781cf 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.png and b/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.png differ
index 330572d..98ca354 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-huge-size-expected.png and b/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-huge-size-expected.png differ
index bb77caa..a32565a 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-override-size-expected.png and b/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-override-size-expected.png differ
index 83c4ed8..9a9d4da 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-percentage-size-expected.png and b/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-percentage-size-expected.png differ
index 3e4b5cf..8808400 100644 (file)
Binary files a/LayoutTests/platform/mac/tables/mozilla/bugs/bug101674-expected.png and b/LayoutTests/platform/mac/tables/mozilla/bugs/bug101674-expected.png differ
index f8b3603..9ecd3ff 100644 (file)
-layer at (0,0) size 785x1560
+layer at (0,0) size 785x1582
   RenderView at (0,0) size 785x600
-layer at (0,0) size 785x1560
-  RenderBlock {HTML} at (0,0) size 785x1560
-    RenderBody {BODY} at (8,8) size 769x1544
-      RenderTable {TABLE} at (0,0) size 769x74 [border: (1px solid #000000)]
-        RenderTableSection {TBODY} at (1,1) size 767x72
-          RenderTableRow {TR} at (0,2) size 767x68
-            RenderTableCell {TD} at (2,2) size 444x68 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
-              RenderImage {IMG} at (2,2) size 88x64
-              RenderImage {IMG} at (90,2) size 88x64
-              RenderImage {IMG} at (178,2) size 88x64
-              RenderImage {IMG} at (266,2) size 88x64
-              RenderImage {IMG} at (354,2) size 88x64
+layer at (0,0) size 785x1582
+  RenderBlock {HTML} at (0,0) size 785x1582
+    RenderBody {BODY} at (8,8) size 769x1566
+      RenderTable {TABLE} at (0,0) size 769x75 [border: (1px solid #000000)]
+        RenderTableSection {TBODY} at (1,1) size 767x73
+          RenderTableRow {TR} at (0,2) size 767x69
+            RenderTableCell {TD} at (2,2) size 444x69 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
+              RenderImage {IMG} at (2,2) size 88x65
+              RenderImage {IMG} at (90,2) size 88x65
+              RenderImage {IMG} at (178,2) size 88x65
+              RenderImage {IMG} at (266,2) size 88x65
+              RenderImage {IMG} at (354,2) size 88x65
             RenderTableCell {TD} at (448,25) size 317x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 157x18
                 text run at (2,2) width 157: "Nothing between images"
-      RenderTable {TABLE} at (0,74) size 769x330 [border: (1px solid #000000)]
-        RenderTableSection {TBODY} at (1,1) size 767x328
-          RenderTableRow {TR} at (0,2) size 767x324
-            RenderTableCell {TD} at (2,2) size 92x324 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
-              RenderImage {IMG} at (2,2) size 88x64
+      RenderTable {TABLE} at (0,75) size 769x335 [border: (1px solid #000000)]
+        RenderTableSection {TBODY} at (1,1) size 767x333
+          RenderTableRow {TR} at (0,2) size 767x329
+            RenderTableCell {TD} at (2,2) size 92x329 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
+              RenderImage {IMG} at (2,2) size 88x65
               RenderText {#text} at (0,0) size 0x0
-              RenderImage {IMG} at (2,66) size 88x64
+              RenderImage {IMG} at (2,67) size 88x65
               RenderText {#text} at (0,0) size 0x0
-              RenderImage {IMG} at (2,130) size 88x64
+              RenderImage {IMG} at (2,132) size 88x65
               RenderText {#text} at (0,0) size 0x0
-              RenderImage {IMG} at (2,194) size 88x64
+              RenderImage {IMG} at (2,197) size 88x65
               RenderText {#text} at (0,0) size 0x0
-              RenderImage {IMG} at (2,258) size 88x64
-            RenderTableCell {TD} at (96,153) size 669x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
+              RenderImage {IMG} at (2,262) size 88x65
+            RenderTableCell {TD} at (96,155) size 669x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 149x18
                 text run at (2,2) width 149: "Spaces between images"
-      RenderTable {TABLE} at (0,404) size 769x330 [border: (1px solid #000000)]
-        RenderTableSection {TBODY} at (1,1) size 767x328
-          RenderTableRow {TR} at (0,2) size 767x324
-            RenderTableCell {TD} at (2,2) size 92x324 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
-              RenderImage {IMG} at (2,2) size 88x64
+      RenderTable {TABLE} at (0,410) size 769x335 [border: (1px solid #000000)]
+        RenderTableSection {TBODY} at (1,1) size 767x333
+          RenderTableRow {TR} at (0,2) size 767x329
+            RenderTableCell {TD} at (2,2) size 92x329 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
+              RenderImage {IMG} at (2,2) size 88x65
               RenderText {#text} at (0,0) size 0x0
-              RenderImage {IMG} at (2,66) size 88x64
+              RenderImage {IMG} at (2,67) size 88x65
               RenderText {#text} at (0,0) size 0x0
-              RenderImage {IMG} at (2,130) size 88x64
+              RenderImage {IMG} at (2,132) size 88x65
               RenderText {#text} at (0,0) size 0x0
-              RenderImage {IMG} at (2,194) size 88x64
+              RenderImage {IMG} at (2,197) size 88x65
               RenderText {#text} at (0,0) size 0x0
-              RenderImage {IMG} at (2,258) size 88x64
-            RenderTableCell {TD} at (96,153) size 669x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
+              RenderImage {IMG} at (2,262) size 88x65
+            RenderTableCell {TD} at (96,155) size 669x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 165x18
                 text run at (2,2) width 165: "Newlines between images"
-      RenderTable {TABLE} at (0,734) size 769x78 [border: (1px solid #000000)]
-        RenderTableSection {TBODY} at (1,1) size 767x76
-          RenderTableRow {TR} at (0,2) size 767x72
-            RenderTableCell {TD} at (2,2) size 596x72 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
-              RenderText {#text} at (2,52) size 27x18
-                text run at (2,52) width 27: "One"
-              RenderImage {IMG} at (29,2) size 88x64
-              RenderText {#text} at (117,52) size 30x18
-                text run at (117,52) width 30: "Two"
-              RenderImage {IMG} at (147,2) size 88x64
-              RenderText {#text} at (235,52) size 37x18
-                text run at (235,52) width 37: "Three"
-              RenderImage {IMG} at (272,2) size 88x64
-              RenderText {#text} at (360,52) size 30x18
-                text run at (360,52) width 30: "Four"
-              RenderImage {IMG} at (390,2) size 88x64
-              RenderText {#text} at (478,52) size 28x18
-                text run at (478,52) width 28: "Five"
-              RenderImage {IMG} at (506,2) size 88x64
+      RenderTable {TABLE} at (0,745) size 769x79 [border: (1px solid #000000)]
+        RenderTableSection {TBODY} at (1,1) size 767x77
+          RenderTableRow {TR} at (0,2) size 767x73
+            RenderTableCell {TD} at (2,2) size 596x73 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,53) size 27x18
+                text run at (2,53) width 27: "One"
+              RenderImage {IMG} at (29,2) size 88x65
+              RenderText {#text} at (117,53) size 30x18
+                text run at (117,53) width 30: "Two"
+              RenderImage {IMG} at (147,2) size 88x65
+              RenderText {#text} at (235,53) size 37x18
+                text run at (235,53) width 37: "Three"
+              RenderImage {IMG} at (272,2) size 88x65
+              RenderText {#text} at (360,53) size 30x18
+                text run at (360,53) width 30: "Four"
+              RenderImage {IMG} at (390,2) size 88x65
+              RenderText {#text} at (478,53) size 28x18
+                text run at (478,53) width 28: "Five"
+              RenderImage {IMG} at (506,2) size 88x65
             RenderTableCell {TD} at (600,27) size 165x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 134x18
                 text run at (2,2) width 134: "Text between images"
-      RenderTable {TABLE} at (0,812) size 769x364 [border: (1px solid #000000)]
-        RenderTableSection {TBODY} at (1,1) size 767x362
-          RenderTableRow {TR} at (0,2) size 767x358
-            RenderTableCell {TD} at (2,2) size 129x358 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
+      RenderTable {TABLE} at (0,824) size 769x369 [border: (1px solid #000000)]
+        RenderTableSection {TBODY} at (1,1) size 767x367
+          RenderTableRow {TR} at (0,2) size 767x363
+            RenderTableCell {TD} at (2,2) size 129x363 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
               RenderText {#text} at (2,2) size 27x18
                 text run at (2,2) width 27: "One"
-              RenderImage {IMG} at (2,20) size 88x64
-              RenderText {#text} at (90,70) size 30x18
-                text run at (90,70) width 30: "Two"
-              RenderImage {IMG} at (2,88) size 88x64
-              RenderText {#text} at (90,138) size 37x18
-                text run at (90,138) width 37: "Three"
-              RenderImage {IMG} at (2,156) size 88x64
-              RenderText {#text} at (90,206) size 30x18
-                text run at (90,206) width 30: "Four"
-              RenderImage {IMG} at (2,224) size 88x64
-              RenderText {#text} at (90,274) size 28x18
-                text run at (90,274) width 28: "Five"
-              RenderImage {IMG} at (2,292) size 88x64
-            RenderTableCell {TD} at (133,170) size 632x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
+              RenderImage {IMG} at (2,20) size 88x65
+              RenderText {#text} at (90,71) size 30x18
+                text run at (90,71) width 30: "Two"
+              RenderImage {IMG} at (2,89) size 88x65
+              RenderText {#text} at (90,140) size 37x18
+                text run at (90,140) width 37: "Three"
+              RenderImage {IMG} at (2,158) size 88x65
+              RenderText {#text} at (90,209) size 30x18
+                text run at (90,209) width 30: "Four"
+              RenderImage {IMG} at (2,227) size 88x65
+              RenderText {#text} at (90,278) size 28x18
+                text run at (90,278) width 28: "Five"
+              RenderImage {IMG} at (2,296) size 88x65
+            RenderTableCell {TD} at (133,172) size 632x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 211x18
                 text run at (2,2) width 211: "Text with spaces between images"
-      RenderTable {TABLE} at (0,1176) size 769x368 [border: (1px solid #000000)]
-        RenderTableSection {TBODY} at (1,1) size 767x366
-          RenderTableRow {TR} at (0,2) size 767x362
-            RenderTableCell {TD} at (2,2) size 137x362 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
-              RenderText {#text} at (2,2) size 27x86
+      RenderTable {TABLE} at (0,1193) size 769x373 [border: (1px solid #000000)]
+        RenderTableSection {TBODY} at (1,1) size 767x371
+          RenderTableRow {TR} at (0,2) size 767x367
+            RenderTableCell {TD} at (2,2) size 137x367 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 27x87
                 text run at (2,2) width 27: "One"
-                text run at (2,70) width 12: "A"
-              RenderImage {IMG} at (14,20) size 88x64
-              RenderText {#text} at (102,70) size 130x86
-                text run at (102,70) width 30: "Two"
-                text run at (2,138) width 8: "b"
-              RenderImage {IMG} at (10,88) size 88x64
-              RenderText {#text} at (98,138) size 133x86
-                text run at (98,138) width 37: "Three"
-                text run at (2,206) width 7: "c"
-              RenderImage {IMG} at (9,156) size 88x64
-              RenderText {#text} at (97,206) size 125x86
-                text run at (97,206) width 30: "Four"
-                text run at (2,274) width 8: "d"
-              RenderImage {IMG} at (10,224) size 88x64
-              RenderText {#text} at (98,274) size 124x86
-                text run at (98,274) width 28: "Five"
-                text run at (2,342) width 7: "e"
-              RenderImage {IMG} at (9,292) size 88x64
-            RenderTableCell {TD} at (141,172) size 624x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
+                text run at (2,71) width 12: "A"
+              RenderImage {IMG} at (14,20) size 88x65
+              RenderText {#text} at (102,71) size 130x87
+                text run at (102,71) width 30: "Two"
+                text run at (2,140) width 8: "b"
+              RenderImage {IMG} at (10,89) size 88x65
+              RenderText {#text} at (98,140) size 133x87
+                text run at (98,140) width 37: "Three"
+                text run at (2,209) width 7: "c"
+              RenderImage {IMG} at (9,158) size 88x65
+              RenderText {#text} at (97,209) size 125x87
+                text run at (97,209) width 30: "Four"
+                text run at (2,278) width 8: "d"
+              RenderImage {IMG} at (10,227) size 88x65
+              RenderText {#text} at (98,278) size 124x87
+                text run at (98,278) width 28: "Five"
+                text run at (2,347) width 7: "e"
+              RenderImage {IMG} at (9,296) size 88x65
+            RenderTableCell {TD} at (141,174) size 624x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 301x18
                 text run at (2,2) width 301: "Text with spaces and more text between images"
index 3af4b74..8830f78 100644 (file)
Binary files a/LayoutTests/platform/mac/tables/mozilla/bugs/bug86708-expected.png and b/LayoutTests/platform/mac/tables/mozilla/bugs/bug86708-expected.png differ
index 67d79c1..83eb3d5 100644 (file)
@@ -3,17 +3,17 @@ layer at (0,0) size 800x600
 layer at (0,0) size 800x600
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
-      RenderTable {TABLE} at (0,0) size 750x235 [border: (2px outset #808080)]
-        RenderTableSection {TBODY} at (2,2) size 746x231
-          RenderTableRow {TR} at (0,0) size 746x211
-            RenderTableCell {TD} at (0,0) size 474x211 [bgcolor=#FF0000] [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+      RenderTable {TABLE} at (0,0) size 750x236 [border: (2px outset #808080)]
+        RenderTableSection {TBODY} at (2,2) size 746x232
+          RenderTableRow {TR} at (0,0) size 746x212
+            RenderTableCell {TD} at (0,0) size 474x212 [bgcolor=#FF0000] [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
               RenderInline {A} at (0,0) size 286x18 [color=#0000EE]
-                RenderImage {IMG} at (1,1) size 286x209
+                RenderImage {IMG} at (1,1) size 286x210
             RenderTableCell {TD} at (474,0) size 272x20 [bgcolor=#FFFF00] [border: (1px inset #808080)] [r=0 c=1 rs=2 cs=1]
               RenderText {#text} at (1,1) size 169x18
                 text run at (1,1) width 169: "ROWSPAN =2 in this cell"
-          RenderTableRow {TR} at (0,211) size 746x20
-            RenderTableCell {TD} at (0,211) size 474x20 [bgcolor=#FFFFFF] [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+          RenderTableRow {TR} at (0,212) size 746x20
+            RenderTableCell {TD} at (0,212) size 474x20 [bgcolor=#FFFFFF] [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
               RenderBlock {P} at (1,1) size 472x18
                 RenderText {#text} at (0,0) size 296x18
                   text run at (0,0) width 296: "Hello, this text may appear on the image above"
index bdf06cb..58e32d3 100644 (file)
Binary files a/LayoutTests/platform/mac/tables/mozilla_expected_failures/bugs/97619-expected.png and b/LayoutTests/platform/mac/tables/mozilla_expected_failures/bugs/97619-expected.png differ
index d61e347..061a7ee 100644 (file)
@@ -3,63 +3,63 @@ layer at (0,0) size 800x600
 layer at (0,0) size 800x600
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
-      RenderTable {TABLE} at (0,0) size 784x120 [border: (1px outset #808080)]
-        RenderTableSection {TBODY} at (1,1) size 782x118
-          RenderTableRow {TR} at (0,2) size 782x114
-            RenderTableCell {TD} at (2,2) size 74x114 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+      RenderTable {TABLE} at (0,0) size 784x121 [border: (1px outset #808080)]
+        RenderTableSection {TBODY} at (1,1) size 782x119
+          RenderTableRow {TR} at (0,2) size 782x115
+            RenderTableCell {TD} at (2,2) size 74x115 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
               RenderText {#text} at (2,2) size 70x72
                 text run at (2,2) width 59: "check for"
                 text run at (2,20) width 55: "handling"
                 text run at (2,38) width 13: "of"
                 text run at (2,56) width 70: "whitespace"
-              RenderImage {IMG} at (2,74) size 20x16
-              RenderText {#text} at (22,76) size 68x36
-                text run at (22,76) width 48: " around"
-                text run at (2,94) width 61: "the image"
+              RenderImage {IMG} at (2,74) size 20x17
+              RenderText {#text} at (22,77) size 68x36
+                text run at (22,77) width 48: " around"
+                text run at (2,95) width 61: "the image"
             RenderTableCell {TD} at (78,48) size 702x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 12x18
                 text run at (2,2) width 12: "X"
-      RenderBlock {HR} at (0,128) size 77x2 [border: (1px inset #000000)]
-      RenderTable {TABLE} at (0,138) size 784x152 [border: (1px outset #808080)]
-        RenderTableSection {TBODY} at (1,1) size 782x150
-          RenderTableRow {TR} at (0,2) size 782x146
-            RenderTableCell {TD} at (2,2) size 24x146 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+      RenderBlock {HR} at (0,129) size 77x2 [border: (1px inset #000000)]
+      RenderTable {TABLE} at (0,139) size 784x153 [border: (1px outset #808080)]
+        RenderTableSection {TBODY} at (1,1) size 782x151
+          RenderTableRow {TR} at (0,2) size 782x147
+            RenderTableCell {TD} at (2,2) size 24x147 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
               RenderText {#text} at (2,2) size 16x72
                 text run at (2,2) width 14: "aa"
                 text run at (2,20) width 16: "bb"
                 text run at (2,38) width 14: "cc"
                 text run at (2,56) width 16: "dd"
-              RenderImage {IMG} at (2,74) size 20x16
-              RenderText {#text} at (2,90) size 16x54
-                text run at (2,90) width 14: "ee"
-                text run at (2,108) width 10: "ff"
-                text run at (2,126) width 16: "gg"
+              RenderImage {IMG} at (2,74) size 20x17
+              RenderText {#text} at (2,91) size 16x54
+                text run at (2,91) width 14: "ee"
+                text run at (2,109) width 10: "ff"
+                text run at (2,127) width 16: "gg"
             RenderTableCell {TD} at (28,64) size 752x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 12x18
                 text run at (2,2) width 12: "X"
-      RenderBlock {HR} at (0,298) size 77x2 [border: (1px inset #000000)]
-      RenderTable {TABLE} at (0,308) size 784x48 [border: (1px outset #808080)]
-        RenderTableSection {TBODY} at (1,1) size 782x46
-          RenderTableRow {TR} at (0,2) size 782x42
-            RenderTableCell {TD} at (2,2) size 213x42 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+      RenderBlock {HR} at (0,300) size 77x2 [border: (1px inset #000000)]
+      RenderTable {TABLE} at (0,310) size 784x49 [border: (1px outset #808080)]
+        RenderTableSection {TBODY} at (1,1) size 782x47
+          RenderTableRow {TR} at (0,2) size 782x43
+            RenderTableCell {TD} at (2,2) size 213x43 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
               RenderText {#text} at (2,2) size 209x18
                 text run at (2,2) width 209: "checkforhandlingofnowhitespace"
-              RenderImage {IMG} at (2,20) size 20x16
-              RenderText {#text} at (22,22) size 105x18
-                text run at (22,22) width 105: " aroundtheimage"
+              RenderImage {IMG} at (2,20) size 20x17
+              RenderText {#text} at (22,23) size 105x18
+                text run at (22,23) width 105: " aroundtheimage"
             RenderTableCell {TD} at (217,12) size 563x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 12x18
                 text run at (2,2) width 12: "X"
-      RenderBlock {HR} at (0,364) size 77x2 [border: (1px inset #000000)]
-      RenderTable {TABLE} at (0,374) size 784x30 [border: (1px outset #808080)]
-        RenderTableSection {TBODY} at (1,1) size 782x28
-          RenderTableRow {TR} at (0,2) size 782x24
-            RenderTableCell {TD} at (2,2) size 334x24 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
-              RenderText {#text} at (2,4) size 209x18
-                text run at (2,4) width 209: "checkforhandlingofnowhitespace"
-              RenderImage {IMG} at (211,2) size 20x16
-              RenderText {#text} at (231,4) size 101x18
-                text run at (231,4) width 101: "aroundtheimage"
+      RenderBlock {HR} at (0,367) size 77x2 [border: (1px inset #000000)]
+      RenderTable {TABLE} at (0,377) size 784x31 [border: (1px outset #808080)]
+        RenderTableSection {TBODY} at (1,1) size 782x29
+          RenderTableRow {TR} at (0,2) size 782x25
+            RenderTableCell {TD} at (2,2) size 334x25 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,5) size 209x18
+                text run at (2,5) width 209: "checkforhandlingofnowhitespace"
+              RenderImage {IMG} at (211,2) size 20x17
+              RenderText {#text} at (231,5) size 101x18
+                text run at (231,5) width 101: "aroundtheimage"
             RenderTableCell {TD} at (338,3) size 442x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
               RenderText {#text} at (2,2) size 12x18
                 text run at (2,2) width 12: "X"
index 03fc3a6..909e77c 100644 (file)
@@ -5,9 +5,9 @@
         html { width: 500px; }
         body { padding: 0; margin: 0; }
         p { padding: 0; margin: 0; }
-        div { position: absolute; top: 0px; left: 0px; width: 125px; height: 75px; background: red; z-index: -1; }
+        div { position: absolute; top: 0px; left: 0px; width: 250px; height: 75px; background: red; z-index: -1; }
         object { width: 250px; height: auto; }
-        svg { position: absolute; top: 80px; left: 0px; width: 125px; height: 75px; }
+        svg { position: absolute; top: 80px; left: 0px; width: 250px; height: 75px; }
     </style>
 </head>
 <body>
index f517127..df25644 100644 (file)
@@ -5,9 +5,9 @@
         html { width: 500px; }
         body { padding: 0; margin: 0; }
         p { padding: 0; margin: 0; }
-        div { position: absolute; top: 0px; left: 0px; width: 125px; height: 112.5px; background: red; z-index: -1; }
+        div { position: absolute; top: 0px; left: 0px; width: 250px; height: 112.5px; background: red; z-index: -1; }
         object { width: 250px; height: auto; }
-        svg { position: absolute; top: 117.5px; left: 0px; width: 125px; height: 112.5px; }
+        svg { position: absolute; top: 117.5px; left: 0px; width: 250px; height: 112.5px; }
     </style>
 </head>
 <body>
index 7f3949a..6c322fe 100644 (file)
@@ -5,9 +5,9 @@
         html { width: 500px; }
         body { padding: 0; margin: 0; }
         p { padding: 0; margin: 0; }
-        div { position: absolute; top: 0px; left: 0px; width: 125px; height: 150px; background: red; z-index: -1; }
+        div { position: absolute; top: 0px; left: 0px; width: 250px; height: 150px; background: red; z-index: -1; }
         object { width: 250px; height: auto; }
-        svg { position: absolute; top: 155px; left: 0px; width: 125px; height: 150px; }
+        svg { position: absolute; top: 155px; left: 0px; width: 250px; height: 150px; }
     </style>
 </head>
 <body>
index abf1eda..136dcd5 100644 (file)
@@ -5,9 +5,9 @@
         html { width: 500px; }
         body { padding: 0; margin: 0; }
         p { padding: 0; margin: 0; }
-        div { position: absolute; top: 0px; left: 0px; width: 281.25px; height: 75px; background: red; z-index: -1; }
+        div { position: absolute; top: 0px; left: 0px; width: 375px; height: 75px; background: red; z-index: -1; }
         object { width: 375px; height: auto; }
-        svg { position: absolute; top: 80px; left: 0px; width: 281.25px; height: 75px; }
+        svg { position: absolute; top: 80px; left: 0px; width: 375px; height: 75px; }
     </style>
 </head>
 <body>
index a058094..27ff864 100644 (file)
@@ -23,7 +23,7 @@ layer at (0,0) size 800x600
         RenderSVGInlineText {#text} at (0,0) size 0x0
       RenderSVGHiddenContainer {defs} at (0,0) size 0x0
         RenderSVGForeignObject {foreignObject} at (0,0) size 0x0
-          RenderSVGRoot {svg} at (0,0) size 42x4
+          RenderSVGRoot {svg} at (0,0) size 0x0
             RenderSVGText {text} at (0,-15) size 42x18 contains 1 chunk(s)
               RenderSVGInlineText {#text} at (0,0) size 42x18
                 chunk 1 text run 1 at (0.00,0.00) startOffset 0 endOffset 5 width 41.00: "Hello"
index b35b5ab..4287a07 100755 (executable)
@@ -1,3 +1,62 @@
+2012-01-20  Nikolas Zimmermann  <nzimmermann@rim.com>
+
+        Differentiate between SVG/CSS width/height attributes/properties
+        https://bugs.webkit.org/show_bug.cgi?id=76447
+
+        Reviewed by Antti Koivisto.
+
+        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:
+
 2012-01-20  Sami Kyostila  <skyostil@chromium.org>
 
         window.innerWidth/Height should not include page scale
index 171c1c4..bc31269 100644 (file)
@@ -46,11 +46,6 @@ svg:not(:root), symbol, image, marker, pattern, foreignObject {
     overflow: hidden
 }
 
-svg {
-    width: 100%;
-    height: 100%;
-}
-
 text, foreignObject {
     display: block
 }
index d72754a..e00e1d8 100644 (file)
@@ -431,7 +431,7 @@ public:
     bool hasVisualOverflow() const { return m_overflow && !borderBoxRect().contains(m_overflow->visualOverflowRect()); }
 
     virtual bool needsPreferredWidthsRecalculation() const;
-    virtual void computeIntrinsicRatioInformation(FloatSize& /* intrinsicRatio */, bool& /* isPercentageIntrinsicSize */) const { }
+    virtual void computeIntrinsicRatioInformation(FloatSize& /* intrinsicSize */, double& /* intrinsicRatio */, bool& /* isPercentageIntrinsicSize */) const { }
 
 protected:
     virtual void willBeDestroyed();
index 2833f18..9d9411d 100644 (file)
@@ -872,16 +872,22 @@ IntSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* imag
         Length intrinsicHeight;
         image->computeIntrinsicDimensions(this, intrinsicWidth, intrinsicHeight, intrinsicRatio);
 
+        // Intrinsic dimensions expressed as percentages must be resolved relative to the dimensions of the rectangle
+        // that establishes the coordinate system for the 'background-position' property. 
+
         // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
-        if (intrinsicWidth.isFixed())
-            resolvedWidth = static_cast<int>(ceilf(intrinsicWidth.value() * style()->effectiveZoom()));
-        if (intrinsicHeight.isFixed())
-            resolvedHeight = static_cast<int>(ceilf(intrinsicHeight.value() * style()->effectiveZoom()));
+        if (intrinsicWidth.isPercent() && intrinsicHeight.isPercent() && intrinsicRatio.isEmpty()) {
+            // Resolve width/height percentages against positioningAreaSize, only if no intrinsic ratio is provided.
+            resolvedWidth = static_cast<int>(round(positioningAreaSize.width() * intrinsicWidth.percent() / 100));
+            resolvedHeight = static_cast<int>(round(positioningAreaSize.height() * intrinsicHeight.percent() / 100));
+        } else {
+            if (intrinsicWidth.isFixed())
+                resolvedWidth = static_cast<int>(intrinsicWidth.value() * style()->effectiveZoom());
+            if (intrinsicHeight.isFixed())
+                resolvedHeight = static_cast<int>(intrinsicHeight.value() * style()->effectiveZoom());
+        }
     }
 
-    // Intrinsic dimensions expressed as percentages must be resolved relative to the dimensions of the rectangle
-    // that establishes the coordinate system for the 'background-position' property. SVG on the other hand
-    // _explicitely_ says that percentage values for the width/height attributes do NOT define intrinsic dimensions.
     if (resolvedWidth > 0 && resolvedHeight > 0)
         return IntSize(resolvedWidth, resolvedHeight);
 
index 441722e..d025c09 100644 (file)
@@ -492,12 +492,8 @@ LayoutUnit RenderImage::computeReplacedLogicalWidth(bool includeMaxWidth) const
         return width;
     }
 
-    RenderBox* contentRenderer = embeddedContentBox();
-    bool hasRelativeWidth = contentRenderer ? contentRenderer->style()->width().isPercent() : m_imageResource->imageHasRelativeWidth();
-    bool hasRelativeHeight = contentRenderer ? contentRenderer->style()->height().isPercent() : m_imageResource->imageHasRelativeHeight();
-
     IntSize containerSize;
-    if (hasRelativeWidth || hasRelativeHeight) {
+    if (m_imageResource->imageHasRelativeWidth() || m_imageResource->imageHasRelativeHeight()) {
         // Propagate the containing block size to the image resource, otherwhise we can't compute our own intrinsic size, if it's relative.
         RenderObject* containingBlock = isPositioned() ? container() : this->containingBlock();
         if (containingBlock->isBox()) {
@@ -523,14 +519,16 @@ LayoutUnit RenderImage::computeReplacedLogicalWidth(bool includeMaxWidth) const
     return RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth);
 }
 
-void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicRatio, bool& isPercentageIntrinsicSize) const
+void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const
 {
     // Assure this method is never used for SVGImages.
     ASSERT(!embeddedContentBox());
     isPercentageIntrinsicSize = false;
     CachedImage* cachedImage = m_imageResource ? m_imageResource->cachedImage() : 0;
-    if (cachedImage && cachedImage->image())
-        intrinsicRatio = cachedImage->image()->size();
+    if (!cachedImage || !cachedImage->image())
+        return;
+    intrinsicSize = cachedImage->image()->size();
+    intrinsicRatio = intrinsicSize.width() / static_cast<double>(intrinsicSize.height());
 }
 
 bool RenderImage::needsPreferredWidthsRecalculation() const
index 54ef16c..489ceb1 100644 (file)
@@ -60,7 +60,7 @@ public:
 protected:
     virtual bool needsPreferredWidthsRecalculation() const;
     virtual RenderBox* embeddedContentBox() const;
-    virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
+    virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
 
     virtual void styleDidChange(StyleDifference, const RenderStyle*);
 
index c51292a..21fc498 100644 (file)
@@ -216,6 +216,68 @@ int RenderReplaced::computeIntrinsicLogicalHeight(RenderBox* contentRenderer) co
     return contentRenderer->computeReplacedLogicalHeightRespectingMinMaxHeight(contentRenderer->computeReplacedLogicalHeightUsing(contentRenderer->style()->logicalHeight()));
 }
 
+static inline RenderBlock* firstContainingBlockWithLogicalWidth(const RenderReplaced* replaced)
+{
+    // We have to lookup the containing block, which has an explicit width, which must not be equal to our direct containing block.
+    // If the embedded document appears _after_ we performed the initial layout, our intrinsic size is 300x150. If our containing
+    // block doesn't provide an explicit width, it's set to the 300 default, coming from the initial layout run.
+    RenderBlock* containingBlock = replaced->containingBlock();
+    if (!containingBlock)
+        return 0;
+
+    for (; !containingBlock->isRenderView() && !containingBlock->isBody(); containingBlock = containingBlock->containingBlock()) {
+        if (containingBlock->style()->logicalWidth().isSpecified())
+            return containingBlock;
+    }
+
+    return 0;
+}
+
+bool RenderReplaced::hasReplacedLogicalWidth() const
+{
+    if (style()->logicalWidth().isSpecified())
+        return true;
+
+    if (style()->logicalWidth().isAuto())
+        return false;
+
+    return firstContainingBlockWithLogicalWidth(this);
+}
+
+static inline bool hasAutoHeightOrContainingBlockWithAutoHeight(const RenderReplaced* replaced)
+{
+    Length logicalHeightLength = replaced->style()->logicalHeight();
+    if (logicalHeightLength.isAuto())
+        return true;
+
+    // For percentage heights: The percentage is calculated with respect to the height of the generated box's
+    // containing block. If the height of the containing block is not specified explicitly (i.e., it depends
+    // on content height), and this element is not absolutely positioned, the value computes to 'auto'.
+    if (!logicalHeightLength.isPercent() || replaced->isPositioned() || replaced->document()->inQuirksMode())
+        return false;
+
+    for (RenderBlock* cb = replaced->containingBlock(); !cb->isRenderView(); cb = cb->containingBlock()) {
+        if (cb->isTableCell() || (!cb->style()->logicalHeight().isAuto() || (!cb->style()->top().isAuto() && !cb->style()->bottom().isAuto())))
+            return false;
+    }
+
+    return true;
+}
+
+bool RenderReplaced::hasReplacedLogicalHeight() const
+{
+    if (style()->logicalHeight().isAuto())
+        return false;
+
+    if (style()->logicalHeight().isSpecified()) {
+        if (hasAutoHeightOrContainingBlockWithAutoHeight(this))
+            return false;
+        return true;
+    }
+
+    return false;
+}
+
 LayoutUnit RenderReplaced::computeReplacedLogicalWidth(bool includeMaxWidth) const
 {
     if (style()->logicalWidth().isSpecified())
@@ -226,75 +288,68 @@ LayoutUnit RenderReplaced::computeReplacedLogicalWidth(bool includeMaxWidth) con
 
     // 10.3.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-width
     bool isPercentageIntrinsicSize = false;
-    FloatSize intrinsicRatio;
+    double intrinsicRatio = 0;
+    FloatSize intrinsicSize;
     if (contentRenderer) {
-        contentRenderer->computeIntrinsicRatioInformation(intrinsicRatio, isPercentageIntrinsicSize);
+        contentRenderer->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
         contentRenderStyle = contentRenderer->style();
         ASSERT(contentRenderStyle);
     } else
-        computeIntrinsicRatioInformation(intrinsicRatio, isPercentageIntrinsicSize);
+        computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
+
+    if (intrinsicRatio && !isHorizontalWritingMode())
+        intrinsicRatio = 1 / intrinsicRatio;
 
     if (style()->logicalWidth().isAuto()) {
         bool heightIsAuto = style()->logicalHeight().isAuto();
-        bool hasIntrinsicWidth = m_hasIntrinsicSize || (contentRenderer && contentRenderStyle->logicalWidth().isFixed());
+        bool hasIntrinsicWidth = m_hasIntrinsicSize || (!isPercentageIntrinsicSize && intrinsicSize.width() > 0);
 
         // If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic width, then that intrinsic width is the used value of 'width'.
-        if (heightIsAuto && hasIntrinsicWidth)
-            return computeIntrinsicLogicalWidth(contentRenderer, includeMaxWidth);
-    
-        bool hasIntrinsicHeight = m_hasIntrinsicSize || (contentRenderer && contentRenderStyle->logicalHeight().isFixed());
-        if (!intrinsicRatio.isEmpty()) {
+        if (heightIsAuto && hasIntrinsicWidth) {
+            if (m_hasIntrinsicSize)
+                return computeReplacedLogicalWidthRespectingMinMaxWidth(calcAspectRatioLogicalWidth(), includeMaxWidth);
+            return static_cast<LayoutUnit>(intrinsicSize.width() * style()->effectiveZoom());
+        }
+
+        bool hasIntrinsicHeight = m_hasIntrinsicSize || (!isPercentageIntrinsicSize && intrinsicSize.height() > 0);
+        if (intrinsicRatio || isPercentageIntrinsicSize) {
             // If 'height' and 'width' both have computed values of 'auto' and the element has no intrinsic width, but does have an intrinsic height and intrinsic ratio;
             // or if 'width' has a computed value of 'auto', 'height' has some other computed value, and the element does have an intrinsic ratio; then the used value
             // of 'width' is: (used height) * (intrinsic ratio)
-            if ((heightIsAuto && !hasIntrinsicWidth && hasIntrinsicHeight) || !heightIsAuto) {
-                if (heightIsAuto) {
-                    if (contentRenderer) {
-                        LayoutUnit logicalHeight = contentRenderer->computeReplacedLogicalHeightUsing(contentRenderStyle->logicalHeight());
-                        // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
-                        return contentRenderer->computeReplacedLogicalWidthRespectingMinMaxWidth(static_cast<int>(ceilf(logicalHeight * intrinsicRatio.width() / intrinsicRatio.height())));
-                    }
-                } else { 
-                    LayoutUnit logicalHeight = computeReplacedLogicalHeightUsing(style()->logicalHeight());
-                    // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
-                    return computeReplacedLogicalWidthRespectingMinMaxWidth(static_cast<int>(ceilf(logicalHeight * intrinsicRatio.width() / intrinsicRatio.height())));
-                }
+            if (intrinsicRatio && ((heightIsAuto && !hasIntrinsicWidth && hasIntrinsicHeight) || !heightIsAuto)) {
+                LayoutUnit logicalHeight = computeReplacedLogicalHeightUsing(style()->logicalHeight());
+                return computeReplacedLogicalWidthRespectingMinMaxWidth(static_cast<LayoutUnit>(ceil(logicalHeight * intrinsicRatio)));
             }
 
             // If 'height' and 'width' both have computed values of 'auto' and the element has an intrinsic ratio but no intrinsic height or width, then the used value of
             // 'width' is undefined in CSS 2.1. However, it is suggested that, if the containing block's width does not itself depend on the replaced element's width, then
             // the used value of 'width' is calculated from the constraint equation used for block-level, non-replaced elements in normal flow.
-            RenderBlock* containingBlock = this->containingBlock();
-            if (heightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeight && contentRenderer && containingBlock) {
+            if (heightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeight && contentRenderer) {
                 // The aforementioned 'constraint equation' used for block-level, non-replaced elements in normal flow:
                 // 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containing block
+                LayoutUnit logicalWidth;
+                if (RenderBlock* blockWithWidth = firstContainingBlockWithLogicalWidth(this))
+                    logicalWidth = blockWithWidth->computeReplacedLogicalWidthRespectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(blockWithWidth->style()->logicalWidth()), false);
+                else
+                    logicalWidth = containingBlock()->availableLogicalWidth();
 
-                // We have to lookup the containing block, which has an explicit width, which must not be equal to our direct containing block.
-                // If the embedded document appears _after_ we performed the initial layout, our intrinsic size is 300x150. If our containing
-                // block doesn't provide an explicit width, it's set to the 300 default, coming from the initial layout run.
-                bool foundExplicitWidth = false;
-                for (; !containingBlock->isRenderView() && !containingBlock->isBody(); containingBlock = containingBlock->containingBlock()) {
-                    if (containingBlock->style()->logicalWidth().isSpecified()) {
-                        foundExplicitWidth = true;
-                        break;
-                    }
-                }
-                
                 // This solves above equation for 'width' (== logicalWidth).
-                LayoutUnit logicalWidth = foundExplicitWidth ? computeIntrinsicLogicalWidth(containingBlock, false) : containingBlock->availableLogicalWidth();
                 LayoutUnit marginStart = style()->marginStart().calcMinValue(logicalWidth);
                 LayoutUnit marginEnd = style()->marginEnd().calcMinValue(logicalWidth);
                 logicalWidth = max(0, logicalWidth - (marginStart + marginEnd + (width() - clientWidth())));
                 if (isPercentageIntrinsicSize)
                     // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
-                    logicalWidth = static_cast<int>(ceilf(logicalWidth * intrinsicRatio.width() / 100));
+                    logicalWidth = static_cast<LayoutUnit>(round(logicalWidth * intrinsicSize.width() / 100));
                 return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth);
             }
         }
 
         // Otherwise, if 'width' has a computed value of 'auto', and the element has an intrinsic width, then that intrinsic width is the used value of 'width'.
-        if (hasIntrinsicWidth)
-            return computeIntrinsicLogicalWidth(contentRenderer, includeMaxWidth);
+        if (hasIntrinsicWidth) {
+            if (isPercentageIntrinsicSize || m_hasIntrinsicSize)
+                return computeReplacedLogicalWidthRespectingMinMaxWidth(calcAspectRatioLogicalWidth(), includeMaxWidth);
+            return static_cast<LayoutUnit>(intrinsicSize.width() * style()->effectiveZoom());
+        }
 
         // Otherwise, if 'width' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'width' becomes 300px. If 300px is too
         // wide to fit the device, UAs should use the width of the largest rectangle that has a 2:1 ratio and fits the device instead.
@@ -304,31 +359,10 @@ LayoutUnit RenderReplaced::computeReplacedLogicalWidth(bool includeMaxWidth) con
     return computeReplacedLogicalWidthRespectingMinMaxWidth(intrinsicLogicalWidth(), includeMaxWidth);
 }
 
-bool RenderReplaced::logicalHeightIsAuto() const
-{
-    Length logicalHeightLength = style()->logicalHeight();
-    if (logicalHeightLength.isAuto())
-        return true;
-    
-    // For percentage heights: The percentage is calculated with respect to the height of the generated box's
-    // containing block. If the height of the containing block is not specified explicitly (i.e., it depends
-    // on content height), and this element is not absolutely positioned, the value computes to 'auto'.
-    if (!logicalHeightLength.isPercent() || isPositioned() || document()->inQuirksMode())
-        return false;
-
-    for (RenderBlock* cb = containingBlock(); !cb->isRenderView(); cb = cb->containingBlock()) {
-        if (cb->isTableCell() || (!cb->style()->logicalHeight().isAuto() || (!cb->style()->top().isAuto() && !cb->style()->bottom().isAuto())))
-            return false;
-    }
-
-    return true;
-}
-
 LayoutUnit RenderReplaced::computeReplacedLogicalHeight() const
 {
     // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/visudet.html#propdef-height
-    bool heightIsAuto = logicalHeightIsAuto();
-    if (style()->logicalHeight().isSpecified() && !heightIsAuto)
+    if (hasReplacedLogicalHeight())
         return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(style()->logicalHeight()));
 
     RenderBox* contentRenderer = embeddedContentBox();
@@ -336,37 +370,45 @@ LayoutUnit RenderReplaced::computeReplacedLogicalHeight() const
 
     // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-height
     bool isPercentageIntrinsicSize = false;
-    FloatSize intrinsicRatio;
+    double intrinsicRatio = 0;
+    FloatSize intrinsicSize;
     if (contentRenderer) {
-        contentRenderer->computeIntrinsicRatioInformation(intrinsicRatio, isPercentageIntrinsicSize);
+        contentRenderer->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
         contentRenderStyle = contentRenderer->style();
         ASSERT(contentRenderStyle);
+    } else
+        computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
+
+    if (intrinsicRatio && !isHorizontalWritingMode())
+        intrinsicRatio = 1 / intrinsicRatio;
+
+    bool widthIsAuto = style()->logicalWidth().isAuto();
+    bool hasIntrinsicHeight = m_hasIntrinsicSize || (!isPercentageIntrinsicSize && intrinsicSize.height() > 0);
+
+    // If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic height, then that intrinsic height is the used value of 'height'.
+    if (widthIsAuto && hasIntrinsicHeight) {
+        if (m_hasIntrinsicSize)
+            return computeReplacedLogicalHeightRespectingMinMaxHeight(calcAspectRatioLogicalHeight());
+        return static_cast<LayoutUnit>(intrinsicSize.height() * style()->effectiveZoom());
     }
 
-    if (heightIsAuto) {
-        bool widthIsAuto = style()->logicalWidth().isAuto();
-        bool hasIntrinsicHeight = m_hasIntrinsicSize || (contentRenderer && contentRenderStyle->logicalHeight().isFixed());
+    // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is:
+    // (used width) / (intrinsic ratio)
+    if (intrinsicRatio && !isPercentageIntrinsicSize) {
+        // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
+        return computeReplacedLogicalHeightRespectingMinMaxHeight(round(availableLogicalWidth() / intrinsicRatio));
+    }
 
-        // If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic height, then that intrinsic height is the used value of 'height'.
-        if (widthIsAuto && hasIntrinsicHeight)
-            return computeIntrinsicLogicalHeight(contentRenderer);
-    
-        // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is:
-        // (used width) / (intrinsic ratio)
-        if (!intrinsicRatio.isEmpty() && !isPercentageIntrinsicSize)
-            // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
-            return computeReplacedLogicalHeightRespectingMinMaxHeight(static_cast<int>(ceilf(availableLogicalWidth() * intrinsicRatio.height() / intrinsicRatio.width())));
-
-        // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'.
-        if (hasIntrinsicHeight)
-            return computeIntrinsicLogicalHeight(contentRenderer);
-
-        // Otherwise, if 'height' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'height' must be set to the height
-        // of the largest rectangle that has a 2:1 ratio, has a height not greater than 150px, and has a width not greater than the device width.
-        return computeReplacedLogicalHeightRespectingMinMaxHeight(cDefaultHeight);
+    // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'.
+    if (hasIntrinsicHeight) {
+        if (m_hasIntrinsicSize)
+            return computeReplacedLogicalHeightRespectingMinMaxHeight(calcAspectRatioLogicalHeight());
+        return static_cast<LayoutUnit>(intrinsicSize.height() * style()->effectiveZoom());
     }
 
-    return computeReplacedLogicalHeightRespectingMinMaxHeight(intrinsicLogicalHeight());
+    // Otherwise, if 'height' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'height' must be set to the height
+    // of the largest rectangle that has a 2:1 ratio, has a height not greater than 150px, and has a width not greater than the device width.
+    return computeReplacedLogicalHeightRespectingMinMaxHeight(cDefaultHeight);
 }
 
 int RenderReplaced::calcAspectRatioLogicalWidth() const
index ce11201..1c6ebbc 100644 (file)
@@ -35,7 +35,8 @@ public:
     virtual LayoutUnit computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
     virtual LayoutUnit computeReplacedLogicalHeight() const;
 
-    bool logicalHeightIsAuto() const;
+    bool hasReplacedLogicalWidth() const;
+    bool hasReplacedLogicalHeight() const;
 
 protected:
     virtual void willBeDestroyed();
index d51617b..d0fe7f1 100644 (file)
@@ -66,35 +66,53 @@ RenderSVGRoot::~RenderSVGRoot()
 {
 }
 
-void RenderSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicRatio, bool& isPercentageIntrinsicSize) const
+void RenderSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const
 {
-    // Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#IntrinsicSizing
-    // The intrinsic aspect ratio of the viewport of SVG content is necessary for example, when including
-    // SVG from an ‘object’ element in HTML styled with CSS. It is possible (indeed, common) for an SVG
-    // graphic to have an intrinsic aspect ratio but not to have an intrinsic width or height.
-    // The intrinsic aspect ratio must be calculated based upon the following rules:
-    // The aspect ratio is calculated by dividing a width by a height.
-
-    // If the ‘width’ and ‘height’ of the rootmost ‘svg’ element are both specified with unit identifiers
-    // (in, mm, cm, pt, pc, px, em, ex) or in user units, then the aspect ratio is calculated from the
-    // ‘width’ and ‘height’ attributes after resolving both values to user units.
-    isPercentageIntrinsicSize = false;
-    if (style()->width().isFixed() && style()->height().isFixed()) {
-        intrinsicRatio = FloatSize(width(), height());
+    // Spec: http://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
+    // SVG needs to specify how to calculate some intrinsic sizing properties to enable inclusion within other languages.
+    // The intrinsic width and height of the viewport of SVG content must be determined from the ‘width’ and ‘height’ attributes.
+    // If either of these are not specified, a value of '100%' must be assumed. Note: the ‘width’ and ‘height’ attributes are not
+    // the same as the CSS width and height properties. Specifically, percentage values do not provide an intrinsic width or height,
+    // and do not indicate a percentage of the containing block. Rather, once the viewport is established, they indicate the portion
+    // of the viewport that is actually covered by image data.
+    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
+    Length intrinsicWidthAttribute = svg->intrinsicWidth(SVGSVGElement::IgnoreCSSProperties);
+    Length intrinsicHeightAttribute = svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties);
+
+    // The intrinsic aspect ratio of the viewport of SVG content is necessary for example, when including SVG from an ‘object’
+    // element in HTML styled with CSS. It is possible (indeed, common) for an SVG graphic to have an intrinsic aspect ratio but
+    // not to have an intrinsic width or height. The intrinsic aspect ratio must be calculated based upon the following rules:
+    // - The aspect ratio is calculated by dividing a width by a height.
+    // - If the ‘width’ and ‘height’ of the rootmost ‘svg’ element are both specified with unit identifiers (in, mm, cm, pt, pc,
+    //   px, em, ex) or in user units, then the aspect ratio is calculated from the ‘width’ and ‘height’ attributes after
+    //   resolving both values to user units.
+    if (intrinsicWidthAttribute.isFixed() || intrinsicHeightAttribute.isFixed()) {
+        if (intrinsicWidthAttribute.isFixed())
+            intrinsicSize.setWidth(intrinsicWidthAttribute.calcFloatValue(0));
+        if (intrinsicHeightAttribute.isFixed())
+            intrinsicSize.setHeight(intrinsicHeightAttribute.calcFloatValue(0));
+        if (!intrinsicSize.isEmpty())
+            intrinsicRatio = intrinsicSize.width() / static_cast<double>(intrinsicSize.height());
         return;
     }
 
-    // If either/both of the ‘width’ and ‘height’ of the rootmost ‘svg’ element are in percentage units (or omitted),
-    // the aspect ratio is calculated from the width and height values of the ‘viewBox’ specified for the current SVG
-    // document fragment. If the ‘viewBox’ is not correctly specified, or set to 'none', the intrinsic aspect ratio
-    // cannot be calculated and is considered unspecified.
-    intrinsicRatio = static_cast<SVGSVGElement*>(node())->currentViewBoxRect().size();
+    // - If either/both of the ‘width’ and ‘height’ of the rootmost ‘svg’ element are in percentage units (or omitted), the
+    //   aspect ratio is calculated from the width and height values of the ‘viewBox’ specified for the current SVG document
+    //   fragment. If the ‘viewBox’ is not correctly specified, or set to 'none', the intrinsic aspect ratio cannot be
+    //   calculated and is considered unspecified.
+    intrinsicSize = svg->viewBox().size();
+    if (!intrinsicSize.isEmpty()) {
+        // The viewBox can only yield an intrinsic ratio, not an intrinsic size.
+        intrinsicRatio = intrinsicSize.width() / static_cast<double>(intrinsicSize.height());
+        intrinsicSize = FloatSize();
+        return;
+    }
 
-    // Compatibility with authors expectations and Firefox/Opera: when percentage units are used, take them into
-    // account for certain cases of the intrinsic width/height calculation in RenderPart::computeReplacedLogicalWidth/Height.
-    if (intrinsicRatio.isEmpty() && style()->width().isPercent() && style()->height().isPercent()) {
+    // If our intrinsic size is in percentage units, return those to the caller through the intrinsicSize. Notify the caller
+    // about the special situation, by setting isPercentageIntrinsicSize=true, so it knows how to interpret the return values.
+    if (intrinsicWidthAttribute.isPercent() && intrinsicHeightAttribute.isPercent()) {
         isPercentageIntrinsicSize = true;
-        intrinsicRatio = FloatSize(style()->width().percent(), style()->height().percent());
+        intrinsicSize = FloatSize(intrinsicWidthAttribute.percent(), intrinsicHeightAttribute.percent());
     }
 }
 
@@ -134,82 +152,54 @@ bool RenderSVGRoot::isEmbeddedThroughFrameContainingSVGDocument() const
     return frame->document()->isSVGDocument();
 }
 
+static inline LayoutUnit resolveLengthAttributeForSVG(const Length& length, float scale, float maxSize)
+{
+    return static_cast<LayoutUnit>(length.calcValue(maxSize) * (length.isFixed() ? scale : 1));
+/*
+    if (length.isFixed())
+        return static_cast<LayoutUnit>(length.calcFloatValue(maxSize) * scale);
+    return static_cast<LayoutUnit>(length.calcFloatValue(maxSize));
+*/
+}
+
 LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(bool includeMaxWidth) const
 {
+    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
+    ASSERT(svg);
+
     // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
-    LayoutUnit replacedWidth = m_containerSize.width();
-    if (replacedWidth > 0)
-        return replacedWidth;
+    if (!m_containerSize.isEmpty())
+        return m_containerSize.width();
 
-    replacedWidth = RenderBox::computeReplacedLogicalWidth(includeMaxWidth);
-    Frame* frame = node() && node()->document() ? node()->document()->frame() : 0;
-    if (!frame)
-        return replacedWidth;
-
-    if (!isEmbeddedThroughFrameContainingSVGDocument())
-        return replacedWidth;
-
-    RenderPart* ownerRenderer = frame->ownerRenderer();
-    RenderStyle* ownerRendererStyle = ownerRenderer->style();
-    ASSERT(ownerRendererStyle);
-    ASSERT(frame->contentRenderer());
-
-    Length ownerWidth = ownerRendererStyle->width();
-    if (ownerWidth.isAuto())
-        return replacedWidth;
-
-    // Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#ViewportSpace
-    // The SVG user agent negotiates with its parent user agent to determine the viewport into which the SVG user agent can render
-    // the document. In some circumstances, SVG content will be embedded (by reference or inline) within a containing document.
-    // This containing document might include attributes, properties and/or other parameters (explicit or implicit) which specify
-    // or provide hints about the dimensions of the viewport for the SVG content. SVG content itself optionally can provide
-    // information about the appropriate viewport region for the content via the ‘width’ and ‘height’ XML attributes on the
-    // outermost svg element. The negotiation process uses any information provided by the containing document and the SVG
-    // content itself to choose the viewport location and size.
-
-    // The ‘width’ attribute on the outermost svg element establishes the viewport's width, unless the following conditions are met:
-    // * the SVG content is a separately stored resource that is embedded by reference (such as the ‘object’ element in XHTML [XHTML]),
-    //   or the SVG content is embedded inline within a containing document;
-    // * and the referencing element or containing document is styled using CSS [CSS2] or XSL [XSL];
-    // * and there are CSS-compatible positioning properties ([CSS2], section 9.3) specified on the referencing element
-    //   (e.g., the ‘object’ element) or on the containing document's outermost svg element that are sufficient to establish
-    //   the width of the viewport.
-    //
-    // Under these conditions, the positioning properties establish the viewport's width.
-    return ownerRenderer->computeReplacedLogicalWidthRespectingMinMaxWidth(ownerRenderer->computeReplacedLogicalWidthUsing(ownerWidth), includeMaxWidth);
+    if (style()->logicalWidth().isSpecified())
+        return RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth);
+
+    if (svg->widthAttributeEstablishesViewport())
+        return resolveLengthAttributeForSVG(svg->intrinsicWidth(SVGSVGElement::IgnoreCSSProperties), style()->effectiveZoom(), containingBlock()->availableLogicalWidth());
+
+    // Only SVGs embedded in <object> reach this point.
+    ASSERT(isEmbeddedThroughFrameContainingSVGDocument());
+    return document()->frame()->ownerRenderer()->availableLogicalWidth();
 }
 
 LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const
 {
-    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
-    LayoutUnit replacedHeight = m_containerSize.height();
-    if (replacedHeight > 0)
-        return replacedHeight;
-
-    replacedHeight = RenderBox::computeReplacedLogicalHeight();
-    Frame* frame = node() && node()->document() ? node()->document()->frame() : 0;
-    if (!frame)
-        return replacedHeight;
-
-    if (!isEmbeddedThroughFrameContainingSVGDocument())
-        return replacedHeight;
+    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
+    ASSERT(svg);
 
-    RenderPart* ownerRenderer = frame->ownerRenderer();
-    ASSERT(ownerRenderer);
+    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
+    if (!m_containerSize.isEmpty())
+        return m_containerSize.height();
 
-    RenderStyle* ownerRendererStyle = ownerRenderer->style();
-    ASSERT(ownerRendererStyle);
+    if (hasReplacedLogicalHeight())
+        return RenderReplaced::computeReplacedLogicalHeight();
 
-    Length ownerHeight = ownerRendererStyle->height();
-    if (ownerHeight.isAuto())
-        return replacedHeight;
+    if (svg->heightAttributeEstablishesViewport())
+        return resolveLengthAttributeForSVG(svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties), style()->effectiveZoom(), containingBlock()->availableLogicalHeight());
 
-    // Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#ViewportSpace
-    // See comment in RenderSVGRoot::computeReplacedLogicalWidth().
-    // Similarly, if there are positioning properties specified on the referencing element or on the outermost svg element that
-    // are sufficient to establish the height of the viewport, then these positioning properties establish the viewport's height;
-    // otherwise, the ‘height’ attribute on the outermost svg element establishes the viewport's height.
-    return ownerRenderer->computeReplacedLogicalHeightRespectingMinMaxHeight(ownerRenderer->computeReplacedLogicalHeightUsing(ownerHeight));
+    // Only SVGs embedded in <object> reach this point.
+    ASSERT(isEmbeddedThroughFrameContainingSVGDocument());
+    return document()->frame()->ownerRenderer()->availableLogicalHeight();
 }
 
 void RenderSVGRoot::layout()
index ea6580f..7b55a28 100644 (file)
@@ -42,7 +42,7 @@ public:
     bool isEmbeddedThroughSVGImage() const;
     bool isEmbeddedThroughFrameContainingSVGDocument() const;
 
-    virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
+    virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
     const RenderObjectChildList* children() const { return &m_children; }
     RenderObjectChildList* children() { return &m_children; }
 
index 66037e6..07be7eb 100644 (file)
@@ -33,6 +33,7 @@ namespace WebCore {
 class RenderSVGViewportContainer : public RenderSVGContainer {
 public:
     explicit RenderSVGViewportContainer(SVGStyledElement*);
+    FloatRect viewport() const { return m_viewport; }
 
 private:
     virtual bool isSVGContainer() const { return true; }
index cb4763d..4f595c2 100755 (executable)
@@ -29,6 +29,8 @@
 #include "ExceptionCode.h"
 #include "Frame.h"
 #include "RenderPart.h"
+#include "RenderSVGRoot.h"
+#include "RenderSVGViewportContainer.h"
 #include "RenderView.h"
 #include "SVGNames.h"
 #include "SVGSVGElement.h"
@@ -274,65 +276,23 @@ bool SVGLengthContext::determineViewport(float& width, float& height) const
         return true;
     }
 
-    // Take size from outermost <svg> element.
-    Document* document = m_context->document();
-    if (document->documentElement() == m_context) {
-        if (m_context->isSVG()) {
-            Frame* frame = m_context->document() ? m_context->document()->frame() : 0;
-            if (!frame)
-                return false;
-
-            // SVGs embedded through <object> resolve percentage values against the owner renderer in the host document.
-            if (RenderPart* ownerRenderer = frame->ownerRenderer()) {
-                width = ownerRenderer->width();
-                height = ownerRenderer->height();
-                return true;
-            }
-        }
-
-        RenderView* view = toRenderView(document->renderer());
-        if (!view)
-            return false;
-
-        // Always resolve percentages against the unscaled viewport, as agreed across browsers.
-        float zoom = view->style()->effectiveZoom();
-        width = view->viewWidth();
-        height = view->viewHeight();
-        if (zoom != 1) {
-            width /= zoom;
-            height /= zoom;
-        }
-        return true;
-    }
+    // SVGLengthContext should NEVER be used to resolve width/height values for <svg> elements,
+    // as they require special treatment, due the relationship with the CSS width/height properties.
+    ASSERT(m_context->document()->documentElement() != m_context);
 
-    // Take size from nearest viewport element (common case: inner <svg> elements)
+    // Take size from nearest viewport element.
     SVGElement* viewportElement = m_context->viewportElement();
-    if (viewportElement && viewportElement->isSVG()) {
-        const SVGSVGElement* svg = static_cast<const SVGSVGElement*>(viewportElement);
-        FloatRect viewBox = svg->currentViewBoxRect();
-        if (viewBox.isEmpty()) {
-            SVGLengthContext viewportContext(svg);
-            width = svg->width().value(viewportContext);
-            height = svg->height().value(viewportContext);
-        } else {
-            width = viewBox.width();
-            height = viewBox.height();
-        }
-
-        return true;
-    }
-    
-    // Take size from enclosing non-SVG RenderBox (common case: inline SVG)
-    if (!m_context->parentNode() || m_context->parentNode()->isSVGElement())
-        return false;
-
-    RenderObject* renderer = m_context->renderer();
-    if (!renderer || !renderer->isBox())
+    if (!viewportElement)
         return false;
-
-    RenderBox* box = toRenderBox(renderer);
-    width = box->width();
-    height = box->height();
+    
+    ASSERT(viewportElement->isSVG());
+    const SVGSVGElement* svg = static_cast<const SVGSVGElement*>(viewportElement);
+    FloatSize viewportSize = svg->currentViewBoxRect().size();
+    if (viewportSize.isEmpty())
+        viewportSize = svg->currentViewportSize();
+
+    width = viewportSize.width();
+    height = viewportSize.height();
     return true;
 }
 
index 03554fd..ebce727 100644 (file)
@@ -27,7 +27,6 @@
 #include "AffineTransform.h"
 #include "Attribute.h"
 #include "CSSHelper.h"
-#include "CSSPropertyNames.h"
 #include "Document.h"
 #include "EventListener.h"
 #include "EventNames.h"
@@ -38,6 +37,7 @@
 #include "FrameTree.h"
 #include "FrameView.h"
 #include "HTMLNames.h"
+#include "RenderPart.h"
 #include "RenderSVGResource.h"
 #include "RenderSVGModelObject.h"
 #include "RenderSVGRoot.h"
@@ -141,13 +141,8 @@ void SVGSVGElement::setContentStyleType(const AtomicString& type)
 FloatRect SVGSVGElement::viewport() const
 {
     // FIXME: This method doesn't follow the spec and is basically untested. Parent documents are not considered here.
-    SVGLengthContext lengthContext(this);
-    FloatRect viewRectangle;
-    if (!isOutermostSVG())
-        viewRectangle.setLocation(FloatPoint(x().value(lengthContext), y().value(lengthContext)));
-
-    viewRectangle.setSize(FloatSize(width().value(lengthContext), height().value(lengthContext)));    
-    return viewBoxToViewTransform(viewRectangle.width(), viewRectangle.height()).mapRect(viewRectangle);
+    // As we have no test coverage for this, we're going to disable it completly for now.
+    return FloatRect();
 }
 
 float SVGSVGElement::pixelUnitToMillimeterX() const
@@ -274,13 +269,11 @@ void SVGSVGElement::parseMappedAttribute(Attribute* attr)
         setXBaseValue(SVGLength::construct(LengthModeWidth, attr->value(), parseError));
     else if (attr->name() == SVGNames::yAttr)
         setYBaseValue(SVGLength::construct(LengthModeHeight, attr->value(), parseError));
-    else if (attr->name() == SVGNames::widthAttr) {
+    else if (attr->name() == SVGNames::widthAttr)
         setWidthBaseValue(SVGLength::construct(LengthModeWidth, attr->value(), parseError, ForbidNegativeLengths));
-        addCSSProperty(attr, CSSPropertyWidth, attr->value());
-    } else if (attr->name() == SVGNames::heightAttr) {
+    else if (attr->name() == SVGNames::heightAttr)
         setHeightBaseValue(SVGLength::construct(LengthModeHeight, attr->value(), parseError, ForbidNegativeLengths));
-        addCSSProperty(attr, CSSPropertyHeight, attr->value());
-    } else if (SVGTests::parseMappedAttribute(attr)
+    else if (SVGTests::parseMappedAttribute(attr)
                || SVGLangSpace::parseMappedAttribute(attr)
                || SVGExternalResourcesRequired::parseMappedAttribute(attr)
                || SVGFitToViewBox::parseMappedAttribute(document(), attr)
@@ -291,33 +284,11 @@ void SVGSVGElement::parseMappedAttribute(Attribute* attr)
     reportAttributeParsingError(parseError, attr);
 }
 
-// This hack will not handle the case where we're setting a width/height
-// on a root <svg> via svg.width.baseValue = when it has none.
-static void updateCSSForAttribute(SVGSVGElement* element, const QualifiedName& attrName, CSSPropertyID property, const SVGLength& value)
-{
-    Attribute* attribute = element->attributes(false)->getAttributeItem(attrName);
-    if (!attribute || !attribute->isMappedAttribute())
-        return;
-    element->addCSSProperty(attribute, property, value.valueAsString());
-}
-
 void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName)
 { 
-    // FIXME: Ugly, ugly hack to around that parseMappedAttribute is not called
-    // when svg.width.baseValue = 100 is evaluated.
-    // Thus the CSS length value for width is not updated, and width() computeLogicalWidth()
-    // calculations on RenderSVGRoot will be wrong.
-    // https://bugs.webkit.org/show_bug.cgi?id=25387
     bool updateRelativeLengths = false;
-    if (attrName == SVGNames::widthAttr) {
-        updateCSSForAttribute(this, attrName, CSSPropertyWidth, widthBaseValue());
-        updateRelativeLengths = true;
-    } else if (attrName == SVGNames::heightAttr) {
-        updateCSSForAttribute(this, attrName, CSSPropertyHeight, heightBaseValue());
-        updateRelativeLengths = true;
-    }
-
-    if (updateRelativeLengths
+    if (attrName == SVGNames::widthAttr
+        || attrName == SVGNames::heightAttr
         || attrName == SVGNames::xAttr
         || attrName == SVGNames::yAttr
         || SVGFitToViewBox::isKnownAttribute(attrName)) {
@@ -450,17 +421,17 @@ SVGTransform SVGSVGElement::createSVGTransformFromMatrix(const SVGMatrix& matrix
 
 AffineTransform SVGSVGElement::localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const
 {
-    // This method resolves length manually, w/o involving the render tree. This is desired, as getCTM()/getScreenCTM()/.. have to work without a renderer.
-    SVGLengthContext lengthContext(this);
-
     AffineTransform viewBoxTransform;
-    if (attributes()->getAttributeItem(SVGNames::viewBoxAttr))
-        viewBoxTransform = viewBoxToViewTransform(width().value(lengthContext), height().value(lengthContext));
+    if (hasAttribute(SVGNames::viewBoxAttr)) {
+        FloatSize size = currentViewportSize();
+        viewBoxTransform = viewBoxToViewTransform(size.width(), size.height());
+    }
 
     AffineTransform transform;
-    if (!isOutermostSVG())
+    if (!isOutermostSVG()) {
+        SVGLengthContext lengthContext(this);
         transform.translate(x().value(lengthContext), y().value(lengthContext));
-    else if (mode == SVGLocatable::ScreenScope) {
+    else if (mode == SVGLocatable::ScreenScope) {
         if (RenderObject* renderer = this->renderer()) {
             // Translate in our CSS parent coordinate space
             // FIXME: This doesn't work correctly with CSS transforms.
@@ -555,37 +526,125 @@ bool SVGSVGElement::isOutermostSVG() const
     return !parentNode()->isSVGElement();
 }
 
-FloatRect SVGSVGElement::currentViewBoxRect(CalculateViewBoxMode mode) const
+FloatRect SVGSVGElement::currentViewBoxRect() const
 {
-    // This method resolves length manually, w/o involving the render tree. This is desired, as getCTM()/getScreenCTM()/.. have to work without a renderer.
-    SVGLengthContext lengthContext(this);
-
-    // FIXME: The interaction of 'currentView' and embedding SVGs in other documents, is untested and unspecified.
     if (useCurrentView()) {
         if (SVGViewSpec* view = currentView()) // what if we should use it but it is not set?
             return view->viewBox();
         return FloatRect();
     }
 
-    bool isEmbeddedThroughSVGImage = renderer() && renderer()->isSVGRoot() ? toRenderSVGRoot(renderer())->isEmbeddedThroughSVGImage() : false;
-    bool hasFixedSize = width().unitType() != LengthTypePercentage && height().unitType() != LengthTypePercentage;
-
     FloatRect useViewBox = viewBox();
-    if (useViewBox.isEmpty()) {
-        // If no viewBox is specified but non-relative width/height values, then we
-        // should always synthesize a viewBox if we're embedded through a SVGImage.
-        if (hasFixedSize && isEmbeddedThroughSVGImage)
-            return FloatRect(0, 0, width().value(lengthContext), height().value(lengthContext));
+    if (!useViewBox.isEmpty())
+        return useViewBox;
+    if (!renderer() || !renderer()->isSVGRoot())
         return FloatRect();
+    if (!toRenderSVGRoot(renderer())->isEmbeddedThroughSVGImage())
+        return FloatRect();
+
+    Length intrinsicWidth = this->intrinsicWidth();
+    Length intrinsicHeight = this->intrinsicHeight();
+    if (!intrinsicWidth.isFixed() || !intrinsicHeight.isFixed())
+        return FloatRect();
+
+    // If no viewBox is specified but non-relative width/height values, then we
+    // should always synthesize a viewBox if we're embedded through a SVGImage.    
+    return FloatRect(FloatPoint(), FloatSize(intrinsicWidth.calcFloatValue(0), intrinsicHeight.calcFloatValue(0)));
+}
+
+FloatSize SVGSVGElement::currentViewportSize() const
+{
+    Length intrinsicWidth = this->intrinsicWidth();
+    Length intrinsicHeight = this->intrinsicHeight();
+    if (intrinsicWidth.isFixed() && intrinsicHeight.isFixed())
+        return FloatSize(intrinsicWidth.calcFloatValue(0), intrinsicHeight.calcFloatValue(0));
+
+    if (!renderer())
+        return FloatSize();
+
+    if (renderer()->isSVGRoot()) {
+        LayoutRect frameRect = toRenderSVGRoot(renderer())->frameRect();
+        return FloatSize(frameRect.width() / renderer()->style()->effectiveZoom(), frameRect.height() / renderer()->style()->effectiveZoom());
     }
 
-    // If a viewBox is specified and non-relative width/height values, then the host document only
-    // uses the width/height values to figure out the intrinsic size when embedding us, whereas the
-    // embedded document sees specified viewBox only.
-    if (hasFixedSize && mode == CalculateViewBoxInHostDocument)
-        return FloatRect(0, 0, width().value(lengthContext), height().value(lengthContext));
+    FloatRect frameRect = toRenderSVGViewportContainer(renderer())->viewport();
+    return FloatSize(frameRect.width() / renderer()->style()->effectiveZoom(), frameRect.height() / renderer()->style()->effectiveZoom());
+}
+
+bool SVGSVGElement::widthAttributeEstablishesViewport() const
+{
+    if (!renderer() || renderer()->isSVGViewportContainer())
+        return true;
+
+    // Spec: http://www.w3.org/TR/SVG/coords.html#ViewportSpace
+    // The ‘width’ attribute on the outermost svg element establishes the viewport's width, unless the following conditions are met:
+    // - the SVG content is a separately stored resource that is embedded by reference (such as the ‘object’ element in XHTML [XHTML]), or
+    //   the SVG content is embedded inline within a containing document;
+    // - and the referencing element or containing document is styled using CSS [CSS2] or XSL [XSL];
+    // - and there are CSS-compatible positioning properties ([CSS2], section 9.3) specified on the referencing element (e.g., the ‘object’ element)
+    //   or on the containing document's outermost svg element that are sufficient to establish the width of the viewport. Under these conditions,
+    //   the positioning properties establish the viewport's width.
+    RenderSVGRoot* root = toRenderSVGRoot(renderer());
+
+    // SVG embedded through object/embed/iframe.
+    if (root->isEmbeddedThroughFrameContainingSVGDocument())
+        return !root->hasReplacedLogicalWidth() && !document()->frame()->ownerRenderer()->hasReplacedLogicalWidth();
+
+    // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SVG.
+    if (root->isEmbeddedThroughSVGImage() || document()->documentElement() != this)
+        return !root->hasReplacedLogicalWidth();
+
+    return true;
+}
+
+bool SVGSVGElement::heightAttributeEstablishesViewport() const
+{
+    if (!renderer() || renderer()->isSVGViewportContainer())
+        return true;
+
+    // Spec: http://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
+    // Similarly, if there are positioning properties specified on the referencing element or on the outermost svg element
+    // that are sufficient to establish the height of the viewport, then these positioning properties establish the viewport's
+    // height; otherwise, the ‘height’ attribute on the outermost svg element establishes the viewport's height.
+    RenderSVGRoot* root = toRenderSVGRoot(renderer());
+
+    // SVG embedded through object/embed/iframe.
+    if (root->isEmbeddedThroughFrameContainingSVGDocument())
+        return !root->hasReplacedLogicalHeight() && !document()->frame()->ownerRenderer()->hasReplacedLogicalHeight();
+
+    // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SVG.
+    if (root->isEmbeddedThroughSVGImage() || document()->documentElement() != this)
+        return !root->hasReplacedLogicalHeight();
+
+    return true;
+}
+
+Length SVGSVGElement::intrinsicWidth(ConsiderCSSMode mode) const
+{
+    if (widthAttributeEstablishesViewport() || mode == IgnoreCSSProperties) {
+        if (width().unitType() == LengthTypePercentage)
+            return Length(width().valueAsPercentage() * 100, Percent);
+
+        SVGLengthContext lengthContext(this);
+        return Length(width().value(lengthContext), Fixed);
+    }
+
+    ASSERT(renderer());
+    return renderer()->style()->width();
+}
+
+Length SVGSVGElement::intrinsicHeight(ConsiderCSSMode mode) const
+{
+    if (heightAttributeEstablishesViewport() || mode == IgnoreCSSProperties) {
+        if (height().unitType() == LengthTypePercentage)
+            return Length(height().valueAsPercentage() * 100, Percent);
+
+        SVGLengthContext lengthContext(this);
+        return Length(height().value(lengthContext), Fixed);
+    }
 
-    return useViewBox;
+    ASSERT(renderer());
+    return renderer()->style()->height();
 }
 
 AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float viewHeight) const
index eb55827..a1d4496 100644 (file)
@@ -73,12 +73,17 @@ public:
 
     SVGViewSpec* currentView() const;
 
-    enum CalculateViewBoxMode {
-        CalculateViewBoxInHostDocument,
-        CalculateViewBoxInCurrentDocument
+    enum ConsiderCSSMode {
+        RespectCSSProperties,
+        IgnoreCSSProperties
     };
 
-    FloatRect currentViewBoxRect(CalculateViewBoxMode = CalculateViewBoxInCurrentDocument) const;
+    // RenderSVGRoot wants to query the intrinsic size, by only examining the width/height attributes.
+    Length intrinsicWidth(ConsiderCSSMode = RespectCSSProperties) const;
+    Length intrinsicHeight(ConsiderCSSMode = RespectCSSProperties) const;
+    FloatSize currentViewportSize() const;
+    FloatRect currentViewBoxRect() const;
+
     float currentScale() const;
     void setCurrentScale(float scale);
 
@@ -125,6 +130,9 @@ public:
 
     Element* getElementById(const AtomicString&) const;
 
+    bool widthAttributeEstablishesViewport() const;
+    bool heightAttributeEstablishesViewport() const;
+
 protected:
     virtual void didMoveToNewDocument(Document* oldDocument) OVERRIDE;
 
index b643ee6..f4c41b7 100644 (file)
@@ -140,9 +140,15 @@ IntSize SVGImage::size() const
 
     // Assure that a container size is always given for a non-identity zoom level.
     ASSERT(renderer->style()->effectiveZoom() == 1);
-    IntSize size = enclosingIntRect(rootElement->currentViewBoxRect(SVGSVGElement::CalculateViewBoxInHostDocument)).size();
-    if (!size.isEmpty())
-        return size;
+
+    FloatSize currentSize;
+    if (rootElement->intrinsicWidth().isFixed() && rootElement->intrinsicHeight().isFixed())
+        currentSize = rootElement->currentViewportSize();
+    else
+        currentSize = rootElement->currentViewBoxRect().size();
+
+    if (!currentSize.isEmpty())
+        return IntSize(static_cast<int>(ceilf(currentSize.width())), static_cast<int>(ceilf(currentSize.height())));
 
     // As last resort, use CSS default intrinsic size.
     return IntSize(300, 150);
@@ -251,6 +257,28 @@ RenderBox* SVGImage::embeddedContentBox() const
     return toRenderBox(rootElement->renderer());
 }
 
+bool SVGImage::hasRelativeWidth() const
+{
+    if (!m_page)
+        return false;
+    Frame* frame = m_page->mainFrame();
+    SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement();
+    if (!rootElement)
+        return false;
+    return rootElement->intrinsicWidth().isPercent();
+}
+
+bool SVGImage::hasRelativeHeight() const
+{
+    if (!m_page)
+        return false;
+    Frame* frame = m_page->mainFrame();
+    SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement();
+    if (!rootElement)
+        return false;
+    return rootElement->intrinsicHeight().isPercent();
+}
+
 void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
 {
     if (!m_page)
@@ -259,14 +287,15 @@ void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrin
     SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement();
     if (!rootElement)
         return;
-    RenderBox* renderer = toRenderBox(rootElement->renderer());
-    if (!renderer)
+
+    intrinsicWidth = rootElement->intrinsicWidth();
+    intrinsicHeight = rootElement->intrinsicHeight();
+    if (rootElement->preserveAspectRatio().align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
         return;
 
-    intrinsicWidth = renderer->style()->width();
-    intrinsicHeight = renderer->style()->height();
-    if (rootElement->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
-        intrinsicRatio = rootElement->currentViewBoxRect().size();
+    intrinsicRatio = rootElement->viewBox().size();
+    if (intrinsicRatio.isEmpty() && intrinsicWidth.isFixed() && intrinsicHeight.isFixed())
+        intrinsicRatio = FloatSize(intrinsicWidth.calcFloatValue(0), intrinsicHeight.calcFloatValue(0));
 }
 
 NativeImagePtr SVGImage::nativeImageForCurrentFrame()
index 1e3fe4f..047b27f 100644 (file)
@@ -57,6 +57,9 @@ public:
     virtual bool isSVGImage() const { return true; }
     virtual IntSize size() const;
 
+    virtual bool hasRelativeWidth() const;
+    virtual bool hasRelativeHeight() const;
+
 private:
     virtual ~SVGImage();