On Android there are some special requirements about word selection. When the selection is to contain all white spaces, select an empty range instead to allow pasting. We also want to treat '.' as delimiters of words even when there is no space after the '.'.
Created attachment 172858 [details] Patch
It's surprising that we're doing this work in the WebKit layer. Most other OS-specific selection handling is done in the editing code.
Comment on attachment 172858 [details] Patch Marking r- for now based on the comment above.
Comment on attachment 172858 [details] Patch Yeah this definitely doesn’t belong in WebKit layer.
Created attachment 173067 [details] Patch
@rniwa: Would you be willing to review this patch? I'm unsure if this is the best way to add OS-specific behavior to visible selection.
Comment on attachment 173067 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=173067&action=review > Source/WebCore/editing/android/VisibleSelectionAndroid.cpp:51 > + // Don't expand beyond '.' for word granularity. > + VisiblePosition originalStart = m_start; > + validate(granularity); No, this is what you want to modify. You want to do this at much lower level by overriding ICU's behavior. Modify findNextWordFromIndex in TextBoundaries.cpp. You probably want to add TextBoundariesAndroid.cpp.
By the way, this won't work in CJK where 。is used as a substitute for period. I bet ICU has some options to tweak this. +xji for ICU expertise, and +ap, +mitz for word break iteration
(In reply to comment #7) > (From update of attachment 173067 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=173067&action=review > > > Source/WebCore/editing/android/VisibleSelectionAndroid.cpp:51 > > + // Don't expand beyond '.' for word granularity. > > + VisiblePosition originalStart = m_start; > > + validate(granularity); > > No, this is what you want to modify. You want to do this at much lower level by overriding ICU's behavior. > Modify findNextWordFromIndex in TextBoundaries.cpp. You probably want to add TextBoundariesAndroid.cpp. Per the requirements, all we want to change is the long press word selection behavior, but not other word breaking behavior. We can discuss the requirements offline.
(In reply to comment #10) > Per the requirements, all we want to change is the long press word selection behavior, but not other word breaking behavior. We can discuss the requirements offline. That's a very interesting requirement. With all due respect, I strongly recommend you to re-consider this feature and possibly get rid of it altogether. I don't know what's special about "." but changing the behavior of word breaking just for the purpose of long press doesn't sound like something we want to support in WebKit.