Re: [CSSOM] does CaretPosition need a "before/after" hint?

On Tue, May 10, 2011 at 10:58 PM, Robert O'Callahan <robert@ocallahan.org>wrote:

> On Wed, May 11, 2011 at 5:46 PM, Ryosuke Niwa <rniwa@webkit.org> wrote:
>
>> On Tue, May 10, 2011 at 10:20 PM, Robert O'Callahan <robert@ocallahan.org
>> > wrote:
>>>
>>> Right now, scripts can only access text in logical order (e.g. ABC 123
>>>> DEF is in logical order and FED 123 CBA is in visual order) and it seems
>>>> like adding this hint and exposing that to script will necessarily exposes
>>>> some information about the visual ordering of text. At that point, it seems
>>>> natural to expose a way to walk text in visual order.
>>>>
>>>
>>> I don't think we need to expose visual ordering or computed bidi levels
>>> to script for this flag to be useful. The most common way we use this flag
>>> is to compute accurate geometric caret positions. So we'd need a Web-exposed
>>> API to find a point or rectangle for a CaretPosition.
>>
>>
>> Same thing. Once you have a way to obtain point / rectangle for a
>> CaretPosition, then you can query that on each logical position in DOM to
>> figure out the visual order of text.
>>
>
> You can use the existing Range.getClientRects API to do that already.
>
>  The attachment flag may also be useful if you're trying to figure out
>>> whether to apply some command to the following text or the preceding text
>>> (or both).
>>
>>
>> I don't follow. Are you saying that some editing commands depend on this
>> flag?
>>
>
> If, for example, you wanted to do something to a word that contains the
> caret (e.g., show spelling corrections), and you had two adjacent words with
> the caret in the middle (e.g. Thai), then you could use the attachment hint
> to decide which word to operate on.
>

I think a binary flag is sufficient here. Ryosuke, are there use-cases
enabled by exposing bidi-level that the flag does not address?

Rob, do you have thoughts on what to name the flag? "attachment" is not
especially clear to me. WebKit uses "affinity", which isn't great either but
reads a bit better to me.

Received on Wednesday, 11 May 2011 17:21:39 UTC