Bug 128589 - Percentage positioning inside SVG symbol
Summary: Percentage positioning inside SVG symbol
Status: RESOLVED DUPLICATE of bug 256702
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.9
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-02-11 01:45 PST by Pavel Manylov
Modified: 2023-06-01 12:24 PDT (History)
7 users (show)

See Also:


Attachments
screenshot: Firefox (top left, works properly), Chrome (right), latest WebKit (bottom left) (185.04 KB, image/png)
2014-02-11 01:45 PST, Pavel Manylov
no flags Details
Test case (1.02 KB, image/svg+xml)
2014-07-12 23:18 PDT, Dirk Schulze
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pavel Manylov 2014-02-11 01:45:08 PST
Created attachment 223828 [details]
screenshot: Firefox (top left, works properly), Chrome (right), latest WebKit (bottom left)

According to SVG specification: 
>> Additionally, there is a new meaning for percentage units defined to be relative to the current viewport since a new viewport has been established
>> …
>> A ‘symbol’ element define new viewports whenever they are instanced by a ‘use’ element.
>> http://www.w3.org/TR/SVG11/coords.html#EstablishingANewViewport"

However, in WebKit (latest WebKit, Safari, dev version of Google Chrome) positioning using percentage cause incorrect positioning relative to main <svg> element. Sometimes (as presented in attachment) elements with such positioning WebKit not renders at all, in latest Safari it renders element incorrectly and then removes rendered element.

On screenshot: Firefox (top left, works properly), Chrome (right), latest WebKit (bottom left).

Test SVG Document:

<svg xmlns='http://www.w3.org/2000/svg'
     xmlns:xlink = "http://www.w3.org/1999/xlink"
     width="100%"
     height="100%"
     viewBox = "0 0 1000 1000"
     preserveAspectRatio = "true">

<defs>
  <symbol id="blueCircle" viewBox="0 0 100 100">
    <circle cx="50" cy="50" r="50" style="fill: blue;"/>
  </symbol>

  <symbol id="mainItem" viewBox="0 0 100 100">
    <circle cx="50" cy="50" r="50" style="fill: yellow;"/>
    <use xlink:href="#blueCircle" height="10" width="10" x="45" y="45"/>
  </symbol>

  <symbol id="whoIsNowAMainItemHuh" viewBox="0 0 300 300">
    <use xlink:href="#mainItem" x="0" y="0" width="100" height="100"/>
    <use xlink:href="#mainItem" x="100" y="100" width="100" height="100"/>
    <!-- here % should be relative to the `use` of current `symbol` -->
    <use xlink:href="#mainItem" x="65%" y="65%" width="100" height="100"/>
  </symbol>
</defs>

<rect width="1000" height="1000" x="0" y="0" style="fill: green;"/>
<use xlink:href="#whoIsNowAMainItemHuh" width="600" height="600" x="100" y="100"/>


</svg>
Comment 1 Dirk Schulze 2014-07-12 23:18:58 PDT
Created attachment 234826 [details]
Test case
Comment 2 Ahmad Saleem 2022-07-10 11:55:58 PDT
I am able to reproduce this bug in Safari 15.5 on macOS 12.4 and Safari Technical Preview 148, it shows just two circles like in attached screenshot on attached test case. 

All other browsers (Chrome Canary 105 and Firefox Nightly 104) match each other and aligned with screenshot of showing three circles. Thanks!
Comment 3 Brent Fulgham 2022-07-15 16:50:57 PDT
Firefox and chrome handle this properly, Safari does not.
Comment 4 Radar WebKit Bug Importer 2022-07-15 16:51:09 PDT
<rdar://problem/97101092>
Comment 5 Ahmad Saleem 2023-06-01 05:50:32 PDT
Working fine now in WebKit ToT (264792@main) (but broken in STP171).
Comment 6 Said Abou-Hallawa 2023-06-01 12:24:06 PDT
This is fixed by the fix of bug 256702 (264596@main).

*** This bug has been marked as a duplicate of bug 256702 ***