Re: Coordinates with units

Daniel Holbert <[email protected]> Mon, 3 Apr 2017 08:28:33 -0700
Newsgroups gmane.comp.mozilla.devel.svg
Message-ID <[email protected]>
On 04/03/2017 02:10 AM, Christophe DANG NGOC CHAN wrote:
> I'm not sure this is the right mailing list so please redirect me if I'm at the wrong place.

Given that this is a possible-Firefox-bug (from your perspective as
someone encountering an issue), then this is one of two right places.

The other place would be in Mozilla's Bugzilla instance:
 https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&component=SVG

But here is fine too, for now.

> A length is a distance measurement, given as a number along with a unit which may be optional."
> 
> So, the following SVG code should be valid:
> 
> **********
[...]
> d="M0 0 L5cm 5cm"
> fill="none" stroke="black" stroke-width="1px"
> />

It looks like some of your markup got stripped out in your post (see
https://groups.google.com/forum/#!topic/mozilla.dev.tech.svg/E8-vuJvbabg
for what your post ended up looking like).  But I assume you were asking
about a <path> element there, and you're wondering: why do the "cm"
units make that path data invalid.

Is that what you're asking?

The values in the path data are not normal SVG 'length' values --
they're more restricted.  The syntax is given here, for path data:
https://www.w3.org/TR/SVG2/paths.html#TheDProperty

In particular, that spec section says: "All coordinates and lengths
specified within path data must be treated as being in user units in the
current user coordinate system."  ("user units" = unitless values)

> It is validated by https://validator.w3.org/

That site doesn't validate arbitrary attribute values, as far as I know.
It's more for basic validation stuff, like missing close tags.  So its
approval isn't relevant here.  For example, I just tested a document
with <svg width="fish">, and it validated correctly there, even though
"fish" is invalid for the width attribute.

> and is correctly displayed in other browsers,
> but *not* in Firefox 52.0.2 (under Windows 7) which shows an empty image.

That is surprising to me, but it's hard to investigate further since
your testcase's markup didn't make it into your post intact.

Could you link to an actual testcase hosted somewhere on the internet,
or post a demo on http://jsfiddle.net/ ?  (Note: you can just directly
write <svg>...</svg> in the HTML box there and it should just work.)  I
tried making your test code into a demo at
https://jsfiddle.net/k2hfdhdc/ , but Chrome renders it just like Firefox
does -- no path.