Re: [CSSOM] getClientRects should work on collapsed ranges in elements

On Thu, Feb 11, 2010 at 1:48 PM, Ojan Vafai <ojan@chromium.org> wrote:

> Given the following DOM and default CSS styling:
> <div><span></span><textnode>foo</textnode></div>
>
> I think it makes sense that getClientRects would return the same result for
> the following ranges as they all correspond to the same visible position
> (e.g. when a text input caret is there):
> 1. startNode: div, startOffset: 0
> 2. startNode: span, startOffset: 0
> 3. startNode: textnode, startOffset: 0
>
> With the current spec 1 and 2 return the empty list and 3 returns a
> zero-width rect. They should all return a zero-width rect with the same
> values, which matches IE (in the cases where IE TextRanges can represent the
> same Range).
>
> The only use-case I can think of for getClientRects is to get the position
> of the Selection for putting up context-specific menus. This makes the API
> hard to use if code needs to first ensure that the endpoints are in
> textnodes (e.g. in the empty span case, the code would need to first insert
> a text node).


To me, this sounds quite hard to specify in a principled way. Have you got
proposed spec text? If the spec text ends up complicated and somewhat
arbitrary, then I think the complexity belongs in author scripts, since
different authors might want to do it different ways.

Rob
-- 
"He was pierced for our transgressions, he was crushed for our iniquities;
the punishment that brought us peace was upon him, and by his wounds we are
healed. We all, like sheep, have gone astray, each of us has turned to his
own way; and the LORD has laid on him the iniquity of us all." [Isaiah
53:5-6]

Received on Thursday, 11 February 2010 03:14:03 UTC