Changeset 169522 in webkit


Ignore:
Timestamp:
Jun 1, 2014 10:01:12 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

getBBox() returns (0,0) when width or height is zero.
https://bugs.webkit.org/show_bug.cgi?id=93290

Patch by Nikos Andronikos <nikos.andronikos-webkit@cisra.canon.com.au> on 2014-06-01
Reviewed by Philip Rogers.

Source/WebCore:

The SVG spec states that a width or height of zero for rects, circles and
ellipses is valid but disables rendering of that shape.
In this case, getBBox() should return the actual bounding box of the element.
Previously, WebKit always returned (0,0,0,0) rather than the
correct bounding box. This patch fixes that.

Rects and ellipses both now follow the same behaviour where
the fall-back code path is only used when the shape will render (e.g. not
when a dimension <= 0).

This necessitates calling calculateRadiiAndCenter for ellipses even
when the calculated values will be discarded in the fall back code path.
But calculateRadiiAndCenter is cheap and this avoids making changes
elsewhere to stop CG drawing a zero width (or height) ellipse.

Tests: svg/custom/getBBox-js-circle-zerodimension.html

svg/custom/getBBox-js-ellipse-zerodimension.html
svg/custom/getBBox-js-rect-zerodimension.html

  • rendering/svg/RenderSVGEllipse.cpp:

(WebCore::RenderSVGEllipse::updateShapeFromElement):
Only follow fall-back code path when shape renders.

width
height==0 is not an error case so calculate bounding box.
  • rendering/svg/RenderSVGRect.cpp:

(WebCore::RenderSVGRect::updateShapeFromElement):
Only follow fall-back code path when shape renders.

rx
ry==0 is not an error case so calculate bounding box.

LayoutTests:

  • platform/mac/svg/W3C-SVG-1.1/shapes-circle-02-t-expected.txt:
  • platform/mac/svg/W3C-SVG-1.1/shapes-ellipse-02-t-expected.txt:
  • platform/mac/svg/W3C-SVG-1.1/shapes-intro-01-t-expected.txt:
  • platform/mac/svg/W3C-SVG-1.1/shapes-rect-02-t-expected.txt:
  • svg/W3C-SVG-1.1/animate-elem-32-t-expected.txt:
  • svg/W3C-SVG-1.1/shapes-circle-02-t-expected.txt:
  • svg/W3C-SVG-1.1/shapes-ellipse-02-t-expected.txt:
  • svg/W3C-SVG-1.1/shapes-intro-01-t-expected.txt:
  • svg/W3C-SVG-1.1/shapes-rect-02-t-expected.txt:
  • svg/custom/getBBox-js-circle-zerodimension-expected.txt: Added.
  • svg/custom/getBBox-js-circle-zerodimension.html: Added.
  • svg/custom/getBBox-js-ellipse-zerodimension-expected.txt: Added.
  • svg/custom/getBBox-js-ellipse-zerodimension.html: Added.
  • svg/custom/getBBox-js-rect-zerodimension-expected.txt: Added.
  • svg/custom/getBBox-js-rect-zerodimension.html: Added.
Location:
trunk
Files:
6 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r169521 r169522  
     12014-06-01  Nikos Andronikos  <nikos.andronikos-webkit@cisra.canon.com.au>
     2
     3        getBBox() returns (0,0) when width or height is zero.
     4        https://bugs.webkit.org/show_bug.cgi?id=93290
     5
     6        Reviewed by Philip Rogers.
     7 
     8        * platform/mac/svg/W3C-SVG-1.1/shapes-circle-02-t-expected.txt:
     9        * platform/mac/svg/W3C-SVG-1.1/shapes-ellipse-02-t-expected.txt:
     10        * platform/mac/svg/W3C-SVG-1.1/shapes-intro-01-t-expected.txt:
     11        * platform/mac/svg/W3C-SVG-1.1/shapes-rect-02-t-expected.txt:
     12        * svg/W3C-SVG-1.1/animate-elem-32-t-expected.txt:
     13        * svg/W3C-SVG-1.1/shapes-circle-02-t-expected.txt:
     14        * svg/W3C-SVG-1.1/shapes-ellipse-02-t-expected.txt:
     15        * svg/W3C-SVG-1.1/shapes-intro-01-t-expected.txt:
     16        * svg/W3C-SVG-1.1/shapes-rect-02-t-expected.txt:
     17        * svg/custom/getBBox-js-circle-zerodimension-expected.txt: Added.
     18        * svg/custom/getBBox-js-circle-zerodimension.html: Added.
     19        * svg/custom/getBBox-js-ellipse-zerodimension-expected.txt: Added.
     20        * svg/custom/getBBox-js-ellipse-zerodimension.html: Added.
     21        * svg/custom/getBBox-js-rect-zerodimension-expected.txt: Added.
     22        * svg/custom/getBBox-js-rect-zerodimension.html: Added.
     23
    1242014-06-01  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    225
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/animate-elem-32-t-expected.txt

    r161884 r169522  
    4141        RenderSVGRect {rect} at (393,154) size 37x62 [stroke={[type=SOLID] [color=#000000]}] [x=394.00] [y=155.00] [width=35.00] [height=60.00]
    4242        RenderSVGRect {rect} at (209,259) size 62x12 [stroke={[type=SOLID] [color=#000000]}] [x=210.00] [y=260.00] [width=60.00] [height=10.00]
    43       RenderSVGRect {rect} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#00FF00]}] [x=55.00] [y=55.00] [width=0.00] [height=50.00]
    44       RenderSVGRect {rect} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#00FF00]}] [x=135.00] [y=55.00] [width=25.00] [height=0.00]
     43      RenderSVGRect {rect} at (54,54) size 2x52 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#00FF00]}] [x=55.00] [y=55.00] [width=0.00] [height=50.00]
     44      RenderSVGRect {rect} at (134,54) size 27x2 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#00FF00]}] [x=135.00] [y=55.00] [width=25.00] [height=0.00]
    4545      RenderSVGRect {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [x=55.00] [y=160.00] [width=0.00] [height=50.00]
    4646      RenderSVGRect {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [x=135.00] [y=160.00] [width=25.00] [height=0.00]
    47       RenderSVGEllipse {circle} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=240.00] [cy=80.00] [r=0.00]
     47      RenderSVGEllipse {circle} at (239,79) size 2x2 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=240.00] [cy=80.00] [r=0.00]
    4848      RenderSVGEllipse {circle} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [cx=240.00] [cy=185.00] [r=0.00]
    49       RenderSVGEllipse {ellipse} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=332.00] [cy=80.00] [rx=0.00] [ry=25.00]
     49      RenderSVGEllipse {ellipse} at (331,54) size 2x52 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=332.00] [cy=80.00] [rx=0.00] [ry=25.00]
    5050      RenderSVGEllipse {ellipse} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [cx=332.00] [cy=185.00] [rx=0.00] [ry=25.00]
    51       RenderSVGEllipse {ellipse} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=411.00] [cy=80.00] [rx=12.00] [ry=0.00]
     51      RenderSVGEllipse {ellipse} at (398,79) size 26x2 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=411.00] [cy=80.00] [rx=12.00] [ry=0.00]
    5252      RenderSVGEllipse {ellipse} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [cx=411.00] [cy=185.00] [rx=12.00] [ry=0.00]
    5353      RenderSVGPath {line} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#000000]}] [x1=240.00] [y1=265.00] [x2=240.00] [y2=265.00]
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/shapes-circle-02-t-expected.txt

    r112667 r169522  
    77      RenderSVGEllipse {circle} at (0,49) size 51x102 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=0.00] [cy=100.00] [r=50.00]
    88      RenderSVGEllipse {circle} at (49,0) size 102x51 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=100.00] [cy=0.00] [r=50.00]
    9       RenderSVGEllipse {circle} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=100.00] [cy=100.00] [r=0.00]
     9      RenderSVGEllipse {circle} at (99,99) size 2x2 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=100.00] [cy=100.00] [r=0.00]
    1010      RenderSVGEllipse {circle} at (49,49) size 102x102 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=100.00] [cy=100.00] [r=50.00]
    1111    RenderSVGText {text} at (10,304) size 264x46 contains 1 chunk(s)
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/shapes-ellipse-02-t-expected.txt

    r112667 r169522  
    55    RenderSVGContainer {g} at (0,0) size 351x301
    66      RenderSVGEllipse {ellipse} at (0,0) size 101x51 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=0.00] [cy=0.00] [rx=100.00] [ry=50.00]
    7       RenderSVGEllipse {ellipse} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=100.00] [cy=150.00] [rx=0.00] [ry=50.00]
    8       RenderSVGEllipse {ellipse} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=200.00] [cy=50.00] [rx=100.00] [ry=0.00]
     7      RenderSVGEllipse {ellipse} at (99,99) size 2x102 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=100.00] [cy=150.00] [rx=0.00] [ry=50.00]
     8      RenderSVGEllipse {ellipse} at (99,49) size 202x2 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=200.00] [cy=50.00] [rx=100.00] [ry=0.00]
    99      RenderSVGEllipse {ellipse} at (149,199) size 202x102 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=250.00] [cy=250.00] [rx=100.00] [ry=50.00]
    1010    RenderSVGText {text} at (10,304) size 264x46 contains 1 chunk(s)
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/shapes-intro-01-t-expected.txt

    r161884 r169522  
    4141          RenderSVGInlineText {#text} at (0,0) size 52x9
    4242            chunk 1 text run 1 at (235.00,290.00) startOffset 0 endOffset 16 width 52.00: "Zero length line"
    43       RenderSVGRect {rect} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [x=55.00] [y=55.00] [width=0.00] [height=50.00]
     43      RenderSVGRect {rect} at (54,54) size 2x52 [stroke={[type=SOLID] [color=#000000]}] [x=55.00] [y=55.00] [width=0.00] [height=50.00]
    4444      RenderSVGRect {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [x=55.00] [y=160.00] [width=0.00] [height=50.00]
    45       RenderSVGRect {rect} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [x=135.00] [y=55.00] [width=25.00] [height=0.00]
     45      RenderSVGRect {rect} at (134,54) size 27x2 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [x=135.00] [y=55.00] [width=25.00] [height=0.00]
    4646      RenderSVGRect {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#00FF00]}] [x=135.00] [y=160.00] [width=25.00] [height=0.00]
    47       RenderSVGEllipse {circle} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [cx=240.00] [cy=80.00] [r=0.00]
     47      RenderSVGEllipse {circle} at (239,79) size 2x2 [stroke={[type=SOLID] [color=#000000]}] [cx=240.00] [cy=80.00] [r=0.00]
    4848      RenderSVGEllipse {circle} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [cx=240.00] [cy=185.00] [r=0.00]
    49       RenderSVGEllipse {ellipse} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=332.00] [cy=80.00] [rx=0.00] [ry=25.00]
     49      RenderSVGEllipse {ellipse} at (331,54) size 2x52 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=332.00] [cy=80.00] [rx=0.00] [ry=25.00]
    5050      RenderSVGEllipse {ellipse} at (0,0) size 0x0 [fill={[type=SOLID] [color=#00FF00]}] [cx=332.00] [cy=185.00] [rx=0.00] [ry=25.00]
    51       RenderSVGEllipse {ellipse} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [cx=411.00] [cy=80.00] [rx=12.00] [ry=0.00]
     51      RenderSVGEllipse {ellipse} at (398,79) size 26x2 [stroke={[type=SOLID] [color=#000000]}] [cx=411.00] [cy=80.00] [rx=12.00] [ry=0.00]
    5252      RenderSVGEllipse {ellipse} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [cx=411.00] [cy=185.00] [rx=12.00] [ry=0.00]
    5353      RenderSVGPath {line} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#000000]}] [x1=240.00] [y1=265.00] [x2=240.00] [y2=265.00]
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/shapes-rect-02-t-expected.txt

    r103407 r169522  
    33layer at (0,0) size 480x360
    44  RenderSVGRoot {svg} at (0,0) size 480x360
    5     RenderSVGContainer {g} at (0,0) size 181x277
     5    RenderSVGContainer {g} at (0,0) size 401x277
    66      RenderSVGRect {rect} at (0,45) size 51x82 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=46.00] [width=50.00] [height=80.00]
    77      RenderSVGRect {rect} at (129,0) size 52x81 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=130.00] [y=0.00] [width=50.00] [height=80.00]
    8       RenderSVGRect {rect} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=250.00] [y=46.00] [width=0.00] [height=80.00]
    9       RenderSVGRect {rect} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=350.00] [y=46.00] [width=50.00] [height=0.00]
     8      RenderSVGRect {rect} at (249,45) size 2x82 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=250.00] [y=46.00] [width=0.00] [height=80.00]
     9      RenderSVGRect {rect} at (349,45) size 52x2 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=350.00] [y=46.00] [width=50.00] [height=0.00]
    1010      RenderSVGRect {rect} at (29,195) size 52x82 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=30.00] [y=196.00] [width=50.00] [height=80.00]
    1111      RenderSVGRect {rect} at (129,195) size 52x82 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=130.00] [y=196.00] [width=50.00] [height=80.00]
  • trunk/LayoutTests/svg/W3C-SVG-1.1/animate-elem-32-t-expected.txt

    r158818 r169522  
    44  RenderSVGRoot {svg} at (0,0) size 480x360
    55    RenderSVGContainer {g} at (5,49) size 458x243
    6       RenderSVGContainer {g} at (5,83) size 458x209
    7         RenderSVGText {text} at (5,83) size 26x9 contains 1 chunk(s)
     6      RenderSVGContainer {g} at (5,82) size 458x210
     7        RenderSVGText {text} at (5,82) size 26x10 contains 1 chunk(s)
    88          RenderSVGInlineText {#text} at (0,0) size 26x9
    99            chunk 1 text run 1 at (5.00,90.00) startOffset 0 endOffset 7 width 26.00: "Stroked"
    10         RenderSVGText {text} at (5,188) size 35x9 contains 1 chunk(s)
     10        RenderSVGText {text} at (5,187) size 35x10 contains 1 chunk(s)
    1111          RenderSVGInlineText {#text} at (0,0) size 35x9
    1212            chunk 1 text run 1 at (5.00,195.00) startOffset 0 endOffset 9 width 35.00: "Unstroked"
    13         RenderSVGText {text} at (50,128) size 51x9 contains 1 chunk(s)
     13        RenderSVGText {text} at (50,127) size 51x10 contains 1 chunk(s)
    1414          RenderSVGInlineText {#text} at (0,0) size 51x9
    1515            chunk 1 text run 1 at (50.00,135.00) startOffset 0 endOffset 15 width 51.00: "Zero width rect"
    16         RenderSVGText {text} at (130,128) size 53x9 contains 1 chunk(s)
     16        RenderSVGText {text} at (130,127) size 53x10 contains 1 chunk(s)
    1717          RenderSVGInlineText {#text} at (0,0) size 53x9
    1818            chunk 1 text run 1 at (130.00,135.00) startOffset 0 endOffset 16 width 53.00: "Zero height rect"
    19         RenderSVGText {text} at (210,128) size 60x9 contains 1 chunk(s)
     19        RenderSVGText {text} at (210,127) size 60x10 contains 1 chunk(s)
    2020          RenderSVGInlineText {#text} at (0,0) size 60x9
    2121            chunk 1 text run 1 at (210.00,135.00) startOffset 0 endOffset 18 width 60.00: "Zero radius circle"
    22         RenderSVGText {text} at (315,128) size 69x9 contains 1 chunk(s)
     22        RenderSVGText {text} at (315,127) size 69x10 contains 1 chunk(s)
    2323          RenderSVGInlineText {#text} at (0,0) size 69x9
    2424            chunk 1 text run 1 at (315.00,135.00) startOffset 0 endOffset 21 width 69.00: "Zero x radius ellipse"
    25         RenderSVGText {text} at (394,128) size 69x9 contains 1 chunk(s)
     25        RenderSVGText {text} at (394,127) size 69x10 contains 1 chunk(s)
    2626          RenderSVGInlineText {#text} at (0,0) size 69x9
    2727            chunk 1 text run 1 at (394.00,135.00) startOffset 0 endOffset 21 width 69.00: "Zero y radius ellipse"
    28         RenderSVGText {text} at (210,283) size 52x9 contains 1 chunk(s)
     28        RenderSVGText {text} at (210,282) size 52x10 contains 1 chunk(s)
    2929          RenderSVGInlineText {#text} at (0,0) size 52x9
    3030            chunk 1 text run 1 at (210.00,290.00) startOffset 0 endOffset 16 width 52.00: "Zero length line"
     
    4141        RenderSVGRect {rect} at (393,154) size 37x62 [stroke={[type=SOLID] [color=#000000]}] [x=394.00] [y=155.00] [width=35.00] [height=60.00]
    4242        RenderSVGRect {rect} at (209,259) size 62x12 [stroke={[type=SOLID] [color=#000000]}] [x=210.00] [y=260.00] [width=60.00] [height=10.00]
    43       RenderSVGRect {rect} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#00FF00]}] [x=55.00] [y=55.00] [width=0.00] [height=50.00]
    44       RenderSVGRect {rect} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#00FF00]}] [x=135.00] [y=55.00] [width=25.00] [height=0.00]
     43      RenderSVGRect {rect} at (54,54) size 2x52 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#00FF00]}] [x=55.00] [y=55.00] [width=0.00] [height=50.00]
     44      RenderSVGRect {rect} at (134,54) size 27x2 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#00FF00]}] [x=135.00] [y=55.00] [width=25.00] [height=0.00]
    4545      RenderSVGRect {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [x=55.00] [y=160.00] [width=0.00] [height=50.00]
    4646      RenderSVGRect {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [x=135.00] [y=160.00] [width=25.00] [height=0.00]
    47       RenderSVGEllipse {circle} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=240.00] [cy=80.00] [r=0.00]
     47      RenderSVGEllipse {circle} at (239,79) size 2x2 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=240.00] [cy=80.00] [r=0.00]
    4848      RenderSVGEllipse {circle} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [cx=240.00] [cy=185.00] [r=0.00]
    49       RenderSVGEllipse {ellipse} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=332.00] [cy=80.00] [rx=0.00] [ry=25.00]
     49      RenderSVGEllipse {ellipse} at (331,54) size 2x52 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=332.00] [cy=80.00] [rx=0.00] [ry=25.00]
    5050      RenderSVGEllipse {ellipse} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [cx=332.00] [cy=185.00] [rx=0.00] [ry=25.00]
    51       RenderSVGEllipse {ellipse} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=411.00] [cy=80.00] [rx=12.00] [ry=0.00]
     51      RenderSVGEllipse {ellipse} at (398,79) size 26x2 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=411.00] [cy=80.00] [rx=12.00] [ry=0.00]
    5252      RenderSVGEllipse {ellipse} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [cx=411.00] [cy=185.00] [rx=12.00] [ry=0.00]
    5353      RenderSVGPath {line} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#000000]}] [x1=240.00] [y1=265.00] [x2=240.00] [y2=265.00]
    54     RenderSVGText {text} at (10,304) size 284x45 contains 1 chunk(s)
    55       RenderSVGInlineText {#text} at (0,0) size 284x45
     54    RenderSVGText {text} at (10,304) size 284x46 contains 1 chunk(s)
     55      RenderSVGInlineText {#text} at (0,0) size 284x46
    5656        chunk 1 text run 1 at (10.00,340.00) startOffset 0 endOffset 17 width 284.00: "$Revision: 1.16 $"
    5757    RenderSVGRect {rect} at (0,0) size 480x360 [stroke={[type=SOLID] [color=#000000]}] [x=1.00] [y=1.00] [width=478.00] [height=358.00]
  • trunk/LayoutTests/svg/W3C-SVG-1.1/shapes-circle-02-t-expected.txt

    r158818 r169522  
    77      RenderSVGEllipse {circle} at (0,49) size 51x102 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=0.00] [cy=100.00] [r=50.00]
    88      RenderSVGEllipse {circle} at (49,0) size 102x51 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=100.00] [cy=0.00] [r=50.00]
    9       RenderSVGEllipse {circle} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=100.00] [cy=100.00] [r=0.00]
     9      RenderSVGEllipse {circle} at (99,99) size 2x2 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=100.00] [cy=100.00] [r=0.00]
    1010      RenderSVGEllipse {circle} at (49,49) size 102x102 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=100.00] [cy=100.00] [r=50.00]
    11     RenderSVGText {text} at (10,304) size 264x45 contains 1 chunk(s)
    12       RenderSVGInlineText {#text} at (0,0) size 264x45
     11    RenderSVGText {text} at (10,304) size 264x46 contains 1 chunk(s)
     12      RenderSVGInlineText {#text} at (0,0) size 264x46
    1313        chunk 1 text run 1 at (10.00,340.00) startOffset 0 endOffset 16 width 264.00: "$Revision: 1.3 $"
    1414    RenderSVGRect {rect} at (0,0) size 480x360 [stroke={[type=SOLID] [color=#000000]}] [x=1.00] [y=1.00] [width=478.00] [height=358.00]
  • trunk/LayoutTests/svg/W3C-SVG-1.1/shapes-ellipse-02-t-expected.txt

    r158818 r169522  
    55    RenderSVGContainer {g} at (0,0) size 351x301
    66      RenderSVGEllipse {ellipse} at (0,0) size 101x51 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=0.00] [cy=0.00] [rx=100.00] [ry=50.00]
    7       RenderSVGEllipse {ellipse} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=100.00] [cy=150.00] [rx=0.00] [ry=50.00]
    8       RenderSVGEllipse {ellipse} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=200.00] [cy=50.00] [rx=100.00] [ry=0.00]
     7      RenderSVGEllipse {ellipse} at (0,0) size 2x102 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=100.00] [cy=150.00] [rx=0.00] [ry=50.00]
     8      RenderSVGEllipse {ellipse} at (0,0) size 202x2 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=200.00] [cy=50.00] [rx=100.00] [ry=0.00]
    99      RenderSVGEllipse {ellipse} at (149,199) size 202x102 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=250.00] [cy=250.00] [rx=100.00] [ry=50.00]
    1010    RenderSVGText {text} at (10,304) size 264x45 contains 1 chunk(s)
  • trunk/LayoutTests/svg/W3C-SVG-1.1/shapes-intro-01-t-expected.txt

    r158818 r169522  
    1616        RenderSVGRect {rect} at (393,154) size 37x62 [stroke={[type=SOLID] [color=#000000]}] [x=394.00] [y=155.00] [width=35.00] [height=60.00]
    1717        RenderSVGRect {rect} at (234,259) size 12x12 [stroke={[type=SOLID] [color=#000000]}] [x=235.00] [y=260.00] [width=10.00] [height=10.00]
    18       RenderSVGContainer {g} at (5,83) size 458x209
    19         RenderSVGText {text} at (5,83) size 26x9 contains 1 chunk(s)
     18      RenderSVGContainer {g} at (5,82) size 458x210
     19        RenderSVGText {text} at (5,82) size 26x10 contains 1 chunk(s)
    2020          RenderSVGInlineText {#text} at (0,0) size 26x9
    2121            chunk 1 text run 1 at (5.00,90.00) startOffset 0 endOffset 7 width 26.00: "Stroked"
    22         RenderSVGText {text} at (5,188) size 35x9 contains 1 chunk(s)
     22        RenderSVGText {text} at (5,187) size 35x10 contains 1 chunk(s)
    2323          RenderSVGInlineText {#text} at (0,0) size 35x9
    2424            chunk 1 text run 1 at (5.00,195.00) startOffset 0 endOffset 9 width 35.00: "Unstroked"
    25         RenderSVGText {text} at (50,128) size 51x9 contains 1 chunk(s)
     25        RenderSVGText {text} at (50,127) size 51x10 contains 1 chunk(s)
    2626          RenderSVGInlineText {#text} at (0,0) size 51x9
    2727            chunk 1 text run 1 at (50.00,135.00) startOffset 0 endOffset 15 width 51.00: "Zero width rect"
    28         RenderSVGText {text} at (130,128) size 53x9 contains 1 chunk(s)
     28        RenderSVGText {text} at (130,127) size 53x10 contains 1 chunk(s)
    2929          RenderSVGInlineText {#text} at (0,0) size 53x9
    3030            chunk 1 text run 1 at (130.00,135.00) startOffset 0 endOffset 16 width 53.00: "Zero height rect"
    31         RenderSVGText {text} at (210,128) size 60x9 contains 1 chunk(s)
     31        RenderSVGText {text} at (210,127) size 60x10 contains 1 chunk(s)
    3232          RenderSVGInlineText {#text} at (0,0) size 60x9
    3333            chunk 1 text run 1 at (210.00,135.00) startOffset 0 endOffset 18 width 60.00: "Zero radius circle"
    34         RenderSVGText {text} at (315,128) size 69x9 contains 1 chunk(s)
     34        RenderSVGText {text} at (315,127) size 69x10 contains 1 chunk(s)
    3535          RenderSVGInlineText {#text} at (0,0) size 69x9
    3636            chunk 1 text run 1 at (315.00,135.00) startOffset 0 endOffset 21 width 69.00: "Zero x radius ellipse"
    37         RenderSVGText {text} at (394,128) size 69x9 contains 1 chunk(s)
     37        RenderSVGText {text} at (394,127) size 69x10 contains 1 chunk(s)
    3838          RenderSVGInlineText {#text} at (0,0) size 69x9
    3939            chunk 1 text run 1 at (394.00,135.00) startOffset 0 endOffset 21 width 69.00: "Zero y radius ellipse"
    40         RenderSVGText {text} at (235,283) size 52x9 contains 1 chunk(s)
     40        RenderSVGText {text} at (235,282) size 52x10 contains 1 chunk(s)
    4141          RenderSVGInlineText {#text} at (0,0) size 52x9
    4242            chunk 1 text run 1 at (235.00,290.00) startOffset 0 endOffset 16 width 52.00: "Zero length line"
    43       RenderSVGRect {rect} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [x=55.00] [y=55.00] [width=0.00] [height=50.00]
     43      RenderSVGRect {rect} at (54,54) size 2x52 [stroke={[type=SOLID] [color=#000000]}] [x=55.00] [y=55.00] [width=0.00] [height=50.00]
    4444      RenderSVGRect {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [x=55.00] [y=160.00] [width=0.00] [height=50.00]
    45       RenderSVGRect {rect} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [x=135.00] [y=55.00] [width=25.00] [height=0.00]
     45      RenderSVGRect {rect} at (134,54) size 27x2 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [x=135.00] [y=55.00] [width=25.00] [height=0.00]
    4646      RenderSVGRect {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#00FF00]}] [x=135.00] [y=160.00] [width=25.00] [height=0.00]
    47       RenderSVGEllipse {circle} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [cx=240.00] [cy=80.00] [r=0.00]
     47      RenderSVGEllipse {circle} at (239,79) size 2x2 [stroke={[type=SOLID] [color=#000000]}] [cx=240.00] [cy=80.00] [r=0.00]
    4848      RenderSVGEllipse {circle} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [cx=240.00] [cy=185.00] [r=0.00]
    49       RenderSVGEllipse {ellipse} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=332.00] [cy=80.00] [rx=0.00] [ry=25.00]
     49      RenderSVGEllipse {ellipse} at (331,54) size 2x52 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#00FF00]}] [cx=332.00] [cy=80.00] [rx=0.00] [ry=25.00]
    5050      RenderSVGEllipse {ellipse} at (0,0) size 0x0 [fill={[type=SOLID] [color=#00FF00]}] [cx=332.00] [cy=185.00] [rx=0.00] [ry=25.00]
    51       RenderSVGEllipse {ellipse} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [cx=411.00] [cy=80.00] [rx=12.00] [ry=0.00]
     51      RenderSVGEllipse {ellipse} at (398,79) size 26x2 [stroke={[type=SOLID] [color=#000000]}] [cx=411.00] [cy=80.00] [rx=12.00] [ry=0.00]
    5252      RenderSVGEllipse {ellipse} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [cx=411.00] [cy=185.00] [rx=12.00] [ry=0.00]
    5353      RenderSVGPath {line} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF]}] [fill={[type=SOLID] [color=#000000]}] [x1=240.00] [y1=265.00] [x2=240.00] [y2=265.00]
    54     RenderSVGText {text} at (10,304) size 264x45 contains 1 chunk(s)
    55       RenderSVGInlineText {#text} at (0,0) size 264x45
     54    RenderSVGText {text} at (10,304) size 264x46 contains 1 chunk(s)
     55      RenderSVGInlineText {#text} at (0,0) size 264x46
    5656        chunk 1 text run 1 at (10.00,340.00) startOffset 0 endOffset 16 width 264.00: "$Revision: 1.9 $"
    5757    RenderSVGRect {rect} at (0,0) size 480x360 [stroke={[type=SOLID] [color=#000000]}] [x=1.00] [y=1.00] [width=478.00] [height=358.00]
  • trunk/LayoutTests/svg/W3C-SVG-1.1/shapes-rect-02-t-expected.txt

    r158818 r169522  
    33layer at (0,0) size 480x360
    44  RenderSVGRoot {svg} at (0,0) size 480x360
    5     RenderSVGContainer {g} at (0,0) size 181x277
     5    RenderSVGContainer {g} at (0,0) size 401x277
    66      RenderSVGRect {rect} at (0,45) size 51x82 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=46.00] [width=50.00] [height=80.00]
    77      RenderSVGRect {rect} at (129,0) size 52x81 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=130.00] [y=0.00] [width=50.00] [height=80.00]
    8       RenderSVGRect {rect} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=250.00] [y=46.00] [width=0.00] [height=80.00]
    9       RenderSVGRect {rect} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=350.00] [y=46.00] [width=50.00] [height=0.00]
     8      RenderSVGRect {rect} at (249,45) size 2x82 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=250.00] [y=46.00] [width=0.00] [height=80.00]
     9      RenderSVGRect {rect} at (349,45) size 52x2 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=350.00] [y=46.00] [width=50.00] [height=0.00]
    1010      RenderSVGRect {rect} at (29,195) size 52x82 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=30.00] [y=196.00] [width=50.00] [height=80.00]
    1111      RenderSVGRect {rect} at (129,195) size 52x82 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [x=130.00] [y=196.00] [width=50.00] [height=80.00]
    12     RenderSVGText {text} at (10,304) size 264x45 contains 1 chunk(s)
    13       RenderSVGInlineText {#text} at (0,0) size 264x45
     12    RenderSVGText {text} at (10,304) size 264x46 contains 1 chunk(s)
     13      RenderSVGInlineText {#text} at (0,0) size 264x46
    1414        chunk 1 text run 1 at (10.00,340.00) startOffset 0 endOffset 16 width 264.00: "$Revision: 1.4 $"
    1515    RenderSVGRect {rect} at (0,0) size 480x360 [stroke={[type=SOLID] [color=#000000]}] [x=1.00] [y=1.00] [width=478.00] [height=358.00]
  • trunk/Source/WebCore/ChangeLog

    r169519 r169522  
     12014-06-01  Nikos Andronikos  <nikos.andronikos-webkit@cisra.canon.com.au>
     2
     3        getBBox() returns (0,0) when width or height is zero.
     4        https://bugs.webkit.org/show_bug.cgi?id=93290
     5
     6        Reviewed by Philip Rogers.
     7
     8        The SVG spec states that a width or height of zero for  rects, circles and
     9        ellipses is valid but disables rendering of that shape.
     10        In this case, getBBox() should return the actual bounding box of the element.
     11        Previously, WebKit always returned (0,0,0,0) rather than the
     12        correct bounding box. This patch fixes that.
     13
     14        Rects and ellipses both now follow the same behaviour where
     15        the fall-back code path is only used when the shape will render (e.g. not
     16        when a dimension <= 0).
     17 
     18        This necessitates calling calculateRadiiAndCenter for ellipses even
     19        when the calculated values will be discarded in the fall back code path.
     20        But calculateRadiiAndCenter is cheap and this avoids making changes
     21        elsewhere to stop CG drawing a zero width (or height) ellipse. 
     22
     23        Tests: svg/custom/getBBox-js-circle-zerodimension.html
     24               svg/custom/getBBox-js-ellipse-zerodimension.html
     25               svg/custom/getBBox-js-rect-zerodimension.html
     26
     27        * rendering/svg/RenderSVGEllipse.cpp:
     28        (WebCore::RenderSVGEllipse::updateShapeFromElement):
     29        Only follow fall-back code path when shape renders.
     30        width||height==0 is not an error case so calculate bounding box.       
     31
     32        * rendering/svg/RenderSVGRect.cpp:
     33        (WebCore::RenderSVGRect::updateShapeFromElement):
     34        Only follow fall-back code path when shape renders.
     35        rx||ry==0 is not an error case so calculate bounding box.       
     36
    1372014-06-01  Simon Fraser  <simon.fraser@apple.com>
    238
  • trunk/Source/WebCore/rendering/svg/RenderSVGEllipse.cpp

    r163440 r169522  
    5353    m_radii = FloatSize();
    5454
    55     // Fallback to RenderSVGShape if shape has a non-scaling stroke.
    56     if (hasNonScalingStroke()) {
    57         RenderSVGShape::updateShapeFromElement();
    58         m_usePathFallback = true;
    59         return;
    60     } else
    61         m_usePathFallback = false;
    62 
    6355    calculateRadiiAndCenter();
    6456
     57    // Element is invalid if either dimension is negative.
     58    if (m_radii.width() < 0 || m_radii.height() < 0)
     59        return;
     60
    6561    // Spec: "A value of zero disables rendering of the element."
    66     if (m_radii.width() <= 0 || m_radii.height() <= 0)
    67         return;
     62    if (!m_radii.isEmpty()) {
     63        if (hasNonScalingStroke()) {
     64            // Fallback to RenderSVGShape if shape has a non-scaling stroke.
     65            RenderSVGShape::updateShapeFromElement();
     66            m_usePathFallback = true;
     67            return;
     68        }
     69        m_usePathFallback = false;
     70    }
    6871
    6972    m_fillBoundingBox = FloatRect(m_center.x() - m_radii.width(), m_center.y() - m_radii.height(), 2 * m_radii.width(), 2 * m_radii.height());
  • trunk/Source/WebCore/rendering/svg/RenderSVGRect.cpp

    r163440 r169522  
    5757
    5858    SVGLengthContext lengthContext(&rectElement());
    59     // Fallback to RenderSVGShape if rect has rounded corners or a non-scaling stroke.
    60     if (rectElement().rx().value(lengthContext) > 0 || rectElement().ry().value(lengthContext) > 0 || hasNonScalingStroke()) {
    61         RenderSVGShape::updateShapeFromElement();
    62         m_usePathFallback = true;
     59    FloatSize boundingBoxSize(rectElement().width().value(lengthContext), rectElement().height().value(lengthContext));
     60
     61    // Element is invalid if either dimension is negative.
     62    if (boundingBoxSize.width() < 0 || boundingBoxSize.height() < 0)
    6363        return;
     64
     65    // Rendering enabled? Spec: "A value of zero disables rendering of the element."
     66    if (!boundingBoxSize.isEmpty()) {
     67        if (rectElement().rx().value(lengthContext) > 0 || rectElement().ry().value(lengthContext) > 0 || hasNonScalingStroke()) {
     68            // Fall back to RenderSVGShape
     69            RenderSVGShape::updateShapeFromElement();
     70            m_usePathFallback = true;
     71            return;
     72        }
     73        m_usePathFallback = false;
    6474    }
    65 
    66     m_usePathFallback = false;
    67     FloatSize boundingBoxSize(rectElement().width().value(lengthContext), rectElement().height().value(lengthContext));
    68     if (boundingBoxSize.isEmpty())
    69         return;
    7075
    7176    m_fillBoundingBox = FloatRect(FloatPoint(rectElement().x().value(lengthContext), rectElement().y().value(lengthContext)), boundingBoxSize);
Note: See TracChangeset for help on using the changeset viewer.