W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2013

Re: [whatwg] Canvas - Should setLineDash be a nullable sequence?

From: Rik Cabanier <cabanier@gmail.com>
Date: Wed, 18 Sep 2013 11:14:32 -0700
Message-ID: <CAGN7qDB5UsS9UETt8FHaLW=m4nn6BfDYqLZzaa4DogqNnegSOA@mail.gmail.com>
To: Ian Hickson <ian@hixie.ch>
Cc: whatwg <whatwg@lists.whatwg.org>, Simon Sarris <simon.sarris@gmail.com>
On Tue, Sep 17, 2013 at 10:06 AM, Ian Hickson <ian@hixie.ch> wrote:

> On Tue, 20 Aug 2013, Simon Sarris wrote:
> >
> > This is minor, but it did recently break formerly-working functionality
> > in Google Chrome, so maybe its worth a discussion.
> >
> > The specification reads:
> >
> >   void setLineDash(sequence<unrestricted double> segments); // default
> empty
> >   sequence<unrestricted double> getLineDash();
> >
> > This means we *cannot* use:
> >
> > ctx.setLineDash(null);
> >
> > In Chrome 28 and previous (for at least 6 months) null was an allowed
> > value, but in Chrome 30 (at least) it switched to throwing a TypeError.
>
> I couldn't find any currently-shipping browsers that supported this, so it
> seems unlikely that there'd be much legacy content that depends on it.
> (Not saying there's none, just that it's limited in scope.) Thus, the
> compatibility issue here is not the only thing we should consider. (It's
> still a factor, just not an automatic win, as it might otherwise be.)
>
> There's certainly an advantage to failing if the input is "null" here --
> it's more likely to catch underlying errors quicker. Instead of just
> getting a solid line where you expected a dashed one, you get an error
> with a precise line number from which to start your search.
>
>
> > In any case, I think it would be better if setLineDash was defined in
> > the spec as a nullable sequence, so that when setting it back to nothing
> > to return to normal not-dashed path stroking (which could happen
> > thousands of times in a an animation frame) less stuff gets allocated in
> > the draw loop.
>
> A literal empty array can get optimised out by compilers, so it really
> shouldn't be that big a deal on the long run.
>
>
> > I think part of the issue is that setLineDash does two things. It sets
> > the dashing properties, but it also acts as the only way to
> > enable/disable dashing, I think that null seems appropriate.
>
> All lines are dashed, it's just that some have an infinitely long dash
> with no space. Don't look at it as enabling/disabling dashing. :-)
>

That's correct.
If we ever allow a 'null', we should equate it to '[]'
Received on Wednesday, 18 September 2013 18:15:06 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:09 UTC