Bug 201575

Summary: Option + arrow moves caret past whitespace on iOS
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: HTML EditingAssignee: Ryosuke Niwa <rniwa>
Status: REOPENED ---    
Severity: Normal CC: ap, commit-queue, darin, ews-watchlist, koivisto, megan_gardner, mifenton, repstein, webkit-bug-importer, wenson_hsieh, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 201531    
Attachments:
Description Flags
Fixes the bug
none
Fixed non-iOS builds
none
GTK build fix attempt
none
Another GTK build fix attempt
none
Yet another GTK build fix attempt
none
Fixed build more
none
Patch for landing none

Description Ryosuke Niwa 2019-09-06 22:10:53 PDT
See https://bugs.webkit.org/show_bug.cgi?id=201531.

This bug tracks the fix for the hardware keyboard.

<rdar://problem/51404664>
Comment 1 Ryosuke Niwa 2019-09-06 22:22:00 PDT
Created attachment 378278 [details]
Fixes the bug
Comment 2 Ryosuke Niwa 2019-09-06 22:48:31 PDT
Created attachment 378279 [details]
Fixed non-iOS builds
Comment 3 Ryosuke Niwa 2019-09-06 23:12:38 PDT
Created attachment 378282 [details]
GTK build fix attempt
Comment 4 Ryosuke Niwa 2019-09-06 23:21:58 PDT
Created attachment 378283 [details]
Another GTK build fix attempt
Comment 5 Ryosuke Niwa 2019-09-06 23:28:58 PDT
Created attachment 378284 [details]
Yet another GTK build fix attempt
Comment 6 Ryosuke Niwa 2019-09-09 13:01:04 PDT
Created attachment 378399 [details]
Fixed build more
Comment 7 Wenson Hsieh 2019-09-09 22:15:42 PDT
Comment on attachment 378399 [details]
Fixed build more

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

> Source/WebCore/ChangeLog:16
> +        are involed from author scripts.

Nit - involed => involved

> Source/WebCore/editing/VisibleUnits.cpp:772
> +    return findNextWordFromIndex(text, offset, NextWordDirection::Backward, iosMode);

Nit - maybe name the variable nextWordMode or whitespaceMode instead of iosMode? (Or perhaps more verbose — nextWordModeInIOS).

> Source/WebCore/editing/VisibleUnits.h:45
> +WEBCORE_EXPORT VisiblePosition nextWordPosition(const VisiblePosition &, NextWordModeInIOS = NextWordModeInIOS::LegacyStopBeforeWord);

Nit - might consider removing the extra space before the ampersand in `const VisiblePosition &`, while we’re touching this line.

> Source/WebCore/platform/text/TextBoundaries.h:51
> +    enum class NextWordDirection { Forward, Backward };

I usually use `enum class NextWordDirection : bool { ~ }` for these, but it doesn’t really matter since NextWordDirection isn’t stored anywhere.

> Source/WebCore/platform/text/TextBoundaries.h:52
> +    enum class NextWordModeInIOS { LegacyStopBeforeWord, StopAfterWord };

(Ditto with the bool enum class)
Comment 8 Ryosuke Niwa 2019-09-09 23:00:23 PDT
Thanks for the review.

(In reply to Wenson Hsieh from comment #7)
> Comment on attachment 378399 [details]
> Fixed build more
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=378399&action=review
> 
> > Source/WebCore/ChangeLog:16
> > +        are involed from author scripts.
> 
> Nit - involed => involved

Fixed.

> > Source/WebCore/editing/VisibleUnits.cpp:772
> > +    return findNextWordFromIndex(text, offset, NextWordDirection::Backward, iosMode);
> 
> Nit - maybe name the variable nextWordMode or whitespaceMode instead of
> iosMode? (Or perhaps more verbose — nextWordModeInIOS).

Will use nextWordModeInIOS. whitespaceMode isn't right because we consider delimiters such as "," as well.

> > Source/WebCore/editing/VisibleUnits.h:45
> > +WEBCORE_EXPORT VisiblePosition nextWordPosition(const VisiblePosition &, NextWordModeInIOS = NextWordModeInIOS::LegacyStopBeforeWord);
> 
> Nit - might consider removing the extra space before the ampersand in `const
> VisiblePosition &`, while we’re touching this line.

Sure, done.

> > Source/WebCore/platform/text/TextBoundaries.h:51
> > +    enum class NextWordDirection { Forward, Backward };
> 
> I usually use `enum class NextWordDirection : bool { ~ }` for these, but it
> doesn’t really matter since NextWordDirection isn’t stored anywhere.

Thanks for catching that. I always forget to specify the enum class' width. I've been coding too long in old C/C++ :(

> > Source/WebCore/platform/text/TextBoundaries.h:52
> > +    enum class NextWordModeInIOS { LegacyStopBeforeWord, StopAfterWord };
> 
> (Ditto with the bool enum class)

Fixed this one too.
Comment 9 Ryosuke Niwa 2019-09-09 23:01:23 PDT
Created attachment 378444 [details]
Patch for landing
Comment 10 Ryosuke Niwa 2019-09-09 23:27:06 PDT
Comment on attachment 378444 [details]
Patch for landing

Wait for EWS again.
Comment 11 Ryosuke Niwa 2019-09-10 02:36:51 PDT
Finally!
Comment 12 Ryosuke Niwa 2019-09-10 03:09:35 PDT
Comment on attachment 378444 [details]
Patch for landing

Ugh... wrong + :(
Comment 13 WebKit Commit Bot 2019-09-10 03:54:06 PDT
Comment on attachment 378444 [details]
Patch for landing

Clearing flags on attachment: 378444

Committed r249709: <https://trac.webkit.org/changeset/249709>
Comment 14 WebKit Commit Bot 2019-09-10 03:54:07 PDT
All reviewed patches have been landed.  Closing bug.
Comment 15 Russell Epstein 2019-09-13 09:53:36 PDT
Reverted r249709 for reason:

Layout test added in this patch has been consistently failing since it landed.

Committed r249838: <https://trac.webkit.org/changeset/249838>