Changeset 105513 in webkit


Ignore:
Timestamp:
Jan 20, 2012 7:30:17 AM (12 years ago)
Author:
Nikolas Zimmermann
Message:

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

Reviewed by Antti Koivisto.

Source/WebCore:

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

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

  • css/svg.css: Remove hardcoded, width/height: 100% on <svg>.
  • rendering/RenderBox.h:

(WebCore::RenderBox::computeIntrinsicRatioInformation): Make 'intrinsicRatio' a float, and add 'intrinsicSize' as seperated FloatSize, to avoid confusion.

  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions): Add forgotton case for percentage intrinsic sizes, that lead to workarounds in other places, that can now be removed.

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::computeReplacedLogicalWidth): Directly use imageHasRelativeWidth/Height(), it does differentiate between SVG/CSS width/height attributes/properties now.
(WebCore::RenderImage::computeIntrinsicRatioInformation): Adapt to 'intrinsicRatio' argument change.

  • rendering/RenderImage.h: Ditto.
  • rendering/RenderReplaced.cpp: Refactor existing code, break out firstContainingBlockWithLogicalWidth/hasReplacedLogicalWidth/hasReplacedLogicalHeight/hasAutoHeightOrContainingBlockWithAutoHeight.

(WebCore::firstContainingBlockWithLogicalWidth): Refactored.
(WebCore::RenderReplaced::hasReplacedLogicalWidth): Refactored, and exported, so SVGSVGElement::widthAttributeEstablishesViewport() can use it.
(WebCore::hasAutoHeightOrContainingBlockWithAutoHeight): Refactored.
(WebCore::RenderReplaced::hasReplacedLogicalHeight): Refactored, and exported, so SVGSVGElement::heightAttributeEstablishesViewport() can use it.
(WebCore::RenderReplaced::computeReplacedLogicalWidth): Adapt to 'intrinsicRatio' changes ('intrinsicSize' is now decoupled from it). Refactor so that RenderSVGRoot can directly use it as well!
(WebCore::RenderReplaced::computeReplacedLogicalHeight): Ditto.

  • rendering/RenderReplaced.h:
  • rendering/svg/RenderSVGRoot.cpp:

(WebCore::RenderSVGRoot::computeIntrinsicRatioInformation): Only determine the intrinsic size & ratio using the SVG width/height attributes, not the CSS width/height properties, as it's specified.
(WebCore::resolveLengthAttributeForSVG): Helper function for computeReplacedLogicalWidth/Height, that scales Length values that come from SVG width/height attributes.
(WebCore::RenderSVGRoot::computeReplacedLogicalWidth): Finally remove home-brewn size computation logic - it can be fully shared with RenderReplaced now that we inherit from it.
(WebCore::RenderSVGRoot::computeReplacedLogicalHeight): Ditto.

  • rendering/svg/RenderSVGRoot.h:
  • rendering/svg/RenderSVGViewportContainer.h:

(WebCore::RenderSVGViewportContainer::viewport): Export viewport() for easier length resolution.

  • svg/SVGLengthContext.cpp:

(WebCore::SVGLengthContext::determineViewport): Finally clean up this hell, and make it easy to understand. Only need to resolve lengths against either RenderSVGRoot or RenderSVGViewportContainer now.

  • svg/SVGSVGElement.cpp:

(WebCore::SVGSVGElement::viewport): Remove wrong code and disable this. Its not used, and we have no test coverage for it. Its current implementation didn't make any sense.
(WebCore::SVGSVGElement::parseMappedAttribute): Remove hacks mapping SVG width/height attributes to CSS properties.
(WebCore::SVGSVGElement::svgAttributeChanged): Ditto.
(WebCore::SVGSVGElement::localCoordinateSpaceTransform): Refactored.
(WebCore::SVGSVGElement::currentViewBoxRect): Ditto.
(WebCore::SVGSVGElement::currentViewportSize): Ditto.
(WebCore::SVGSVGElement::widthAttributeEstablishesViewport): Main logic determining if the SVG or CSS properties establish the viewport - a direct transliteration from the spec.
(WebCore::SVGSVGElement::heightAttributeEstablishesViewport): Ditto.
(WebCore::SVGSVGElement::intrinsicWidth): Helper.
(WebCore::SVGSVGElement::intrinsicHeight): Ditto.

  • svg/SVGSVGElement.h:
  • svg/graphics/SVGImage.cpp:

(WebCore::SVGImage::size): Cleanup code.
(WebCore::SVGImage::hasRelativeWidth): Added, avoids hacks in RenderBoxModelObject.
(WebCore::SVGImage::hasRelativeHeight): Ditto.
(WebCore::SVGImage::computeIntrinsicDimensions): Make use of new SVGSVGElement::computeIntrinsicDimensions.

  • svg/graphics/SVGImage.h:

LayoutTests:

Update SVG pixel test baseline.

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

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r105512 r105513  
     12012-01-20  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        Differentiate between SVG/CSS width/height attributes/properties
     4        https://bugs.webkit.org/show_bug.cgi?id=76447
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Update SVG pixel test baseline.
     9
     10        * platform/mac/svg/custom/dynamic-empty-path-expected.png: Marginal changes.
     11        * platform/mac/svg/custom/fractional-rects-expected.png: Ditto.
     12        * platform/mac/svg/custom/js-update-container-expected.png: Ditto.
     13        * 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.
     14        * platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.txt: Ditto.
     15        * platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.png: Ditto.
     16        * platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.txt: Ditto.
     17        * platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.png: Ditto.
     18        * platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.txt: Ditto.
     19        * platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.png: Ditto.
     20        * platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.txt: Ditto.
     21        * platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.png: Ditto.
     22        * platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.txt: Ditto.
     23        * platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.png: Ditto.
     24        * platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.txt: Ditto.
     25        * platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.png: Marginal changes.
     26        * platform/mac/svg/custom/viewBox-hit-expected.png: Ditto.
     27        * platform/mac/svg/zoom/page/absolute-sized-document-no-scrollbars-expected.png: Ditto.
     28        * platform/mac/svg/zoom/page/zoom-background-image-tiled-expected.png: Ditto.
     29        * platform/mac/svg/zoom/page/zoom-background-images-expected.png: Ditto.
     30        * platform/mac/svg/zoom/page/zoom-hixie-mixed-009-expected.png: Ditto.
     31        * platform/mac/svg/zoom/page/zoom-img-preserveAspectRatio-support-1-expected.png: Ditto.
     32        * platform/mac/svg/zoom/page/zoom-replaced-intrinsic-ratio-001-expected.png: Ditto.
     33        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.png: Ditto.
     34        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.txt: Ditto.
     35        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.png: Ditto.
     36        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.png: Ditto.
     37        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.txt: Ditto.
     38        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-huge-size-expected.png: Ditto.
     39        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-override-size-expected.png: Ditto.
     40        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-percentage-size-expected.png: Ditto.
     41        * platform/mac/tables/mozilla/bugs/bug101674-expected.png: Ditto.
     42        * platform/mac/tables/mozilla/bugs/bug101674-expected.txt: Ditto.
     43        * platform/mac/tables/mozilla/bugs/bug86708-expected.png: Ditto.
     44        * platform/mac/tables/mozilla/bugs/bug86708-expected.txt: Ditto.
     45        * platform/mac/tables/mozilla_expected_failures/bugs/97619-expected.png: Ditto.
     46        * platform/mac/tables/mozilla_expected_failures/bugs/97619-expected.txt: Ditto.
     47        * svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute.xhtml: Fix test, now that our bug is fixed.
     48        * svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute.xhtml: Ditto.
     49        * svg/custom/object-sizing-width-50p-on-target-svg-absolute.xhtml: Ditto.
     50        * svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute.xhtml: Ditto.
     51        * svg/foreignObject/text-tref-02-b-expected.txt: Size is not reported anymore.
     52
    1532012-01-20  Sami Kyostila  <skyostil@chromium.org>
    254
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r105510 r105513  
    39103910BUGWK76646 : svg/foreignObject/text-tref-02-b.svg = TEXT
    39113911
     3912// Slight changes in RenderReplaced extents.
     3913BUGWK76647 : svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute.xhtml = IMAGE+TEXT
     3914BUGWK76647 : svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute.xhtml = IMAGE+TEXT
     3915BUGWK76647 : svg/custom/object-sizing-width-50p-height-75p-on-target-svg.xhtml = IMAGE+TEXT
     3916BUGWK76647 : svg/custom/object-sizing-width-50p-on-target-svg-absolute.xhtml = IMAGE+TEXT
     3917BUGWK76647 : svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute.xhtml = IMAGE+TEXT
     3918BUGWK76647 : svg/custom/object-sizing-width-75p-height-50p-on-target-svg.xhtml = IMAGE+TEXT
     3919BUGWK76647 : tables/mozilla/bugs/bug101674.html = IMAGE+TEXT
     3920BUGWK76647 : tables/mozilla/bugs/bug86708.html = IMAGE+TEXT
     3921BUGWK76647 : tables/mozilla_expected_failures/bugs/97619.html = IMAGE+TEXT
     3922BUGWK76647 : svg/zoom/page/zoom-background-images.html = IMAGE
     3923
    39123924// Change error (misspelling) underlines from Windows look to Mac look.
    39133925BUG_CARYCLARK MAC : editing/deleting/delete-3928305-fix.html = IMAGE
  • trunk/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.txt

    r105404 r105513  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 500x154 layerType: background only
    4 layer at (0,0) size 125x75
    5   RenderBlock (positioned) zI: -1 {div} at (0,0) size 125x75 [bgcolor=#FF0000]
     4layer at (0,0) size 250x75
     5  RenderBlock (positioned) zI: -1 {div} at (0,0) size 250x75 [bgcolor=#FF0000]
    66layer at (0,0) size 500x154 layerType: foreground only
    77  RenderBlock {html} at (0,0) size 500x154
     
    1212            RenderView at (0,0) size 250x150
    1313          layer at (0,0) size 250x75
    14             RenderSVGRoot {svg} at (0,0) size 125x75
    15               RenderSVGRect {rect} at (0,0) size 125x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=125.00] [height=75.00]
    16               RenderSVGRect {rect} at (6,3) size 113x69 [fill={[type=SOLID] [color=#008000]}] [x=6.25] [y=3.75] [width=112.50] [height=67.50]
    17 layer at (0,80) size 125x75
    18   RenderSVGRoot {svg} at (0,80) size 125x75
    19     RenderSVGRect {rect} at (0,80) size 125x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    20     RenderSVGRect {rect} at (6,83) size 113x69 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
     14            RenderSVGRoot {svg} at (0,0) size 250x75
     15              RenderSVGRect {rect} at (0,0) size 250x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=250.00] [height=75.00]
     16              RenderSVGRect {rect} at (12,3) size 226x69 [fill={[type=SOLID] [color=#008000]}] [x=12.50] [y=3.75] [width=225.00] [height=67.50]
     17layer at (0,80) size 250x75
     18  RenderSVGRoot {svg} at (0,80) size 250x75
     19    RenderSVGRect {rect} at (0,80) size 250x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
     20    RenderSVGRect {rect} at (12,83) size 226x69 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
  • trunk/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.txt

    r105404 r105513  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 500x154 layerType: background only
    4 layer at (0,0) size 125x112
    5   RenderBlock (positioned) zI: -1 {div} at (0,0) size 125x112 [bgcolor=#FF0000]
     4layer at (0,0) size 250x112
     5  RenderBlock (positioned) zI: -1 {div} at (0,0) size 250x112 [bgcolor=#FF0000]
    66layer at (0,0) size 500x154 layerType: foreground only
    77  RenderBlock {html} at (0,0) size 500x154
     
    1212            RenderView at (0,0) size 250x150
    1313          layer at (0,0) size 250x112
    14             RenderSVGRoot {svg} at (0,0) size 125x112
    15               RenderSVGRect {rect} at (0,0) size 125x112 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=125.00] [height=112.50]
    16               RenderSVGRect {rect} at (6,5) size 113x102 [fill={[type=SOLID] [color=#008000]}] [x=6.25] [y=5.63] [width=112.50] [height=101.25]
    17 layer at (0,117) size 125x112
    18   RenderSVGRoot {svg} at (0,117) size 125x112
    19     RenderSVGRect {rect} at (0,117) size 125x112 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    20     RenderSVGRect {rect} at (6,122) size 113x102 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
     14            RenderSVGRoot {svg} at (0,0) size 250x112
     15              RenderSVGRect {rect} at (0,0) size 250x112 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=250.00] [height=112.00]
     16              RenderSVGRect {rect} at (12,5) size 226x102 [fill={[type=SOLID] [color=#008000]}] [x=12.50] [y=5.60] [width=225.00] [height=100.80]
     17layer at (0,117) size 250x112
     18  RenderSVGRoot {svg} at (0,117) size 250x112
     19    RenderSVGRect {rect} at (0,117) size 250x112 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
     20    RenderSVGRect {rect} at (12,122) size 226x102 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
  • trunk/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.txt

    r105404 r105513  
    1313          layer at (0,0) size 125x112
    1414            RenderSVGRoot {svg} at (0,0) size 125x112
    15               RenderSVGRect {rect} at (0,0) size 125x112 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=125.00] [height=112.50]
    16               RenderSVGRect {rect} at (6,5) size 113x102 [fill={[type=SOLID] [color=#008000]}] [x=6.25] [y=5.63] [width=112.50] [height=101.25]
     15              RenderSVGRect {rect} at (0,0) size 125x112 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=125.00] [height=112.00]
     16              RenderSVGRect {rect} at (6,5) size 113x102 [fill={[type=SOLID] [color=#008000]}] [x=6.25] [y=5.60] [width=112.50] [height=100.80]
    1717layer at (0,117) size 125x112
    1818  RenderSVGRoot {svg} at (0,117) size 125x112
  • trunk/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.txt

    r105404 r105513  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 500x154 layerType: background only
    4 layer at (0,0) size 125x150
    5   RenderBlock (positioned) zI: -1 {div} at (0,0) size 125x150 [bgcolor=#FF0000]
     4layer at (0,0) size 250x150
     5  RenderBlock (positioned) zI: -1 {div} at (0,0) size 250x150 [bgcolor=#FF0000]
    66layer at (0,0) size 500x154 layerType: foreground only
    77  RenderBlock {html} at (0,0) size 500x154
     
    1212            RenderView at (0,0) size 250x150
    1313          layer at (0,0) size 250x150
    14             RenderSVGRoot {svg} at (0,0) size 125x150
    15               RenderSVGRect {rect} at (0,0) size 125x150 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=125.00] [height=150.00]
    16               RenderSVGRect {rect} at (6,7) size 113x136 [fill={[type=SOLID] [color=#008000]}] [x=6.25] [y=7.50] [width=112.50] [height=135.00]
    17 layer at (0,155) size 125x150
    18   RenderSVGRoot {svg} at (0,155) size 125x150
    19     RenderSVGRect {rect} at (0,155) size 125x150 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    20     RenderSVGRect {rect} at (6,162) size 113x136 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
     14            RenderSVGRoot {svg} at (0,0) size 250x150
     15              RenderSVGRect {rect} at (0,0) size 250x150 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=250.00] [height=150.00]
     16              RenderSVGRect {rect} at (12,7) size 226x136 [fill={[type=SOLID] [color=#008000]}] [x=12.50] [y=7.50] [width=225.00] [height=135.00]
     17layer at (0,155) size 250x150
     18  RenderSVGRoot {svg} at (0,155) size 250x150
     19    RenderSVGRect {rect} at (0,155) size 250x150 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
     20    RenderSVGRect {rect} at (12,162) size 226x136 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
  • trunk/LayoutTests/platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.txt

    r105404 r105513  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 500x154 layerType: background only
    4 layer at (0,0) size 281x75
    5   RenderBlock (positioned) zI: -1 {div} at (0,0) size 281x75 [bgcolor=#FF0000]
     4layer at (0,0) size 375x75
     5  RenderBlock (positioned) zI: -1 {div} at (0,0) size 375x75 [bgcolor=#FF0000]
    66layer at (0,0) size 500x154 layerType: foreground only
    77  RenderBlock {html} at (0,0) size 500x154
     
    1212            RenderView at (0,0) size 375x150
    1313          layer at (0,0) size 375x75
    14             RenderSVGRoot {svg} at (0,0) size 282x75
    15               RenderSVGRect {rect} at (0,0) size 282x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=281.25] [height=75.00]
    16               RenderSVGRect {rect} at (14,3) size 254x69 [fill={[type=SOLID] [color=#008000]}] [x=14.06] [y=3.75] [width=253.13] [height=67.50]
    17 layer at (0,80) size 281x75
    18   RenderSVGRoot {svg} at (0,80) size 281x75
    19     RenderSVGRect {rect} at (0,80) size 281x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    20     RenderSVGRect {rect} at (14,83) size 253x69 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
     14            RenderSVGRoot {svg} at (0,0) size 375x75
     15              RenderSVGRect {rect} at (0,0) size 375x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=375.00] [height=75.00]
     16              RenderSVGRect {rect} at (18,3) size 339x69 [fill={[type=SOLID] [color=#008000]}] [x=18.75] [y=3.75] [width=337.50] [height=67.50]
     17layer at (0,80) size 375x75
     18  RenderSVGRoot {svg} at (0,80) size 375x75
     19    RenderSVGRect {rect} at (0,80) size 375x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
     20    RenderSVGRect {rect} at (18,83) size 339x69 [fill={[type=SOLID] [color=#008000]}] [x=5.00] [y=5.00] [width=90.00] [height=90.00]
  • trunk/LayoutTests/platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.txt

    r105404 r105513  
    1313          layer at (0,0) size 281x75
    1414            RenderSVGRoot {svg} at (0,0) size 281x75
    15               RenderSVGRect {rect} at (0,0) size 281x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=281.25] [height=75.00]
    16               RenderSVGRect {rect} at (14,3) size 254x69 [fill={[type=SOLID] [color=#008000]}] [x=14.06] [y=3.75] [width=253.13] [height=67.50]
     15              RenderSVGRect {rect} at (0,0) size 281x75 [fill={[type=SOLID] [color=#ADD8E6]}] [x=0.00] [y=0.00] [width=281.00] [height=75.00]
     16              RenderSVGRect {rect} at (14,3) size 253x69 [fill={[type=SOLID] [color=#008000]}] [x=14.05] [y=3.75] [width=252.90] [height=67.50]
    1717layer at (0,80) size 281x75
    1818  RenderSVGRoot {svg} at (0,80) size 281x75
  • trunk/LayoutTests/platform/mac/tables/mozilla/bugs/bug101674-expected.txt

    r30635 r105513  
    1 layer at (0,0) size 785x1560
     1layer at (0,0) size 785x1582
    22  RenderView at (0,0) size 785x600
    3 layer at (0,0) size 785x1560
    4   RenderBlock {HTML} at (0,0) size 785x1560
    5     RenderBody {BODY} at (8,8) size 769x1544
    6       RenderTable {TABLE} at (0,0) size 769x74 [border: (1px solid #000000)]
    7         RenderTableSection {TBODY} at (1,1) size 767x72
    8           RenderTableRow {TR} at (0,2) size 767x68
    9             RenderTableCell {TD} at (2,2) size 444x68 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
    10               RenderImage {IMG} at (2,2) size 88x64
    11               RenderImage {IMG} at (90,2) size 88x64
    12               RenderImage {IMG} at (178,2) size 88x64
    13               RenderImage {IMG} at (266,2) size 88x64
    14               RenderImage {IMG} at (354,2) size 88x64
     3layer at (0,0) size 785x1582
     4  RenderBlock {HTML} at (0,0) size 785x1582
     5    RenderBody {BODY} at (8,8) size 769x1566
     6      RenderTable {TABLE} at (0,0) size 769x75 [border: (1px solid #000000)]
     7        RenderTableSection {TBODY} at (1,1) size 767x73
     8          RenderTableRow {TR} at (0,2) size 767x69
     9            RenderTableCell {TD} at (2,2) size 444x69 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
     10              RenderImage {IMG} at (2,2) size 88x65
     11              RenderImage {IMG} at (90,2) size 88x65
     12              RenderImage {IMG} at (178,2) size 88x65
     13              RenderImage {IMG} at (266,2) size 88x65
     14              RenderImage {IMG} at (354,2) size 88x65
    1515            RenderTableCell {TD} at (448,25) size 317x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
    1616              RenderText {#text} at (2,2) size 157x18
    1717                text run at (2,2) width 157: "Nothing between images"
    18       RenderTable {TABLE} at (0,74) size 769x330 [border: (1px solid #000000)]
    19         RenderTableSection {TBODY} at (1,1) size 767x328
    20           RenderTableRow {TR} at (0,2) size 767x324
    21             RenderTableCell {TD} at (2,2) size 92x324 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
    22               RenderImage {IMG} at (2,2) size 88x64
     18      RenderTable {TABLE} at (0,75) size 769x335 [border: (1px solid #000000)]
     19        RenderTableSection {TBODY} at (1,1) size 767x333
     20          RenderTableRow {TR} at (0,2) size 767x329
     21            RenderTableCell {TD} at (2,2) size 92x329 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
     22              RenderImage {IMG} at (2,2) size 88x65
    2323              RenderText {#text} at (0,0) size 0x0
    24               RenderImage {IMG} at (2,66) size 88x64
     24              RenderImage {IMG} at (2,67) size 88x65
    2525              RenderText {#text} at (0,0) size 0x0
    26               RenderImage {IMG} at (2,130) size 88x64
     26              RenderImage {IMG} at (2,132) size 88x65
    2727              RenderText {#text} at (0,0) size 0x0
    28               RenderImage {IMG} at (2,194) size 88x64
     28              RenderImage {IMG} at (2,197) size 88x65
    2929              RenderText {#text} at (0,0) size 0x0
    30               RenderImage {IMG} at (2,258) size 88x64
    31             RenderTableCell {TD} at (96,153) size 669x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
     30              RenderImage {IMG} at (2,262) size 88x65
     31            RenderTableCell {TD} at (96,155) size 669x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
    3232              RenderText {#text} at (2,2) size 149x18
    3333                text run at (2,2) width 149: "Spaces between images"
    34       RenderTable {TABLE} at (0,404) size 769x330 [border: (1px solid #000000)]
    35         RenderTableSection {TBODY} at (1,1) size 767x328
    36           RenderTableRow {TR} at (0,2) size 767x324
    37             RenderTableCell {TD} at (2,2) size 92x324 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
    38               RenderImage {IMG} at (2,2) size 88x64
     34      RenderTable {TABLE} at (0,410) size 769x335 [border: (1px solid #000000)]
     35        RenderTableSection {TBODY} at (1,1) size 767x333
     36          RenderTableRow {TR} at (0,2) size 767x329
     37            RenderTableCell {TD} at (2,2) size 92x329 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
     38              RenderImage {IMG} at (2,2) size 88x65
    3939              RenderText {#text} at (0,0) size 0x0
    40               RenderImage {IMG} at (2,66) size 88x64
     40              RenderImage {IMG} at (2,67) size 88x65
    4141              RenderText {#text} at (0,0) size 0x0
    42               RenderImage {IMG} at (2,130) size 88x64
     42              RenderImage {IMG} at (2,132) size 88x65
    4343              RenderText {#text} at (0,0) size 0x0
    44               RenderImage {IMG} at (2,194) size 88x64
     44              RenderImage {IMG} at (2,197) size 88x65
    4545              RenderText {#text} at (0,0) size 0x0
    46               RenderImage {IMG} at (2,258) size 88x64
    47             RenderTableCell {TD} at (96,153) size 669x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
     46              RenderImage {IMG} at (2,262) size 88x65
     47            RenderTableCell {TD} at (96,155) size 669x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
    4848              RenderText {#text} at (2,2) size 165x18
    4949                text run at (2,2) width 165: "Newlines between images"
    50       RenderTable {TABLE} at (0,734) size 769x78 [border: (1px solid #000000)]
    51         RenderTableSection {TBODY} at (1,1) size 767x76
    52           RenderTableRow {TR} at (0,2) size 767x72
    53             RenderTableCell {TD} at (2,2) size 596x72 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
    54               RenderText {#text} at (2,52) size 27x18
    55                 text run at (2,52) width 27: "One"
    56               RenderImage {IMG} at (29,2) size 88x64
    57               RenderText {#text} at (117,52) size 30x18
    58                 text run at (117,52) width 30: "Two"
    59               RenderImage {IMG} at (147,2) size 88x64
    60               RenderText {#text} at (235,52) size 37x18
    61                 text run at (235,52) width 37: "Three"
    62               RenderImage {IMG} at (272,2) size 88x64
    63               RenderText {#text} at (360,52) size 30x18
    64                 text run at (360,52) width 30: "Four"
    65               RenderImage {IMG} at (390,2) size 88x64
    66               RenderText {#text} at (478,52) size 28x18
    67                 text run at (478,52) width 28: "Five"
    68               RenderImage {IMG} at (506,2) size 88x64
     50      RenderTable {TABLE} at (0,745) size 769x79 [border: (1px solid #000000)]
     51        RenderTableSection {TBODY} at (1,1) size 767x77
     52          RenderTableRow {TR} at (0,2) size 767x73
     53            RenderTableCell {TD} at (2,2) size 596x73 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
     54              RenderText {#text} at (2,53) size 27x18
     55                text run at (2,53) width 27: "One"
     56              RenderImage {IMG} at (29,2) size 88x65
     57              RenderText {#text} at (117,53) size 30x18
     58                text run at (117,53) width 30: "Two"
     59              RenderImage {IMG} at (147,2) size 88x65
     60              RenderText {#text} at (235,53) size 37x18
     61                text run at (235,53) width 37: "Three"
     62              RenderImage {IMG} at (272,2) size 88x65
     63              RenderText {#text} at (360,53) size 30x18
     64                text run at (360,53) width 30: "Four"
     65              RenderImage {IMG} at (390,2) size 88x65
     66              RenderText {#text} at (478,53) size 28x18
     67                text run at (478,53) width 28: "Five"
     68              RenderImage {IMG} at (506,2) size 88x65
    6969            RenderTableCell {TD} at (600,27) size 165x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
    7070              RenderText {#text} at (2,2) size 134x18
    7171                text run at (2,2) width 134: "Text between images"
    72       RenderTable {TABLE} at (0,812) size 769x364 [border: (1px solid #000000)]
    73         RenderTableSection {TBODY} at (1,1) size 767x362
    74           RenderTableRow {TR} at (0,2) size 767x358
    75             RenderTableCell {TD} at (2,2) size 129x358 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
     72      RenderTable {TABLE} at (0,824) size 769x369 [border: (1px solid #000000)]
     73        RenderTableSection {TBODY} at (1,1) size 767x367
     74          RenderTableRow {TR} at (0,2) size 767x363
     75            RenderTableCell {TD} at (2,2) size 129x363 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
    7676              RenderText {#text} at (2,2) size 27x18
    7777                text run at (2,2) width 27: "One"
    78               RenderImage {IMG} at (2,20) size 88x64
    79               RenderText {#text} at (90,70) size 30x18
    80                 text run at (90,70) width 30: "Two"
    81               RenderImage {IMG} at (2,88) size 88x64
    82               RenderText {#text} at (90,138) size 37x18
    83                 text run at (90,138) width 37: "Three"
    84               RenderImage {IMG} at (2,156) size 88x64
    85               RenderText {#text} at (90,206) size 30x18
    86                 text run at (90,206) width 30: "Four"
    87               RenderImage {IMG} at (2,224) size 88x64
    88               RenderText {#text} at (90,274) size 28x18
    89                 text run at (90,274) width 28: "Five"
    90               RenderImage {IMG} at (2,292) size 88x64
    91             RenderTableCell {TD} at (133,170) size 632x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
     78              RenderImage {IMG} at (2,20) size 88x65
     79              RenderText {#text} at (90,71) size 30x18
     80                text run at (90,71) width 30: "Two"
     81              RenderImage {IMG} at (2,89) size 88x65
     82              RenderText {#text} at (90,140) size 37x18
     83                text run at (90,140) width 37: "Three"
     84              RenderImage {IMG} at (2,158) size 88x65
     85              RenderText {#text} at (90,209) size 30x18
     86                text run at (90,209) width 30: "Four"
     87              RenderImage {IMG} at (2,227) size 88x65
     88              RenderText {#text} at (90,278) size 28x18
     89                text run at (90,278) width 28: "Five"
     90              RenderImage {IMG} at (2,296) size 88x65
     91            RenderTableCell {TD} at (133,172) size 632x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
    9292              RenderText {#text} at (2,2) size 211x18
    9393                text run at (2,2) width 211: "Text with spaces between images"
    94       RenderTable {TABLE} at (0,1176) size 769x368 [border: (1px solid #000000)]
    95         RenderTableSection {TBODY} at (1,1) size 767x366
    96           RenderTableRow {TR} at (0,2) size 767x362
    97             RenderTableCell {TD} at (2,2) size 137x362 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
    98               RenderText {#text} at (2,2) size 27x86
     94      RenderTable {TABLE} at (0,1193) size 769x373 [border: (1px solid #000000)]
     95        RenderTableSection {TBODY} at (1,1) size 767x371
     96          RenderTableRow {TR} at (0,2) size 767x367
     97            RenderTableCell {TD} at (2,2) size 137x367 [border: (1px solid #000000)] [r=0 c=0 rs=1 cs=1]
     98              RenderText {#text} at (2,2) size 27x87
    9999                text run at (2,2) width 27: "One"
    100                 text run at (2,70) width 12: "A"
    101               RenderImage {IMG} at (14,20) size 88x64
    102               RenderText {#text} at (102,70) size 130x86
    103                 text run at (102,70) width 30: "Two"
    104                 text run at (2,138) width 8: "b"
    105               RenderImage {IMG} at (10,88) size 88x64
    106               RenderText {#text} at (98,138) size 133x86
    107                 text run at (98,138) width 37: "Three"
    108                 text run at (2,206) width 7: "c"
    109               RenderImage {IMG} at (9,156) size 88x64
    110               RenderText {#text} at (97,206) size 125x86
    111                 text run at (97,206) width 30: "Four"
    112                 text run at (2,274) width 8: "d"
    113               RenderImage {IMG} at (10,224) size 88x64
    114               RenderText {#text} at (98,274) size 124x86
    115                 text run at (98,274) width 28: "Five"
    116                 text run at (2,342) width 7: "e"
    117               RenderImage {IMG} at (9,292) size 88x64
    118             RenderTableCell {TD} at (141,172) size 624x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
     100                text run at (2,71) width 12: "A"
     101              RenderImage {IMG} at (14,20) size 88x65
     102              RenderText {#text} at (102,71) size 130x87
     103                text run at (102,71) width 30: "Two"
     104                text run at (2,140) width 8: "b"
     105              RenderImage {IMG} at (10,89) size 88x65
     106              RenderText {#text} at (98,140) size 133x87
     107                text run at (98,140) width 37: "Three"
     108                text run at (2,209) width 7: "c"
     109              RenderImage {IMG} at (9,158) size 88x65
     110              RenderText {#text} at (97,209) size 125x87
     111                text run at (97,209) width 30: "Four"
     112                text run at (2,278) width 8: "d"
     113              RenderImage {IMG} at (10,227) size 88x65
     114              RenderText {#text} at (98,278) size 124x87
     115                text run at (98,278) width 28: "Five"
     116                text run at (2,347) width 7: "e"
     117              RenderImage {IMG} at (9,296) size 88x65
     118            RenderTableCell {TD} at (141,174) size 624x22 [border: (1px solid #000000)] [r=0 c=1 rs=1 cs=1]
    119119              RenderText {#text} at (2,2) size 301x18
    120120                text run at (2,2) width 301: "Text with spaces and more text between images"
  • trunk/LayoutTests/platform/mac/tables/mozilla/bugs/bug86708-expected.txt

    r47440 r105513  
    44  RenderBlock {HTML} at (0,0) size 800x600
    55    RenderBody {BODY} at (8,8) size 784x584
    6       RenderTable {TABLE} at (0,0) size 750x235 [border: (2px outset #808080)]
    7         RenderTableSection {TBODY} at (2,2) size 746x231
    8           RenderTableRow {TR} at (0,0) size 746x211
    9             RenderTableCell {TD} at (0,0) size 474x211 [bgcolor=#FF0000] [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
     6      RenderTable {TABLE} at (0,0) size 750x236 [border: (2px outset #808080)]
     7        RenderTableSection {TBODY} at (2,2) size 746x232
     8          RenderTableRow {TR} at (0,0) size 746x212
     9            RenderTableCell {TD} at (0,0) size 474x212 [bgcolor=#FF0000] [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
    1010              RenderInline {A} at (0,0) size 286x18 [color=#0000EE]
    11                 RenderImage {IMG} at (1,1) size 286x209
     11                RenderImage {IMG} at (1,1) size 286x210
    1212            RenderTableCell {TD} at (474,0) size 272x20 [bgcolor=#FFFF00] [border: (1px inset #808080)] [r=0 c=1 rs=2 cs=1]
    1313              RenderText {#text} at (1,1) size 169x18
    1414                text run at (1,1) width 169: "ROWSPAN =2 in this cell"
    15           RenderTableRow {TR} at (0,211) size 746x20
    16             RenderTableCell {TD} at (0,211) size 474x20 [bgcolor=#FFFFFF] [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
     15          RenderTableRow {TR} at (0,212) size 746x20
     16            RenderTableCell {TD} at (0,212) size 474x20 [bgcolor=#FFFFFF] [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
    1717              RenderBlock {P} at (1,1) size 472x18
    1818                RenderText {#text} at (0,0) size 296x18
  • trunk/LayoutTests/platform/mac/tables/mozilla_expected_failures/bugs/97619-expected.txt

    r30635 r105513  
    44  RenderBlock {HTML} at (0,0) size 800x600
    55    RenderBody {BODY} at (8,8) size 784x584
    6       RenderTable {TABLE} at (0,0) size 784x120 [border: (1px outset #808080)]
    7         RenderTableSection {TBODY} at (1,1) size 782x118
    8           RenderTableRow {TR} at (0,2) size 782x114
    9             RenderTableCell {TD} at (2,2) size 74x114 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
     6      RenderTable {TABLE} at (0,0) size 784x121 [border: (1px outset #808080)]
     7        RenderTableSection {TBODY} at (1,1) size 782x119
     8          RenderTableRow {TR} at (0,2) size 782x115
     9            RenderTableCell {TD} at (2,2) size 74x115 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
    1010              RenderText {#text} at (2,2) size 70x72
    1111                text run at (2,2) width 59: "check for"
     
    1313                text run at (2,38) width 13: "of"
    1414                text run at (2,56) width 70: "whitespace"
    15               RenderImage {IMG} at (2,74) size 20x16
    16               RenderText {#text} at (22,76) size 68x36
    17                 text run at (22,76) width 48: " around"
    18                 text run at (2,94) width 61: "the image"
     15              RenderImage {IMG} at (2,74) size 20x17
     16              RenderText {#text} at (22,77) size 68x36
     17                text run at (22,77) width 48: " around"
     18                text run at (2,95) width 61: "the image"
    1919            RenderTableCell {TD} at (78,48) size 702x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
    2020              RenderText {#text} at (2,2) size 12x18
    2121                text run at (2,2) width 12: "X"
    22       RenderBlock {HR} at (0,128) size 77x2 [border: (1px inset #000000)]
    23       RenderTable {TABLE} at (0,138) size 784x152 [border: (1px outset #808080)]
    24         RenderTableSection {TBODY} at (1,1) size 782x150
    25           RenderTableRow {TR} at (0,2) size 782x146
    26             RenderTableCell {TD} at (2,2) size 24x146 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
     22      RenderBlock {HR} at (0,129) size 77x2 [border: (1px inset #000000)]
     23      RenderTable {TABLE} at (0,139) size 784x153 [border: (1px outset #808080)]
     24        RenderTableSection {TBODY} at (1,1) size 782x151
     25          RenderTableRow {TR} at (0,2) size 782x147
     26            RenderTableCell {TD} at (2,2) size 24x147 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
    2727              RenderText {#text} at (2,2) size 16x72
    2828                text run at (2,2) width 14: "aa"
     
    3030                text run at (2,38) width 14: "cc"
    3131                text run at (2,56) width 16: "dd"
    32               RenderImage {IMG} at (2,74) size 20x16
    33               RenderText {#text} at (2,90) size 16x54
    34                 text run at (2,90) width 14: "ee"
    35                 text run at (2,108) width 10: "ff"
    36                 text run at (2,126) width 16: "gg"
     32              RenderImage {IMG} at (2,74) size 20x17
     33              RenderText {#text} at (2,91) size 16x54
     34                text run at (2,91) width 14: "ee"
     35                text run at (2,109) width 10: "ff"
     36                text run at (2,127) width 16: "gg"
    3737            RenderTableCell {TD} at (28,64) size 752x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
    3838              RenderText {#text} at (2,2) size 12x18
    3939                text run at (2,2) width 12: "X"
    40       RenderBlock {HR} at (0,298) size 77x2 [border: (1px inset #000000)]
    41       RenderTable {TABLE} at (0,308) size 784x48 [border: (1px outset #808080)]
    42         RenderTableSection {TBODY} at (1,1) size 782x46
    43           RenderTableRow {TR} at (0,2) size 782x42
    44             RenderTableCell {TD} at (2,2) size 213x42 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
     40      RenderBlock {HR} at (0,300) size 77x2 [border: (1px inset #000000)]
     41      RenderTable {TABLE} at (0,310) size 784x49 [border: (1px outset #808080)]
     42        RenderTableSection {TBODY} at (1,1) size 782x47
     43          RenderTableRow {TR} at (0,2) size 782x43
     44            RenderTableCell {TD} at (2,2) size 213x43 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
    4545              RenderText {#text} at (2,2) size 209x18
    4646                text run at (2,2) width 209: "checkforhandlingofnowhitespace"
    47               RenderImage {IMG} at (2,20) size 20x16
    48               RenderText {#text} at (22,22) size 105x18
    49                 text run at (22,22) width 105: " aroundtheimage"
     47              RenderImage {IMG} at (2,20) size 20x17
     48              RenderText {#text} at (22,23) size 105x18
     49                text run at (22,23) width 105: " aroundtheimage"
    5050            RenderTableCell {TD} at (217,12) size 563x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
    5151              RenderText {#text} at (2,2) size 12x18
    5252                text run at (2,2) width 12: "X"
    53       RenderBlock {HR} at (0,364) size 77x2 [border: (1px inset #000000)]
    54       RenderTable {TABLE} at (0,374) size 784x30 [border: (1px outset #808080)]
    55         RenderTableSection {TBODY} at (1,1) size 782x28
    56           RenderTableRow {TR} at (0,2) size 782x24
    57             RenderTableCell {TD} at (2,2) size 334x24 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
    58               RenderText {#text} at (2,4) size 209x18
    59                 text run at (2,4) width 209: "checkforhandlingofnowhitespace"
    60               RenderImage {IMG} at (211,2) size 20x16
    61               RenderText {#text} at (231,4) size 101x18
    62                 text run at (231,4) width 101: "aroundtheimage"
     53      RenderBlock {HR} at (0,367) size 77x2 [border: (1px inset #000000)]
     54      RenderTable {TABLE} at (0,377) size 784x31 [border: (1px outset #808080)]
     55        RenderTableSection {TBODY} at (1,1) size 782x29
     56          RenderTableRow {TR} at (0,2) size 782x25
     57            RenderTableCell {TD} at (2,2) size 334x25 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
     58              RenderText {#text} at (2,5) size 209x18
     59                text run at (2,5) width 209: "checkforhandlingofnowhitespace"
     60              RenderImage {IMG} at (211,2) size 20x17
     61              RenderText {#text} at (231,5) size 101x18
     62                text run at (231,5) width 101: "aroundtheimage"
    6363            RenderTableCell {TD} at (338,3) size 442x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
    6464              RenderText {#text} at (2,2) size 12x18
  • trunk/LayoutTests/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute.xhtml

    r105404 r105513  
    66        body { padding: 0; margin: 0; }
    77        p { padding: 0; margin: 0; }
    8         div { position: absolute; top: 0px; left: 0px; width: 125px; height: 75px; background: red; z-index: -1; }
     8        div { position: absolute; top: 0px; left: 0px; width: 250px; height: 75px; background: red; z-index: -1; }
    99        object { width: 250px; height: auto; }
    10         svg { position: absolute; top: 80px; left: 0px; width: 125px; height: 75px; }
     10        svg { position: absolute; top: 80px; left: 0px; width: 250px; height: 75px; }
    1111    </style>
    1212</head>
  • trunk/LayoutTests/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute.xhtml

    r105404 r105513  
    66        body { padding: 0; margin: 0; }
    77        p { padding: 0; margin: 0; }
    8         div { position: absolute; top: 0px; left: 0px; width: 125px; height: 112.5px; background: red; z-index: -1; }
     8        div { position: absolute; top: 0px; left: 0px; width: 250px; height: 112.5px; background: red; z-index: -1; }
    99        object { width: 250px; height: auto; }
    10         svg { position: absolute; top: 117.5px; left: 0px; width: 125px; height: 112.5px; }
     10        svg { position: absolute; top: 117.5px; left: 0px; width: 250px; height: 112.5px; }
    1111    </style>
    1212</head>
  • trunk/LayoutTests/svg/custom/object-sizing-width-50p-on-target-svg-absolute.xhtml

    r105404 r105513  
    66        body { padding: 0; margin: 0; }
    77        p { padding: 0; margin: 0; }
    8         div { position: absolute; top: 0px; left: 0px; width: 125px; height: 150px; background: red; z-index: -1; }
     8        div { position: absolute; top: 0px; left: 0px; width: 250px; height: 150px; background: red; z-index: -1; }
    99        object { width: 250px; height: auto; }
    10         svg { position: absolute; top: 155px; left: 0px; width: 125px; height: 150px; }
     10        svg { position: absolute; top: 155px; left: 0px; width: 250px; height: 150px; }
    1111    </style>
    1212</head>
  • trunk/LayoutTests/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute.xhtml

    r105404 r105513  
    66        body { padding: 0; margin: 0; }
    77        p { padding: 0; margin: 0; }
    8         div { position: absolute; top: 0px; left: 0px; width: 281.25px; height: 75px; background: red; z-index: -1; }
     8        div { position: absolute; top: 0px; left: 0px; width: 375px; height: 75px; background: red; z-index: -1; }
    99        object { width: 375px; height: auto; }
    10         svg { position: absolute; top: 80px; left: 0px; width: 281.25px; height: 75px; }
     10        svg { position: absolute; top: 80px; left: 0px; width: 375px; height: 75px; }
    1111    </style>
    1212</head>
  • trunk/LayoutTests/svg/foreignObject/text-tref-02-b-expected.txt

    r105404 r105513  
    2424      RenderSVGHiddenContainer {defs} at (0,0) size 0x0
    2525        RenderSVGForeignObject {foreignObject} at (0,0) size 0x0
    26           RenderSVGRoot {svg} at (0,0) size 42x4
     26          RenderSVGRoot {svg} at (0,0) size 0x0
    2727            RenderSVGText {text} at (0,-15) size 42x18 contains 1 chunk(s)
    2828              RenderSVGInlineText {#text} at (0,0) size 42x18
  • trunk/Source/WebCore/ChangeLog

    r105512 r105513  
     12012-01-20  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        Differentiate between SVG/CSS width/height attributes/properties
     4        https://bugs.webkit.org/show_bug.cgi?id=76447
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Remove a gazillion of hacks out of our SVG implementation, by correctly differentiating between the
     9        SVG width/height attributes and the CSS width/height properties. They need to be treated independently
     10        when handling the intrinsic size negotiation, according to both CSS 2.1 & SVG 1.1 2nd Edition specs.
     11
     12        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.
     13
     14        * css/svg.css: Remove hardcoded, width/height: 100% on <svg>.
     15        * rendering/RenderBox.h:
     16        (WebCore::RenderBox::computeIntrinsicRatioInformation): Make 'intrinsicRatio' a float, and add 'intrinsicSize' as seperated FloatSize, to avoid confusion.
     17        * rendering/RenderBoxModelObject.cpp:
     18        (WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions): Add forgotton case for percentage intrinsic sizes, that lead to workarounds in other places, that can now be removed.
     19        * rendering/RenderImage.cpp:
     20        (WebCore::RenderImage::computeReplacedLogicalWidth): Directly use imageHasRelativeWidth/Height(), it does differentiate between SVG/CSS width/height attributes/properties now.
     21        (WebCore::RenderImage::computeIntrinsicRatioInformation): Adapt to 'intrinsicRatio' argument change.
     22        * rendering/RenderImage.h: Ditto.
     23        * rendering/RenderReplaced.cpp: Refactor existing code, break out firstContainingBlockWithLogicalWidth/hasReplacedLogicalWidth/hasReplacedLogicalHeight/hasAutoHeightOrContainingBlockWithAutoHeight.
     24        (WebCore::firstContainingBlockWithLogicalWidth): Refactored.
     25        (WebCore::RenderReplaced::hasReplacedLogicalWidth): Refactored, and exported, so SVGSVGElement::widthAttributeEstablishesViewport() can use it.
     26        (WebCore::hasAutoHeightOrContainingBlockWithAutoHeight): Refactored.
     27        (WebCore::RenderReplaced::hasReplacedLogicalHeight): Refactored, and exported, so SVGSVGElement::heightAttributeEstablishesViewport() can use it.
     28        (WebCore::RenderReplaced::computeReplacedLogicalWidth): Adapt to 'intrinsicRatio' changes ('intrinsicSize' is now decoupled from it). Refactor so that RenderSVGRoot can directly use it as well!
     29        (WebCore::RenderReplaced::computeReplacedLogicalHeight): Ditto.
     30        * rendering/RenderReplaced.h:
     31        * rendering/svg/RenderSVGRoot.cpp:
     32        (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.
     33        (WebCore::resolveLengthAttributeForSVG): Helper function for computeReplacedLogicalWidth/Height, that scales Length values that come from SVG width/height attributes.
     34        (WebCore::RenderSVGRoot::computeReplacedLogicalWidth): Finally remove home-brewn size computation logic - it can be fully shared with RenderReplaced now that we inherit from it.
     35        (WebCore::RenderSVGRoot::computeReplacedLogicalHeight): Ditto.
     36        * rendering/svg/RenderSVGRoot.h:
     37        * rendering/svg/RenderSVGViewportContainer.h:
     38        (WebCore::RenderSVGViewportContainer::viewport): Export viewport() for easier length resolution.
     39        * svg/SVGLengthContext.cpp:
     40        (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.
     41        * svg/SVGSVGElement.cpp:
     42        (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.
     43        (WebCore::SVGSVGElement::parseMappedAttribute): Remove hacks mapping SVG width/height attributes to CSS properties.
     44        (WebCore::SVGSVGElement::svgAttributeChanged): Ditto.
     45        (WebCore::SVGSVGElement::localCoordinateSpaceTransform): Refactored.
     46        (WebCore::SVGSVGElement::currentViewBoxRect): Ditto.
     47        (WebCore::SVGSVGElement::currentViewportSize): Ditto.
     48        (WebCore::SVGSVGElement::widthAttributeEstablishesViewport): Main logic determining if the SVG or CSS properties establish the viewport -  a direct transliteration from the spec.
     49        (WebCore::SVGSVGElement::heightAttributeEstablishesViewport): Ditto.
     50        (WebCore::SVGSVGElement::intrinsicWidth): Helper.
     51        (WebCore::SVGSVGElement::intrinsicHeight): Ditto.
     52        * svg/SVGSVGElement.h:
     53        * svg/graphics/SVGImage.cpp:
     54        (WebCore::SVGImage::size): Cleanup code.
     55        (WebCore::SVGImage::hasRelativeWidth): Added, avoids hacks in RenderBoxModelObject.
     56        (WebCore::SVGImage::hasRelativeHeight): Ditto.
     57        (WebCore::SVGImage::computeIntrinsicDimensions): Make use of new SVGSVGElement::computeIntrinsicDimensions.
     58        * svg/graphics/SVGImage.h:
     59
    1602012-01-20  Sami Kyostila  <skyostil@chromium.org>
    261
  • trunk/Source/WebCore/css/svg.css

    r105404 r105513  
    4747}
    4848
    49 svg {
    50     width: 100%;
    51     height: 100%;
    52 }
    53 
    5449text, foreignObject {
    5550    display: block
  • trunk/Source/WebCore/rendering/RenderBox.h

    r105404 r105513  
    432432
    433433    virtual bool needsPreferredWidthsRecalculation() const;
    434     virtual void computeIntrinsicRatioInformation(FloatSize& /* intrinsicRatio */, bool& /* isPercentageIntrinsicSize */) const { }
     434    virtual void computeIntrinsicRatioInformation(FloatSize& /* intrinsicSize */, double& /* intrinsicRatio */, bool& /* isPercentageIntrinsicSize */) const { }
    435435
    436436protected:
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r105404 r105513  
    873873        image->computeIntrinsicDimensions(this, intrinsicWidth, intrinsicHeight, intrinsicRatio);
    874874
     875        // Intrinsic dimensions expressed as percentages must be resolved relative to the dimensions of the rectangle
     876        // that establishes the coordinate system for the 'background-position' property.
     877
    875878        // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    876         if (intrinsicWidth.isFixed())
    877             resolvedWidth = static_cast<int>(ceilf(intrinsicWidth.value() * style()->effectiveZoom()));
    878         if (intrinsicHeight.isFixed())
    879             resolvedHeight = static_cast<int>(ceilf(intrinsicHeight.value() * style()->effectiveZoom()));
    880     }
    881 
    882     // Intrinsic dimensions expressed as percentages must be resolved relative to the dimensions of the rectangle
    883     // that establishes the coordinate system for the 'background-position' property. SVG on the other hand
    884     // _explicitely_ says that percentage values for the width/height attributes do NOT define intrinsic dimensions.
     879        if (intrinsicWidth.isPercent() && intrinsicHeight.isPercent() && intrinsicRatio.isEmpty()) {
     880            // Resolve width/height percentages against positioningAreaSize, only if no intrinsic ratio is provided.
     881            resolvedWidth = static_cast<int>(round(positioningAreaSize.width() * intrinsicWidth.percent() / 100));
     882            resolvedHeight = static_cast<int>(round(positioningAreaSize.height() * intrinsicHeight.percent() / 100));
     883        } else {
     884            if (intrinsicWidth.isFixed())
     885                resolvedWidth = static_cast<int>(intrinsicWidth.value() * style()->effectiveZoom());
     886            if (intrinsicHeight.isFixed())
     887                resolvedHeight = static_cast<int>(intrinsicHeight.value() * style()->effectiveZoom());
     888        }
     889    }
     890
    885891    if (resolvedWidth > 0 && resolvedHeight > 0)
    886892        return IntSize(resolvedWidth, resolvedHeight);
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r105404 r105513  
    493493    }
    494494
    495     RenderBox* contentRenderer = embeddedContentBox();
    496     bool hasRelativeWidth = contentRenderer ? contentRenderer->style()->width().isPercent() : m_imageResource->imageHasRelativeWidth();
    497     bool hasRelativeHeight = contentRenderer ? contentRenderer->style()->height().isPercent() : m_imageResource->imageHasRelativeHeight();
    498 
    499495    IntSize containerSize;
    500     if (hasRelativeWidth || hasRelativeHeight) {
     496    if (m_imageResource->imageHasRelativeWidth() || m_imageResource->imageHasRelativeHeight()) {
    501497        // Propagate the containing block size to the image resource, otherwhise we can't compute our own intrinsic size, if it's relative.
    502498        RenderObject* containingBlock = isPositioned() ? container() : this->containingBlock();
     
    524520}
    525521
    526 void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicRatio, bool& isPercentageIntrinsicSize) const
     522void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const
    527523{
    528524    // Assure this method is never used for SVGImages.
     
    530526    isPercentageIntrinsicSize = false;
    531527    CachedImage* cachedImage = m_imageResource ? m_imageResource->cachedImage() : 0;
    532     if (cachedImage && cachedImage->image())
    533         intrinsicRatio = cachedImage->image()->size();
     528    if (!cachedImage || !cachedImage->image())
     529        return;
     530    intrinsicSize = cachedImage->image()->size();
     531    intrinsicRatio = intrinsicSize.width() / static_cast<double>(intrinsicSize.height());
    534532}
    535533
  • trunk/Source/WebCore/rendering/RenderImage.h

    r105404 r105513  
    6161    virtual bool needsPreferredWidthsRecalculation() const;
    6262    virtual RenderBox* embeddedContentBox() const;
    63     virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
     63    virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
    6464
    6565    virtual void styleDidChange(StyleDifference, const RenderStyle*);
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r105404 r105513  
    217217}
    218218
     219static inline RenderBlock* firstContainingBlockWithLogicalWidth(const RenderReplaced* replaced)
     220{
     221    // We have to lookup the containing block, which has an explicit width, which must not be equal to our direct containing block.
     222    // If the embedded document appears _after_ we performed the initial layout, our intrinsic size is 300x150. If our containing
     223    // block doesn't provide an explicit width, it's set to the 300 default, coming from the initial layout run.
     224    RenderBlock* containingBlock = replaced->containingBlock();
     225    if (!containingBlock)
     226        return 0;
     227
     228    for (; !containingBlock->isRenderView() && !containingBlock->isBody(); containingBlock = containingBlock->containingBlock()) {
     229        if (containingBlock->style()->logicalWidth().isSpecified())
     230            return containingBlock;
     231    }
     232
     233    return 0;
     234}
     235
     236bool RenderReplaced::hasReplacedLogicalWidth() const
     237{
     238    if (style()->logicalWidth().isSpecified())
     239        return true;
     240
     241    if (style()->logicalWidth().isAuto())
     242        return false;
     243
     244    return firstContainingBlockWithLogicalWidth(this);
     245}
     246
     247static inline bool hasAutoHeightOrContainingBlockWithAutoHeight(const RenderReplaced* replaced)
     248{
     249    Length logicalHeightLength = replaced->style()->logicalHeight();
     250    if (logicalHeightLength.isAuto())
     251        return true;
     252
     253    // For percentage heights: The percentage is calculated with respect to the height of the generated box's
     254    // containing block. If the height of the containing block is not specified explicitly (i.e., it depends
     255    // on content height), and this element is not absolutely positioned, the value computes to 'auto'.
     256    if (!logicalHeightLength.isPercent() || replaced->isPositioned() || replaced->document()->inQuirksMode())
     257        return false;
     258
     259    for (RenderBlock* cb = replaced->containingBlock(); !cb->isRenderView(); cb = cb->containingBlock()) {
     260        if (cb->isTableCell() || (!cb->style()->logicalHeight().isAuto() || (!cb->style()->top().isAuto() && !cb->style()->bottom().isAuto())))
     261            return false;
     262    }
     263
     264    return true;
     265}
     266
     267bool RenderReplaced::hasReplacedLogicalHeight() const
     268{
     269    if (style()->logicalHeight().isAuto())
     270        return false;
     271
     272    if (style()->logicalHeight().isSpecified()) {
     273        if (hasAutoHeightOrContainingBlockWithAutoHeight(this))
     274            return false;
     275        return true;
     276    }
     277
     278    return false;
     279}
     280
    219281LayoutUnit RenderReplaced::computeReplacedLogicalWidth(bool includeMaxWidth) const
    220282{
     
    227289    // 10.3.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-width
    228290    bool isPercentageIntrinsicSize = false;
    229     FloatSize intrinsicRatio;
     291    double intrinsicRatio = 0;
     292    FloatSize intrinsicSize;
    230293    if (contentRenderer) {
    231         contentRenderer->computeIntrinsicRatioInformation(intrinsicRatio, isPercentageIntrinsicSize);
     294        contentRenderer->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
    232295        contentRenderStyle = contentRenderer->style();
    233296        ASSERT(contentRenderStyle);
    234297    } else
    235         computeIntrinsicRatioInformation(intrinsicRatio, isPercentageIntrinsicSize);
     298        computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
     299
     300    if (intrinsicRatio && !isHorizontalWritingMode())
     301        intrinsicRatio = 1 / intrinsicRatio;
    236302
    237303    if (style()->logicalWidth().isAuto()) {
    238304        bool heightIsAuto = style()->logicalHeight().isAuto();
    239         bool hasIntrinsicWidth = m_hasIntrinsicSize || (contentRenderer && contentRenderStyle->logicalWidth().isFixed());
     305        bool hasIntrinsicWidth = m_hasIntrinsicSize || (!isPercentageIntrinsicSize && intrinsicSize.width() > 0);
    240306
    241307        // 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'.
    242         if (heightIsAuto && hasIntrinsicWidth)
    243             return computeIntrinsicLogicalWidth(contentRenderer, includeMaxWidth);
    244    
    245         bool hasIntrinsicHeight = m_hasIntrinsicSize || (contentRenderer && contentRenderStyle->logicalHeight().isFixed());
    246         if (!intrinsicRatio.isEmpty()) {
     308        if (heightIsAuto && hasIntrinsicWidth) {
     309            if (m_hasIntrinsicSize)
     310                return computeReplacedLogicalWidthRespectingMinMaxWidth(calcAspectRatioLogicalWidth(), includeMaxWidth);
     311            return static_cast<LayoutUnit>(intrinsicSize.width() * style()->effectiveZoom());
     312        }
     313
     314        bool hasIntrinsicHeight = m_hasIntrinsicSize || (!isPercentageIntrinsicSize && intrinsicSize.height() > 0);
     315        if (intrinsicRatio || isPercentageIntrinsicSize) {
    247316            // 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;
    248317            // 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
    249318            // of 'width' is: (used height) * (intrinsic ratio)
    250             if ((heightIsAuto && !hasIntrinsicWidth && hasIntrinsicHeight) || !heightIsAuto) {
    251                 if (heightIsAuto) {
    252                     if (contentRenderer) {
    253                         LayoutUnit logicalHeight = contentRenderer->computeReplacedLogicalHeightUsing(contentRenderStyle->logicalHeight());
    254                         // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    255                         return contentRenderer->computeReplacedLogicalWidthRespectingMinMaxWidth(static_cast<int>(ceilf(logicalHeight * intrinsicRatio.width() / intrinsicRatio.height())));
    256                     }
    257                 } else {
    258                     LayoutUnit logicalHeight = computeReplacedLogicalHeightUsing(style()->logicalHeight());
    259                     // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    260                     return computeReplacedLogicalWidthRespectingMinMaxWidth(static_cast<int>(ceilf(logicalHeight * intrinsicRatio.width() / intrinsicRatio.height())));
    261                 }
     319            if (intrinsicRatio && ((heightIsAuto && !hasIntrinsicWidth && hasIntrinsicHeight) || !heightIsAuto)) {
     320                LayoutUnit logicalHeight = computeReplacedLogicalHeightUsing(style()->logicalHeight());
     321                return computeReplacedLogicalWidthRespectingMinMaxWidth(static_cast<LayoutUnit>(ceil(logicalHeight * intrinsicRatio)));
    262322            }
    263323
     
    265325            // '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
    266326            // the used value of 'width' is calculated from the constraint equation used for block-level, non-replaced elements in normal flow.
    267             RenderBlock* containingBlock = this->containingBlock();
    268             if (heightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeight && contentRenderer && containingBlock) {
     327            if (heightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeight && contentRenderer) {
    269328                // The aforementioned 'constraint equation' used for block-level, non-replaced elements in normal flow:
    270329                // 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containing block
    271 
    272                 // We have to lookup the containing block, which has an explicit width, which must not be equal to our direct containing block.
    273                 // If the embedded document appears _after_ we performed the initial layout, our intrinsic size is 300x150. If our containing
    274                 // block doesn't provide an explicit width, it's set to the 300 default, coming from the initial layout run.
    275                 bool foundExplicitWidth = false;
    276                 for (; !containingBlock->isRenderView() && !containingBlock->isBody(); containingBlock = containingBlock->containingBlock()) {
    277                     if (containingBlock->style()->logicalWidth().isSpecified()) {
    278                         foundExplicitWidth = true;
    279                         break;
    280                     }
    281                 }
    282                
     330                LayoutUnit logicalWidth;
     331                if (RenderBlock* blockWithWidth = firstContainingBlockWithLogicalWidth(this))
     332                    logicalWidth = blockWithWidth->computeReplacedLogicalWidthRespectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(blockWithWidth->style()->logicalWidth()), false);
     333                else
     334                    logicalWidth = containingBlock()->availableLogicalWidth();
     335
    283336                // This solves above equation for 'width' (== logicalWidth).
    284                 LayoutUnit logicalWidth = foundExplicitWidth ? computeIntrinsicLogicalWidth(containingBlock, false) : containingBlock->availableLogicalWidth();
    285337                LayoutUnit marginStart = style()->marginStart().calcMinValue(logicalWidth);
    286338                LayoutUnit marginEnd = style()->marginEnd().calcMinValue(logicalWidth);
     
    288340                if (isPercentageIntrinsicSize)
    289341                    // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    290                     logicalWidth = static_cast<int>(ceilf(logicalWidth * intrinsicRatio.width() / 100));
     342                    logicalWidth = static_cast<LayoutUnit>(round(logicalWidth * intrinsicSize.width() / 100));
    291343                return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth);
    292344            }
     
    294346
    295347        // 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'.
    296         if (hasIntrinsicWidth)
    297             return computeIntrinsicLogicalWidth(contentRenderer, includeMaxWidth);
     348        if (hasIntrinsicWidth) {
     349            if (isPercentageIntrinsicSize || m_hasIntrinsicSize)
     350                return computeReplacedLogicalWidthRespectingMinMaxWidth(calcAspectRatioLogicalWidth(), includeMaxWidth);
     351            return static_cast<LayoutUnit>(intrinsicSize.width() * style()->effectiveZoom());
     352        }
    298353
    299354        // 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
     
    305360}
    306361
    307 bool RenderReplaced::logicalHeightIsAuto() const
    308 {
    309     Length logicalHeightLength = style()->logicalHeight();
    310     if (logicalHeightLength.isAuto())
    311         return true;
    312    
    313     // For percentage heights: The percentage is calculated with respect to the height of the generated box's
    314     // containing block. If the height of the containing block is not specified explicitly (i.e., it depends
    315     // on content height), and this element is not absolutely positioned, the value computes to 'auto'.
    316     if (!logicalHeightLength.isPercent() || isPositioned() || document()->inQuirksMode())
    317         return false;
    318 
    319     for (RenderBlock* cb = containingBlock(); !cb->isRenderView(); cb = cb->containingBlock()) {
    320         if (cb->isTableCell() || (!cb->style()->logicalHeight().isAuto() || (!cb->style()->top().isAuto() && !cb->style()->bottom().isAuto())))
    321             return false;
    322     }
    323 
    324     return true;
    325 }
    326 
    327362LayoutUnit RenderReplaced::computeReplacedLogicalHeight() const
    328363{
    329364    // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/visudet.html#propdef-height
    330     bool heightIsAuto = logicalHeightIsAuto();
    331     if (style()->logicalHeight().isSpecified() && !heightIsAuto)
     365    if (hasReplacedLogicalHeight())
    332366        return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(style()->logicalHeight()));
    333367
     
    337371    // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-height
    338372    bool isPercentageIntrinsicSize = false;
    339     FloatSize intrinsicRatio;
     373    double intrinsicRatio = 0;
     374    FloatSize intrinsicSize;
    340375    if (contentRenderer) {
    341         contentRenderer->computeIntrinsicRatioInformation(intrinsicRatio, isPercentageIntrinsicSize);
     376        contentRenderer->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
    342377        contentRenderStyle = contentRenderer->style();
    343378        ASSERT(contentRenderStyle);
    344     }
    345 
    346     if (heightIsAuto) {
    347         bool widthIsAuto = style()->logicalWidth().isAuto();
    348         bool hasIntrinsicHeight = m_hasIntrinsicSize || (contentRenderer && contentRenderStyle->logicalHeight().isFixed());
    349 
    350         // 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'.
    351         if (widthIsAuto && hasIntrinsicHeight)
    352             return computeIntrinsicLogicalHeight(contentRenderer);
    353    
    354         // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is:
    355         // (used width) / (intrinsic ratio)
    356         if (!intrinsicRatio.isEmpty() && !isPercentageIntrinsicSize)
    357             // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    358             return computeReplacedLogicalHeightRespectingMinMaxHeight(static_cast<int>(ceilf(availableLogicalWidth() * intrinsicRatio.height() / intrinsicRatio.width())));
    359 
    360         // 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'.
    361         if (hasIntrinsicHeight)
    362             return computeIntrinsicLogicalHeight(contentRenderer);
    363 
    364         // 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
    365         // 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.
    366         return computeReplacedLogicalHeightRespectingMinMaxHeight(cDefaultHeight);
    367     }
    368 
    369     return computeReplacedLogicalHeightRespectingMinMaxHeight(intrinsicLogicalHeight());
     379    } else
     380        computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
     381
     382    if (intrinsicRatio && !isHorizontalWritingMode())
     383        intrinsicRatio = 1 / intrinsicRatio;
     384
     385    bool widthIsAuto = style()->logicalWidth().isAuto();
     386    bool hasIntrinsicHeight = m_hasIntrinsicSize || (!isPercentageIntrinsicSize && intrinsicSize.height() > 0);
     387
     388    // 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'.
     389    if (widthIsAuto && hasIntrinsicHeight) {
     390        if (m_hasIntrinsicSize)
     391            return computeReplacedLogicalHeightRespectingMinMaxHeight(calcAspectRatioLogicalHeight());
     392        return static_cast<LayoutUnit>(intrinsicSize.height() * style()->effectiveZoom());
     393    }
     394
     395    // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is:
     396    // (used width) / (intrinsic ratio)
     397    if (intrinsicRatio && !isPercentageIntrinsicSize) {
     398        // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
     399        return computeReplacedLogicalHeightRespectingMinMaxHeight(round(availableLogicalWidth() / intrinsicRatio));
     400    }
     401
     402    // 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'.
     403    if (hasIntrinsicHeight) {
     404        if (m_hasIntrinsicSize)
     405            return computeReplacedLogicalHeightRespectingMinMaxHeight(calcAspectRatioLogicalHeight());
     406        return static_cast<LayoutUnit>(intrinsicSize.height() * style()->effectiveZoom());
     407    }
     408
     409    // 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
     410    // 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.
     411    return computeReplacedLogicalHeightRespectingMinMaxHeight(cDefaultHeight);
    370412}
    371413
  • trunk/Source/WebCore/rendering/RenderReplaced.h

    r105404 r105513  
    3636    virtual LayoutUnit computeReplacedLogicalHeight() const;
    3737
    38     bool logicalHeightIsAuto() const;
     38    bool hasReplacedLogicalWidth() const;
     39    bool hasReplacedLogicalHeight() const;
    3940
    4041protected:
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp

    r105404 r105513  
    6767}
    6868
    69 void RenderSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicRatio, bool& isPercentageIntrinsicSize) const
    70 {
    71     // Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#IntrinsicSizing
    72     // The intrinsic aspect ratio of the viewport of SVG content is necessary for example, when including
    73     // SVG from an ‘object’ element in HTML styled with CSS. It is possible (indeed, common) for an SVG
    74     // graphic to have an intrinsic aspect ratio but not to have an intrinsic width or height.
    75     // The intrinsic aspect ratio must be calculated based upon the following rules:
    76     // The aspect ratio is calculated by dividing a width by a height.
    77 
    78     // If the ‘width’ and ‘height’ of the rootmost ‘svg’ element are both specified with unit identifiers
    79     // (in, mm, cm, pt, pc, px, em, ex) or in user units, then the aspect ratio is calculated from the
    80     // ‘width’ and ‘height’ attributes after resolving both values to user units.
    81     isPercentageIntrinsicSize = false;
    82     if (style()->width().isFixed() && style()->height().isFixed()) {
    83         intrinsicRatio = FloatSize(width(), height());
     69void RenderSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const
     70{
     71    // Spec: http://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
     72    // SVG needs to specify how to calculate some intrinsic sizing properties to enable inclusion within other languages.
     73    // The intrinsic width and height of the viewport of SVG content must be determined from the ‘width’ and ‘height’ attributes.
     74    // If either of these are not specified, a value of '100%' must be assumed. Note: the ‘width’ and ‘height’ attributes are not
     75    // the same as the CSS width and height properties. Specifically, percentage values do not provide an intrinsic width or height,
     76    // and do not indicate a percentage of the containing block. Rather, once the viewport is established, they indicate the portion
     77    // of the viewport that is actually covered by image data.
     78    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
     79    Length intrinsicWidthAttribute = svg->intrinsicWidth(SVGSVGElement::IgnoreCSSProperties);
     80    Length intrinsicHeightAttribute = svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties);
     81
     82    // The intrinsic aspect ratio of the viewport of SVG content is necessary for example, when including SVG from an ‘object’
     83    // element in HTML styled with CSS. It is possible (indeed, common) for an SVG graphic to have an intrinsic aspect ratio but
     84    // not to have an intrinsic width or height. The intrinsic aspect ratio must be calculated based upon the following rules:
     85    // - The aspect ratio is calculated by dividing a width by a height.
     86    // - If the ‘width’ and ‘height’ of the rootmost ‘svg’ element are both specified with unit identifiers (in, mm, cm, pt, pc,
     87    //   px, em, ex) or in user units, then the aspect ratio is calculated from the ‘width’ and ‘height’ attributes after
     88    //   resolving both values to user units.
     89    if (intrinsicWidthAttribute.isFixed() || intrinsicHeightAttribute.isFixed()) {
     90        if (intrinsicWidthAttribute.isFixed())
     91            intrinsicSize.setWidth(intrinsicWidthAttribute.calcFloatValue(0));
     92        if (intrinsicHeightAttribute.isFixed())
     93            intrinsicSize.setHeight(intrinsicHeightAttribute.calcFloatValue(0));
     94        if (!intrinsicSize.isEmpty())
     95            intrinsicRatio = intrinsicSize.width() / static_cast<double>(intrinsicSize.height());
    8496        return;
    8597    }
    8698
    87     // If either/both of the ‘width’ and ‘height’ of the rootmost ‘svg’ element are in percentage units (or omitted),
    88     // the aspect ratio is calculated from the width and height values of the ‘viewBox’ specified for the current SVG
    89     // document fragment. If the ‘viewBox’ is not correctly specified, or set to 'none', the intrinsic aspect ratio
    90     // cannot be calculated and is considered unspecified.
    91     intrinsicRatio = static_cast<SVGSVGElement*>(node())->currentViewBoxRect().size();
    92 
    93     // Compatibility with authors expectations and Firefox/Opera: when percentage units are used, take them into
    94     // account for certain cases of the intrinsic width/height calculation in RenderPart::computeReplacedLogicalWidth/Height.
    95     if (intrinsicRatio.isEmpty() && style()->width().isPercent() && style()->height().isPercent()) {
     99    // - If either/both of the ‘width’ and ‘height’ of the rootmost ‘svg’ element are in percentage units (or omitted), the
     100    //   aspect ratio is calculated from the width and height values of the ‘viewBox’ specified for the current SVG document
     101    //   fragment. If the ‘viewBox’ is not correctly specified, or set to 'none', the intrinsic aspect ratio cannot be
     102    //   calculated and is considered unspecified.
     103    intrinsicSize = svg->viewBox().size();
     104    if (!intrinsicSize.isEmpty()) {
     105        // The viewBox can only yield an intrinsic ratio, not an intrinsic size.
     106        intrinsicRatio = intrinsicSize.width() / static_cast<double>(intrinsicSize.height());
     107        intrinsicSize = FloatSize();
     108        return;
     109    }
     110
     111    // If our intrinsic size is in percentage units, return those to the caller through the intrinsicSize. Notify the caller
     112    // about the special situation, by setting isPercentageIntrinsicSize=true, so it knows how to interpret the return values.
     113    if (intrinsicWidthAttribute.isPercent() && intrinsicHeightAttribute.isPercent()) {
    96114        isPercentageIntrinsicSize = true;
    97         intrinsicRatio = FloatSize(style()->width().percent(), style()->height().percent());
     115        intrinsicSize = FloatSize(intrinsicWidthAttribute.percent(), intrinsicHeightAttribute.percent());
    98116    }
    99117}
     
    135153}
    136154
     155static inline LayoutUnit resolveLengthAttributeForSVG(const Length& length, float scale, float maxSize)
     156{
     157    return static_cast<LayoutUnit>(length.calcValue(maxSize) * (length.isFixed() ? scale : 1));
     158/*
     159    if (length.isFixed())
     160        return static_cast<LayoutUnit>(length.calcFloatValue(maxSize) * scale);
     161    return static_cast<LayoutUnit>(length.calcFloatValue(maxSize));
     162*/
     163}
     164
    137165LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(bool includeMaxWidth) const
    138166{
     167    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
     168    ASSERT(svg);
     169
    139170    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
    140     LayoutUnit replacedWidth = m_containerSize.width();
    141     if (replacedWidth > 0)
    142         return replacedWidth;
    143 
    144     replacedWidth = RenderBox::computeReplacedLogicalWidth(includeMaxWidth);
    145     Frame* frame = node() && node()->document() ? node()->document()->frame() : 0;
    146     if (!frame)
    147         return replacedWidth;
    148 
    149     if (!isEmbeddedThroughFrameContainingSVGDocument())
    150         return replacedWidth;
    151 
    152     RenderPart* ownerRenderer = frame->ownerRenderer();
    153     RenderStyle* ownerRendererStyle = ownerRenderer->style();
    154     ASSERT(ownerRendererStyle);
    155     ASSERT(frame->contentRenderer());
    156 
    157     Length ownerWidth = ownerRendererStyle->width();
    158     if (ownerWidth.isAuto())
    159         return replacedWidth;
    160 
    161     // Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#ViewportSpace
    162     // The SVG user agent negotiates with its parent user agent to determine the viewport into which the SVG user agent can render
    163     // the document. In some circumstances, SVG content will be embedded (by reference or inline) within a containing document.
    164     // This containing document might include attributes, properties and/or other parameters (explicit or implicit) which specify
    165     // or provide hints about the dimensions of the viewport for the SVG content. SVG content itself optionally can provide
    166     // information about the appropriate viewport region for the content via the ‘width’ and ‘height’ XML attributes on the
    167     // outermost svg element. The negotiation process uses any information provided by the containing document and the SVG
    168     // content itself to choose the viewport location and size.
    169 
    170     // The ‘width’ attribute on the outermost svg element establishes the viewport's width, unless the following conditions are met:
    171     // * the SVG content is a separately stored resource that is embedded by reference (such as the ‘object’ element in XHTML [XHTML]),
    172     //   or the SVG content is embedded inline within a containing document;
    173     // * and the referencing element or containing document is styled using CSS [CSS2] or XSL [XSL];
    174     // * and there are CSS-compatible positioning properties ([CSS2], section 9.3) specified on the referencing element
    175     //   (e.g., the ‘object’ element) or on the containing document's outermost svg element that are sufficient to establish
    176     //   the width of the viewport.
    177     //
    178     // Under these conditions, the positioning properties establish the viewport's width.
    179     return ownerRenderer->computeReplacedLogicalWidthRespectingMinMaxWidth(ownerRenderer->computeReplacedLogicalWidthUsing(ownerWidth), includeMaxWidth);
     171    if (!m_containerSize.isEmpty())
     172        return m_containerSize.width();
     173
     174    if (style()->logicalWidth().isSpecified())
     175        return RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth);
     176
     177    if (svg->widthAttributeEstablishesViewport())
     178        return resolveLengthAttributeForSVG(svg->intrinsicWidth(SVGSVGElement::IgnoreCSSProperties), style()->effectiveZoom(), containingBlock()->availableLogicalWidth());
     179
     180    // Only SVGs embedded in <object> reach this point.
     181    ASSERT(isEmbeddedThroughFrameContainingSVGDocument());
     182    return document()->frame()->ownerRenderer()->availableLogicalWidth();
    180183}
    181184
    182185LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const
    183186{
     187    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
     188    ASSERT(svg);
     189
    184190    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
    185     LayoutUnit replacedHeight = m_containerSize.height();
    186     if (replacedHeight > 0)
    187         return replacedHeight;
    188 
    189     replacedHeight = RenderBox::computeReplacedLogicalHeight();
    190     Frame* frame = node() && node()->document() ? node()->document()->frame() : 0;
    191     if (!frame)
    192         return replacedHeight;
    193 
    194     if (!isEmbeddedThroughFrameContainingSVGDocument())
    195         return replacedHeight;
    196 
    197     RenderPart* ownerRenderer = frame->ownerRenderer();
    198     ASSERT(ownerRenderer);
    199 
    200     RenderStyle* ownerRendererStyle = ownerRenderer->style();
    201     ASSERT(ownerRendererStyle);
    202 
    203     Length ownerHeight = ownerRendererStyle->height();
    204     if (ownerHeight.isAuto())
    205         return replacedHeight;
    206 
    207     // Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#ViewportSpace
    208     // See comment in RenderSVGRoot::computeReplacedLogicalWidth().
    209     // Similarly, if there are positioning properties specified on the referencing element or on the outermost svg element that
    210     // are sufficient to establish the height of the viewport, then these positioning properties establish the viewport's height;
    211     // otherwise, the ‘height’ attribute on the outermost svg element establishes the viewport's height.
    212     return ownerRenderer->computeReplacedLogicalHeightRespectingMinMaxHeight(ownerRenderer->computeReplacedLogicalHeightUsing(ownerHeight));
     191    if (!m_containerSize.isEmpty())
     192        return m_containerSize.height();
     193
     194    if (hasReplacedLogicalHeight())
     195        return RenderReplaced::computeReplacedLogicalHeight();
     196
     197    if (svg->heightAttributeEstablishesViewport())
     198        return resolveLengthAttributeForSVG(svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties), style()->effectiveZoom(), containingBlock()->availableLogicalHeight());
     199
     200    // Only SVGs embedded in <object> reach this point.
     201    ASSERT(isEmbeddedThroughFrameContainingSVGDocument());
     202    return document()->frame()->ownerRenderer()->availableLogicalHeight();
    213203}
    214204
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h

    r105404 r105513  
    4343    bool isEmbeddedThroughFrameContainingSVGDocument() const;
    4444
    45     virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
     45    virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
    4646    const RenderObjectChildList* children() const { return &m_children; }
    4747    RenderObjectChildList* children() { return &m_children; }
  • trunk/Source/WebCore/rendering/svg/RenderSVGViewportContainer.h

    r105404 r105513  
    3434public:
    3535    explicit RenderSVGViewportContainer(SVGStyledElement*);
     36    FloatRect viewport() const { return m_viewport; }
    3637
    3738private:
  • trunk/Source/WebCore/svg/SVGLengthContext.cpp

    r105404 r105513  
    3030#include "Frame.h"
    3131#include "RenderPart.h"
     32#include "RenderSVGRoot.h"
     33#include "RenderSVGViewportContainer.h"
    3234#include "RenderView.h"
    3335#include "SVGNames.h"
     
    275277    }
    276278
    277     // Take size from outermost <svg> element.
    278     Document* document = m_context->document();
    279     if (document->documentElement() == m_context) {
    280         if (m_context->isSVG()) {
    281             Frame* frame = m_context->document() ? m_context->document()->frame() : 0;
    282             if (!frame)
    283                 return false;
    284 
    285             // SVGs embedded through <object> resolve percentage values against the owner renderer in the host document.
    286             if (RenderPart* ownerRenderer = frame->ownerRenderer()) {
    287                 width = ownerRenderer->width();
    288                 height = ownerRenderer->height();
    289                 return true;
    290             }
    291         }
    292 
    293         RenderView* view = toRenderView(document->renderer());
    294         if (!view)
    295             return false;
    296 
    297         // Always resolve percentages against the unscaled viewport, as agreed across browsers.
    298         float zoom = view->style()->effectiveZoom();
    299         width = view->viewWidth();
    300         height = view->viewHeight();
    301         if (zoom != 1) {
    302             width /= zoom;
    303             height /= zoom;
    304         }
    305         return true;
    306     }
    307 
    308     // Take size from nearest viewport element (common case: inner <svg> elements)
     279    // SVGLengthContext should NEVER be used to resolve width/height values for <svg> elements,
     280    // as they require special treatment, due the relationship with the CSS width/height properties.
     281    ASSERT(m_context->document()->documentElement() != m_context);
     282
     283    // Take size from nearest viewport element.
    309284    SVGElement* viewportElement = m_context->viewportElement();
    310     if (viewportElement && viewportElement->isSVG()) {
    311         const SVGSVGElement* svg = static_cast<const SVGSVGElement*>(viewportElement);
    312         FloatRect viewBox = svg->currentViewBoxRect();
    313         if (viewBox.isEmpty()) {
    314             SVGLengthContext viewportContext(svg);
    315             width = svg->width().value(viewportContext);
    316             height = svg->height().value(viewportContext);
    317         } else {
    318             width = viewBox.width();
    319             height = viewBox.height();
    320         }
    321 
    322         return true;
    323     }
     285    if (!viewportElement)
     286        return false;
    324287   
    325     // Take size from enclosing non-SVG RenderBox (common case: inline SVG)
    326     if (!m_context->parentNode() || m_context->parentNode()->isSVGElement())
    327         return false;
    328 
    329     RenderObject* renderer = m_context->renderer();
    330     if (!renderer || !renderer->isBox())
    331         return false;
    332 
    333     RenderBox* box = toRenderBox(renderer);
    334     width = box->width();
    335     height = box->height();
     288    ASSERT(viewportElement->isSVG());
     289    const SVGSVGElement* svg = static_cast<const SVGSVGElement*>(viewportElement);
     290    FloatSize viewportSize = svg->currentViewBoxRect().size();
     291    if (viewportSize.isEmpty())
     292        viewportSize = svg->currentViewportSize();
     293
     294    width = viewportSize.width();
     295    height = viewportSize.height();
    336296    return true;
    337297}
  • trunk/Source/WebCore/svg/SVGSVGElement.cpp

    r105404 r105513  
    2828#include "Attribute.h"
    2929#include "CSSHelper.h"
    30 #include "CSSPropertyNames.h"
    3130#include "Document.h"
    3231#include "EventListener.h"
     
    3938#include "FrameView.h"
    4039#include "HTMLNames.h"
     40#include "RenderPart.h"
    4141#include "RenderSVGResource.h"
    4242#include "RenderSVGModelObject.h"
     
    142142{
    143143    // FIXME: This method doesn't follow the spec and is basically untested. Parent documents are not considered here.
    144     SVGLengthContext lengthContext(this);
    145     FloatRect viewRectangle;
    146     if (!isOutermostSVG())
    147         viewRectangle.setLocation(FloatPoint(x().value(lengthContext), y().value(lengthContext)));
    148 
    149     viewRectangle.setSize(FloatSize(width().value(lengthContext), height().value(lengthContext)));   
    150     return viewBoxToViewTransform(viewRectangle.width(), viewRectangle.height()).mapRect(viewRectangle);
     144    // As we have no test coverage for this, we're going to disable it completly for now.
     145    return FloatRect();
    151146}
    152147
     
    275270    else if (attr->name() == SVGNames::yAttr)
    276271        setYBaseValue(SVGLength::construct(LengthModeHeight, attr->value(), parseError));
    277     else if (attr->name() == SVGNames::widthAttr) {
     272    else if (attr->name() == SVGNames::widthAttr)
    278273        setWidthBaseValue(SVGLength::construct(LengthModeWidth, attr->value(), parseError, ForbidNegativeLengths));
    279         addCSSProperty(attr, CSSPropertyWidth, attr->value());
    280     } else if (attr->name() == SVGNames::heightAttr) {
     274    else if (attr->name() == SVGNames::heightAttr)
    281275        setHeightBaseValue(SVGLength::construct(LengthModeHeight, attr->value(), parseError, ForbidNegativeLengths));
    282         addCSSProperty(attr, CSSPropertyHeight, attr->value());
    283     } else if (SVGTests::parseMappedAttribute(attr)
     276    else if (SVGTests::parseMappedAttribute(attr)
    284277               || SVGLangSpace::parseMappedAttribute(attr)
    285278               || SVGExternalResourcesRequired::parseMappedAttribute(attr)
     
    292285}
    293286
    294 // This hack will not handle the case where we're setting a width/height
    295 // on a root <svg> via svg.width.baseValue = when it has none.
    296 static void updateCSSForAttribute(SVGSVGElement* element, const QualifiedName& attrName, CSSPropertyID property, const SVGLength& value)
    297 {
    298     Attribute* attribute = element->attributes(false)->getAttributeItem(attrName);
    299     if (!attribute || !attribute->isMappedAttribute())
    300         return;
    301     element->addCSSProperty(attribute, property, value.valueAsString());
    302 }
    303 
    304287void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName)
    305288{
    306     // FIXME: Ugly, ugly hack to around that parseMappedAttribute is not called
    307     // when svg.width.baseValue = 100 is evaluated.
    308     // Thus the CSS length value for width is not updated, and width() computeLogicalWidth()
    309     // calculations on RenderSVGRoot will be wrong.
    310     // https://bugs.webkit.org/show_bug.cgi?id=25387
    311289    bool updateRelativeLengths = false;
    312     if (attrName == SVGNames::widthAttr) {
    313         updateCSSForAttribute(this, attrName, CSSPropertyWidth, widthBaseValue());
    314         updateRelativeLengths = true;
    315     } else if (attrName == SVGNames::heightAttr) {
    316         updateCSSForAttribute(this, attrName, CSSPropertyHeight, heightBaseValue());
    317         updateRelativeLengths = true;
    318     }
    319 
    320     if (updateRelativeLengths
     290    if (attrName == SVGNames::widthAttr
     291        || attrName == SVGNames::heightAttr
    321292        || attrName == SVGNames::xAttr
    322293        || attrName == SVGNames::yAttr
     
    451422AffineTransform SVGSVGElement::localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const
    452423{
    453     // This method resolves length manually, w/o involving the render tree. This is desired, as getCTM()/getScreenCTM()/.. have to work without a renderer.
    454     SVGLengthContext lengthContext(this);
    455 
    456424    AffineTransform viewBoxTransform;
    457     if (attributes()->getAttributeItem(SVGNames::viewBoxAttr))
    458         viewBoxTransform = viewBoxToViewTransform(width().value(lengthContext), height().value(lengthContext));
     425    if (hasAttribute(SVGNames::viewBoxAttr)) {
     426        FloatSize size = currentViewportSize();
     427        viewBoxTransform = viewBoxToViewTransform(size.width(), size.height());
     428    }
    459429
    460430    AffineTransform transform;
    461     if (!isOutermostSVG())
     431    if (!isOutermostSVG()) {
     432        SVGLengthContext lengthContext(this);
    462433        transform.translate(x().value(lengthContext), y().value(lengthContext));
    463     else if (mode == SVGLocatable::ScreenScope) {
     434    } else if (mode == SVGLocatable::ScreenScope) {
    464435        if (RenderObject* renderer = this->renderer()) {
    465436            // Translate in our CSS parent coordinate space
     
    556527}
    557528
    558 FloatRect SVGSVGElement::currentViewBoxRect(CalculateViewBoxMode mode) const
    559 {
    560     // This method resolves length manually, w/o involving the render tree. This is desired, as getCTM()/getScreenCTM()/.. have to work without a renderer.
    561     SVGLengthContext lengthContext(this);
    562 
    563     // FIXME: The interaction of 'currentView' and embedding SVGs in other documents, is untested and unspecified.
     529FloatRect SVGSVGElement::currentViewBoxRect() const
     530{
    564531    if (useCurrentView()) {
    565532        if (SVGViewSpec* view = currentView()) // what if we should use it but it is not set?
     
    568535    }
    569536
    570     bool isEmbeddedThroughSVGImage = renderer() && renderer()->isSVGRoot() ? toRenderSVGRoot(renderer())->isEmbeddedThroughSVGImage() : false;
    571     bool hasFixedSize = width().unitType() != LengthTypePercentage && height().unitType() != LengthTypePercentage;
    572 
    573537    FloatRect useViewBox = viewBox();
    574     if (useViewBox.isEmpty()) {
    575         // If no viewBox is specified but non-relative width/height values, then we
    576         // should always synthesize a viewBox if we're embedded through a SVGImage.
    577         if (hasFixedSize && isEmbeddedThroughSVGImage)
    578             return FloatRect(0, 0, width().value(lengthContext), height().value(lengthContext));
     538    if (!useViewBox.isEmpty())
     539        return useViewBox;
     540    if (!renderer() || !renderer()->isSVGRoot())
    579541        return FloatRect();
    580     }
    581 
    582     // If a viewBox is specified and non-relative width/height values, then the host document only
    583     // uses the width/height values to figure out the intrinsic size when embedding us, whereas the
    584     // embedded document sees specified viewBox only.
    585     if (hasFixedSize && mode == CalculateViewBoxInHostDocument)
    586         return FloatRect(0, 0, width().value(lengthContext), height().value(lengthContext));
    587 
    588     return useViewBox;
     542    if (!toRenderSVGRoot(renderer())->isEmbeddedThroughSVGImage())
     543        return FloatRect();
     544
     545    Length intrinsicWidth = this->intrinsicWidth();
     546    Length intrinsicHeight = this->intrinsicHeight();
     547    if (!intrinsicWidth.isFixed() || !intrinsicHeight.isFixed())
     548        return FloatRect();
     549
     550    // If no viewBox is specified but non-relative width/height values, then we
     551    // should always synthesize a viewBox if we're embedded through a SVGImage.   
     552    return FloatRect(FloatPoint(), FloatSize(intrinsicWidth.calcFloatValue(0), intrinsicHeight.calcFloatValue(0)));
     553}
     554
     555FloatSize SVGSVGElement::currentViewportSize() const
     556{
     557    Length intrinsicWidth = this->intrinsicWidth();
     558    Length intrinsicHeight = this->intrinsicHeight();
     559    if (intrinsicWidth.isFixed() && intrinsicHeight.isFixed())
     560        return FloatSize(intrinsicWidth.calcFloatValue(0), intrinsicHeight.calcFloatValue(0));
     561
     562    if (!renderer())
     563        return FloatSize();
     564
     565    if (renderer()->isSVGRoot()) {
     566        LayoutRect frameRect = toRenderSVGRoot(renderer())->frameRect();
     567        return FloatSize(frameRect.width() / renderer()->style()->effectiveZoom(), frameRect.height() / renderer()->style()->effectiveZoom());
     568    }
     569
     570    FloatRect frameRect = toRenderSVGViewportContainer(renderer())->viewport();
     571    return FloatSize(frameRect.width() / renderer()->style()->effectiveZoom(), frameRect.height() / renderer()->style()->effectiveZoom());
     572}
     573
     574bool SVGSVGElement::widthAttributeEstablishesViewport() const
     575{
     576    if (!renderer() || renderer()->isSVGViewportContainer())
     577        return true;
     578
     579    // Spec: http://www.w3.org/TR/SVG/coords.html#ViewportSpace
     580    // The ‘width’ attribute on the outermost svg element establishes the viewport's width, unless the following conditions are met:
     581    // - the SVG content is a separately stored resource that is embedded by reference (such as the ‘object’ element in XHTML [XHTML]), or
     582    //   the SVG content is embedded inline within a containing document;
     583    // - and the referencing element or containing document is styled using CSS [CSS2] or XSL [XSL];
     584    // - and there are CSS-compatible positioning properties ([CSS2], section 9.3) specified on the referencing element (e.g., the ‘object’ element)
     585    //   or on the containing document's outermost svg element that are sufficient to establish the width of the viewport. Under these conditions,
     586    //   the positioning properties establish the viewport's width.
     587    RenderSVGRoot* root = toRenderSVGRoot(renderer());
     588
     589    // SVG embedded through object/embed/iframe.
     590    if (root->isEmbeddedThroughFrameContainingSVGDocument())
     591        return !root->hasReplacedLogicalWidth() && !document()->frame()->ownerRenderer()->hasReplacedLogicalWidth();
     592
     593    // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SVG.
     594    if (root->isEmbeddedThroughSVGImage() || document()->documentElement() != this)
     595        return !root->hasReplacedLogicalWidth();
     596
     597    return true;
     598}
     599
     600bool SVGSVGElement::heightAttributeEstablishesViewport() const
     601{
     602    if (!renderer() || renderer()->isSVGViewportContainer())
     603        return true;
     604
     605    // Spec: http://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
     606    // Similarly, if there are positioning properties specified on the referencing element or on the outermost svg element
     607    // that are sufficient to establish the height of the viewport, then these positioning properties establish the viewport's
     608    // height; otherwise, the ‘height’ attribute on the outermost svg element establishes the viewport's height.
     609    RenderSVGRoot* root = toRenderSVGRoot(renderer());
     610
     611    // SVG embedded through object/embed/iframe.
     612    if (root->isEmbeddedThroughFrameContainingSVGDocument())
     613        return !root->hasReplacedLogicalHeight() && !document()->frame()->ownerRenderer()->hasReplacedLogicalHeight();
     614
     615    // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SVG.
     616    if (root->isEmbeddedThroughSVGImage() || document()->documentElement() != this)
     617        return !root->hasReplacedLogicalHeight();
     618
     619    return true;
     620}
     621
     622Length SVGSVGElement::intrinsicWidth(ConsiderCSSMode mode) const
     623{
     624    if (widthAttributeEstablishesViewport() || mode == IgnoreCSSProperties) {
     625        if (width().unitType() == LengthTypePercentage)
     626            return Length(width().valueAsPercentage() * 100, Percent);
     627
     628        SVGLengthContext lengthContext(this);
     629        return Length(width().value(lengthContext), Fixed);
     630    }
     631
     632    ASSERT(renderer());
     633    return renderer()->style()->width();
     634}
     635
     636Length SVGSVGElement::intrinsicHeight(ConsiderCSSMode mode) const
     637{
     638    if (heightAttributeEstablishesViewport() || mode == IgnoreCSSProperties) {
     639        if (height().unitType() == LengthTypePercentage)
     640            return Length(height().valueAsPercentage() * 100, Percent);
     641
     642        SVGLengthContext lengthContext(this);
     643        return Length(height().value(lengthContext), Fixed);
     644    }
     645
     646    ASSERT(renderer());
     647    return renderer()->style()->height();
    589648}
    590649
  • trunk/Source/WebCore/svg/SVGSVGElement.h

    r105404 r105513  
    7474    SVGViewSpec* currentView() const;
    7575
    76     enum CalculateViewBoxMode {
    77         CalculateViewBoxInHostDocument,
    78         CalculateViewBoxInCurrentDocument
     76    enum ConsiderCSSMode {
     77        RespectCSSProperties,
     78        IgnoreCSSProperties
    7979    };
    8080
    81     FloatRect currentViewBoxRect(CalculateViewBoxMode = CalculateViewBoxInCurrentDocument) const;
     81    // RenderSVGRoot wants to query the intrinsic size, by only examining the width/height attributes.
     82    Length intrinsicWidth(ConsiderCSSMode = RespectCSSProperties) const;
     83    Length intrinsicHeight(ConsiderCSSMode = RespectCSSProperties) const;
     84    FloatSize currentViewportSize() const;
     85    FloatRect currentViewBoxRect() const;
     86
    8287    float currentScale() const;
    8388    void setCurrentScale(float scale);
     
    125130
    126131    Element* getElementById(const AtomicString&) const;
     132
     133    bool widthAttributeEstablishesViewport() const;
     134    bool heightAttributeEstablishesViewport() const;
    127135
    128136protected:
  • trunk/Source/WebCore/svg/graphics/SVGImage.cpp

    r105404 r105513  
    141141    // Assure that a container size is always given for a non-identity zoom level.
    142142    ASSERT(renderer->style()->effectiveZoom() == 1);
    143     IntSize size = enclosingIntRect(rootElement->currentViewBoxRect(SVGSVGElement::CalculateViewBoxInHostDocument)).size();
    144     if (!size.isEmpty())
    145         return size;
     143
     144    FloatSize currentSize;
     145    if (rootElement->intrinsicWidth().isFixed() && rootElement->intrinsicHeight().isFixed())
     146        currentSize = rootElement->currentViewportSize();
     147    else
     148        currentSize = rootElement->currentViewBoxRect().size();
     149
     150    if (!currentSize.isEmpty())
     151        return IntSize(static_cast<int>(ceilf(currentSize.width())), static_cast<int>(ceilf(currentSize.height())));
    146152
    147153    // As last resort, use CSS default intrinsic size.
     
    252258}
    253259
     260bool SVGImage::hasRelativeWidth() const
     261{
     262    if (!m_page)
     263        return false;
     264    Frame* frame = m_page->mainFrame();
     265    SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement();
     266    if (!rootElement)
     267        return false;
     268    return rootElement->intrinsicWidth().isPercent();
     269}
     270
     271bool SVGImage::hasRelativeHeight() const
     272{
     273    if (!m_page)
     274        return false;
     275    Frame* frame = m_page->mainFrame();
     276    SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement();
     277    if (!rootElement)
     278        return false;
     279    return rootElement->intrinsicHeight().isPercent();
     280}
     281
    254282void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
    255283{
     
    260288    if (!rootElement)
    261289        return;
    262     RenderBox* renderer = toRenderBox(rootElement->renderer());
    263     if (!renderer)
    264         return;
    265 
    266     intrinsicWidth = renderer->style()->width();
    267     intrinsicHeight = renderer->style()->height();
    268     if (rootElement->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
    269         intrinsicRatio = rootElement->currentViewBoxRect().size();
     290
     291    intrinsicWidth = rootElement->intrinsicWidth();
     292    intrinsicHeight = rootElement->intrinsicHeight();
     293    if (rootElement->preserveAspectRatio().align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
     294        return;
     295
     296    intrinsicRatio = rootElement->viewBox().size();
     297    if (intrinsicRatio.isEmpty() && intrinsicWidth.isFixed() && intrinsicHeight.isFixed())
     298        intrinsicRatio = FloatSize(intrinsicWidth.calcFloatValue(0), intrinsicHeight.calcFloatValue(0));
    270299}
    271300
  • trunk/Source/WebCore/svg/graphics/SVGImage.h

    r105404 r105513  
    5858    virtual IntSize size() const;
    5959
     60    virtual bool hasRelativeWidth() const;
     61    virtual bool hasRelativeHeight() const;
     62
    6063private:
    6164    virtual ~SVGImage();
Note: See TracChangeset for help on using the changeset viewer.