Bug 86649

Summary: isStartOfDocument and isEndOfDocument are poorly named
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: HTML EditingAssignee: Ryosuke Niwa <rniwa>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, dglazkov, eae, enrica, leviw, mnaganov, ojan, webkit.review.bot, xji
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 82875    
Bug Blocks:    
Attachments:
Description Flags
Renames isEndOfDocument and adds fixed versions functions
none
Removed erroneous change in FrameSelection
none
Fixed builds
none
Put back the missing changes leviw: review+

Description Ryosuke Niwa 2012-05-16 10:16:14 PDT
bool isStartOfDocument(const VisiblePosition &p)
{
    return p.isNotNull() && p.previous().isNull();
}

bool isEndOfDocument(const VisiblePosition &p)
{
    return p.isNotNull() && p.next().isNull();
}

These functions are extremely poorly named. They don't check whether we're at the end of a document at all. They check whether we're at an editing boundary or not.
Comment 1 Ryosuke Niwa 2012-05-18 17:15:16 PDT
I'm fixing isStartOfDocument and isEndOfDocument to cross editing boundary and adding isEndOfEditableOrNonEditableContent which does what isEndOfDocument used to do.

After this change, selectFrameElementInParentIfFullySelected is the only client of isStartOfDocument and isEndOfDocument. The problem is that this function was added in http://trac.webkit.org/changeset/8942 without any tests without any tests. As far as I know, this function had been broken for ages (it only checked if the selection started and ended at the beginning and the end of the current editable region).

So I'm very inclined to just delete it altogether. If anything, we should probably support control selection on iframes per https://bugs.webkit.org/show_bug.cgi?id=12250.

Darin, what is your opinion on this?
Comment 2 Ryosuke Niwa 2012-05-18 17:47:51 PDT
Created attachment 142833 [details]
Renames isEndOfDocument and adds fixed versions functions
Comment 3 Ryosuke Niwa 2012-05-18 18:02:33 PDT
Created attachment 142836 [details]
Removed erroneous change in FrameSelection
Comment 4 Early Warning System Bot 2012-05-18 18:10:29 PDT
Comment on attachment 142836 [details]
Removed erroneous change in FrameSelection

Attachment 142836 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/12726614
Comment 5 WebKit Review Bot 2012-05-18 18:13:20 PDT
Comment on attachment 142836 [details]
Removed erroneous change in FrameSelection

Attachment 142836 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/12731052
Comment 6 Gyuyoung Kim 2012-05-18 19:27:02 PDT
Comment on attachment 142836 [details]
Removed erroneous change in FrameSelection

Attachment 142836 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/12732062
Comment 7 Ryosuke Niwa 2012-05-18 19:42:54 PDT
Comment on attachment 142836 [details]
Removed erroneous change in FrameSelection

View in context: https://bugs.webkit.org/attachment.cgi?id=142836&action=review

> Source/WebCore/editing/visible_units.cpp:-1379
> -bool isStartOfDocument(const VisiblePosition &p)
> -{
> -    return p.isNotNull() && p.previous().isNull();
> -}
> -
> -bool isEndOfDocument(const VisiblePosition &p)
> -{
> -    return p.isNotNull() && p.next().isNull();
> -}
> -

How odd. I shouldn't be removing these functions. Will fix.
Comment 8 Early Warning System Bot 2012-05-18 19:45:34 PDT
Comment on attachment 142836 [details]
Removed erroneous change in FrameSelection

Attachment 142836 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/12730070
Comment 9 Build Bot 2012-05-18 20:13:07 PDT
Comment on attachment 142836 [details]
Removed erroneous change in FrameSelection

Attachment 142836 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/12729275
Comment 10 Ryosuke Niwa 2012-05-18 20:59:59 PDT
Created attachment 142847 [details]
Fixed builds
Comment 11 Ryosuke Niwa 2012-05-18 21:02:12 PDT
For now, I kept selectFrameElementInParentIfFullySelected intact (in fact I'm probably fixing a bug in it).
Comment 12 Mikhail Naganov 2012-05-21 02:04:02 PDT
Comment on attachment 142847 [details]
Fixed builds

View in context: https://bugs.webkit.org/attachment.cgi?id=142847&action=review

> Source/WebCore/ChangeLog:10
> +        Also added new versions of isStartOfDocument and isEndOfDocument that correctly cross editing boundaries

Is this true? I don't see the new versions.
Comment 13 Ryosuke Niwa 2012-05-21 07:37:43 PDT
(In reply to comment #12)
> (From update of attachment 142847 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=142847&action=review
> 
> > Source/WebCore/ChangeLog:10
> > +        Also added new versions of isStartOfDocument and isEndOfDocument that correctly cross editing boundaries
> 
> Is this true? I don't see the new versions.

Ugh... my change in isStartOfDocument and isEndOfDocument have been lost.
Comment 14 Ryosuke Niwa 2012-05-21 09:39:07 PDT
Created attachment 143050 [details]
Put back the missing changes
Comment 15 Levi Weintraub 2012-05-21 10:58:52 PDT
Comment on attachment 143050 [details]
Put back the missing changes

View in context: https://bugs.webkit.org/attachment.cgi?id=143050&action=review

> Source/WebCore/ChangeLog:8
> +        isEndOfDocument to isEndOfEditableOrNonEditableContent because that's what this function checks.

I believe you're missing the word "Changed" at the beginning :)

> Source/WebCore/ChangeLog:11
> +        Also added new versions of isStartOfDocument and isEndOfDocument that correctly cross editing boundaries
> +        to be used in selectFrameElementInParentIfFullySelected.

Since you didn't create a isStartOfEditableOrNonEditableContent (man that's long) was isStartOfDocument just never used? Is isEndOfDocument still used after this patch?
Comment 16 Ryosuke Niwa 2012-05-21 11:02:20 PDT
Comment on attachment 143050 [details]
Put back the missing changes

View in context: https://bugs.webkit.org/attachment.cgi?id=143050&action=review

>> Source/WebCore/ChangeLog:11
>> +        to be used in selectFrameElementInParentIfFullySelected.
> 
> Since you didn't create a isStartOfEditableOrNonEditableContent (man that's long) was isStartOfDocument just never used? Is isEndOfDocument still used after this patch?

isEndOfDocument and isStartOfDocument are still used in selectFrameElementInParentIfFullySelected.
See my comment #1.
Comment 17 Emil A Eklund 2012-05-21 11:11:22 PDT
Comment on attachment 143050 [details]
Put back the missing changes

View in context: https://bugs.webkit.org/attachment.cgi?id=143050&action=review

> Source/WebCore/editing/visible_units.cpp:1400
> +bool isEndOfEditableOrNonEditableContent(const VisiblePosition &p)

This is still a pretty poor name. How about isAtEditableBoundary or even isAtEndOfEditableBoundary?
Comment 18 Ryosuke Niwa 2012-05-21 11:21:54 PDT
(In reply to comment #17)
> (From update of attachment 143050 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=143050&action=review
> 
> > Source/WebCore/editing/visible_units.cpp:1400
> > +bool isEndOfEditableOrNonEditableContent(const VisiblePosition &p)
> 
> This is still a pretty poor name. How about isAtEditableBoundary or even isAtEndOfEditableBoundary?

isAtEditableBoundary is inaccurate. isAtEndOfEditableBoundary doesn't make sense because an editing boundary is a point in DOM and a point/position doesn't have a start/end.
Comment 19 Emil A Eklund 2012-05-21 11:49:31 PDT
> isAtEditableBoundary is inaccurate. isAtEndOfEditableBoundary doesn't make sense because an editing boundary is a point in DOM and a point/position doesn't have a start/end.

Then what is isEndOfEditableOrNonEditableContent trying to communicate if it isn't a boundary? I'm confused.
Comment 20 Levi Weintraub 2012-05-21 11:49:50 PDT
Comment on attachment 143050 [details]
Put back the missing changes

View in context: https://bugs.webkit.org/attachment.cgi?id=143050&action=review

>> Source/WebCore/ChangeLog:8
>> +        isEndOfDocument to isEndOfEditableOrNonEditableContent because that's what this function checks.
> 
> I believe you're missing the word "Changed" at the beginning :)

Make this a sentence.

>>> Source/WebCore/editing/visible_units.cpp:1400
>>> +bool isEndOfEditableOrNonEditableContent(const VisiblePosition &p)
>> 
>> This is still a pretty poor name. How about isAtEditableBoundary or even isAtEndOfEditableBoundary?
> 
> isAtEditableBoundary is inaccurate. isAtEndOfEditableBoundary doesn't make sense because an editing boundary is a point in DOM and a point/position doesn't have a start/end.

I'm not in love with this name, but it's at least accurate in what it portrays :)
Comment 21 Ryosuke Niwa 2012-05-21 13:51:36 PDT
Committed r117813: <http://trac.webkit.org/changeset/117813>