Re: [whatwg] The srcset attribute - some implementation feedback & questions

On Sun, 22 Sep 2013 13:05:20 +0200, Yoav Weiss <yoav@yoav.ws> wrote:

> I've recently ported the WebKit srcset implementation into Blink, and
> pretty much rewrote it in the process.
>
> I'd like to provide some feedback and ask for clarifications, in order to
> improve the implementation's spec[1] compliance. Below I'll discuss the
> algorithm's step and points that I'd like clarifications on.
>
> Step 5
> ----------
> What happens when the srcset attribute is of the form "candidate1.png,
> candidate2.png 2x"?
> As far as I understand it, according to the spec it results in a single
> image candidate url "candidate1.png," followed by the descriptors
> "candidate2.png 2x",

Correct.

> which is probably not what the author intended.
> As a note, both WebKit & Blink implementations diverge from the spec  
> here,
> by adding a "check if the URL's last char is ',' and if so, continue
> without trying to parse out descriptors" step. This also enables the
> implementations to ignore empty candidates such as "candidate1.png 1x, ,  
> ,
> , , candidate2.png 2x".

Maybe we can change the spec to do that. If the author wants to use a URL  
with a comma at the end, it can be percent-escaped.

> A similar case of <img srcset="candidate1.png,candidate2.png 2x"> results
> in the image candidate URL being "candidate1.png,candidate2.png". Is that
> the correct behavior?

Yes.

> I'm not sure what should be the result here (since splitting on commas  
> will
> break data URIs), but I'm certain this will be a source of confusion for
> authors.
>
> Step 13.6
> ------------
> What happens when one of the valid qualifier characters is followed by
> other non qualifier chars? e.g.is "2xbla" a valid descriptor?

It doesn't match any of the three cases in that step, so it gets dropped  
on the floor.

> What happens when one of the valid qualifier characters is followed by
> another qualifier char? e.g.is "2xwh" a valid descriptor?

Same as above.

> Does it set all
> three variables to 2?

No.

> What happens to invalid descriptors? If I understand correctly, invalid
> descriptors should just be ignored so that "2x 500tt bla" will results  
> in a
> density of 2, width of infinity and height of infinity.
> Is that correct?

Yes.

Step 13.6. could say "Otherwise, do nothing", but that's implied.

> Yoav
>
> [1]
> http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-1.html#processing-the-image-candidates


-- 
Simon Pieters
Opera Software

Received on Monday, 23 September 2013 09:40:35 UTC