Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-value] Fragment URLs #274

Closed
CJKu opened this issue Jul 6, 2016 · 7 comments
Closed

[css-value] Fragment URLs #274

CJKu opened this issue Jul 6, 2016 · 7 comments
Assignees

Comments

@CJKu
Copy link

CJKu commented Jul 6, 2016

https://lists.w3.org/Archives/Public/www-style/2016Jul/0025.html

While implementing fragment urls[1] inside gecko, I have come across a
behavior which can not find definition on the spec.

When a SVG use element[2] references to a graphic element(located in
another document) with a local-ref url. By referring behavior on most
modern browsers, I think the correct behavior is to resolve the local-ref
url by base of the referenced document.

Here is an example: ref-external.svg uses a rect in ref-resource.svg
ref-external.svg

<svg>
  <!-- draw in blue -->
  <linearGradient id="grad1 ">
    <stop offset="0.0" stop-color="blue"/>
  </linearGradient>

  <use xlink:href="ref-resource.svg#myrect">
</svg>

ref-resource.svg

<svg>
  <!-- draw in red -->
  <linearGradient id="grad1 ">
    <stop offset="0.0" stop-color="red"/>
  </linearGradient>

  <rect id="myrect" x="200" y="125" width="200" height="125" stroke="none"
fill="url(#grad1)" />
</svg>

While rendering ref-external.svg, I would expect(can be wrong) seeing a
red rectangle on the screen, since url(#radialGrad1) will be resolved as
http://.../ref-source.svg#grad1
not
http://.../ref-external.svg#grad1.

Have clear definition of how resolving local-ref of
an anonymous clones element is super useful.

[1] https://drafts.csswg.org/css-values/#local-urls
[2] https://svgwg.org/svg2-draft/struct.html#UseElement

@tabatkins tabatkins self-assigned this Jul 6, 2016
@fantasai
Copy link
Collaborator

I think this should be clarified by the SVG spec defining .

@nikosandronikos
Copy link
Member

nikosandronikos commented Jul 21, 2016

@AmeliaBR has a massive PR (w3c/svgwg#206) waiting to be merged that totally rewrites the sections of SVG 2 that deal with the use element. We'll be discussing the PR this week during the telcon and will hopefully merge after that.

You can see the built spec on this branch:
https://ameliabr.github.io/svgwg/build/publish/struct.html#UseElement

This issue appears to be clarified there in the following text:

If the referenced element is in an external file, then all URL references in attributes and style properties must be made absolute (relative to the base URL of the source file) before copying the value to the element instances. The shadow tree itself uses the same base URL as the document that includes it.

@AmeliaBR
Copy link
Contributor

Yes, this is exactly the sort of situation I was considering when I added in that requirement. It will sometimes mean that the URL references points back to the external file instead of to another cloned element in the shadow tree as an author might expect, but the final result should be the same.

@CJKu If you're working on the Gecko implementation, I would be glad to hear your feedback on the proposed new text. Do leave a comment on the PR (w3c/svgwg#206) if you can think of anything else that is undefined or problematic.

@fantasai
Copy link
Collaborator

fantasai commented Aug 2, 2016

Amelia, does that mean we can close this issue here? :)

~fantasai

@AmeliaBR
Copy link
Contributor

AmeliaBR commented Aug 2, 2016

Yes, I think we've got it covered. Close away, @fantasai !

Relevant paragraph of the SVG 2 editor's draft, soon to be in CR:

If the referenced element is in an external file, then all URL references in attributes and style properties must be made absolute as described in Generating the absolute URL, before copying the value to the element instances. The shadow tree itself uses the same document base URL as the document that includes it.

@fantasai
Copy link
Collaborator

fantasai commented Aug 2, 2016

Excellent!

@fantasai fantasai closed this as completed Aug 2, 2016
@ByteEater-pl
Copy link

Should be "resource", not "file".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants