W3C home > Mailing lists > Public > www-style@w3.org > May 2011

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

From: Ryosuke Niwa <rniwa@webkit.org>
Date: Thu, 12 May 2011 21:53:59 -0700
Message-ID: <BANLkTikZ=pWX_eBeoxfb3RVuNnwT0tyj0w@mail.gmail.com>
To: Andrew Fedoniouk <news@terrainformatica.com>
Cc: Ojan Vafai <ojan@chromium.org>, "Robert O'Callahan" <robert@ocallahan.org>, Julie Parent <jparent@chromium.org>, Eric Seidel <eseidel@chromium.org>, www-style@w3.org, Levi Weintraub <leviw@chromium.org>, Xiaomei Ji <xji@google.com>
On Thu, May 12, 2011 at 9:05 PM, Andrew Fedoniouk <andrew.fedoniouk@live.com
> wrote:
>  In general object that represents caret position in HTML should have
> following interface:

Where did you get this interface?  There are many flaws in this design.  To
name a few:

 interface CaretPosition
> {
>    bool atCharacter() ;
>         // true – character input at given position will not change DOM
> structure.
>         // false – the caret is positioned on “head” or “tail” of DOM
> element.

The method name and comment say two different things.

>     bool atTail() ;
>         // true – this is the “tail” position – either on the tail of DOM
> element
>         //        or on “after” edge of the character.
>         // false – this is the head position of the element or character.


    Element  currentElement();  // element containing the CP
>    TextNode currentTextNode();  // TextNode, valid if  atCharacter() ==
> true.

I don't think currentElement makes much sense.  If you're at <hr>|<br>, what
is the current element?  br because the position is before br?  But then
what would you do in the case of <div><hr>|</div>?

>     bool isLess( CaretPosition other ) // true if this position is less
> than other.
>    bool isLessVisual( CaretPosition other ) // true if this position
> visually less than other.

What does it mean to say X is visually less than Y?  Does that mean the
other appears before this position?  Is that in visual order?  Or in logical
order?  What if the text were oriented vertically?  What if X was in a
absolutely positioned div and Y was in another absolutely positioned div?

    bool isEqualTo( CaretPosition other ) // true if this position and other
> position
>                                          // will end up in the same
> rectangle on the canvas.

Why are we talking about canvas?  Also can't we just use == operator for
this?  Also, a position shouldn't be a rectangle.

    bool fromXY( coord x, coord y, ... )  // true if the position is set to
> closest one to x,y.

This method seems completely arbitrary and impossible to implement.  What
does it mean to say it's closest?  What should I return if multiple caret
positions are away from (x,y) with the same distance?

- Ryosuke
Received on Friday, 13 May 2011 04:54:47 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:45 UTC