Changeset 105404 in webkit


Ignore:
Timestamp:
Jan 19, 2012 5:03:30 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r105402.
http://trac.webkit.org/changeset/105402
https://bugs.webkit.org/show_bug.cgi?id=76623

Layout test problems (Requested by WildFox on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-01-19

Source/WebCore:

  • css/svg.css:

(svg):

  • rendering/RenderBox.h:

(WebCore::RenderBox::computeIntrinsicRatioInformation):

  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions):

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::computeReplacedLogicalWidth):
(WebCore::RenderImage::computeIntrinsicRatioInformation):

  • rendering/RenderImage.h:
  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::computeReplacedLogicalWidth):
(WebCore::RenderReplaced::logicalHeightIsAuto):
(WebCore::RenderReplaced::computeReplacedLogicalHeight):

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

(WebCore::RenderSVGRoot::computeIntrinsicRatioInformation):
(WebCore::RenderSVGRoot::computeReplacedLogicalWidth):
(WebCore::RenderSVGRoot::computeReplacedLogicalHeight):

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

(WebCore::SVGLengthContext::determineViewport):

  • svg/SVGSVGElement.cpp:

(WebCore::SVGSVGElement::viewport):
(WebCore::SVGSVGElement::parseMappedAttribute):
(WebCore::updateCSSForAttribute):
(WebCore::SVGSVGElement::svgAttributeChanged):
(WebCore::SVGSVGElement::localCoordinateSpaceTransform):
(WebCore::SVGSVGElement::currentViewBoxRect):

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

(WebCore::SVGImage::size):
(WebCore::SVGImage::computeIntrinsicDimensions):

  • svg/graphics/SVGImage.h:

LayoutTests:

  • platform/mac/svg/custom/dynamic-empty-path-expected.png:
  • platform/mac/svg/custom/fractional-rects-expected.png:
  • platform/mac/svg/custom/js-update-container-expected.png:
  • platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.png:
  • platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.txt:
  • platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.png:
  • platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.txt:
  • platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.png:
  • platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.txt:
  • platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.png:
  • platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.txt:
  • platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.png:
  • platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.txt:
  • platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.png:
  • platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.txt:
  • platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.png:
  • platform/mac/svg/custom/viewBox-hit-expected.png:
  • platform/mac/svg/zoom/page/absolute-sized-document-no-scrollbars-expected.png:
  • platform/mac/svg/zoom/page/zoom-hixie-mixed-009-expected.png:
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.png:
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.txt:
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.png:
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.txt:
  • svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute.xhtml:
  • svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute.xhtml:
  • svg/custom/object-sizing-width-50p-on-target-svg-absolute.xhtml:
  • svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute.xhtml:
  • svg/foreignObject/text-tref-02-b-expected.txt:
Location:
trunk
Files:
45 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r105403 r105404  
     12012-01-19  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r105402.
     4        http://trac.webkit.org/changeset/105402
     5        https://bugs.webkit.org/show_bug.cgi?id=76623
     6
     7        Layout test problems (Requested by WildFox on #webkit).
     8
     9        * platform/mac/svg/custom/dynamic-empty-path-expected.png:
     10        * platform/mac/svg/custom/fractional-rects-expected.png:
     11        * platform/mac/svg/custom/js-update-container-expected.png:
     12        * platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.png:
     13        * platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.txt:
     14        * platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.png:
     15        * platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.txt:
     16        * platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.png:
     17        * platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.txt:
     18        * platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.png:
     19        * platform/mac/svg/custom/object-sizing-width-50p-on-target-svg-absolute-expected.txt:
     20        * platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.png:
     21        * platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.txt:
     22        * platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.png:
     23        * platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.txt:
     24        * platform/mac/svg/custom/use-css-no-effect-on-shadow-tree-expected.png:
     25        * platform/mac/svg/custom/viewBox-hit-expected.png:
     26        * platform/mac/svg/zoom/page/absolute-sized-document-no-scrollbars-expected.png:
     27        * platform/mac/svg/zoom/page/zoom-hixie-mixed-009-expected.png:
     28        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.png:
     29        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.txt:
     30        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.png:
     31        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.txt:
     32        * svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute.xhtml:
     33        * svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute.xhtml:
     34        * svg/custom/object-sizing-width-50p-on-target-svg-absolute.xhtml:
     35        * svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute.xhtml:
     36        * svg/foreignObject/text-tref-02-b-expected.txt:
     37
    1382012-01-19  Alexis Menard  <alexis.menard@openbossa.org>
    239
  • trunk/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute-expected.txt

    r105402 r105404  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 500x154 layerType: background only
    4 layer at (0,0) size 250x75
    5   RenderBlock (positioned) zI: -1 {div} at (0,0) size 250x75 [bgcolor=#FF0000]
     4layer at (0,0) size 125x75
     5  RenderBlock (positioned) zI: -1 {div} at (0,0) size 125x75 [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 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]
    17 layer 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]
     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]
     17layer 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]
  • trunk/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-absolute-expected.txt

    r105402 r105404  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 500x154 layerType: background only
    4 layer at (0,0) size 250x112
    5   RenderBlock (positioned) zI: -1 {div} at (0,0) size 250x112 [bgcolor=#FF0000]
     4layer at (0,0) size 125x112
     5  RenderBlock (positioned) zI: -1 {div} at (0,0) size 125x112 [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 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]
    17 layer 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]
     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]
     17layer 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]
  • trunk/LayoutTests/platform/mac/svg/custom/object-sizing-width-50p-height-75p-on-target-svg-expected.txt

    r105402 r105404  
    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.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]
     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]
    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

    r105402 r105404  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 500x154 layerType: background only
    4 layer at (0,0) size 250x150
    5   RenderBlock (positioned) zI: -1 {div} at (0,0) size 250x150 [bgcolor=#FF0000]
     4layer at (0,0) size 125x150
     5  RenderBlock (positioned) zI: -1 {div} at (0,0) size 125x150 [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 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]
    17 layer 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]
     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]
     17layer 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]
  • trunk/LayoutTests/platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-absolute-expected.txt

    r105402 r105404  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 500x154 layerType: background only
    4 layer at (0,0) size 375x75
    5   RenderBlock (positioned) zI: -1 {div} at (0,0) size 375x75 [bgcolor=#FF0000]
     4layer at (0,0) size 281x75
     5  RenderBlock (positioned) zI: -1 {div} at (0,0) size 281x75 [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 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]
    17 layer 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]
     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]
     17layer 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]
  • trunk/LayoutTests/platform/mac/svg/custom/object-sizing-width-75p-height-50p-on-target-svg-expected.txt

    r105402 r105404  
    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.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]
     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]
    1717layer at (0,80) size 281x75
    1818  RenderSVGRoot {svg} at (0,80) size 281x75
  • trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.txt

    r105402 r105404  
    11layer at (0,0) size 800x600
    22  RenderView at (0,0) size 800x600
    3 layer at (0,0) size 800x196
    4   RenderBlock {html} at (0,0) size 800x196
    5     RenderBody {body} at (5,5) size 790x186
    6       RenderTable {table} at (144,0) size 502x186
    7         RenderTableSection (anonymous) at (0,0) size 502x186
    8           RenderTableRow {tr} at (0,0) size 502x186
    9             RenderTableCell {td} at (0,0) size 502x186 [r=0 c=0 rs=1 cs=3]
    10               RenderTable {table} at (6,6) size 490x174
    11                 RenderTableSection (anonymous) at (0,0) size 490x174
     3layer at (0,0) size 800x195
     4  RenderBlock {html} at (0,0) size 800x195
     5    RenderBody {body} at (5,5) size 790x185
     6      RenderTable {table} at (144,0) size 502x185
     7        RenderTableSection (anonymous) at (0,0) size 502x185
     8          RenderTableRow {tr} at (0,0) size 502x185
     9            RenderTableCell {td} at (0,0) size 502x185 [r=0 c=0 rs=1 cs=3]
     10              RenderTable {table} at (6,6) size 490x173
     11                RenderTableSection (anonymous) at (0,0) size 490x173
    1212                  RenderTableRow {tr} at (0,1) size 490x64
    1313                    RenderTableCell {td} at (1,1) size 488x64 [r=0 c=0 rs=1 cs=2]
     
    1616                          text run at (0,0) width 478: "Both sides should have identical size after zooming"
    1717                  RenderTableRow {tr} at (0,66) size 490x23
    18                     RenderTableCell {td} at (1,66) size 244x23 [r=1 c=0 rs=1 cs=1]
     18                    RenderTableCell {td} at (1,66) size 243x23 [r=1 c=0 rs=1 cs=1]
     19                      RenderText {#text} at (94,5) size 55x13
     20                        text run at (94,5) width 55: "SVG Image"
     21                    RenderTableCell {td} at (245,66) size 244x23 [r=1 c=1 rs=1 cs=1]
    1922                      RenderText {#text} at (95,5) size 54x13
    20                         text run at (95,5) width 54: "SVG Image"
    21                     RenderTableCell {td} at (246,66) size 243x23 [r=1 c=1 rs=1 cs=1]
    22                       RenderText {#text} at (94,5) size 55x13
    23                         text run at (94,5) width 55: "PNG Image"
    24                   RenderTableRow {tr} at (0,90) size 490x83
    25                     RenderTableCell {td} at (1,90) size 244x83 [r=2 c=0 rs=1 cs=1]
    26                       RenderEmbeddedObject {object} at (100,5) size 139x70
    27                         layer at (0,0) size 139x70
    28                           RenderView at (0,0) size 139x70
     23                        text run at (95,5) width 54: "PNG Image"
     24                  RenderTableRow {tr} at (0,90) size 490x82
     25                    RenderTableCell {td} at (1,90) size 243x82 [r=2 c=0 rs=1 cs=1]
     26                      RenderEmbeddedObject {object} at (100,5) size 138x69
     27                        layer at (0,0) size 138x69
     28                          RenderView at (0,0) size 138x69
    2929                        layer at (0,0) size 138x69
    3030                          RenderSVGRoot {svg} at (23,0) size 92x69
     
    4343                            RenderSVGRect {rect} at (23,0) size 92x69 [stroke={[type=SOLID] [color=#000000]}] [x=1.00] [y=1.00] [width=478.00] [height=358.00]
    4444                      RenderText {#text} at (0,0) size 0x0
    45                     RenderTableCell {td} at (246,90) size 243x82 [r=2 c=1 rs=1 cs=1]
     45                    RenderTableCell {td} at (245,90) size 244x82 [r=2 c=1 rs=1 cs=1]
    4646                      RenderImage {img} at (5,5) size 138x69
    4747                      RenderText {#text} at (0,0) size 0x0
  • trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.txt

    r105402 r105404  
    11layer at (0,0) size 800x600
    22  RenderView at (0,0) size 800x600
    3 layer at (0,0) size 800x172
    4   RenderBlock {HTML} at (0,0) size 800x172
    5     RenderBody {BODY} at (5,5) size 790x162
    6       RenderEmbeddedObject {OBJECT} at (0,0) size 159x159 [border: (1px dashed #800000)]
    7         layer at (0,0) size 153x153
    8           RenderView at (0,0) size 153x153
     3layer at (0,0) size 800x171
     4  RenderBlock {HTML} at (0,0) size 800x171
     5    RenderBody {BODY} at (5,5) size 790x161
     6      RenderEmbeddedObject {OBJECT} at (0,0) size 158x158 [border: (1px dashed #800000)]
     7        layer at (0,0) size 152x152
     8          RenderView at (0,0) size 152x152
    99        layer at (0,0) size 152x152
    1010          RenderSVGRoot {svg} at (0,0) size 152x152
    1111            RenderSVGPath {circle} at (0,0) size 152x152 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#D9BB7A] [fill rule=EVEN-ODD]}] [cx=110.00] [cy=110.00] [r=110.00]
    12       RenderText {#text} at (159,149) size 3x13
    13         text run at (159,149) width 3: " "
    14       RenderEmbeddedObject {OBJECT} at (162,1) size 158x158 [border: (1px dashed #800000)]
     12      RenderText {#text} at (158,148) size 3x13
     13        text run at (158,148) width 3: " "
     14      RenderEmbeddedObject {OBJECT} at (161,0) size 158x158 [border: (1px dashed #800000)]
    1515        layer at (0,0) size 152x152
    1616          RenderView at (0,0) size 152x152
  • trunk/LayoutTests/svg/custom/object-sizing-width-50p-height-50p-on-target-svg-absolute.xhtml

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

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

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

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

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

    r105403 r105404  
     12012-01-19  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r105402.
     4        http://trac.webkit.org/changeset/105402
     5        https://bugs.webkit.org/show_bug.cgi?id=76623
     6
     7        Layout test problems (Requested by WildFox on #webkit).
     8
     9        * css/svg.css:
     10        (svg):
     11        * rendering/RenderBox.h:
     12        (WebCore::RenderBox::computeIntrinsicRatioInformation):
     13        * rendering/RenderBoxModelObject.cpp:
     14        (WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions):
     15        * rendering/RenderImage.cpp:
     16        (WebCore::RenderImage::computeReplacedLogicalWidth):
     17        (WebCore::RenderImage::computeIntrinsicRatioInformation):
     18        * rendering/RenderImage.h:
     19        * rendering/RenderReplaced.cpp:
     20        (WebCore::RenderReplaced::computeReplacedLogicalWidth):
     21        (WebCore::RenderReplaced::logicalHeightIsAuto):
     22        (WebCore::RenderReplaced::computeReplacedLogicalHeight):
     23        * rendering/RenderReplaced.h:
     24        * rendering/svg/RenderSVGRoot.cpp:
     25        (WebCore::RenderSVGRoot::computeIntrinsicRatioInformation):
     26        (WebCore::RenderSVGRoot::computeReplacedLogicalWidth):
     27        (WebCore::RenderSVGRoot::computeReplacedLogicalHeight):
     28        * rendering/svg/RenderSVGRoot.h:
     29        * rendering/svg/RenderSVGViewportContainer.h:
     30        * svg/SVGLengthContext.cpp:
     31        (WebCore::SVGLengthContext::determineViewport):
     32        * svg/SVGSVGElement.cpp:
     33        (WebCore::SVGSVGElement::viewport):
     34        (WebCore::SVGSVGElement::parseMappedAttribute):
     35        (WebCore::updateCSSForAttribute):
     36        (WebCore::SVGSVGElement::svgAttributeChanged):
     37        (WebCore::SVGSVGElement::localCoordinateSpaceTransform):
     38        (WebCore::SVGSVGElement::currentViewBoxRect):
     39        * svg/SVGSVGElement.h:
     40        * svg/graphics/SVGImage.cpp:
     41        (WebCore::SVGImage::size):
     42        (WebCore::SVGImage::computeIntrinsicDimensions):
     43        * svg/graphics/SVGImage.h:
     44
    1452012-01-19  Alexis Menard  <alexis.menard@openbossa.org>
    246
  • trunk/Source/WebCore/css/svg.css

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

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

    r105402 r105404  
    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 
    878875        // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    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>(ceilf(positioningAreaSize.width() * intrinsicWidth.percent() / 100));
    882             resolvedHeight = static_cast<int>(ceilf(positioningAreaSize.height() * intrinsicHeight.percent() / 100));
    883         } else {
    884             if (intrinsicWidth.isFixed())
    885                 resolvedWidth = static_cast<int>(ceilf(intrinsicWidth.value() * style()->effectiveZoom()));
    886             if (intrinsicHeight.isFixed())
    887                 resolvedHeight = static_cast<int>(ceilf(intrinsicHeight.value() * style()->effectiveZoom()));
    888         }
    889     }
    890 
     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.
    891885    if (resolvedWidth > 0 && resolvedHeight > 0)
    892886        return IntSize(resolvedWidth, resolvedHeight);
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r105402 r105404  
    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
    495499    IntSize containerSize;
    496     if (m_imageResource->imageHasRelativeWidth() || m_imageResource->imageHasRelativeHeight()) {
     500    if (hasRelativeWidth || hasRelativeHeight) {
    497501        // Propagate the containing block size to the image resource, otherwhise we can't compute our own intrinsic size, if it's relative.
    498502        RenderObject* containingBlock = isPositioned() ? container() : this->containingBlock();
     
    520524}
    521525
    522 void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, float& intrinsicRatio, bool& isPercentageIntrinsicSize) const
     526void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicRatio, bool& isPercentageIntrinsicSize) const
    523527{
    524528    // Assure this method is never used for SVGImages.
     
    526530    isPercentageIntrinsicSize = false;
    527531    CachedImage* cachedImage = m_imageResource ? m_imageResource->cachedImage() : 0;
    528     if (!cachedImage || !cachedImage->image())
    529         return;
    530     intrinsicSize = cachedImage->image()->size();
    531     intrinsicRatio = intrinsicSize.width() / intrinsicSize.height();
     532    if (cachedImage && cachedImage->image())
     533        intrinsicRatio = cachedImage->image()->size();
    532534}
    533535
  • trunk/Source/WebCore/rendering/RenderImage.h

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

    r105402 r105404  
    217217}
    218218
    219 static 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 
    236 bool 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 
    247 static 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 
    267 bool 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 
    281219LayoutUnit RenderReplaced::computeReplacedLogicalWidth(bool includeMaxWidth) const
    282220{
     
    289227    // 10.3.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-width
    290228    bool isPercentageIntrinsicSize = false;
    291     float intrinsicRatio = 0;
    292     FloatSize intrinsicSize;
     229    FloatSize intrinsicRatio;
    293230    if (contentRenderer) {
    294         contentRenderer->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
     231        contentRenderer->computeIntrinsicRatioInformation(intrinsicRatio, isPercentageIntrinsicSize);
    295232        contentRenderStyle = contentRenderer->style();
    296233        ASSERT(contentRenderStyle);
    297234    } else
    298         computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
     235        computeIntrinsicRatioInformation(intrinsicRatio, isPercentageIntrinsicSize);
    299236
    300237    if (style()->logicalWidth().isAuto()) {
    301238        bool heightIsAuto = style()->logicalHeight().isAuto();
    302         bool hasIntrinsicWidth = m_hasIntrinsicSize || (!isPercentageIntrinsicSize && intrinsicSize.width() > 0);
     239        bool hasIntrinsicWidth = m_hasIntrinsicSize || (contentRenderer && contentRenderStyle->logicalWidth().isFixed());
    303240
    304241        // 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'.
    305         if (heightIsAuto && hasIntrinsicWidth) {
    306             if (m_hasIntrinsicSize)
    307                 return computeReplacedLogicalWidthRespectingMinMaxWidth(calcAspectRatioLogicalWidth(), includeMaxWidth);
    308             // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    309             return static_cast<LayoutUnit>(ceilf(intrinsicSize.width() * style()->effectiveZoom()));
    310         }
    311 
    312         bool hasIntrinsicHeight = m_hasIntrinsicSize || (!isPercentageIntrinsicSize && intrinsicSize.height() > 0);
    313         if (intrinsicRatio || isPercentageIntrinsicSize) {
     242        if (heightIsAuto && hasIntrinsicWidth)
     243            return computeIntrinsicLogicalWidth(contentRenderer, includeMaxWidth);
     244   
     245        bool hasIntrinsicHeight = m_hasIntrinsicSize || (contentRenderer && contentRenderStyle->logicalHeight().isFixed());
     246        if (!intrinsicRatio.isEmpty()) {
    314247            // 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;
    315248            // 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
    316249            // of 'width' is: (used height) * (intrinsic ratio)
    317             if (intrinsicRatio && ((heightIsAuto && !hasIntrinsicWidth && hasIntrinsicHeight) || !heightIsAuto)) {
    318                 LayoutUnit logicalHeight = computeReplacedLogicalHeightUsing(style()->logicalHeight());
    319                 return computeReplacedLogicalWidthRespectingMinMaxWidth(static_cast<LayoutUnit>(ceilf(logicalHeight * intrinsicRatio)));
     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                }
    320262            }
    321263
     
    323265            // '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
    324266            // the used value of 'width' is calculated from the constraint equation used for block-level, non-replaced elements in normal flow.
    325             if (heightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeight && contentRenderer) {
     267            RenderBlock* containingBlock = this->containingBlock();
     268            if (heightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeight && contentRenderer && containingBlock) {
    326269                // The aforementioned 'constraint equation' used for block-level, non-replaced elements in normal flow:
    327270                // 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containing block
    328                 LayoutUnit logicalWidth;
    329                 if (RenderBlock* blockWithWidth = firstContainingBlockWithLogicalWidth(this))
    330                     logicalWidth = blockWithWidth->computeReplacedLogicalWidthRespectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(blockWithWidth->style()->logicalWidth()), false);
    331                 else
    332                     logicalWidth = containingBlock()->availableLogicalWidth();
    333 
     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               
    334283                // This solves above equation for 'width' (== logicalWidth).
     284                LayoutUnit logicalWidth = foundExplicitWidth ? computeIntrinsicLogicalWidth(containingBlock, false) : containingBlock->availableLogicalWidth();
    335285                LayoutUnit marginStart = style()->marginStart().calcMinValue(logicalWidth);
    336286                LayoutUnit marginEnd = style()->marginEnd().calcMinValue(logicalWidth);
     
    338288                if (isPercentageIntrinsicSize)
    339289                    // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    340                     logicalWidth = static_cast<LayoutUnit>(ceilf(logicalWidth * intrinsicSize.width() / 100));
     290                    logicalWidth = static_cast<int>(ceilf(logicalWidth * intrinsicRatio.width() / 100));
    341291                return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth);
    342292            }
     
    344294
    345295        // 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'.
    346         if (hasIntrinsicWidth) {
    347             if (isPercentageIntrinsicSize)
    348                 return computeReplacedLogicalWidthRespectingMinMaxWidth(calcAspectRatioLogicalWidth(), includeMaxWidth);
    349             // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    350             return static_cast<LayoutUnit>(ceilf(intrinsicSize.width() * style()->effectiveZoom()));
    351         }
     296        if (hasIntrinsicWidth)
     297            return computeIntrinsicLogicalWidth(contentRenderer, includeMaxWidth);
    352298
    353299        // 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
     
    359305}
    360306
     307bool 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
    361327LayoutUnit RenderReplaced::computeReplacedLogicalHeight() const
    362328{
    363329    // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/visudet.html#propdef-height
    364     if (hasReplacedLogicalHeight())
     330    bool heightIsAuto = logicalHeightIsAuto();
     331    if (style()->logicalHeight().isSpecified() && !heightIsAuto)
    365332        return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(style()->logicalHeight()));
    366333
     
    370337    // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-height
    371338    bool isPercentageIntrinsicSize = false;
    372     float intrinsicRatio = 0;
    373     FloatSize intrinsicSize;
     339    FloatSize intrinsicRatio;
    374340    if (contentRenderer) {
    375         contentRenderer->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
     341        contentRenderer->computeIntrinsicRatioInformation(intrinsicRatio, isPercentageIntrinsicSize);
    376342        contentRenderStyle = contentRenderer->style();
    377343        ASSERT(contentRenderStyle);
    378     } else
    379         computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
    380 
    381     bool widthIsAuto = style()->logicalWidth().isAuto();
    382     bool hasIntrinsicHeight = m_hasIntrinsicSize || (!isPercentageIntrinsicSize && intrinsicSize.height() > 0);
    383 
    384     // 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'.
    385     if (widthIsAuto && hasIntrinsicHeight) {
    386         if (m_hasIntrinsicSize)
    387             return computeReplacedLogicalHeightRespectingMinMaxHeight(calcAspectRatioLogicalHeight());
    388         // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    389         return static_cast<LayoutUnit>(ceilf(intrinsicSize.height() * style()->effectiveZoom()));
    390     }
    391 
    392     // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is:
    393     // (used width) / (intrinsic ratio)
    394     if (intrinsicRatio && !isPercentageIntrinsicSize) {
    395         // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    396         return computeReplacedLogicalHeightRespectingMinMaxHeight(static_cast<LayoutUnit>(ceilf(availableLogicalWidth() / intrinsicRatio)));
    397     }
    398 
    399     // 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'.
    400     if (hasIntrinsicHeight) {
    401         if (m_hasIntrinsicSize)
    402             return computeReplacedLogicalHeightRespectingMinMaxHeight(calcAspectRatioLogicalHeight());
    403         // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    404         return static_cast<LayoutUnit>(ceilf(intrinsicSize.height() * style()->effectiveZoom()));
    405     }
    406 
    407     // 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
    408     // 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.
    409     return computeReplacedLogicalHeightRespectingMinMaxHeight(cDefaultHeight);
     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());
    410370}
    411371
  • trunk/Source/WebCore/rendering/RenderReplaced.h

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

    r105402 r105404  
    6767}
    6868
    69 void RenderSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, float& 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->intrinsicWidthIgnoringCSSProperties();
    80     Length intrinsicHeightAttribute = svg->intrinsicHeightIgnoringCSSProperties();
    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() / intrinsicSize.height();
     69void 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());
    9684        return;
    9785    }
    9886
    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() / 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()) {
     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()) {
    11496        isPercentageIntrinsicSize = true;
    115         intrinsicSize = FloatSize(intrinsicWidthAttribute.percent(), intrinsicHeightAttribute.percent());
     97        intrinsicRatio = FloatSize(style()->width().percent(), style()->height().percent());
    11698    }
    11799}
     
    153135}
    154136
    155 static 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 
    160137LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(bool includeMaxWidth) const
    161138{
    162     SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
    163     ASSERT(svg);
    164 
    165139    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
    166     if (!m_containerSize.isEmpty())
    167         return m_containerSize.width();
    168 
    169     if (style()->logicalWidth().isSpecified())
    170         return RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth);
    171 
    172     if (svg->widthAttributeEstablishesViewport())
    173         return resolveLengthAttributeForSVG(svg->intrinsicWidthIgnoringCSSProperties(), style()->effectiveZoom(), containingBlock()->availableLogicalWidth());
    174 
    175     // Only SVGs embedded in <object> reach this point.
    176     ASSERT(isEmbeddedThroughFrameContainingSVGDocument());
    177     return document()->frame()->ownerRenderer()->availableLogicalWidth();
     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);
    178180}
    179181
    180182LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const
    181183{
    182     SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
    183     ASSERT(svg);
    184 
    185184    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
    186     if (!m_containerSize.isEmpty())
    187         return m_containerSize.height();
    188 
    189     if (hasReplacedLogicalHeight())
    190         return RenderReplaced::computeReplacedLogicalHeight();
    191 
    192     if (svg->heightAttributeEstablishesViewport())
    193         return resolveLengthAttributeForSVG(svg->intrinsicHeightIgnoringCSSProperties(), style()->effectiveZoom(), containingBlock()->availableLogicalHeight());
    194 
    195     // Only SVGs embedded in <object> reach this point.
    196     ASSERT(isEmbeddedThroughFrameContainingSVGDocument());
    197     return document()->frame()->ownerRenderer()->availableLogicalHeight();
     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));
    198213}
    199214
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h

    r105402 r105404  
    4343    bool isEmbeddedThroughFrameContainingSVGDocument() const;
    4444
    45     virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, float& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
     45    virtual void computeIntrinsicRatioInformation(FloatSize& 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

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

    r105402 r105404  
    3030#include "Frame.h"
    3131#include "RenderPart.h"
    32 #include "RenderSVGRoot.h"
    33 #include "RenderSVGViewportContainer.h"
    3432#include "RenderView.h"
    3533#include "SVGNames.h"
     
    277275    }
    278276
    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.
     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)
    284309    SVGElement* viewportElement = m_context->viewportElement();
    285     if (!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    }
     324   
     325    // Take size from enclosing non-SVG RenderBox (common case: inline SVG)
     326    if (!m_context->parentNode() || m_context->parentNode()->isSVGElement())
    286327        return false;
    287    
    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();
     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();
    296336    return true;
    297337}
  • trunk/Source/WebCore/svg/SVGSVGElement.cpp

    r105402 r105404  
    2828#include "Attribute.h"
    2929#include "CSSHelper.h"
     30#include "CSSPropertyNames.h"
    3031#include "Document.h"
    3132#include "EventListener.h"
     
    3839#include "FrameView.h"
    3940#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     // As we have no test coverage for this, we're going to disable it completly for now.
    145     return FloatRect();
     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);
    146151}
    147152
     
    270275    else if (attr->name() == SVGNames::yAttr)
    271276        setYBaseValue(SVGLength::construct(LengthModeHeight, attr->value(), parseError));
    272     else if (attr->name() == SVGNames::widthAttr)
     277    else if (attr->name() == SVGNames::widthAttr) {
    273278        setWidthBaseValue(SVGLength::construct(LengthModeWidth, attr->value(), parseError, ForbidNegativeLengths));
    274     else if (attr->name() == SVGNames::heightAttr)
     279        addCSSProperty(attr, CSSPropertyWidth, attr->value());
     280    } else if (attr->name() == SVGNames::heightAttr) {
    275281        setHeightBaseValue(SVGLength::construct(LengthModeHeight, attr->value(), parseError, ForbidNegativeLengths));
    276     else if (SVGTests::parseMappedAttribute(attr)
     282        addCSSProperty(attr, CSSPropertyHeight, attr->value());
     283    } else if (SVGTests::parseMappedAttribute(attr)
    277284               || SVGLangSpace::parseMappedAttribute(attr)
    278285               || SVGExternalResourcesRequired::parseMappedAttribute(attr)
     
    285292}
    286293
     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.
     296static 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
    287304void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName)
    288305{
     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
    289311    bool updateRelativeLengths = false;
    290     if (attrName == SVGNames::widthAttr
    291         || attrName == SVGNames::heightAttr
     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
    292321        || attrName == SVGNames::xAttr
    293322        || attrName == SVGNames::yAttr
     
    422451AffineTransform SVGSVGElement::localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const
    423452{
     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
    424456    AffineTransform viewBoxTransform;
    425     if (hasAttribute(SVGNames::viewBoxAttr)) {
    426         FloatSize size = currentViewportSize();
    427         viewBoxTransform = viewBoxToViewTransform(size.width(), size.height());
    428     }
     457    if (attributes()->getAttributeItem(SVGNames::viewBoxAttr))
     458        viewBoxTransform = viewBoxToViewTransform(width().value(lengthContext), height().value(lengthContext));
    429459
    430460    AffineTransform transform;
    431     if (!isOutermostSVG()) {
    432         SVGLengthContext lengthContext(this);
     461    if (!isOutermostSVG())
    433462        transform.translate(x().value(lengthContext), y().value(lengthContext));
    434     } else if (mode == SVGLocatable::ScreenScope) {
     463    else if (mode == SVGLocatable::ScreenScope) {
    435464        if (RenderObject* renderer = this->renderer()) {
    436465            // Translate in our CSS parent coordinate space
     
    527556}
    528557
    529 FloatRect SVGSVGElement::currentViewBoxRect() const
    530 {
     558FloatRect 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.
    531564    if (useCurrentView()) {
    532565        if (SVGViewSpec* view = currentView()) // what if we should use it but it is not set?
     
    535568    }
    536569
     570    bool isEmbeddedThroughSVGImage = renderer() && renderer()->isSVGRoot() ? toRenderSVGRoot(renderer())->isEmbeddedThroughSVGImage() : false;
     571    bool hasFixedSize = width().unitType() != LengthTypePercentage && height().unitType() != LengthTypePercentage;
     572
    537573    FloatRect useViewBox = viewBox();
    538     if (!useViewBox.isEmpty())
    539         return useViewBox;
    540     if (!renderer() || !renderer()->isSVGRoot())
     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));
    541579        return FloatRect();
    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 
    555 FloatSize 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 
    574 bool 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 
    600 bool 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 
    622 Length SVGSVGElement::intrinsicWidthIgnoringCSSProperties() const
    623 {
    624     if (width().unitType() == LengthTypePercentage)
    625         return Length(width().valueAsPercentage() * 100, Percent);
    626 
    627     SVGLengthContext lengthContext(this);
    628     return Length(width().value(lengthContext), Fixed);
    629 }
    630 
    631 Length SVGSVGElement::intrinsicWidth() const
    632 {
    633     if (widthAttributeEstablishesViewport())
    634         return intrinsicWidthIgnoringCSSProperties();
    635 
    636     ASSERT(renderer());
    637     return renderer()->style()->width();
    638 }
    639 
    640 Length SVGSVGElement::intrinsicHeightIgnoringCSSProperties() const
    641 {
    642     if (height().unitType() == LengthTypePercentage)
    643         return Length(height().valueAsPercentage() * 100, Percent);
    644 
    645     SVGLengthContext lengthContext(this);
    646     return Length(height().value(lengthContext), Fixed);
    647 }
    648 
    649 Length SVGSVGElement::intrinsicHeight() const
    650 {
    651     if (heightAttributeEstablishesViewport())
    652         return intrinsicHeightIgnoringCSSProperties();
    653 
    654     ASSERT(renderer());
    655     return renderer()->style()->height();
     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;
    656589}
    657590
  • trunk/Source/WebCore/svg/SVGSVGElement.h

    r105402 r105404  
    7474    SVGViewSpec* currentView() const;
    7575
    76     // RenderSVGRoot wants to query the intrinsic size, by only examining the width/height attributes.
    77     Length intrinsicWidthIgnoringCSSProperties() const;
    78     Length intrinsicHeightIgnoringCSSProperties() const;
    79     Length intrinsicWidth() const;
    80     Length intrinsicHeight() const;
    81     FloatSize currentViewportSize() const;
    82     FloatRect currentViewBoxRect() const;
     76    enum CalculateViewBoxMode {
     77        CalculateViewBoxInHostDocument,
     78        CalculateViewBoxInCurrentDocument
     79    };
    8380
     81    FloatRect currentViewBoxRect(CalculateViewBoxMode = CalculateViewBoxInCurrentDocument) const;
    8482    float currentScale() const;
    8583    void setCurrentScale(float scale);
     
    127125
    128126    Element* getElementById(const AtomicString&) const;
    129 
    130     bool widthAttributeEstablishesViewport() const;
    131     bool heightAttributeEstablishesViewport() const;
    132127
    133128protected:
  • trunk/Source/WebCore/svg/graphics/SVGImage.cpp

    r105402 r105404  
    141141    // Assure that a container size is always given for a non-identity zoom level.
    142142    ASSERT(renderer->style()->effectiveZoom() == 1);
    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())));
     143    IntSize size = enclosingIntRect(rootElement->currentViewBoxRect(SVGSVGElement::CalculateViewBoxInHostDocument)).size();
     144    if (!size.isEmpty())
     145        return size;
    152146
    153147    // As last resort, use CSS default intrinsic size.
     
    258252}
    259253
    260 bool 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 
    271 bool 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 
    282254void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
    283255{
     
    288260    if (!rootElement)
    289261        return;
    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));
     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();
    299270}
    300271
  • trunk/Source/WebCore/svg/graphics/SVGImage.h

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