W3C home > Mailing lists > Public > www-style@w3.org > August 2010

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

From: Anne van Kesteren <annevk@opera.com>
Date: Fri, 13 Aug 2010 11:48:17 +0200
To: "Ojan Vafai" <ojan@chromium.org>, "Robert O'Callahan" <robert@ocallahan.org>
Cc: www-style@w3.org, "Daniel Danilatos" <danilatos@google.com>, "Julie Parent" <jparent@chromium.org>, "Tony Chang" <tony@chromium.org>, "TAMURA, Kent" <tkent@chromium.org>, "Roland Steiner" <rolandsteiner@google.com>
Message-ID: <op.vhdeurvc64w2qv@anne-van-kesterens-macbook-pro.local>
On Sat, 01 May 2010 04:45:37 +0200, Robert O'Callahan  
<robert@ocallahan.org> wrote:
> On Sat, May 1, 2010 at 6:14 AM, Ojan Vafai <ojan@chromium.org> wrote:
>> On Wed, Feb 10, 2010 at 8:13 PM, Robert O'Callahan  
>> <robert@ocallahan.org>wrote:
>>> 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.
>>
>> Would it not be sufficient, in the case of a collapsed range to just  
>> act as if there is a textnode there?
>
> You mean an empty textnode?
>
> In some cases, such as inside tables, an empty textnode will not lead to  
> the construction of a CSS box, so you'll still get an empty list. Would  
> that be OK?

This thread never concluded in my inbox so I'm not sure what to do. :-)


-- 
Anne van Kesteren
http://annevankesteren.nl/
Received on Friday, 13 August 2010 09:48:58 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:30 GMT