Re: [selection] extend() behavior when there is no range needs to be clarified

Implementation of Blink/WebKit checks whether anchor node is null or not.
If anchor node is null, Blink/WebKit sets both anchor and focus positions.

Not sure the reason why Blink/WebKit does so. The implementation is created
at least 6+ years ago.

I'm not sure which implementation is better for web devs, FireFox (error
for empty selection) or Blink/WebKit (collapse to specified position). It
seems the spec is written based on FireFox behavior.

If Selection.extend doesn't throw exception when selection is empty, we can
write:

if (event.buttons == 1 && event.shiftKey) {
   // We don't care selection is empty or not.
   getSelection().extend(positionFromPoint(event.location));
}

Anyway, it is bad for making web devs confusing, I file a bug for Blink.
We'll fix Selection.extend to follow current spec.

-yosi



On Sat, Jun 7, 2014 at 5:22 AM, Ryosuke Niwa <rniwa@apple.com> wrote:

> It's probably a bug in WebKit/Blink. Since we're already throwing other
> exceptions in some cases (e.g. INDEX_SIZE_ERR), we can probably change our
> engine behavior.
>
> yoshin: any opinions for blink?
>
> On Jun 6, 2014, at 11:31 AM, Ben Peters <Ben.Peters@microsoft.com> wrote:
>
> > I just filed this bug. Do we know of reasons why Chrome (Webkit?)
> doesn't throw an exception for this scenario? It seems confusing to web
> devs.
> >
> > Ben
> >
> >> -----Original Message-----
> >> From: bugzilla@jessica.w3.org [mailto:bugzilla@jessica.w3.org]
> >>
> >> https://www.w3.org/Bugs/Public/show_bug.cgi?id=26005
> >>
> >>            Bug ID: 26005
> >>           Summary: Selection.extend behavior when there is no range
> needs
> >>                    to be clarified
> >>           Product: WebAppsWG
> >>           Version: unspecified
> >>          Hardware: PC
> >>                OS: Windows NT
> >>            Status: NEW
> >>          Severity: normal
> >>          Priority: P2
> >>         Component: Selection API
> >>          Assignee: rniwa@webkit.org
> >>          Reporter: benjamp@microsoft.com
> >>        QA Contact: public-webapps-bugzilla@w3.org
> >>                CC: benjamp@microsoft.com, public-webapps@w3.org
> >>
> >> Today, the Selection API spec seems to say that if selection.rangeCount
> is 0,
> >> then selection.extend should throw an error and abort. This is true in
> Firefox,
> >> but not Chrome. In Chrome, it appears that a new collapsed range is
> created
> >> at the position specified in selection.extend. Without an error, it's
> possible a
> >> site might end up creating a selection when they think they're
> extending it.
> >> But errors in JS should be used sparingly. Not sure which of these makes
> >> more sense.
> >>
> >> --
> >> You are receiving this mail because:
> >> You are on the CC list for the bug.
> >
>
>

Received on Monday, 9 June 2014 01:26:32 UTC