RESOLVED FIXED 215647
Programmatic selection of text in a text field causes the highlight overlay to spill out
https://bugs.webkit.org/show_bug.cgi?id=215647
Summary Programmatic selection of text in a text field causes the highlight overlay t...
Simon Fraser (smfr)
Reported 2020-08-19 08:31:54 PDT
Testcase at <https://codepen.io/ShaneHudson/pen/bGpeVPG> shows an issue where the selection is not clipped to the bounds of the text input.
Attachments
Patch (29.53 KB, patch)
2020-08-23 13:31 PDT, Wenson Hsieh
darin: review+
Patch (29.73 KB, patch)
2020-08-23 15:19 PDT, Wenson Hsieh
no flags
Radar WebKit Bug Importer
Comment 1 2020-08-19 08:32:16 PDT
Simon Fraser (smfr)
Comment 2 2020-08-19 08:32:25 PDT
Wenson Hsieh
Comment 3 2020-08-19 08:35:32 PDT
This is likely because -[WKContentView _selectionClipRect] returns the null rect, since we're not showing any input view for a focused element.
Wenson Hsieh
Comment 4 2020-08-21 16:49:11 PDT
(Note: one way to work around this is to programmatically focus() the readonly input before calling select() on it)
Wenson Hsieh
Comment 5 2020-08-23 13:31:09 PDT
Darin Adler
Comment 6 2020-08-23 13:46:58 PDT
Comment on attachment 407080 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=407080&action=review > Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:796 > + auto selectionClipRect = [(UIView <UITextInputPrivate> *)contentView _selectionClipRect]; Casting to a type with a protocol without checking if the view implements the protocol seems peculiar. Normally we’d call respondsToProtocol in a case like this. Alternatively we could assert that and comment why we know it’s true. Or could leave it just like this if you prefer.
Wenson Hsieh
Comment 7 2020-08-23 14:49:36 PDT
Comment on attachment 407080 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=407080&action=review Thanks for the review! >> Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:796 >> + auto selectionClipRect = [(UIView <UITextInputPrivate> *)contentView _selectionClipRect]; > > Casting to a type with a protocol without checking if the view implements the protocol seems peculiar. Normally we’d call respondsToProtocol in a case like this. Alternatively we could assert that and comment why we know it’s true. Or could leave it just like this if you prefer. Sounds good — I'll add an assertion and comment here.
Wenson Hsieh
Comment 8 2020-08-23 15:19:59 PDT
EWS
Comment 9 2020-08-23 18:52:01 PDT
Committed r266051: <https://trac.webkit.org/changeset/266051> All reviewed patches have been landed. Closing bug and clearing flags on attachment 407082 [details].
Note You need to log in before you can comment on or make changes to this bug.