Changeset 87526 in webkit


Ignore:
Timestamp:
May 27, 2011 11:27:50 AM (13 years ago)
Author:
Nikolas Zimmermann
Message:

2011-05-27 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Rob Buis.

embedded SVG object doesn't scale right
https://bugs.webkit.org/show_bug.cgi?id=10526

<object> tags should treat width/height on a referenced SVG as intrinsic width/height
https://bugs.webkit.org/show_bug.cgi?id=11976

Incorrect handling of percentage values for width/height on embedded elements
https://bugs.webkit.org/show_bug.cgi?id=14793

WebKit fails some WICD 1.0 core test cases
https://bugs.webkit.org/show_bug.cgi?id=15836 (partially fixed, all 'rightsizing' tests are fixed)

CSS 2.1: Support replaced elements with relative intrinsic sizes
https://bugs.webkit.org/show_bug.cgai?id=15849 (partially fixed)

SVG embedded as <object> doesn't respect width/height attributes
https://bugs.webkit.org/show_bug.cgi?id=34972

Explicit size of object tag ignored
https://bugs.webkit.org/show_bug.cgi?id=37086

  • http/tests/misc/object-embedding-svg-delayed-size-negotiation.xhtml: Added.
  • http/tests/misc/resources/embedded.svg: Added.
  • http/tests/misc/resources/svg-slow.pl: Added.
  • platform/mac/http/tests/misc/object-embedding-svg-delayed-size-negotiation-expected.png: Added.
  • platform/mac/http/tests/misc/object-embedding-svg-delayed-size-negotiation-expected.txt: Added.
  • platform/mac/svg/custom/object-no-size-attributes-expected.png: Added.
  • platform/mac/svg/custom/object-no-size-attributes-expected.txt: Added.
  • platform/mac/svg/custom/object-sizing-expected.png: Added.
  • platform/mac/svg/custom/object-sizing-expected.txt: Added.
  • platform/mac/svg/custom/object-sizing-explicit-height-expected.png: Added.
  • platform/mac/svg/custom/object-sizing-explicit-height-expected.txt: Added.
  • platform/mac/svg/custom/object-sizing-explicit-width-expected.png: Added.
  • platform/mac/svg/custom/object-sizing-explicit-width-expected.txt: Added.
  • platform/mac/svg/custom/object-sizing-explicit-width-height-expected.png: Added.
  • platform/mac/svg/custom/object-sizing-explicit-width-height-expected.txt: Added.
  • platform/mac/svg/custom/object-sizing-no-width-height-change-content-box-size-expected.png: Added.
  • platform/mac/svg/custom/object-sizing-no-width-height-change-content-box-size-expected.txt: Added.
  • platform/mac/svg/custom/object-sizing-no-width-height-expected.png: Added.
  • platform/mac/svg/custom/object-sizing-no-width-height-expected.txt: Added.
  • platform/mac/svg/hixie/text/003-expected.png:
  • platform/mac/svg/hixie/text/003-expected.txt:
  • platform/mac/svg/in-html/by-reference-expected.txt:
  • platform/mac/svg/wicd: Added.
  • platform/mac/svg/wicd/rightsizing-grid-expected.png: Added.
  • platform/mac/svg/wicd/rightsizing-grid-expected.txt: Added.
  • platform/mac/svg/wicd/test-rightsizing-a-expected.png: Added.
  • platform/mac/svg/wicd/test-rightsizing-a-expected.txt: Added.
  • platform/mac/svg/wicd/test-rightsizing-b-expected.png: Added.
  • platform/mac/svg/wicd/test-rightsizing-b-expected.txt: Added.
  • platform/mac/svg/zoom/page/relative-sized-document-scrollbars-expected.txt:
  • platform/mac/svg/zoom/page/zoom-foreignObject-expected.png:
  • platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt:
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.png: Added.
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.txt: Added.
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.png: Added.
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.txt: Added.
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-huge-size-expected.png: Added.
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-huge-size-expected.txt: Added.
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-no-width-height-expected.png: Added.
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-no-width-height-expected.txt: Added.
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-override-size-expected.png: Added.
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-override-size-expected.txt: Added.
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-percentage-size-expected.png: Added.
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-percentage-size-expected.txt: Added.
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-text-expected.png: Added.
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-text-expected.txt: Added.
  • svg/custom/object-no-size-attributes.xhtml: Added.
  • svg/custom/object-sizing-explicit-height.xhtml: Added.
  • svg/custom/object-sizing-explicit-width-height.xhtml: Added.
  • svg/custom/object-sizing-explicit-width.xhtml: Added.
  • svg/custom/object-sizing-no-width-height-change-content-box-size.xhtml: Added.
  • svg/custom/object-sizing-no-width-height.xhtml: Added.
  • svg/custom/object-sizing.xhtml: Added.
  • svg/custom/resources/embedded.svg: Added.
  • svg/custom/resources/red-circle.svg: Added.
  • svg/in-html/by-reference-expected.png:
  • svg/wicd: Added.
  • svg/wicd/resources: Added.
  • svg/wicd/resources/a.svg: Added.
  • svg/wicd/resources/bcde.svg: Added.
  • svg/wicd/resources/empty1.svg: Added.
  • svg/wicd/resources/empty2.svg: Added.
  • svg/wicd/resources/empty3.svg: Added.
  • svg/wicd/resources/f.svg: Added.
  • svg/wicd/resources/g.svg: Added.
  • svg/wicd/resources/h.svg: Added.
  • svg/wicd/resources/i.svg: Added.
  • svg/wicd/resources/j.svg: Added.
  • svg/wicd/resources/k.svg: Added.
  • svg/wicd/resources/l.svg: Added.
  • svg/wicd/resources/main.css: Added. (body,html): (body): (.buttons): (h1): (h2): (h4): (p): (table): (th): (td,th): (td a): (a): (a:hover): (a:focus): (a:visited): (a.index): (a.index:hover): (a.index:focus): (a.index:visited): (ul): (ol): (.red): (.navi): (.navi a): (.navi a:hover): (.navi a:visited):
  • svg/wicd/resources/mnop.svg: Added.
  • svg/wicd/resources/q.svg: Added.
  • svg/wicd/resources/r.svg: Added.
  • svg/wicd/resources/s.svg: Added.
  • svg/wicd/resources/t.svg: Added.
  • svg/wicd/resources/test-rightsizing-a.css: Added. (html,body): (div.all): (object.w100): (object.h100):
  • svg/wicd/resources/test-rightsizing-b.css: Added. (html,body): (object):
  • svg/wicd/resources/test-svg-child-object-rightsizing.gif: Added.
  • svg/wicd/resources/test-svg-child-object-rightsizing.png: Added.
  • svg/wicd/resources/test-svg-child-object-rightsizing.svg: Added.
  • svg/wicd/resources/test-svg-child-object-rightsizing1.svg: Added.
  • svg/wicd/rightsizing-grid.xhtml: Added.
  • svg/wicd/test-rightsizing-a.xhtml: Added.
  • svg/wicd/test-rightsizing-b.xhtml: Added.
  • svg/zoom/page/resources: Added.
  • svg/zoom/page/resources/absolute-sized-svg.png: Added.
  • svg/zoom/page/resources/absolute-sized-svg.svg: Added.
  • svg/zoom/page/resources/huge-rect.svg: Added.
  • svg/zoom/page/resources/percentage-sized-svg.png: Added.
  • svg/zoom/page/resources/percentage-sized-svg.svg: Added.
  • svg/zoom/page/resources/text.svg: Added.
  • svg/zoom/page/resources/tux.svg: Added.
  • svg/zoom/page/zoom-svg-through-object-with-absolute-size-2.xhtml: Added.
  • svg/zoom/page/zoom-svg-through-object-with-absolute-size.xhtml: Added.
  • svg/zoom/page/zoom-svg-through-object-with-huge-size.xhtml: Added.
  • svg/zoom/page/zoom-svg-through-object-with-override-size.html: Added.
  • svg/zoom/page/zoom-svg-through-object-with-percentage-size.xhtml: Added.
  • svg/zoom/page/zoom-svg-through-object-with-text.xhtml: Added.

2011-05-27 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Rob Buis.

embedded SVG object doesn't scale right
https://bugs.webkit.org/show_bug.cgi?id=10526

<object> tags should treat width/height on a referenced SVG as intrinsic width/height
https://bugs.webkit.org/show_bug.cgi?id=11976

Incorrect handling of percentage values for width/height on embedded elements
https://bugs.webkit.org/show_bug.cgi?id=14793

WebKit fails some WICD 1.0 core test cases
https://bugs.webkit.org/show_bug.cgi?id=15836 (partially fixed, all 'rightsizing' tests are fixed)

CSS 2.1: Support replaced elements with relative intrinsic sizes
https://bugs.webkit.org/show_bug.cgai?id=15849 (partially fixed)

SVG embedded as <object> doesn't respect width/height attributes
https://bugs.webkit.org/show_bug.cgi?id=34972

Explicit size of object tag ignored
https://bugs.webkit.org/show_bug.cgi?id=37086

Add partial support of CSS 2.1 replaced elements with intrinsic size. The feature itself is complete but has only
been implemented for RenderPart, to support SVG content document size negotiation. It serves as starting point for a generalization, in future.
The changes in RenderPart are a 1:1 transliteration of the spec (http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-width/height, see code).

SVG 1.1 says:
The 'width' attribute on the outermost svg element establishes the viewport's width, unless the following conditions are met:
...
and there are CSS-compatible positioning properties ([CSS2], section 9.3) specified on the referencing element (e.g., the 'object' element)
or on the containing document's outermost svg element that are sufficient to establish the width of the viewport. Under these conditions,
the positioning properties establish the viewport's width.

If an <object> carries width/height attributes, these specify the viewport size of the embedded SVG, instead of its own
width/height or viewBox properties. If an <object> has no width/height information, its intrinsic size needs to be calculated depending
on the intrinsic ratio (viewBox width divided by height ratio) and the width/height properties on the outermost referenced <svg> element.
This requires a negotiation between the host document and the embedded document.
(There are several more factors that need to be considered, the CSS spec covers this and the RenderPart::computeReplaced* code covers this.)

Fixes dozens of long-standing bug reports. The number one integration issue when using SVG through <object> is resolved: "right sizing".

Tests: http/tests/misc/object-embedding-svg-delayed-size-negotiation.xhtml

svg/custom/object-no-size-attributes.xhtml (bug 11976, from Eric Seidel)
svg/custom/object-sizing-explicit-height.xhtml (bug 10526, from Ryan Cannon)
svg/custom/object-sizing-explicit-width-height.xhtml
svg/custom/object-sizing-explicit-width.xhtml (bug 14793, from Oliver Hunt)
svg/custom/object-sizing-no-width-height-change-content-box-size.xhtml
svg/custom/object-sizing-no-width-height.xhtml
svg/custom/object-sizing.xhtml (bug 37086, from Jeff Schiller)
svg/wicd/rightsizing-grid.xhtml (bug 15836, WICD rightsizing test now works)
svg/wicd/test-rightsizing-a.xhtml (ditto)
svg/wicd/test-rightsizing-b.xhtml (ditto)
svg/zoom/page/zoom-svg-through-object-with-absolute-size-2.xhtml
svg/zoom/page/zoom-svg-through-object-with-absolute-size.xhtml
svg/zoom/page/zoom-svg-through-object-with-huge-size.xhtml
svg/zoom/page/zoom-svg-through-object-with-override-size.html (bug 34972, from Andreas Kling)
svg/zoom/page/zoom-svg-through-object-with-percentage-size.xhtml
svg/zoom/page/zoom-svg-through-object-with-text.xhtml

  • platform/Length.h: (WebCore::Length::isSpecified):
  • rendering/RenderPart.cpp: (WebCore::RenderPart::embeddedSVGContentRenderer): (WebCore::RenderPart::computeEmbeddedDocumentReplacedWidth): (WebCore::RenderPart::computeEmbeddedDocumentReplacedHeight): (WebCore::RenderPart::computeReplacedLogicalWidth): (WebCore::RenderPart::computeReplacedLogicalHeight): (WebCore::RenderPart::layout):
  • rendering/RenderPart.h:
  • rendering/RenderReplaced.cpp: (WebCore::RenderReplaced::computeReplacedLogicalWidth): (WebCore::RenderReplaced::computeReplacedLogicalHeight):
  • rendering/svg/RenderSVGRoot.cpp: (WebCore::RenderSVGRoot::RenderSVGRoot): (WebCore::RenderSVGRoot::computeIntrinsicRatio): (WebCore::RenderSVGRoot::computeIntrinsicWidth): (WebCore::RenderSVGRoot::computeIntrinsicHeight): (WebCore::RenderSVGRoot::negotiateSizeWithHostDocumentIfNeeded): (WebCore::RenderSVGRoot::computeReplacedLogicalWidth): (WebCore::RenderSVGRoot::computeReplacedLogicalHeight): (WebCore::RenderSVGRoot::layout):
  • rendering/svg/RenderSVGRoot.h:
  • svg/SVGLength.cpp: (WebCore::SVGLength::determineViewport):
  • svg/SVGSVGElement.cpp: (WebCore::SVGSVGElement::currentScale): (WebCore::SVGSVGElement::setCurrentScale): (WebCore::SVGSVGElement::currentViewBoxRect): (WebCore::SVGSVGElement::viewBoxToViewTransform):
  • svg/SVGSVGElement.h:
Location:
trunk
Files:
92 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r87523 r87526  
     12011-05-27  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        Reviewed by Rob Buis.
     4
     5        embedded SVG object doesn't scale right
     6        https://bugs.webkit.org/show_bug.cgi?id=10526
     7
     8        <object> tags should treat width/height on a referenced SVG as intrinsic width/height
     9        https://bugs.webkit.org/show_bug.cgi?id=11976
     10
     11        Incorrect handling of percentage values for width/height on embedded elements
     12        https://bugs.webkit.org/show_bug.cgi?id=14793
     13
     14        WebKit fails some WICD 1.0 core test cases
     15        https://bugs.webkit.org/show_bug.cgi?id=15836 (partially fixed, all 'rightsizing' tests are fixed)
     16
     17        CSS 2.1: Support replaced elements with relative intrinsic sizes
     18        https://bugs.webkit.org/show_bug.cgai?id=15849 (partially fixed)
     19
     20        SVG embedded as <object> doesn't respect width/height attributes
     21        https://bugs.webkit.org/show_bug.cgi?id=34972
     22
     23        Explicit size of object tag ignored
     24        https://bugs.webkit.org/show_bug.cgi?id=37086
     25
     26        * http/tests/misc/object-embedding-svg-delayed-size-negotiation.xhtml: Added.
     27        * http/tests/misc/resources/embedded.svg: Added.
     28        * http/tests/misc/resources/svg-slow.pl: Added.
     29        * platform/mac/http/tests/misc/object-embedding-svg-delayed-size-negotiation-expected.png: Added.
     30        * platform/mac/http/tests/misc/object-embedding-svg-delayed-size-negotiation-expected.txt: Added.
     31        * platform/mac/svg/custom/object-no-size-attributes-expected.png: Added.
     32        * platform/mac/svg/custom/object-no-size-attributes-expected.txt: Added.
     33        * platform/mac/svg/custom/object-sizing-expected.png: Added.
     34        * platform/mac/svg/custom/object-sizing-expected.txt: Added.
     35        * platform/mac/svg/custom/object-sizing-explicit-height-expected.png: Added.
     36        * platform/mac/svg/custom/object-sizing-explicit-height-expected.txt: Added.
     37        * platform/mac/svg/custom/object-sizing-explicit-width-expected.png: Added.
     38        * platform/mac/svg/custom/object-sizing-explicit-width-expected.txt: Added.
     39        * platform/mac/svg/custom/object-sizing-explicit-width-height-expected.png: Added.
     40        * platform/mac/svg/custom/object-sizing-explicit-width-height-expected.txt: Added.
     41        * platform/mac/svg/custom/object-sizing-no-width-height-change-content-box-size-expected.png: Added.
     42        * platform/mac/svg/custom/object-sizing-no-width-height-change-content-box-size-expected.txt: Added.
     43        * platform/mac/svg/custom/object-sizing-no-width-height-expected.png: Added.
     44        * platform/mac/svg/custom/object-sizing-no-width-height-expected.txt: Added.
     45        * platform/mac/svg/hixie/text/003-expected.png:
     46        * platform/mac/svg/hixie/text/003-expected.txt:
     47        * platform/mac/svg/in-html/by-reference-expected.txt:
     48        * platform/mac/svg/wicd: Added.
     49        * platform/mac/svg/wicd/rightsizing-grid-expected.png: Added.
     50        * platform/mac/svg/wicd/rightsizing-grid-expected.txt: Added.
     51        * platform/mac/svg/wicd/test-rightsizing-a-expected.png: Added.
     52        * platform/mac/svg/wicd/test-rightsizing-a-expected.txt: Added.
     53        * platform/mac/svg/wicd/test-rightsizing-b-expected.png: Added.
     54        * platform/mac/svg/wicd/test-rightsizing-b-expected.txt: Added.
     55        * platform/mac/svg/zoom/page/relative-sized-document-scrollbars-expected.txt:
     56        * platform/mac/svg/zoom/page/zoom-foreignObject-expected.png:
     57        * platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt:
     58        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.png: Added.
     59        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.txt: Added.
     60        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.png: Added.
     61        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.txt: Added.
     62        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-huge-size-expected.png: Added.
     63        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-huge-size-expected.txt: Added.
     64        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-no-width-height-expected.png: Added.
     65        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-no-width-height-expected.txt: Added.
     66        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-override-size-expected.png: Added.
     67        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-override-size-expected.txt: Added.
     68        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-percentage-size-expected.png: Added.
     69        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-percentage-size-expected.txt: Added.
     70        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-text-expected.png: Added.
     71        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-text-expected.txt: Added.
     72        * svg/custom/object-no-size-attributes.xhtml: Added.
     73        * svg/custom/object-sizing-explicit-height.xhtml: Added.
     74        * svg/custom/object-sizing-explicit-width-height.xhtml: Added.
     75        * svg/custom/object-sizing-explicit-width.xhtml: Added.
     76        * svg/custom/object-sizing-no-width-height-change-content-box-size.xhtml: Added.
     77        * svg/custom/object-sizing-no-width-height.xhtml: Added.
     78        * svg/custom/object-sizing.xhtml: Added.
     79        * svg/custom/resources/embedded.svg: Added.
     80        * svg/custom/resources/red-circle.svg: Added.
     81        * svg/in-html/by-reference-expected.png:
     82        * svg/wicd: Added.
     83        * svg/wicd/resources: Added.
     84        * svg/wicd/resources/a.svg: Added.
     85        * svg/wicd/resources/bcde.svg: Added.
     86        * svg/wicd/resources/empty1.svg: Added.
     87        * svg/wicd/resources/empty2.svg: Added.
     88        * svg/wicd/resources/empty3.svg: Added.
     89        * svg/wicd/resources/f.svg: Added.
     90        * svg/wicd/resources/g.svg: Added.
     91        * svg/wicd/resources/h.svg: Added.
     92        * svg/wicd/resources/i.svg: Added.
     93        * svg/wicd/resources/j.svg: Added.
     94        * svg/wicd/resources/k.svg: Added.
     95        * svg/wicd/resources/l.svg: Added.
     96        * svg/wicd/resources/main.css: Added.
     97        (body,html):
     98        (body):
     99        (.buttons):
     100        (h1):
     101        (h2):
     102        (h4):
     103        (p):
     104        (table):
     105        (th):
     106        (td,th):
     107        (td a):
     108        (a):
     109        (a:hover):
     110        (a:focus):
     111        (a:visited):
     112        (a.index):
     113        (a.index:hover):
     114        (a.index:focus):
     115        (a.index:visited):
     116        (ul):
     117        (ol):
     118        (.red):
     119        (.navi):
     120        (.navi a):
     121        (.navi a:hover):
     122        (.navi a:visited):
     123        * svg/wicd/resources/mnop.svg: Added.
     124        * svg/wicd/resources/q.svg: Added.
     125        * svg/wicd/resources/r.svg: Added.
     126        * svg/wicd/resources/s.svg: Added.
     127        * svg/wicd/resources/t.svg: Added.
     128        * svg/wicd/resources/test-rightsizing-a.css: Added.
     129        (html,body):
     130        (div.all):
     131        (object.w100):
     132        (object.h100):
     133        * svg/wicd/resources/test-rightsizing-b.css: Added.
     134        (html,body):
     135        (object):
     136        * svg/wicd/resources/test-svg-child-object-rightsizing.gif: Added.
     137        * svg/wicd/resources/test-svg-child-object-rightsizing.png: Added.
     138        * svg/wicd/resources/test-svg-child-object-rightsizing.svg: Added.
     139        * svg/wicd/resources/test-svg-child-object-rightsizing1.svg: Added.
     140        * svg/wicd/rightsizing-grid.xhtml: Added.
     141        * svg/wicd/test-rightsizing-a.xhtml: Added.
     142        * svg/wicd/test-rightsizing-b.xhtml: Added.
     143        * svg/zoom/page/resources: Added.
     144        * svg/zoom/page/resources/absolute-sized-svg.png: Added.
     145        * svg/zoom/page/resources/absolute-sized-svg.svg: Added.
     146        * svg/zoom/page/resources/huge-rect.svg: Added.
     147        * svg/zoom/page/resources/percentage-sized-svg.png: Added.
     148        * svg/zoom/page/resources/percentage-sized-svg.svg: Added.
     149        * svg/zoom/page/resources/text.svg: Added.
     150        * svg/zoom/page/resources/tux.svg: Added.
     151        * svg/zoom/page/zoom-svg-through-object-with-absolute-size-2.xhtml: Added.
     152        * svg/zoom/page/zoom-svg-through-object-with-absolute-size.xhtml: Added.
     153        * svg/zoom/page/zoom-svg-through-object-with-huge-size.xhtml: Added.
     154        * svg/zoom/page/zoom-svg-through-object-with-override-size.html: Added.
     155        * svg/zoom/page/zoom-svg-through-object-with-percentage-size.xhtml: Added.
     156        * svg/zoom/page/zoom-svg-through-object-with-text.xhtml: Added.
     157
    11582011-05-25  Martin Robinson  <mrobinson@igalia.com>
    2159
  • trunk/LayoutTests/platform/mac/svg/hixie/text/003-expected.txt

    r77485 r87526  
    11layer at (0,0) size 800x600
    22  RenderView at (0,0) size 800x600
    3 layer at (0,0) size 800x402
    4   RenderBlock {HTML} at (0,0) size 800x402
    5     RenderBody {BODY} at (8,16) size 784x370
     3layer at (0,0) size 800x416
     4  RenderBlock {HTML} at (0,0) size 800x416
     5    RenderBody {BODY} at (8,16) size 784x384
    66      RenderBlock {P} at (0,0) size 784x18
    77        RenderText {#text} at (0,0) size 608x18
    88          text run at (0,0) width 608: "The following two blocks should look identical (to the pixel), and they should both say \"PASS\":"
    9       RenderBlock {P} at (0,34) size 784x160
    10         RenderEmbeddedObject {OBJECT} at (0,0) size 306x156 [border: (3px inset #000080)]
    11           layer at (0,0) size 300x150
    12             RenderView at (0,0) size 300x150
    13           layer at (0,0) size 300x150
    14             RenderSVGRoot {svg} at (0,0) size 180x150
     9      RenderBlock {P} at (0,34) size 784x167
     10        RenderEmbeddedObject {OBJECT} at (0,0) size 790x163 [border: (3px inset #000080)]
     11          layer at (0,0) size 784x157
     12            RenderView at (0,0) size 784x157
     13          layer at (0,0) size 784x157
     14            RenderSVGRoot {svg} at (0,0) size 471x157
    1515              RenderSVGText {text} at (0,-1) size 3x3 contains 1 chunk(s)
    1616                RenderSVGInlineText {#text} at (0,0) size 3x3
    17                   chunk 1 text run 1 at (0.00,0.80) startOffset 0 endOffset 4 width 2.37: "PASS"
    18       RenderBlock {P} at (0,210) size 784x160
    19         RenderEmbeddedObject {OBJECT} at (0,0) size 306x156 [border: (3px inset #000080)]
    20           layer at (0,0) size 300x150
    21             RenderView at (0,0) size 300x150
    22           layer at (0,0) size 300x150
    23             RenderSVGRoot {svg} at (0,39) size 143x69
    24               RenderSVGText {text} at (0,-100) size 2367x1150 contains 1 chunk(s)
    25                 RenderSVGInlineText {#text} at (0,0) size 2367x1150
    26                   chunk 1 text run 1 at (0.00,800.00) startOffset 0 endOffset 4 width 2366.67: "PASS"
     17                  chunk 1 text run 1 at (0.00,0.80) startOffset 0 endOffset 4 width 2.39: "PASS"
     18      RenderBlock {P} at (0,217) size 784x167
     19        RenderEmbeddedObject {OBJECT} at (0,0) size 790x163 [border: (3px inset #000080)]
     20          layer at (0,0) size 784x157
     21            RenderView at (0,0) size 784x157
     22          layer at (0,0) size 784x157
     23            RenderSVGRoot {svg} at (0,0) size 375x157
     24              RenderSVGText {text} at (0,-105) size 2386x1156 contains 1 chunk(s)
     25                RenderSVGInlineText {#text} at (0,0) size 2386x1156
     26                  chunk 1 text run 1 at (0.00,800.00) startOffset 0 endOffset 4 width 2385.20: "PASS"
  • trunk/LayoutTests/platform/mac/svg/in-html/by-reference-expected.txt

    r68198 r87526  
    2222          layer at (0,0) size 100x100
    2323            RenderView at (0,0) size 100x100
    24           layer at (0,0) size 50x50
     24          layer at (0,0) size 100x100
    2525            RenderSVGRoot {svg} at (0,0) size 0x0
    2626        RenderText {#text} at (208,86) size 4x18
  • trunk/LayoutTests/platform/mac/svg/zoom/page/relative-sized-document-scrollbars-expected.txt

    r69386 r87526  
    1 layer at (0,0) size 1356x1011
     1layer at (0,0) size 1357x1011
    22  RenderView at (0,0) size 785x585
    3 layer at (0,0) size 1356x1011
     3layer at (0,0) size 1357x1011
    44  RenderSVGRoot {svg} at (12,8) size 1333x995
    55    RenderSVGPath {rect} at (12,8) size 1333x995 [stroke={[type=SOLID] [color=#000000]}] [x=7.85] [y=5.85] [width=769.30] [height=573.30]
  • trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt

    r75351 r87526  
    1 layer at (0,0) size 1130x842
     1layer at (0,0) size 1131x843
    22  RenderView at (0,0) size 785x585
    3 layer at (0,0) size 1130x842
    4   RenderSVGRoot {svg} at (12,12) size 1118x830
     3layer at (0,0) size 1131x843
     4  RenderSVGRoot {svg} at (12,12) size 1119x831
    55    RenderSVGForeignObject {foreignObject} at (10,10) size 580x380
    66      RenderBlock {xhtml:div} at (0,0) size 580x18
  • trunk/LayoutTests/svg/in-html/by-reference-expected.png

    • Property svn:mime-type set to image/png
  • trunk/Source/WebCore/ChangeLog

    r87524 r87526  
     12011-05-27  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        Reviewed by Rob Buis.
     4
     5        embedded SVG object doesn't scale right
     6        https://bugs.webkit.org/show_bug.cgi?id=10526
     7
     8        <object> tags should treat width/height on a referenced SVG as intrinsic width/height
     9        https://bugs.webkit.org/show_bug.cgi?id=11976
     10
     11        Incorrect handling of percentage values for width/height on embedded elements
     12        https://bugs.webkit.org/show_bug.cgi?id=14793
     13
     14        WebKit fails some WICD 1.0 core test cases
     15        https://bugs.webkit.org/show_bug.cgi?id=15836 (partially fixed, all 'rightsizing' tests are fixed)
     16
     17        CSS 2.1: Support replaced elements with relative intrinsic sizes
     18        https://bugs.webkit.org/show_bug.cgai?id=15849 (partially fixed)
     19
     20        SVG embedded as <object> doesn't respect width/height attributes
     21        https://bugs.webkit.org/show_bug.cgi?id=34972
     22
     23        Explicit size of object tag ignored
     24        https://bugs.webkit.org/show_bug.cgi?id=37086
     25
     26        Add partial support of CSS 2.1 replaced elements with intrinsic size. The feature itself is complete but has only
     27        been implemented for RenderPart, to support SVG content document size negotiation. It serves as starting point for a generalization, in future.
     28        The changes in RenderPart are a 1:1 transliteration of the spec (http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-width/height, see code).
     29
     30        SVG 1.1 says:
     31        The 'width' attribute on the outermost svg element establishes the viewport's width, unless the following conditions are met:
     32        ...
     33        and there are CSS-compatible positioning properties ([CSS2], section 9.3) specified on the referencing element (e.g., the 'object' element)
     34        or on the containing document's outermost svg element that are sufficient to establish the width of the viewport. Under these conditions,
     35        the positioning properties establish the viewport's width.
     36
     37        If an <object> carries width/height attributes, these specify the viewport size of the embedded SVG, instead of its own
     38        width/height or viewBox properties. If an <object> has no width/height information, its intrinsic size needs to be calculated depending
     39        on the intrinsic ratio (viewBox width divided by height ratio) and the width/height properties on the outermost referenced <svg> element.
     40        This requires a negotiation between the host document and the embedded document.
     41        (There are several more factors that need to be considered, the CSS spec covers this and the RenderPart::computeReplaced* code covers this.)
     42
     43        Fixes dozens of long-standing bug reports. The number one integration issue when using SVG through <object> is resolved: "right sizing".
     44
     45        Tests: http/tests/misc/object-embedding-svg-delayed-size-negotiation.xhtml
     46               svg/custom/object-no-size-attributes.xhtml (bug 11976, from Eric Seidel)
     47               svg/custom/object-sizing-explicit-height.xhtml (bug 10526, from Ryan Cannon)
     48               svg/custom/object-sizing-explicit-width-height.xhtml
     49               svg/custom/object-sizing-explicit-width.xhtml (bug 14793, from Oliver Hunt)
     50               svg/custom/object-sizing-no-width-height-change-content-box-size.xhtml
     51               svg/custom/object-sizing-no-width-height.xhtml
     52               svg/custom/object-sizing.xhtml (bug 37086, from Jeff Schiller)
     53               svg/wicd/rightsizing-grid.xhtml (bug 15836, WICD rightsizing test now works)
     54               svg/wicd/test-rightsizing-a.xhtml (ditto)
     55               svg/wicd/test-rightsizing-b.xhtml (ditto)
     56               svg/zoom/page/zoom-svg-through-object-with-absolute-size-2.xhtml
     57               svg/zoom/page/zoom-svg-through-object-with-absolute-size.xhtml
     58               svg/zoom/page/zoom-svg-through-object-with-huge-size.xhtml
     59               svg/zoom/page/zoom-svg-through-object-with-override-size.html (bug 34972, from Andreas Kling)
     60               svg/zoom/page/zoom-svg-through-object-with-percentage-size.xhtml
     61               svg/zoom/page/zoom-svg-through-object-with-text.xhtml
     62
     63        * platform/Length.h:
     64        (WebCore::Length::isSpecified):
     65        * rendering/RenderPart.cpp:
     66        (WebCore::RenderPart::embeddedSVGContentRenderer):
     67        (WebCore::RenderPart::computeEmbeddedDocumentReplacedWidth):
     68        (WebCore::RenderPart::computeEmbeddedDocumentReplacedHeight):
     69        (WebCore::RenderPart::computeReplacedLogicalWidth):
     70        (WebCore::RenderPart::computeReplacedLogicalHeight):
     71        (WebCore::RenderPart::layout):
     72        * rendering/RenderPart.h:
     73        * rendering/RenderReplaced.cpp:
     74        (WebCore::RenderReplaced::computeReplacedLogicalWidth):
     75        (WebCore::RenderReplaced::computeReplacedLogicalHeight):
     76        * rendering/svg/RenderSVGRoot.cpp:
     77        (WebCore::RenderSVGRoot::RenderSVGRoot):
     78        (WebCore::RenderSVGRoot::computeIntrinsicRatio):
     79        (WebCore::RenderSVGRoot::computeIntrinsicWidth):
     80        (WebCore::RenderSVGRoot::computeIntrinsicHeight):
     81        (WebCore::RenderSVGRoot::negotiateSizeWithHostDocumentIfNeeded):
     82        (WebCore::RenderSVGRoot::computeReplacedLogicalWidth):
     83        (WebCore::RenderSVGRoot::computeReplacedLogicalHeight):
     84        (WebCore::RenderSVGRoot::layout):
     85        * rendering/svg/RenderSVGRoot.h:
     86        * svg/SVGLength.cpp:
     87        (WebCore::SVGLength::determineViewport):
     88        * svg/SVGSVGElement.cpp:
     89        (WebCore::SVGSVGElement::currentScale):
     90        (WebCore::SVGSVGElement::setCurrentScale):
     91        (WebCore::SVGSVGElement::currentViewBoxRect):
     92        (WebCore::SVGSVGElement::viewBoxToViewTransform):
     93        * svg/SVGSVGElement.h:
     94
    1952011-05-27  Michael Saboff  <msaboff@apple.com>
    296
  • trunk/Source/WebCore/platform/Length.h

    r81925 r87526  
    174174    bool isFixed() const { return type() == Fixed; }
    175175    bool isIntrinsicOrAuto() const { return type() == Auto || type() == MinIntrinsic || type() == Intrinsic; }
     176    bool isSpecified() const { return type() == Fixed || type() == Percent; }
    176177
    177178    Length blend(const Length& from, float progress) const
  • trunk/Source/WebCore/rendering/RenderPart.cpp

    r83518 r87526  
    44 *           (C) 2000 Stefan Schimanski (1Stein@gmx.de)
    55 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
     6 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
    67 *
    78 * This library is free software; you can redistribute it and/or
     
    2930#include "HTMLFrameElementBase.h"
    3031#include "PluginViewBase.h"
     32#include "RenderSVGRoot.h"
    3133#include "RenderView.h"
     34
     35using namespace std;
    3236
    3337namespace WebCore {
     
    9195#endif
    9296
    93 }
     97#if ENABLE(SVG)
     98RenderSVGRoot* RenderPart::embeddedSVGContentRenderer() const
     99{
     100    if (!node() || !widget() || !widget()->isFrameView())
     101        return 0;
     102
     103    FrameView* view = static_cast<FrameView*>(widget());
     104    RenderObject* contentRenderer = view->frame() ? view->frame()->contentRenderer() : 0;
     105    if (!contentRenderer)
     106        return 0;
     107
     108    RenderObject* svgRootRenderer = contentRenderer->firstChild();
     109    if (!svgRootRenderer || !svgRootRenderer->isSVGRoot())
     110        return 0;
     111
     112    return toRenderSVGRoot(svgRootRenderer);
     113}
     114
     115int RenderPart::computeEmbeddedDocumentReplacedWidth(bool includeMaxWidth, RenderStyle* contentRenderStyle) const
     116{
     117    int logicalWidth = computeReplacedLogicalWidthUsing(contentRenderStyle->logicalWidth());
     118    int minLogicalWidth = computeReplacedLogicalWidthUsing(contentRenderStyle->logicalMinWidth());
     119    int maxLogicalWidth = !includeMaxWidth || contentRenderStyle->logicalMaxWidth().isUndefined() ? logicalWidth : computeReplacedLogicalWidthUsing(contentRenderStyle->logicalMaxWidth());
     120    int width = max(minLogicalWidth, min(logicalWidth, maxLogicalWidth));
     121    return width;
     122}
     123
     124int RenderPart::computeEmbeddedDocumentReplacedHeight(RenderStyle* contentRenderStyle) const
     125{
     126    int logicalHeight = computeReplacedLogicalHeightUsing(contentRenderStyle->logicalHeight());
     127    int minLogicalHeight = computeReplacedLogicalHeightUsing(contentRenderStyle->logicalMinHeight());
     128    int maxLogicalHeight = contentRenderStyle->logicalMaxHeight().isUndefined() ? logicalHeight : computeReplacedLogicalHeightUsing(contentRenderStyle->logicalMaxHeight());
     129    int height = max(minLogicalHeight, min(logicalHeight, maxLogicalHeight));
     130    return height;
     131}
     132
     133int RenderPart::computeReplacedLogicalWidth(bool includeMaxWidth) const
     134{
     135    RenderSVGRoot* contentRenderer = embeddedSVGContentRenderer();
     136    RenderStyle* contentRenderStyle = contentRenderer ? contentRenderer->style() : 0;
     137
     138    if (!contentRenderer || !contentRenderStyle || style()->width().isSpecified())
     139        return RenderWidget::computeReplacedLogicalWidth(includeMaxWidth);
     140
     141    // 10.3.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-width
     142    if (style()->width().isAuto()) {
     143        bool heightIsAuto = style()->height().isAuto();
     144        bool hasIntrinsicWidth = contentRenderStyle->width().isFixed();
     145
     146        // 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'.
     147        if (heightIsAuto && hasIntrinsicWidth)
     148            return computeEmbeddedDocumentReplacedWidth(includeMaxWidth, contentRenderStyle);
     149   
     150        bool hasIntrinsicHeight = contentRenderStyle->height().isFixed();
     151        FloatSize intrinsicRatio = contentRenderer->computeIntrinsicRatio();
     152        if (!intrinsicRatio.isEmpty()) {
     153            // 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;
     154            // 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
     155            // of 'width' is: (used height) * (intrinsic ratio)
     156            if ((heightIsAuto && !hasIntrinsicWidth && hasIntrinsicHeight) || !heightIsAuto) {
     157                int logicalHeight = computeReplacedLogicalHeightUsing(heightIsAuto ? contentRenderStyle->logicalHeight() : style()->logicalHeight());
     158                return static_cast<int>(ceilf(logicalHeight * intrinsicRatio.width() / intrinsicRatio.height()));
     159            }
     160
     161            // If 'height' and 'width' both have computed values of 'auto' and the element has an intrinsic ratio but no intrinsic height or width, then the used value of
     162            // '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
     163            // the used value of 'width' is calculated from the constraint equation used for block-level, non-replaced elements in normal flow.
     164            // FIXME: Don't ignore padding/margin/border here.
     165            RenderBlock* containingBlock = this->containingBlock();
     166            if (heightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeight && containingBlock)
     167                return containingBlock->width();
     168        }
     169
     170        // 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'.
     171        if (hasIntrinsicWidth)
     172            return computeEmbeddedDocumentReplacedWidth(includeMaxWidth, contentRenderStyle);
     173    }
     174
     175    // 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
     176    // wide to fit the device, UAs should use the width of the largest rectangle that has a 2:1 ratio and fits the device instead.
     177    return intrinsicLogicalWidth();
     178}
     179
     180int RenderPart::computeReplacedLogicalHeight() const
     181{
     182    RenderSVGRoot* contentRenderer = embeddedSVGContentRenderer();
     183    RenderStyle* contentRenderStyle = contentRenderer ? contentRenderer->style() : 0;
     184
     185    if (!contentRenderer || !contentRenderStyle || style()->height().isSpecified())
     186        return RenderWidget::computeReplacedLogicalHeight();
     187
     188    // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-height
     189    if (style()->height().isAuto()) {
     190        bool widthIsAuto = style()->width().isAuto();
     191        bool hasIntrinsicHeight = contentRenderStyle->height().isFixed();
     192
     193        // 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'.
     194        if (widthIsAuto && hasIntrinsicHeight)
     195            return computeEmbeddedDocumentReplacedHeight(contentRenderStyle);
     196   
     197        // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is:
     198        // (used width) / (intrinsic ratio)
     199        FloatSize intrinsicRatio = contentRenderer->computeIntrinsicRatio();
     200        if (!intrinsicRatio.isEmpty()) {
     201            int logicalWidth = computeReplacedLogicalWidthUsing(widthIsAuto ? contentRenderStyle->logicalWidth() : style()->logicalWidth());
     202            return static_cast<int>(ceilf(logicalWidth * intrinsicRatio.height() / intrinsicRatio.width()));
     203        }
     204
     205        // 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'.
     206        if (hasIntrinsicHeight)
     207            return computeEmbeddedDocumentReplacedHeight(contentRenderStyle);
     208    }
     209
     210    // 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
     211    // 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.
     212    return intrinsicLogicalHeight();
     213}
     214
     215void RenderPart::layout()
     216{
     217    ASSERT(needsLayout());
     218
     219    if ((style()->width().isAuto() || style()->height().isAuto()) && embeddedSVGContentRenderer())
     220        setPreferredLogicalWidthsDirty(true);
     221
     222    RenderWidget::layout();
     223}
     224#endif
     225
     226}
  • trunk/Source/WebCore/rendering/RenderPart.h

    r83518 r87526  
    2828namespace WebCore {
    2929
     30class RenderSVGRoot;
     31
    3032// Renderer for frames via RenderFrameBase, and plug-ins via RenderEmbeddedObject.
    3133class RenderPart : public RenderWidget {
     
    4446#if USE(ACCELERATED_COMPOSITING)
    4547    virtual bool requiresLayer() const;
     48#endif
     49
     50#if ENABLE(SVG)
     51    RenderSVGRoot* embeddedSVGContentRenderer() const;
     52    int computeEmbeddedDocumentReplacedWidth(bool includeMaxWidth, RenderStyle* contentRenderStyle) const;
     53    int computeEmbeddedDocumentReplacedHeight(RenderStyle* contentRenderStyle) const;
     54    virtual int computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
     55    virtual int computeReplacedLogicalHeight() const;
     56    virtual void layout();
    4657#endif
    4758
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r86400 r87526  
    192192}
    193193
    194 static inline bool lengthIsSpecified(Length length)
    195 {
    196     LengthType lengthType = length.type();
    197     return lengthType == Fixed || lengthType == Percent;
    198 }
    199 
    200194int RenderReplaced::computeReplacedLogicalWidth(bool includeMaxWidth) const
    201195{
    202196    int logicalWidth;
    203     if (lengthIsSpecified(style()->width()))
     197    // FIXME: Shouldn't this use style()->logicalWidth(), similar to what computeReplacedLogicalHeight() does?
     198    if (style()->width().isSpecified())
    204199        logicalWidth = computeReplacedLogicalWidthUsing(style()->logicalWidth());
    205200    else if (m_hasIntrinsicSize)
     
    217212{
    218213    int logicalHeight;
    219     if (lengthIsSpecified(style()->logicalHeight()))
     214    if (style()->logicalHeight().isSpecified())
    220215        logicalHeight = computeReplacedLogicalHeightUsing(style()->logicalHeight());
    221216    else if (m_hasIntrinsicSize)
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp

    r87277 r87526  
    44 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
    55 * Copyright (C) 2009 Google, Inc.
     6 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
    67 *
    78 * This library is free software; you can redistribute it and/or
     
    2627#include "RenderSVGRoot.h"
    2728
     29#include "Frame.h"
    2830#include "GraphicsContext.h"
    2931#include "HitTestResult.h"
     32#include "RenderPart.h"
    3033#include "RenderSVGContainer.h"
    3134#include "RenderSVGResource.h"
     
    3639#include "SVGSVGElement.h"
    3740#include "SVGStyledElement.h"
     41#include "SVGViewSpec.h"
    3842#include "TransformState.h"
    3943
     
    5054    , m_isLayoutSizeChanged(false)
    5155    , m_needsBoundariesOrTransformUpdate(true)
     56    , m_didNegotiateSize(false)
    5257{
    5358    setReplaced(true);
     
    5661RenderSVGRoot::~RenderSVGRoot()
    5762{
     63}
     64
     65FloatSize RenderSVGRoot::computeIntrinsicRatio() const
     66{
     67    // Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#IntrinsicSizing
     68    // The intrinsic aspect ratio of the viewport of SVG content is necessary for example, when including
     69    // SVG from an ‘object’ element in HTML styled with CSS. It is possible (indeed, common) for an SVG
     70    // graphic to have an intrinsic aspect ratio but not to have an intrinsic width or height.
     71    // The intrinsic aspect ratio must be calculated based upon the following rules:
     72    // The aspect ratio is calculated by dividing a width by a height.
     73
     74    // If the ‘width’ and ‘height’ of the rootmost ‘svg’ element are both specified with unit identifiers
     75    // (in, mm, cm, pt, pc, px, em, ex) or in user units, then the aspect ratio is calculated from the
     76    // ‘width’ and ‘height’ attributes after resolving both values to user units.
     77    if (style()->width().isFixed() && style()->height().isFixed())
     78        return FloatSize(width(), height());
     79
     80    // If either/both of the ‘width’ and ‘height’ of the rootmost ‘svg’ element are in percentage units (or omitted),
     81    // the aspect ratio is calculated from the width and height values of the ‘viewBox’ specified for the current SVG
     82    // document fragment. If the ‘viewBox’ is not correctly specified, or set to 'none', the intrinsic aspect ratio
     83    // cannot be calculated and is considered unspecified.
     84    return static_cast<SVGSVGElement*>(node())->currentViewBoxRect().size();
    5885}
    5986
     
    77104}
    78105
     106int RenderSVGRoot::computeIntrinsicWidth(int replacedWidth) const
     107{
     108    if (!style()->width().isPercent())
     109        return replacedWidth;
     110
     111    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
     112    return static_cast<int>(ceilf(replacedWidth * svg->currentScale()));
     113}
     114
     115int RenderSVGRoot::computeIntrinsicHeight(int replacedHeight) const
     116{
     117    if (!style()->height().isPercent())
     118        return replacedHeight;
     119
     120    const SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
     121    return static_cast<int>(ceilf(replacedHeight * svg->currentScale()));
     122}
     123
     124void RenderSVGRoot::negotiateSizeWithHostDocumentIfNeeded()
     125{
     126    if (m_didNegotiateSize)
     127        return;
     128
     129    Frame* frame = node() && node()->document() ? node()->document()->frame() : 0;
     130    if (!frame)
     131        return;
     132
     133    // If our frame has an owner renderer, we're embedded through eg. object/embed.
     134    // If we're embedded in a host document, we may be loaded after the host document
     135    // has finished layout. If the <object> doesn't specifiy width/height attributes
     136    // it has defaulted to 300x150 intrinsic size. If the SVG document has been loaded
     137    // we notify the RenderPart about the potential size changes, now it can properly
     138    // synchronize the intrinsic width/height/ratio, as defined in the SVG spec.
     139    if (RenderPart* ownerRenderer = frame->ownerRenderer()) {
     140        ownerRenderer->setNeedsLayoutAndPrefWidthsRecalc();
     141        m_didNegotiateSize = true;
     142    }
     143}
     144
    79145int RenderSVGRoot::computeReplacedLogicalWidth(bool includeMaxWidth) const
    80146{
    81147    int replacedWidth = RenderBox::computeReplacedLogicalWidth(includeMaxWidth);
    82     if (!style()->logicalWidth().isPercent())
    83         return replacedWidth;
    84 
    85     // FIXME: Investigate in size rounding issues
    86     SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
    87     return static_cast<int>(roundf(replacedWidth * svg->currentScale()));
     148    Frame* frame = node() && node()->document() ? node()->document()->frame() : 0;
     149    if (!frame)
     150        return computeIntrinsicWidth(replacedWidth);
     151
     152    // If our frame has an owner renderer, we're embedded through eg. object/embed.
     153    RenderPart* ownerRenderer = frame->ownerRenderer();
     154    if (!ownerRenderer)
     155        return computeIntrinsicWidth(replacedWidth);
     156
     157    RenderStyle* ownerRendererStyle = ownerRenderer->style();
     158    ASSERT(ownerRendererStyle);
     159    ASSERT(frame->contentRenderer());
     160
     161    Length ownerWidth = ownerRendererStyle->width();
     162    if (ownerWidth.isAuto())
     163        return computeIntrinsicWidth(replacedWidth);
     164
     165    // Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#ViewportSpace
     166    // The SVG user agent negotiates with its parent user agent to determine the viewport into which the SVG user agent can render
     167    // the document. In some circumstances, SVG content will be embedded (by reference or inline) within a containing document.
     168    // This containing document might include attributes, properties and/or other parameters (explicit or implicit) which specify
     169    // or provide hints about the dimensions of the viewport for the SVG content. SVG content itself optionally can provide
     170    // information about the appropriate viewport region for the content via the ‘width’ and ‘height’ XML attributes on the
     171    // outermost svg element. The negotiation process uses any information provided by the containing document and the SVG
     172    // content itself to choose the viewport location and size.
     173
     174    // The ‘width’ attribute on the outermost svg element establishes the viewport's width, unless the following conditions are met:
     175    // * the SVG content is a separately stored resource that is embedded by reference (such as the ‘object’ element in XHTML [XHTML]),
     176    //   or the SVG content is embedded inline within a containing document;
     177    // * and the referencing element or containing document is styled using CSS [CSS2] or XSL [XSL];
     178    // * and there are CSS-compatible positioning properties ([CSS2], section 9.3) specified on the referencing element
     179    //   (e.g., the ‘object’ element) or on the containing document's outermost svg element that are sufficient to establish
     180    //   the width of the viewport.
     181    //
     182    // Under these conditions, the positioning properties establish the viewport's width.
     183    int logicalWidth = ownerRenderer->computeReplacedLogicalWidthUsing(ownerWidth);
     184    int minLogicalWidth = ownerRenderer->computeReplacedLogicalWidthUsing(ownerRendererStyle->logicalMinWidth());
     185    int maxLogicalWidth = !includeMaxWidth || ownerRendererStyle->logicalMaxWidth().isUndefined() ? logicalWidth : ownerRenderer->computeReplacedLogicalWidthUsing(ownerRendererStyle->logicalMaxWidth());
     186    return max(minLogicalWidth, min(logicalWidth, maxLogicalWidth));
    88187}
    89188
     
    91190{
    92191    int replacedHeight = RenderBox::computeReplacedLogicalHeight();
    93     if (!style()->logicalHeight().isPercent())
    94         return replacedHeight;
    95 
    96     // FIXME: Investigate in size rounding issues
    97     SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
    98     return static_cast<int>(roundf(replacedHeight * svg->currentScale()));
     192
     193    Frame* frame = node() && node()->document() ? node()->document()->frame() : 0;
     194    if (!frame)
     195        return computeIntrinsicHeight(replacedHeight);
     196
     197    // If our frame has an owner renderer, we're embedded through eg. object/embed.
     198    RenderPart* ownerRenderer = frame->ownerRenderer();
     199    if (!ownerRenderer)
     200        return computeIntrinsicHeight(replacedHeight);
     201
     202    RenderStyle* ownerRendererStyle = ownerRenderer->style();
     203    ASSERT(ownerRendererStyle);
     204    ASSERT(frame->contentRenderer());
     205
     206    Length ownerHeight = ownerRendererStyle->height();
     207    if (ownerHeight.isAuto())
     208        return computeIntrinsicHeight(replacedHeight);
     209
     210    // Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#ViewportSpace
     211    // See comment in RenderSVGRoot::computeReplacedLogicalWidth().
     212    // Similarly, if there are positioning properties specified on the referencing element or on the outermost svg element that
     213    // are sufficient to establish the height of the viewport, then these positioning properties establish the viewport's height;
     214    // otherwise, the ‘height’ attribute on the outermost svg element establishes the viewport's height.
     215    int logicalHeight = ownerRenderer->computeReplacedLogicalHeightUsing(ownerHeight);
     216    int minLogicalHeight = ownerRenderer->computeReplacedLogicalHeightUsing(ownerRendererStyle->logicalMinHeight());
     217    int maxLogicalHeight = ownerRendererStyle->logicalMaxHeight().isUndefined() ? logicalHeight : ownerRenderer->computeReplacedLogicalHeightUsing(ownerRendererStyle->logicalMaxHeight());
     218    return max(minLogicalHeight, min(logicalHeight, maxLogicalHeight));
    99219}
    100220
     
    110230
    111231    IntSize oldSize(width(), height());
     232    negotiateSizeWithHostDocumentIfNeeded();
    112233    computeLogicalWidth();
    113234    computeLogicalHeight();
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h

    r86705 r87526  
    4040    virtual ~RenderSVGRoot();
    4141
     42    FloatSize computeIntrinsicRatio() const;
    4243    const RenderObjectChildList* children() const { return &m_children; }
    4344    RenderObjectChildList* children() { return &m_children; }
     
    4849
    4950private:
     51    int computeIntrinsicWidth(int replacedWidth) const;
     52    int computeIntrinsicHeight(int replacedHeight) const;
     53    void negotiateSizeWithHostDocumentIfNeeded();
     54
    5055    virtual RenderObjectChildList* virtualChildren() { return children(); }
    5156    virtual const RenderObjectChildList* virtualChildren() const { return children(); }
     
    99104    bool m_isLayoutSizeChanged : 1;
    100105    bool m_needsBoundariesOrTransformUpdate : 1;
     106    bool m_didNegotiateSize : 1;
    101107};
    102108
  • trunk/Source/WebCore/svg/SVGLength.cpp

    r86542 r87526  
    2727#include "CSSHelper.h"
    2828#include "FloatConversion.h"
     29#include "Frame.h"
    2930#include "FrameView.h"
    3031#include "RenderObject.h"
     32#include "RenderPart.h"
    3133#include "RenderView.h"
    3234#include "SVGNames.h"
     
    318320    Document* document = context->document();
    319321    if (document->documentElement() == context) {
    320         if (RenderView* view = toRenderView(document->renderer())) {
    321             width = view->viewWidth();
    322             height = view->viewHeight();
    323             return true;
     322        if (context->isSVG()) {
     323            Frame* frame = context->document() ? context->document()->frame() : 0;
     324            if (RenderPart* ownerRenderer = frame->ownerRenderer()) {
     325                width = ownerRenderer->width();
     326                height = ownerRenderer->height();
     327                return true;
     328            }
    324329        }
    325330
    326         return false;
    327     }
    328 
    329     // Resolve value against nearest viewport element (common case: inner <svg> elements)
     331        RenderView* view = toRenderView(document->renderer());
     332        if (!view)
     333            return false;
     334
     335        width = view->viewWidth();
     336        height = view->viewHeight();
     337        return true;
     338    }
     339
     340    // Take size from nearest viewport element (common case: inner <svg> elements)
    330341    SVGElement* viewportElement = context->viewportElement();
    331342    if (viewportElement && viewportElement->isSVG()) {
     
    342353    }
    343354   
    344     // Resolve value against enclosing non-SVG RenderBox
     355    // Take size from enclosing non-SVG RenderBox (common case: inline SVG)
    345356    if (!context->parentNode() || context->parentNode()->isSVGElement())
    346357        return false;
  • trunk/Source/WebCore/svg/SVGSVGElement.cpp

    r87010 r87526  
    3535#include "FloatRect.h"
    3636#include "Frame.h"
     37#include "FrameTree.h"
    3738#include "FrameSelection.h"
    3839#include "FrameView.h"
     
    199200float SVGSVGElement::currentScale() const
    200201{
    201     // Only the page zoom factor is relevant for SVG
    202     if (Frame* frame = document()->frame())
    203         return frame->pageZoomFactor();
    204     return m_scale;
     202    if (!inDocument())
     203        return 1;
     204
     205    Frame* frame = document()->frame();
     206    if (!frame)
     207        return 1;
     208
     209    FrameTree* frameTree = frame->tree();
     210    ASSERT(frameTree);
     211
     212    // If we have a parent frame, only return the user-specified m_scale here.
     213    if (frameTree->parent())
     214        return m_scale;
     215
     216    return frame->pageZoomFactor();
    205217}
    206218
    207219void SVGSVGElement::setCurrentScale(float scale)
    208220{
    209     if (Frame* frame = document()->frame()) {
    210         // Calling setCurrentScale() on the outermost <svg> element in a standalone SVG document
    211         // is allowed to change the page zoom factor, influencing the document size, scrollbars etc.
    212         if (parentNode() == document())
    213             frame->setPageZoomFactor(scale);
     221    if (!inDocument())
    214222        return;
     223
     224    Frame* frame = document()->frame();
     225    if (!frame)
     226        return;
     227
     228    FrameTree* frameTree = frame->tree();
     229    ASSERT(frameTree);
     230
     231    bool hasFrameParent = frameTree->parent();
     232
     233    // Calling setCurrentScale() on the outermost <svg> element in a standalone SVG document
     234    // is allowed to change the page zoom factor, influencing the document size, scrollbars etc.
     235    if (!hasFrameParent && isOutermostSVG()) {
     236        frame->setPageZoomFactor(scale);
     237        m_scale = 1;
     238        return;
    215239    }
    216240
    217241    m_scale = scale;
     242
    218243    if (RenderObject* object = renderer())
    219244        RenderSVGResource::markForLayoutAndParentResourceInvalidation(object);
     
    587612}
    588613
     614FloatRect SVGSVGElement::currentViewBoxRect() const
     615{
     616    if (useCurrentView()) {
     617        if (SVGViewSpec* view = currentView()) // what if we should use it but it is not set?
     618            return view->viewBox();
     619        return FloatRect();
     620    }
     621
     622    return viewBox();
     623}
     624
    589625AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float viewHeight) const
    590626{
    591     FloatRect viewBoxRect;
    592     if (useCurrentView()) {
    593         if (currentView()) // what if we should use it but it is not set?
    594             viewBoxRect = currentView()->viewBox();
    595     } else
    596         viewBoxRect = viewBox();
    597 
    598     AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(viewBoxRect, preserveAspectRatio(), viewWidth, viewHeight);
    599 
     627    AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(currentViewBoxRect(), preserveAspectRatio(), viewWidth, viewHeight);
    600628    if (useCurrentView() && currentView()) {
    601629        AffineTransform transform;
  • trunk/Source/WebCore/svg/SVGSVGElement.h

    r87125 r87526  
    7878
    7979    SVGViewSpec* currentView() const;
     80    FloatRect currentViewBoxRect() const;
    8081
    8182    float currentScale() const;
Note: See TracChangeset for help on using the changeset viewer.