W3C home > Mailing lists > Public > public-html@w3.org > April 2011

Re: Working Group Decision on ISSUE-131 caret-location-api

From: Aryeh Gregor <Simetrical+w3c@gmail.com>
Date: Fri, 29 Apr 2011 13:20:48 -0400
Message-ID: <BANLkTinrV-_SM7FMa53heJk4JD2US6tmFQ@mail.gmail.com>
To: Benjamin Hawkes-Lewis <bhawkeslewis@googlemail.com>
Cc: Jonas Sicking <jonas@sicking.cc>, HTMLWG WG <public-html@w3.org>
On Fri, Apr 29, 2011 at 12:20 PM, Benjamin Hawkes-Lewis
<bhawkeslewis@googlemail.com> wrote:
> We could define some constants on the canvas context interface for use as
> arguments, as with Node.ELEMENT_NODE etc.
>
> Would that be better?

I personally think that arrays of strings are nicer.  Then they don't
have to be globally unique, only unique per-function, so they can be
much shorter.  Thus you could have

    ctx.drawFocusRing(elem, 10, 20, ["canDrawCustom"])

if you want canDrawCustom enabled.  You could make the keyword shorter
if you liked, too.  Sadly, this matches no existing JS APIs I know of
-- they mostly require bitwise or'ing long named constants, as you
suggest.  I think this is an API style that only makes sense in
languages like C, which have no array literal syntax and prefer tiny
performance improvements over big usability improvements.  This kind
of thing is ridiculously verbose (not parameters, but it's the same
idea):

    if (node1.compareDocumentPosition(node2) &
(Node.DOCUMENT_POSITION_CONTAINS |
Node.DOCUMENT_POSITION_CONTAINED_BY)) {

But it's still better than boolean parameters.

(This is a bit of a tangent, though.)
Received on Friday, 29 April 2011 17:21:35 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:17:28 GMT