Re: [cssom-view] Range.getClientRects() when the range contains part of a grapheme cluster

On Sat, Apr 9, 2016 at 12:11 AM, Simon Pieters <simonp@opera.com> wrote:

>
> 3. What to do when the range contains part of a ligature.
>>
>
> Ligatures are typically (always?) split up for the purpose of text
> selection, and so should probably be split up in the same way in this API.
>

Agreed, so leave it undefined?

On Sat, Apr 9, 2016 at 10:28 PM, Xidorn Quan <quanxunzhen@gmail.com> wrote:

> On Sat, Apr 9, 2016 at 1:11 AM, Simon Pieters <simonp@opera.com> wrote:
>
>> On Thu, 07 Apr 2016 13:29:34 +0200, Koji Ishii <kojiishi@gmail.com>
>> wrote:
>>
>> We recently figured out that the spec[1] isn't clear when the range
>>> contains part of a grapheme cluster. Our behavior for the case was
>>> recently
>>> changed due to some other improvements, which lead to a discussion of the
>>> right behavior of getClientRects() and getBoundingClientRect().
>>>
>>> Could we define cases such as:
>>> 1. What to do when the range contains part of a grapheme cluster.
>>> 2. What to do when the range contains part of a surrogate pair.
>>>
>>
>> I think these two should cover the whole grapheme cluster.
>>
>
> In my opinion, a range should never contain only part of a surrogate pair.
> I'd suggest that browsers should force the range to be either cover the
> whole pair, or none of the parts. Containing part of surrogate pair makes
> no sense to me.
>

Agreed, I wish us to define when and how.

1. var range = document.createRange();
2. range.setStart(node, 0);
3. range.setEnd(node, 1);
4. var rects = range.getClientRects();

When the first code unit of the node is part of a grapheme cluster, when do
we extend the range? I can think 3 options:

a. Range is always adjusted to cover grapheme cluster, so at step 3.
b. Adjusted when particular operations are invoked, so at step 4.
c. Adjusted when particular operations are invoked, at step 4 internally,
but does not change the range itself.

I prefer option b at this moment, but I'm fine with option c if that looks
more useful. I'm not a big fan of option a because it's expensive.

/koji

Received on Sunday, 10 April 2016 04:06:30 UTC