Changeset 110692 in webkit


Ignore:
Timestamp:
Mar 14, 2012 5:00:44 AM (12 years ago)
Author:
Nikolas Zimmermann
Message:

2012-03-14 Nikolas Zimmermann <nzimmermann@rim.com>

External <use> xlink:href references do not work
https://bugs.webkit.org/show_bug.cgi?id=12499

Reviewed by Zoltan Herczeg.

Rebaseline tests after r110676 using Generic RGB Profile on Lion, and update them after my fixes.
Replace xml:id with id everywhere, to make the new tiny tests work.

  • platform/mac/svg/W3C-SVG-1.2-Tiny/struct-use-recursion-02-t-expected.png:
  • platform/mac/svg/W3C-SVG-1.2-Tiny/struct-use-recursion-02-t-expected.txt:
  • platform/mac/svg/W3C-SVG-1.2-Tiny/struct-use-recursion-03-t-expected.png:
  • platform/mac/svg/W3C-SVG-1.2-Tiny/struct-use-recursion-03-t-expected.txt:
  • platform/mac/svg/batik/filters/feTile-expected.png:
  • platform/mac/svg/batik/filters/filterRegions-expected.png:
  • platform/mac/svg/batik/text/textEffect-expected.png:
  • platform/mac/svg/batik/text/textEffect3-expected.png:
  • platform/mac/svg/dynamic-updates/SVGUseElement-svgdom-href1-prop-expected.png:
  • svg/W3C-SVG-1.2-Tiny/struct-use-recursion-01-t.svg:
  • svg/W3C-SVG-1.2-Tiny/struct-use-recursion-02-t.svg:
  • svg/W3C-SVG-1.2-Tiny/struct-use-recursion-03-t.svg:
  • svg/custom/use-external-crash-expected.txt: Added.
  • svg/custom/use-external-crash.svg: Added.

2012-03-14 Nikolas Zimmermann <nzimmermann@rim.com>

External <use> xlink:href references do not work
https://bugs.webkit.org/show_bug.cgi?id=12499

Reviewed by Zoltan Herczeg.

Follow-up fix after r110676.
Assertions are firing due last minute changes in isExternalURIReference.

Fix detecting local resources properly, when the given iri contains a /complex/path.
Use document->completeURL() instead, and compare with the document->url() to decide
if its a local reference or not.

If an external document load fails with an error (eg. file missing) don't assert
in debug builds, instead handle it gracefully.

I decided to clean the code up as well, to make it more safe & obvious.

Test: svg/custom/use-external-crash.svg

  • svg/SVGURIReference.cpp: (WebCore::SVGURIReference::targetElementFromIRIString):
  • svg/SVGURIReference.h: (WebCore::SVGURIReference::isExternalURIReference):
  • svg/SVGUseElement.cpp: (WebCore::SVGUseElement::externalDocument): (WebCore::SVGUseElement::buildPendingResource):
Location:
trunk
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r110690 r110692  
     12012-03-14  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        External <use> xlink:href references do not work
     4        https://bugs.webkit.org/show_bug.cgi?id=12499
     5
     6        Reviewed by Zoltan Herczeg.
     7
     8        Rebaseline tests after r110676 using Generic RGB Profile on Lion, and update them after my fixes.
     9        Replace xml:id with id everywhere, to make the new tiny tests work.
     10
     11        * platform/mac/svg/W3C-SVG-1.2-Tiny/struct-use-recursion-02-t-expected.png:
     12        * platform/mac/svg/W3C-SVG-1.2-Tiny/struct-use-recursion-02-t-expected.txt:
     13        * platform/mac/svg/W3C-SVG-1.2-Tiny/struct-use-recursion-03-t-expected.png:
     14        * platform/mac/svg/W3C-SVG-1.2-Tiny/struct-use-recursion-03-t-expected.txt:
     15        * platform/mac/svg/batik/filters/feTile-expected.png:
     16        * platform/mac/svg/batik/filters/filterRegions-expected.png:
     17        * platform/mac/svg/batik/text/textEffect-expected.png:
     18        * platform/mac/svg/batik/text/textEffect3-expected.png:
     19        * platform/mac/svg/dynamic-updates/SVGUseElement-svgdom-href1-prop-expected.png:
     20        * svg/W3C-SVG-1.2-Tiny/struct-use-recursion-01-t.svg:
     21        * svg/W3C-SVG-1.2-Tiny/struct-use-recursion-02-t.svg:
     22        * svg/W3C-SVG-1.2-Tiny/struct-use-recursion-03-t.svg:
     23        * svg/custom/use-external-crash-expected.txt: Added.
     24        * svg/custom/use-external-crash.svg: Added.
     25
    1262012-03-14  Ádám Kallai  <kadam@inf.u-szeged.hu>
    227
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.2-Tiny/struct-use-recursion-02-t-expected.txt

    r110676 r110692  
    44  RenderSVGRoot {svg} at (0,0) size 800x600
    55    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
    6     RenderSVGContainer {g} at (150,25) size 484x452
    7       RenderSVGContainer {g} at (150,25) size 34x34
     6    RenderSVGContainer {g} at (150,25) size 502x452
     7      RenderSVGContainer {g} at (150,25) size 502x77
    88        RenderSVGPath {circle} at (150,25) size 34x34 [fill={[type=SOLID] [color=#FF7F00]}] [cx=100.00] [cy=25.00] [r=10.00]
    9         RenderSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
     9        RenderSVGContainer {use} at (614,64) size 38x38 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
     10          RenderSVGContainer {g} at (614,64) size 38x38
     11            RenderSVGContainer {g} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
     12            RenderSVGPath {circle} at (614,64) size 38x38 [stroke={[type=SOLID] [color=#808080] [stroke width=2.00] [line cap=ROUND] [dash array={4.00}]}] [fill={[type=SOLID] [color=#FFFF00]}] [cx=380.00] [cy=25.00] [r=10.00]
    1013      RenderSVGText {text} at (100,257) size 280x28 contains 1 chunk(s)
    1114        RenderSVGInlineText {#text} at (0,0) size 280x28
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.2-Tiny/struct-use-recursion-03-t-expected.txt

    r110676 r110692  
    44  RenderSVGRoot {svg} at (0,0) size 800x600
    55    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
    6     RenderSVGContainer {g} at (166,25) size 484x452
    7       RenderSVGContainer {g} at (616,25) size 34x34
    8         RenderSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
     6    RenderSVGContainer {g} at (148,25) size 502x452
     7      RenderSVGContainer {g} at (148,25) size 502x77
     8        RenderSVGContainer {use} at (148,64) size 37x38 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
     9          RenderSVGContainer {g} at (148,64) size 37x38
     10            RenderSVGPath {circle} at (148,64) size 37x38 [stroke={[type=SOLID] [color=#808080] [stroke width=2.00] [line cap=ROUND] [dash array={4.00}]}] [fill={[type=SOLID] [color=#FF7F00]}] [cx=100.00] [cy=25.00] [r=10.00]
     11            RenderSVGContainer {g} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
    912        RenderSVGPath {circle} at (616,25) size 34x34 [fill={[type=SOLID] [color=#FFFF00]}] [cx=380.00] [cy=25.00] [r=10.00]
    1013      RenderSVGText {text} at (100,257) size 280x28 contains 1 chunk(s)
  • trunk/LayoutTests/svg/W3C-SVG-1.2-Tiny/struct-use-recursion-01-t.svg

    r110676 r110692  
    11<?xml version="1.0" encoding="UTF-8"?>
    2 <svg version="1.2" baseProfile="tiny" xml:id="svg-root" width="100%" height="100%"
     2<svg version="1.2" baseProfile="tiny" id="svg-root" width="100%" height="100%"
    33  viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg"
    44  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xe="http://www.w3.org/2001/xml-events">
     
    2222    </d:OperatorScript>
    2323  </SVGTestCase>
    24   <title xml:id="test-title">$RCSfile: struct-use-recursion-01-t.svg,v $</title>
     24  <title id="test-title">$RCSfile: struct-use-recursion-01-t.svg,v $</title>
    2525  <defs>
    2626    <font-face
     
    3232    </font-face>
    3333  </defs>
    34   <g xml:id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
     34  <g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
    3535
    36     <g xml:id="group-1">
    37       <circle xml:id="circle-1" cx='100' cy='25' r='10' fill='#FF7F00' />
    38       <use xml:id="use-1" x="0" y="25" xlink:href="#group-2" stroke="gray" stroke-width="2" stroke-dasharray="4" stroke-linecap="round"/>
     36    <g id="group-1">
     37      <circle id="circle-1" cx='100' cy='25' r='10' fill='#FF7F00' />
     38      <use id="use-1" x="0" y="25" xlink:href="#group-2" stroke="gray" stroke-width="2" stroke-dasharray="4" stroke-linecap="round"/>
    3939    </g>
    40     <g xml:id="group-2">
    41       <circle xml:id="circle-2" cx='380' cy='25' r='10' fill='#FFFF00' />
    42       <use xml:id="use-2" x="0" y="25"  xlink:href="#group-1" stroke="gray" stroke-width="2" stroke-dasharray="4" stroke-linecap="round"/>
     40    <g id="group-2">
     41      <circle id="circle-2" cx='380' cy='25' r='10' fill='#FFFF00' />
     42      <use id="use-2" x="0" y="25"  xlink:href="#group-1" stroke="gray" stroke-width="2" stroke-dasharray="4" stroke-linecap="round"/>
    4343    </g>
    4444
    45     <text xml:id="pass" x="240" y="280" text-anchor="middle" fill="green" font-size="24">This text should be visible.</text>
     45    <text id="pass" x="240" y="280" text-anchor="middle" fill="green" font-size="24">This text should be visible.</text>
    4646
    4747  </g>
    4848  <g font-family="SVGFreeSansASCII,sans-serif" font-size="32">
    49     <text xml:id="revision" x="10" y="340" stroke="none"
     49    <text id="revision" x="10" y="340" stroke="none"
    5050      fill="black">$Revision: 1.5 $</text>
    5151  </g>
    52   <rect xml:id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
     52  <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
    5353
    5454</svg>
  • trunk/LayoutTests/svg/W3C-SVG-1.2-Tiny/struct-use-recursion-02-t.svg

    r110676 r110692  
    11<?xml version="1.0" encoding="UTF-8"?>
    2 <svg version="1.2" baseProfile="tiny" xml:id="svg-root" width="100%" height="100%"
     2<svg version="1.2" baseProfile="tiny" id="svg-root" width="100%" height="100%"
    33  viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg"
    44  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xe="http://www.w3.org/2001/xml-events">
     
    2525    </d:OperatorScript>
    2626  </SVGTestCase>
    27   <title xml:id="test-title">$RCSfile: struct-use-recursion-02-t.svg,v $</title>
     27  <title id="test-title">$RCSfile: struct-use-recursion-02-t.svg,v $</title>
    2828  <defs>
    2929    <font-face
     
    3535    </font-face>
    3636  </defs>
    37   <g xml:id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
     37  <g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
    3838
    39     <g xml:id="group-1">
    40       <circle xml:id="circle-1" cx='100' cy='25' r='10' fill='#FF7F00' />
    41       <use xml:id="use-1" x="0" y="25" xlink:href="struct-use-recursion-03-t.svg#group-2" stroke="gray" stroke-width="2" stroke-dasharray="4" stroke-linecap="round"/>
     39    <g id="group-1">
     40      <circle id="circle-1" cx='100' cy='25' r='10' fill='#FF7F00' />
     41      <use id="use-1" x="0" y="25" xlink:href="struct-use-recursion-03-t.svg#group-2" stroke="gray" stroke-width="2" stroke-dasharray="4" stroke-linecap="round"/>
    4242    </g>
    4343
    44     <text xml:id="pass" x="240" y="280" text-anchor="middle" fill="green" font-size="24">This text should be visible.</text>
     44    <text id="pass" x="240" y="280" text-anchor="middle" fill="green" font-size="24">This text should be visible.</text>
    4545
    4646  </g>
    4747  <g font-family="SVGFreeSansASCII,sans-serif" font-size="32">
    48     <text xml:id="revision" x="10" y="340" stroke="none"
     48    <text id="revision" x="10" y="340" stroke="none"
    4949      fill="black">$Revision: 1.5 $</text>
    5050  </g>
    51   <rect xml:id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
     51  <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
    5252
    5353</svg>
  • trunk/LayoutTests/svg/W3C-SVG-1.2-Tiny/struct-use-recursion-03-t.svg

    r110676 r110692  
    11<?xml version="1.0" encoding="UTF-8"?>
    2 <svg version="1.2" baseProfile="tiny" xml:id="svg-root" width="100%" height="100%"
     2<svg version="1.2" baseProfile="tiny" id="svg-root" width="100%" height="100%"
    33  viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg"
    44  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xe="http://www.w3.org/2001/xml-events">
     
    2525    </d:OperatorScript>
    2626  </SVGTestCase>
    27   <title xml:id="test-title">$RCSfile: struct-use-recursion-03-t.svg,v $</title>
     27  <title id="test-title">$RCSfile: struct-use-recursion-03-t.svg,v $</title>
    2828  <defs>
    2929    <font-face
     
    3535    </font-face>
    3636  </defs>
    37   <g xml:id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
     37  <g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
    3838
    39     <g xml:id="group-2">
    40       <use xml:id="use-2" x="0" y="25"  xlink:href="struct-use-recursion-02-t.svg#group-1" stroke="gray" stroke-width="2" stroke-dasharray="4" stroke-linecap="round"/>
    41       <circle xml:id="circle-2" cx='380' cy='25' r='10' fill='#FFFF00' />
     39    <g id="group-2">
     40      <use id="use-2" x="0" y="25"  xlink:href="struct-use-recursion-02-t.svg#group-1" stroke="gray" stroke-width="2" stroke-dasharray="4" stroke-linecap="round"/>
     41      <circle id="circle-2" cx='380' cy='25' r='10' fill='#FFFF00' />
    4242    </g>
    4343
    44     <text xml:id="pass" x="240" y="280" text-anchor="middle" fill="green" font-size="24">This text should be visible.</text>
     44    <text id="pass" x="240" y="280" text-anchor="middle" fill="green" font-size="24">This text should be visible.</text>
    4545
    4646  </g>
    4747  <g font-family="SVGFreeSansASCII,sans-serif" font-size="32">
    48     <text xml:id="revision" x="10" y="340" stroke="none"
     48    <text id="revision" x="10" y="340" stroke="none"
    4949      fill="black">$Revision: 1.5 $</text>
    5050  </g>
    51   <rect xml:id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
     51  <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
    5252
    5353</svg>
  • trunk/Source/WebCore/ChangeLog

    r110691 r110692  
     12012-03-14  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        External <use> xlink:href references do not work
     4        https://bugs.webkit.org/show_bug.cgi?id=12499
     5
     6        Reviewed by Zoltan Herczeg.
     7
     8        Follow-up fix after r110676.
     9        Assertions are firing due last minute changes in isExternalURIReference.
     10
     11        Fix detecting local resources properly, when the given iri contains a /complex/path.
     12        Use document->completeURL() instead, and compare with the document->url() to decide
     13        if its a local reference or not.
     14
     15        If an external document load fails with an error (eg. file missing) don't assert
     16        in debug builds, instead handle it gracefully.
     17
     18        I decided to clean the code up as well, to make it more safe & obvious.
     19
     20        Test: svg/custom/use-external-crash.svg
     21
     22        * svg/SVGURIReference.cpp:
     23        (WebCore::SVGURIReference::targetElementFromIRIString):
     24        * svg/SVGURIReference.h:
     25        (WebCore::SVGURIReference::isExternalURIReference):
     26        * svg/SVGUseElement.cpp:
     27        (WebCore::SVGUseElement::externalDocument):
     28        (WebCore::SVGUseElement::buildPendingResource):
     29
    1302012-03-14  Lars Knudsen  <lars.knudsen@nokia.com>
    231
  • trunk/Source/WebCore/svg/SVGURIReference.cpp

    r110676 r110692  
    8888        return 0;
    8989
    90     // If we're requesting an external resources, and externalDocument is non-zero, the load already succeeded.
    91     // Go ahead and check if the externalDocuments URL matches the expected URL, that we resolved using the
    92     // host document before in urlFromIRIStringWithFragmentIdentifier(). For internal resources, the same
    93     // assumption must hold true, just with the host documents URL, not the external documents URL.
    94     if (!equalIgnoringFragmentIdentifier(url, externalDocument ? externalDocument->url() : document->url()))
    95         return 0;
    96 
    9790    if (fragmentIdentifier)
    9891        *fragmentIdentifier = id;
     
    10194        return 0;
    10295
    103     if (externalDocument)
     96    if (externalDocument) {
     97        // Enforce that the referenced url matches the url of the document that we've loaded for it!
     98        ASSERT(equalIgnoringFragmentIdentifier(url, externalDocument->url()));
    10499        return externalDocument->getElementById(id);
     100    }
     101
     102    // Exit early if the referenced url is external, and we have no externalDocument given.
    105103    if (isExternalURIReference(iri, document))
    106         return 0; // Non-existing external resource
     104        return 0;
    107105
    108106    return document->getElementById(id);
  • trunk/Source/WebCore/svg/SVGURIReference.h

    r110676 r110692  
    4343    static Element* targetElementFromIRIString(const String&, Document*, String* = 0, Document* = 0);
    4444
    45     static inline bool isExternalURIReference(const String& uri, Document* baseDocument)
     45    static inline bool isExternalURIReference(const String& uri, Document* document)
    4646    {
    47         if (uri.startsWith("#"))
     47        // If the URI matches our documents URL, early exit, we're dealing with a local reference.
     48        ASSERT(document);
     49        KURL url = document->completeURL(uri);
     50        if (equalIgnoringFragmentIdentifier(url, document->url()))
    4851            return false;
    4952
    50         size_t startOfFragmentIdentifier = uri.find('#');
    51         // If the target document is the base document but its path is given in format href="thisDocument.svg#targetTag"
    52         // then we should handle it as internal.
    53         if (uri.substring(0, startOfFragmentIdentifier) != baseDocument->url().lastPathComponent())
    54             return true;
    55         return false;
     53        // If the URI doesn't contain a base string, just see if it starts with a fragment-identifier.
     54        return uri.find('#') != notFound;
    5655    }
    5756
  • trunk/Source/WebCore/svg/SVGUseElement.cpp

    r110676 r110692  
    199199{
    200200    if (m_cachedDocument && m_cachedDocument->isLoaded()) {
     201        // Gracefully handle error condition.
     202        if (m_cachedDocument->errorOccurred())
     203            return 0;
    201204        ASSERT(m_cachedDocument->document());
    202205        return m_cachedDocument->document();
     
    401404    Element* target = SVGURIReference::targetElementFromIRIString(href(), document(), &id, externalDocument());
    402405    if (!target) {
     406        // If we can't find the target of an external element, just give up.
     407        // We can't observe if the target somewhen enters the external document, nor should we do it.
     408        if (externalDocument())
     409            return;
    403410        if (hasPendingResources() || id.isEmpty())
    404411            return;
Note: See TracChangeset for help on using the changeset viewer.