Re: feedback requested: Canvas change for improved hit testing that also facilitates accessibility

On 4/5/2011 8:56 AM, Richard Schwerdtfeger wrote:
> - Have canvas manage a hierarchy of last drawn objects to manage the 
> hit test. That which is last drawn is on top in the canvas. So, if 
> there if one object's bounding path overlaps another it is the last 
> one drawn on top that receives the pointing event.
How are setLastDrawn and setClickableRegion reset?

Is it this?:
ctx.beginPath();
ctx.closePath();
ctx.setLastDrawn(elementToReset);

Is it necessary for the UA to perform hit-testing?

I'd prefer to make the data available to the AT, but not require much 
more from the UA than
to keep lists accessible by DOM, and send off the usual ARIA events.

When the user is working with the UA, pointer events can be handled by 
the scripting environment.

This is what I imagine practice would look like:

/* event sent to AT to get bounding box+element,  aria-d attribute set 
on element*/
if(ctx && 'setLastDrawn' in ctx) ctx.setLastDrawn(element);
/* aria-d attribute set on element, css used to position element */
else { element.setAttribute('aria-d', mySimpleClickablePath); 
element.style.left = ...; element.style.zIndex=1; }

<canvas onclick="myReplayPathChain( 
childNodes[...].d/aria-*..isPointInPath() .. element.click(event);">
<input type="checkbox" aria-d="M20,20 40,20...z" /> <!-- normalized svg 
path, 0,0 is from the element -->
</canvas>

Bounding boxes and shapes are exposed to the AT and motivated authors 
can do the same in fallback situations.
The aria-d path represented is not guaranteed to be be the same that the 
author provided hit testing responds to.

This maintains a clean separation between DOM and Canvas 2D,
serializing the relationship and allowing each to exist independently.

In the example, I'm using the aria-d attribute, as aria-* is a reserved 
namespace for AT data.



-Charles

Received on Tuesday, 5 April 2011 21:29:34 UTC