Re: [editing] Comments on WebKit addRange implementation

On Fri, Apr 5, 2013 at 4:48 PM, Nathan Vander Wilt <nate-lists@calftrail.com
> wrote:

> The comments on
> https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#dom-selection-addrange say
> "Chrome 15 dev seems to ignore addRange() if there's already a range."
>
> In case it's helpful, I wanted to note that this isn't quite the case. The
> WebKit implementation is here:
>
> http://trac.webkit.org/browser/trunk/Source/WebCore/page/DOMSelection.cpp#L385
>
> What that code does, if the selection has not already been cleared via
> e.g. `.removeAllRanges()`, is set the selection to the *intersection* of
> the old selection and range being "added".
>
> Why? I have no idea. Union or extension I could see; intersection just
> seems bizarre. Hopefully this information is useful, though — even if it
> seems really hard to reconcile spec-wise with other implementations. If
> WebKit/Blink can't be fixed, maybe the behaviour of `addRange(range)` is
> simply "undefined" if `rangeCount` is 1…
>
>
Webkit does use the union, that's what the VisiblePosition stuff is doing.

- E

Received on Friday, 12 April 2013 10:35:40 UTC