Changeset 87721 in webkit


Ignore:
Timestamp:
May 31, 2011 3:46:25 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-05-31 Oliver Varga <Varga.Oliver@stud.u-szeged.hu>

Reviewed by Nikolas Zimmermann.

Invalid color handling is broken for SVG
https://bugs.webkit.org/show_bug.cgi?id=58531

Fix invalid color fallback handling. If the fill/stroke attributes computed
value leads to a an invalid color, inherit the desired color from the parent
style instead. Matches Opera/FF and SVG 1.1 Second Edition (http://www.w3.org/TR/SVG/).

  • platform/chromium-linux/svg/custom/invalid-fill-expected.txt:
  • platform/chromium-linux/svg/custom/invalid-fill-hex-expected.txt:
  • platform/chromium-linux/svg/custom/invalid-stroke-hex-expected.txt: Added.
  • platform/chromium-linux/svg/custom/invalid-uri-stroke-expected.txt: Added.
  • platform/mac/svg/custom/invalid-fill-expected.png:
  • platform/mac/svg/custom/invalid-fill-expected.txt:
  • platform/mac/svg/custom/invalid-fill-hex-expected.png:
  • platform/mac/svg/custom/invalid-fill-hex-expected.txt:
  • platform/mac/svg/custom/invalid-stroke-hex-expected.png: Added.
  • platform/mac/svg/custom/invalid-stroke-hex-expected.txt: Added.
  • platform/mac/svg/custom/invalid-uri-stroke-expected.png: Added.
  • platform/mac/svg/custom/invalid-uri-stroke-expected.txt: Added.
  • platform/qt/svg/custom/invalid-fill-expected.txt:
  • platform/qt/svg/custom/invalid-fill-hex-expected.txt:
  • platform/qt/svg/custom/invalid-stroke-hex-expected.txt: Added.
  • platform/qt/svg/custom/invalid-uri-stroke-expected.txt: Added.
  • svg/custom/invalid-fill-hex.svg:
  • svg/custom/invalid-fill.svg:
  • svg/custom/invalid-stroke-hex.svg: Added.
  • svg/custom/invalid-uri-stroke.svg: Added.

2011-05-31 Oliver Varga <Varga.Oliver@stud.u-szeged.hu>

Reviewed by Nikolas Zimmermann.

Invalid color handling is broken for SVG
https://bugs.webkit.org/show_bug.cgi?id=58531

Fix invalid color fallback handling. If the fill/stroke attributes computed
value leads to a an invalid color, inherit the desired color from the parent
style instead. Matches Opera/FF and SVG 1.1 Second Edition (http://www.w3.org/TR/SVG/).

Tests: svg/custom/invalid-stroke-hex.svg

svg/custom/invalid-uri-stroke.svg

  • rendering/svg/RenderSVGResource.cpp: (WebCore::inheritColorFromParentStyleIfNeeded): (WebCore::requestPaintingResource):
Location:
trunk
Files:
10 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r87719 r87721  
     12011-05-31  Oliver Varga  <Varga.Oliver@stud.u-szeged.hu>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        Invalid color handling is broken for SVG
     6        https://bugs.webkit.org/show_bug.cgi?id=58531
     7
     8        Fix invalid color fallback handling. If the fill/stroke attributes computed
     9        value leads to a an invalid color, inherit the desired color from the parent
     10        style instead. Matches Opera/FF and SVG 1.1 Second Edition (http://www.w3.org/TR/SVG/).
     11
     12        * platform/chromium-linux/svg/custom/invalid-fill-expected.txt:
     13        * platform/chromium-linux/svg/custom/invalid-fill-hex-expected.txt:
     14        * platform/chromium-linux/svg/custom/invalid-stroke-hex-expected.txt: Added.
     15        * platform/chromium-linux/svg/custom/invalid-uri-stroke-expected.txt: Added.
     16        * platform/mac/svg/custom/invalid-fill-expected.png:
     17        * platform/mac/svg/custom/invalid-fill-expected.txt:
     18        * platform/mac/svg/custom/invalid-fill-hex-expected.png:
     19        * platform/mac/svg/custom/invalid-fill-hex-expected.txt:
     20        * platform/mac/svg/custom/invalid-stroke-hex-expected.png: Added.
     21        * platform/mac/svg/custom/invalid-stroke-hex-expected.txt: Added.
     22        * platform/mac/svg/custom/invalid-uri-stroke-expected.png: Added.
     23        * platform/mac/svg/custom/invalid-uri-stroke-expected.txt: Added.
     24        * platform/qt/svg/custom/invalid-fill-expected.txt:
     25        * platform/qt/svg/custom/invalid-fill-hex-expected.txt:
     26        * platform/qt/svg/custom/invalid-stroke-hex-expected.txt: Added.
     27        * platform/qt/svg/custom/invalid-uri-stroke-expected.txt: Added.
     28        * svg/custom/invalid-fill-hex.svg:
     29        * svg/custom/invalid-fill.svg:
     30        * svg/custom/invalid-stroke-hex.svg: Added.
     31        * svg/custom/invalid-uri-stroke.svg: Added.
     32
    1332011-05-31  Yuta Kitamura  <yutak@chromium.org>
    234
  • trunk/LayoutTests/platform/chromium-linux/svg/custom/invalid-fill-expected.txt

    r69417 r87721  
    55    RenderSVGContainer {g} at (0,0) size 635x214
    66      RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    7       RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#000000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
     7      RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FFA500]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    88      RenderSVGContainer {g} at (10,115) size 625x99
    99        RenderSVGText {text} at (10,115) size 214x19 contains 1 chunk(s)
  • trunk/LayoutTests/platform/chromium-linux/svg/custom/invalid-fill-hex-expected.txt

    r69417 r87721  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 800x600
    4   RenderSVGRoot {svg} at (0,0) size 616x214
    5     RenderSVGContainer {g} at (0,0) size 616x214
     4  RenderSVGRoot {svg} at (0,0) size 639x214
     5    RenderSVGContainer {g} at (0,0) size 639x214
    66      RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    7       RenderSVGPath {rect} at (0,0) size 100x100 [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    8       RenderSVGContainer {g} at (10,115) size 606x99
    9         RenderSVGText {text} at (10,115) size 191x19 contains 1 chunk(s)
    10           RenderSVGInlineText {#text} at (0,0) size 191x19
    11             chunk 1 text run 1 at (10.00,130.00) startOffset 0 endOffset 29 width 191.00: "The above rect should be RED."
     7      RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FFA500]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
     8      RenderSVGContainer {g} at (10,115) size 629x99
     9        RenderSVGText {text} at (10,115) size 226x19 contains 1 chunk(s)
     10          RenderSVGInlineText {#text} at (0,0) size 226x19
     11            chunk 1 text run 1 at (10.00,130.00) startOffset 0 endOffset 32 width 226.00: "The above rect should be ORANGE."
    1212        RenderSVGText {text} at (10,135) size 606x19 contains 1 chunk(s)
    1313          RenderSVGInlineText {#text} at (0,0) size 606x19
     
    1616          RenderSVGInlineText {#text} at (0,0) size 448x19
    1717            chunk 1 text run 1 at (10.00,170.00) startOffset 0 endOffset 77 width 448.00: "Browsers don't display such an error, instead use some sort of fill-fallback."
    18         RenderSVGText {text} at (10,175) size 528x19 contains 1 chunk(s)
    19           RenderSVGInlineText {#text} at (0,0) size 528x19
    20             chunk 1 text run 1 at (10.00,190.00) startOffset 0 endOffset 99 width 528.00: "If there's an invalid fill color, but no fallback specified, it is as if fill=\"none\" was specified."
    21         RenderSVGText {text} at (10,195) size 529x19 contains 1 chunk(s)
    22           RenderSVGInlineText {#text} at (0,0) size 529x19
    23             chunk 1 text run 1 at (10.00,210.00) startOffset 0 endOffset 84 width 529.00: "This has recently been changed in SVG 1.1 2nd edition. Our result matches Opera now."
     18        RenderSVGText {text} at (10,175) size 629x19 contains 1 chunk(s)
     19          RenderSVGInlineText {#text} at (0,0) size 629x19
     20            chunk 1 text run 1 at (10.00,190.00) startOffset 0 endOffset 116 width 629.00: "If there's an invalid fill color, but no fallback specified, the fill of the object is inherited from parent object."
     21        RenderSVGText {text} at (10,195) size 263x19 contains 1 chunk(s)
     22          RenderSVGInlineText {#text} at (0,0) size 263x19
     23            chunk 1 text run 1 at (10.00,210.00) startOffset 0 endOffset 41 width 263.00: "Our result matches Opera and Firefox now."
  • trunk/LayoutTests/platform/mac/svg/custom/invalid-fill-expected.txt

    r69413 r87721  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 800x600
    4   RenderSVGRoot {svg} at (0,0) size 677x214
    5     RenderSVGContainer {g} at (0,0) size 677x214
     4  RenderSVGRoot {svg} at (0,0) size 673x214
     5    RenderSVGContainer {g} at (0,0) size 673x214
    66      RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    7       RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#000000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    8       RenderSVGContainer {g} at (10,116) size 667x98
    9         RenderSVGText {text} at (10,116) size 223x18 contains 1 chunk(s)
    10           RenderSVGInlineText {#text} at (0,0) size 223x18
    11             chunk 1 text run 1 at (10.00,130.00) startOffset 0 endOffset 31 width 223.00: "The above rect should be BLACK."
    12         RenderSVGText {text} at (10,136) size 667x18 contains 1 chunk(s)
    13           RenderSVGInlineText {#text} at (0,0) size 667x18
    14             chunk 1 text run 1 at (10.00,150.00) startOffset 0 endOffset 104 width 667.00: "SVG 1.1 FULL says there should be a \"highly perceivable error\" message when an invalid fill url is used."
     7      RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FFA500]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
     8      RenderSVGContainer {g} at (10,116) size 663x98
     9        RenderSVGText {text} at (10,116) size 236x18 contains 1 chunk(s)
     10          RenderSVGInlineText {#text} at (0,0) size 236x18
     11            chunk 1 text run 1 at (10.00,130.00) startOffset 0 endOffset 32 width 236.00: "The above rect should be ORANGE."
     12        RenderSVGText {text} at (10,136) size 646x18 contains 1 chunk(s)
     13          RenderSVGInlineText {#text} at (0,0) size 646x18
     14            chunk 1 text run 1 at (10.00,150.00) startOffset 0 endOffset 100 width 646.00: "SVG 1.1 FULL says there should be a \"highly perceivable error\" message when an invalid fill is used."
    1515        RenderSVGText {text} at (10,156) size 468x18 contains 1 chunk(s)
    1616          RenderSVGInlineText {#text} at (0,0) size 468x18
    1717            chunk 1 text run 1 at (10.00,170.00) startOffset 0 endOffset 77 width 468.00: "Browsers don't display such an error, instead use some sort of fill-fallback."
    18         RenderSVGText {text} at (10,176) size 566x18 contains 1 chunk(s)
    19           RenderSVGInlineText {#text} at (0,0) size 566x18
    20             chunk 1 text run 1 at (10.00,190.00) startOffset 0 endOffset 98 width 566.00: "If there's an invalid fill URI, but no fallback specified, it is as if fill=\"black\" was specified."
     18        RenderSVGText {text} at (10,176) size 663x18 contains 1 chunk(s)
     19          RenderSVGInlineText {#text} at (0,0) size 663x18
     20            chunk 1 text run 1 at (10.00,190.00) startOffset 0 endOffset 114 width 663.00: "If there's an non-existent uri, but no fallback specified, the fill of the object is inherited from parent object."
    2121        RenderSVGText {text} at (10,196) size 555x18 contains 1 chunk(s)
    2222          RenderSVGInlineText {#text} at (0,0) size 555x18
  • trunk/LayoutTests/platform/mac/svg/custom/invalid-fill-hex-expected.txt

    r69413 r87721  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 800x600
    4   RenderSVGRoot {svg} at (0,0) size 656x214
    5     RenderSVGContainer {g} at (0,0) size 656x214
     4  RenderSVGRoot {svg} at (0,0) size 675x214
     5    RenderSVGContainer {g} at (0,0) size 675x214
    66      RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    7       RenderSVGPath {rect} at (0,0) size 100x100 [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    8       RenderSVGContainer {g} at (10,116) size 646x98
    9         RenderSVGText {text} at (10,116) size 200x18 contains 1 chunk(s)
    10           RenderSVGInlineText {#text} at (0,0) size 200x18
    11             chunk 1 text run 1 at (10.00,130.00) startOffset 0 endOffset 29 width 200.00: "The above rect should be RED."
     7      RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FFA500]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
     8      RenderSVGContainer {g} at (10,116) size 665x98
     9        RenderSVGText {text} at (10,116) size 236x18 contains 1 chunk(s)
     10          RenderSVGInlineText {#text} at (0,0) size 236x18
     11            chunk 1 text run 1 at (10.00,130.00) startOffset 0 endOffset 32 width 236.00: "The above rect should be ORANGE."
    1212        RenderSVGText {text} at (10,136) size 646x18 contains 1 chunk(s)
    1313          RenderSVGInlineText {#text} at (0,0) size 646x18
     
    1616          RenderSVGInlineText {#text} at (0,0) size 468x18
    1717            chunk 1 text run 1 at (10.00,170.00) startOffset 0 endOffset 77 width 468.00: "Browsers don't display such an error, instead use some sort of fill-fallback."
    18         RenderSVGText {text} at (10,176) size 567x18 contains 1 chunk(s)
    19           RenderSVGInlineText {#text} at (0,0) size 567x18
    20             chunk 1 text run 1 at (10.00,190.00) startOffset 0 endOffset 99 width 567.00: "If there's an invalid fill color, but no fallback specified, it is as if fill=\"none\" was specified."
    21         RenderSVGText {text} at (10,196) size 555x18 contains 1 chunk(s)
    22           RenderSVGInlineText {#text} at (0,0) size 555x18
    23             chunk 1 text run 1 at (10.00,210.00) startOffset 0 endOffset 84 width 555.00: "This has recently been changed in SVG 1.1 2nd edition. Our result matches Opera now."
     18        RenderSVGText {text} at (10,176) size 665x18 contains 1 chunk(s)
     19          RenderSVGInlineText {#text} at (0,0) size 665x18
     20            chunk 1 text run 1 at (10.00,190.00) startOffset 0 endOffset 116 width 665.00: "If there's an invalid fill color, but no fallback specified, the fill of the object is inherited from parent object."
     21        RenderSVGText {text} at (10,196) size 274x18 contains 1 chunk(s)
     22          RenderSVGInlineText {#text} at (0,0) size 274x18
     23            chunk 1 text run 1 at (10.00,210.00) startOffset 0 endOffset 41 width 274.00: "Our result matches Opera and Firefox now."
  • trunk/LayoutTests/platform/qt/svg/custom/invalid-fill-expected.txt

    r83871 r87721  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 800x600
    4   RenderSVGRoot {svg} at (0,0) size 721x216
    5     RenderSVGContainer {g} at (0,0) size 721x216
     4  RenderSVGRoot {svg} at (0,0) size 724x216
     5    RenderSVGContainer {g} at (0,0) size 724x216
    66      RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    7       RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#000000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    8       RenderSVGContainer {g} at (10,114) size 711x102
    9         RenderSVGText {text} at (10,114) size 236x22 contains 1 chunk(s)
    10           RenderSVGInlineText {#text} at (0,0) size 236x22
    11             chunk 1 text run 1 at (10.00,130.00) startOffset 0 endOffset 31 width 236.00: "The above rect should be BLACK."
    12         RenderSVGText {text} at (10,134) size 711x22 contains 1 chunk(s)
    13           RenderSVGInlineText {#text} at (0,0) size 711x22
    14             chunk 1 text run 1 at (10.00,150.00) startOffset 0 endOffset 104 width 711.00: "SVG 1.1 FULL says there should be a \"highly perceivable error\" message when an invalid fill url is used."
     7      RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FFA500]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
     8      RenderSVGContainer {g} at (10,114) size 714x102
     9        RenderSVGText {text} at (10,114) size 249x22 contains 1 chunk(s)
     10          RenderSVGInlineText {#text} at (0,0) size 249x22
     11            chunk 1 text run 1 at (10.00,130.00) startOffset 0 endOffset 32 width 249.00: "The above rect should be ORANGE."
     12        RenderSVGText {text} at (10,134) size 687x22 contains 1 chunk(s)
     13          RenderSVGInlineText {#text} at (0,0) size 687x22
     14            chunk 1 text run 1 at (10.00,150.00) startOffset 0 endOffset 100 width 687.00: "SVG 1.1 FULL says there should be a \"highly perceivable error\" message when an invalid fill is used."
    1515        RenderSVGText {text} at (10,154) size 502x22 contains 1 chunk(s)
    1616          RenderSVGInlineText {#text} at (0,0) size 502x22
    1717            chunk 1 text run 1 at (10.00,170.00) startOffset 0 endOffset 77 width 502.00: "Browsers don't display such an error, instead use some sort of fill-fallback."
    18         RenderSVGText {text} at (10,174) size 601x22 contains 1 chunk(s)
    19           RenderSVGInlineText {#text} at (0,0) size 601x22
    20             chunk 1 text run 1 at (10.00,190.00) startOffset 0 endOffset 98 width 601.00: "If there's an invalid fill URI, but no fallback specified, it is as if fill=\"black\" was specified."
     18        RenderSVGText {text} at (10,174) size 714x22 contains 1 chunk(s)
     19          RenderSVGInlineText {#text} at (0,0) size 714x22
     20            chunk 1 text run 1 at (10.00,190.00) startOffset 0 endOffset 114 width 714.00: "If there's an non-existent uri, but no fallback specified, the fill of the object is inherited from parent object."
    2121        RenderSVGText {text} at (10,194) size 591x22 contains 1 chunk(s)
    2222          RenderSVGInlineText {#text} at (0,0) size 591x22
  • trunk/LayoutTests/platform/qt/svg/custom/invalid-fill-hex-expected.txt

    r83871 r87721  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 800x600
    4   RenderSVGRoot {svg} at (0,0) size 697x216
    5     RenderSVGContainer {g} at (0,0) size 697x216
     4  RenderSVGRoot {svg} at (0,0) size 723x216
     5    RenderSVGContainer {g} at (0,0) size 723x216
    66      RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    7       RenderSVGPath {rect} at (0,0) size 100x100 [x=0.00] [y=0.00] [width=100.00] [height=100.00]
    8       RenderSVGContainer {g} at (10,114) size 687x102
    9         RenderSVGText {text} at (10,114) size 213x22 contains 1 chunk(s)
    10           RenderSVGInlineText {#text} at (0,0) size 213x22
    11             chunk 1 text run 1 at (10.00,130.00) startOffset 0 endOffset 29 width 213.00: "The above rect should be RED."
     7      RenderSVGPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FFA500]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
     8      RenderSVGContainer {g} at (10,114) size 713x102
     9        RenderSVGText {text} at (10,114) size 249x22 contains 1 chunk(s)
     10          RenderSVGInlineText {#text} at (0,0) size 249x22
     11            chunk 1 text run 1 at (10.00,130.00) startOffset 0 endOffset 32 width 249.00: "The above rect should be ORANGE."
    1212        RenderSVGText {text} at (10,134) size 687x22 contains 1 chunk(s)
    1313          RenderSVGInlineText {#text} at (0,0) size 687x22
     
    1616          RenderSVGInlineText {#text} at (0,0) size 502x22
    1717            chunk 1 text run 1 at (10.00,170.00) startOffset 0 endOffset 77 width 502.00: "Browsers don't display such an error, instead use some sort of fill-fallback."
    18         RenderSVGText {text} at (10,174) size 601x22 contains 1 chunk(s)
    19           RenderSVGInlineText {#text} at (0,0) size 601x22
    20             chunk 1 text run 1 at (10.00,190.00) startOffset 0 endOffset 99 width 601.00: "If there's an invalid fill color, but no fallback specified, it is as if fill=\"none\" was specified."
    21         RenderSVGText {text} at (10,194) size 591x22 contains 1 chunk(s)
    22           RenderSVGInlineText {#text} at (0,0) size 591x22
    23             chunk 1 text run 1 at (10.00,210.00) startOffset 0 endOffset 84 width 591.00: "This has recently been changed in SVG 1.1 2nd edition. Our result matches Opera now."
     18        RenderSVGText {text} at (10,174) size 713x22 contains 1 chunk(s)
     19          RenderSVGInlineText {#text} at (0,0) size 713x22
     20            chunk 1 text run 1 at (10.00,190.00) startOffset 0 endOffset 116 width 713.00: "If there's an invalid fill color, but no fallback specified, the fill of the object is inherited from parent object."
     21        RenderSVGText {text} at (10,194) size 296x22 contains 1 chunk(s)
     22          RenderSVGInlineText {#text} at (0,0) size 296x22
     23            chunk 1 text run 1 at (10.00,210.00) startOffset 0 endOffset 41 width 296.00: "Our result matches Opera and Firefox now."
  • trunk/LayoutTests/svg/custom/invalid-fill-hex.svg

    r69413 r87721  
    55    <rect width="100" height="100" fill="#ff"/>
    66    <g fill="black">
    7       <text x="10" y="130">The above rect should be RED.</text>
     7      <text x="10" y="130">The above rect should be ORANGE.</text>
    88      <text x="10" y="150">SVG 1.1 FULL says there should be a "highly perceivable error" message when an invalid fill is used.</text>
    99      <text x="10" y="170">Browsers don't display such an error, instead use some sort of fill-fallback.</text>
    10       <text x="10" y="190">If there's an invalid fill color, but no fallback specified, it is as if fill="none" was specified.</text>
    11       <text x="10" y="210">This has recently been changed in SVG 1.1 2nd edition. Our result matches Opera now.</text>
     10      <text x="10" y="190">If there's an invalid fill color, but no fallback specified, the fill of the object is inherited from parent object.</text>
     11      <text x="10" y="210">Our result matches Opera and Firefox now.</text>
    1212    </g>
    1313  </g>
  • trunk/LayoutTests/svg/custom/invalid-fill.svg

    r69413 r87721  
    55    <rect width="100" height="100" fill="url(#notthere)"/>
    66    <g fill="black">
    7       <text x="10" y="130">The above rect should be BLACK.</text>
    8       <text x="10" y="150">SVG 1.1 FULL says there should be a "highly perceivable error" message when an invalid fill url is used.</text>
     7      <text x="10" y="130">The above rect should be ORANGE.</text>
     8      <text x="10" y="150">SVG 1.1 FULL says there should be a "highly perceivable error" message when an invalid fill is used.</text>
    99      <text x="10" y="170">Browsers don't display such an error, instead use some sort of fill-fallback.</text>
    10       <text x="10" y="190">If there's an invalid fill URI, but no fallback specified, it is as if fill="black" was specified.</text>
     10      <text x="10" y="190">If there's an non-existent uri, but no fallback specified, the fill of the object is inherited from parent object.</text>
    1111      <text x="10" y="210">This has recently been changed in SVG 1.1 2nd edition. Our result matches Opera now.</text>
    1212    </g>
  • trunk/Source/WebCore/ChangeLog

    r87718 r87721  
     12011-05-31  Oliver Varga  <Varga.Oliver@stud.u-szeged.hu>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        Invalid color handling is broken for SVG
     6        https://bugs.webkit.org/show_bug.cgi?id=58531
     7
     8        Fix invalid color fallback handling. If the fill/stroke attributes computed
     9        value leads to a an invalid color, inherit the desired color from the parent
     10        style instead. Matches Opera/FF and SVG 1.1 Second Edition (http://www.w3.org/TR/SVG/).
     11
     12        Tests: svg/custom/invalid-stroke-hex.svg
     13               svg/custom/invalid-uri-stroke.svg
     14
     15        * rendering/svg/RenderSVGResource.cpp:
     16        (WebCore::inheritColorFromParentStyleIfNeeded):
     17        (WebCore::requestPaintingResource):
     18
    1192011-05-31  Vangelis Kokkevis  <vangelis@chromium.org>
    220
  • trunk/Source/WebCore/rendering/svg/RenderSVGResource.cpp

    r79985 r87721  
    3232
    3333namespace WebCore {
     34
     35static inline bool inheritColorFromParentStyleIfNeeded(RenderObject* object, bool applyToFill, Color& color)
     36{
     37    if (color.isValid())
     38        return true;
     39    if (!object->parent() || !object->parent()->style())
     40        return false;
     41    const SVGRenderStyle* parentSVGStyle = object->parent()->style()->svgStyle();
     42    color = applyToFill ? parentSVGStyle->fillPaintColor() : parentSVGStyle->strokePaintColor();
     43    return true;
     44}
    3445
    3546static inline RenderSVGResource* requestPaintingResource(RenderSVGResourceMode mode, RenderObject* object, const RenderStyle* style, Color& fallbackColor)
     
    8899    RenderSVGResourceSolidColor* colorResource = RenderSVGResource::sharedSolidPaintingResource();
    89100    if (paintType < SVGPaint::SVG_PAINTTYPE_URI_NONE) {
    90         // If an invalid fill color is specified, fallback to fill/stroke="none".
    91         if (!color.isValid())
     101        if (!inheritColorFromParentStyleIfNeeded(object, applyToFill, color))
    92102            return 0;
    93103
     
    99109    SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(object);
    100110    if (!resources) {
    101         // If a paint server is specified, and no or an invalid fallback color is given, default to fill/stroke="black".
    102         if (!color.isValid())
    103             color = Color::black;
     111        if (!inheritColorFromParentStyleIfNeeded(object, applyToFill, color))
     112            return 0;
    104113
    105114        colorResource->setColor(color);
     
    110119    RenderSVGResource* uriResource = mode == ApplyToFillMode ? resources->fill() : resources->stroke();
    111120    if (!uriResource) {
    112         // If a paint server is specified, and no or an invalid fallback color is given, default to fill/stroke="black".
    113         if (!color.isValid())
    114             color = Color::black;
     121        if (!inheritColorFromParentStyleIfNeeded(object, applyToFill, color))
     122            return 0;
    115123
    116124        colorResource->setColor(color);
     
    163171
    164172#endif
     173
Note: See TracChangeset for help on using the changeset viewer.