Bug 5240 - WebKit+SVG does not always display <use> tags correctly.
Summary: WebKit+SVG does not always display <use> tags correctly.
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Eric Seidel (no email)
URL: http://openclipart.org/clipart//compu...
Depends on:
Reported: 2005-10-02 20:10 PDT by Tobin Richard
Modified: 2005-10-08 03:18 PDT (History)
0 users

See Also:

Reduced example (355 bytes, text/plain)
2005-10-05 05:07 PDT, Julien Palmas
no flags Details
same file, but line 2 and 3 have been inverted. Working now (355 bytes, text/plain)
2005-10-05 10:54 PDT, Julien Palmas
no flags Details
Handle <use> that forward references (2.64 KB, patch)
2005-10-05 12:36 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Handle forward references correctly (1.38 KB, patch)
2005-10-06 00:30 PDT, Rob Buis
eric: review+
Details | Formatted Diff | Diff
Only one out of 2 <use> tags are rendered (1.85 KB, image/svg+xml)
2005-10-06 05:40 PDT, Julien Palmas
no flags Details
Expected result (2.58 KB, image/png)
2005-10-06 05:41 PDT, Julien Palmas
no flags Details
Final patch which I landed. (2.92 KB, patch)
2005-10-08 02:10 PDT, Eric Seidel (no email)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tobin Richard 2005-10-02 20:10:04 PDT
This is possibly a KSVG problem.

Some SVG images appear incomplete when displayed using Safari+SVG (latest build
from 2005-09-03).

Example 1: http://openclipart.org/clipart//computer/cpu_heatsink_fan_socket_.svg
should look like
http://openclipart.org/clipart//computer/cpu_heatsink_fan_socket_.png (note
missing side)

Example 2:
http://openclipart.org/clipart//unsorted/newspaper_aubanel_monnie_01.svg should
look like
http://openclipart.org/clipart//unsorted/newspaper_aubanel_monnie_01.png (note
missing text)
Comment 1 Eric Seidel (no email) 2005-10-02 23:38:35 PDT
The missing text is caused by:

The first example seems to be something else.  Not sure yet.
Comment 2 Julien Palmas 2005-10-05 05:07:05 PDT
Created attachment 4212 [details]
Reduced example

The problem comes from the <use> tag.
Comment 3 Eric Seidel (no email) 2005-10-05 09:55:31 PDT
This may have been related to memory fixes I made to KSVG::StyledElementImpl::attach()

            if (parentElement && parentElement->isStyled())
                    styledParent = static_cast<SVGStyledElementImpl *>(parentElement);
            if(styledParent && styledParent->canvasItem() && styledParent->allowAttachChildren(this))
            else if (styledParent && (styledParent->id() != ID_PATTERN)) {
                // FIXME: This exists until we can find a better way to create root && pattern nodes. -- ecs 
                delete m_canvasItem;
                m_canvasItem = NULL;
                //fprintf(stderr, "FAILED CANVAS INSERTION: <%s>\n", KDOM::DOMString(nodeName

Then again, it may not be related to that at all, since <use> shouldnt' have any children in this 
example.  We would have to talk with rwlbuis or WildFox to make sure.

It might also be worth checking this SVG in DrawTest (where you can scroll around), or reducing it 
further to not have such complicated transforms.  It's possible we're actually still drawing the <use> 
content, but outside the visible region.  I know we have some transformation bugs, possibly in <use> 
content too.
Comment 4 Julien Palmas 2005-10-05 10:54:16 PDT
Created attachment 4218 [details]
same file, but line 2 and 3 have been inverted. Working now

Actually, the <use> element works, but it needs to be written after the
reference element declaration in the source code.

Working example :
<rect width="10" height="10" fill="blue" id="myrect">
<use x="20" y="30" xlink:href="#myrect"/>

Wrong example :
<use x="20" y="30" xlink:href="#myrect"/>
<rect width="10" height="10" fill="blue" id="myrect">
Comment 5 Rob Buis 2005-10-05 12:35:01 PDT
First, a good bug find! 
I think the second example is not a <use> problem, but just 
indicating missing text support. Lets not make this all more 
complex than needed ;) 
I'll attach my current solution soon. 
Comment 6 Rob Buis 2005-10-05 12:36:06 PDT
Created attachment 4221 [details]
Handle <use> that forward references
Comment 7 Rob Buis 2005-10-06 00:30:29 PDT
Created attachment 4229 [details]
Handle forward references correctly

A cleaned up version.
Comment 8 Julien Palmas 2005-10-06 05:40:22 PDT
Created attachment 4231 [details]
Only one out of 2 <use> tags are rendered

Patch 4229 solved the first reduced example, but this new example is still not
rendered correctly.
Comment 9 Julien Palmas 2005-10-06 05:41:34 PDT
Created attachment 4232 [details]
Expected result
Comment 10 Eric Seidel (no email) 2005-10-08 02:08:40 PDT
Comment on attachment 4229 [details]
Handle forward references correctly

Looks good.  I made one small modification (moved the remove() out when doing
the delayed close, and instead added a clear() after all the closes).  I'll
post my fixed patch and land.
Comment 11 Eric Seidel (no email) 2005-10-08 02:10:03 PDT
Created attachment 4253 [details]
Final patch which I landed.