setDrawingFor proposal - was Re: correct and incorrect uses of canvas

On 7/14/2011 1:40 PM, Jonas Sicking wrote:
> So I do think we need to add some sort of API which lets you declare a
> region on the canvas which can be used for hit testing. Possibly do
...
> Ideally setting the area covered by one of these regions should be
> easy to set while performing one or more drawing operations.
>
> Adding something like:
>
> interface CanvasRenderingContext2D {
> ...
>    void setDrawingFor(in Element target);
>    void clearRegionFor(in Element target);
>    void clearAllRegions();
> ...
> };
>
...
> Removing an element from the DOM contained inside the canvas, for
> example using removeChild, would act as if clearRegionFor had been
> called with that element passed in. Calling setDrawingFor(null) would
> allow drawing things that should not be associated with any element.

I'm not sure I understand that final semantic. I believe it needs to be 
associated with -some- object,
even if it's an object not in the DOM. The closest I can think of would 
be assigning it to an object
created-on-execution in the shadow DOM. Still.. it's a little confusing. 
So, let me know what you're thinking of there.

> Once a region has been associated with an element, it would act
> similarly to how a<label>  acts. So clicking that region would
> dispatch a "click" event to the element and hovering it would dispatch
> "mouseover" etc.

Sounds straightforward to me.

> There are of course lots of unanswered questions, such as if focus
> outlines should automatically be drawn by the UA if an element with an
> associated region is focused. But the above might be a start.

We have drawFocusRing for that one. Authors should setup onfocus events,
and then run drawFocusRing. It does seem that it'd be -easier- if they could
from the setDrawingFor, but I don't know that it's a necessity.

The UA/AT itself can do what it will, and it could use setDrawingFor as 
a fallback,
when drawFocusRing is not called. Is that something we need to specify, 
or is
that something the implementors can decide on their own?

What other unanswered questions do we have?

I believe that we do want a "z-index" setting. It may only apply
relative to elements in the canvas itself, but it's certainly something 
I'd want to see
both in the accessibility tree and in the hit testing.


-Charles

Received on Friday, 19 August 2011 00:07:05 UTC