Bug 209380 - Support inserting text or dictation alternative by simulating keyboard input
Summary: Support inserting text or dictation alternative by simulating keyboard input
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-03-21 16:54 PDT by Daniel Bates
Modified: 2020-07-21 10:57 PDT (History)
2 users (show)

See Also:


Attachments
Patch (20.93 KB, patch)
2020-03-21 17:16 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (20.93 KB, patch)
2020-03-21 17:17 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch and unit tests (20.08 KB, patch)
2020-03-21 23:01 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch and unit tests (20.08 KB, patch)
2020-03-21 23:02 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch and unit tests (20.09 KB, patch)
2020-03-21 23:34 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
To Land (20.18 KB, patch)
2020-03-23 13:57 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2020-03-21 16:54:00 PDT
Some web sites, like facebook.com or reddit.com, implement their own text editing system, which listens for DOM keyboard events or the DOM change event. When text corrections or dictation alternatives are inserted the behavior of the editor does not match what it would have done if a user manually typed the correction or alternative. For example, facebook.com listens for a DOM keyup event to hide the placeholder text shown in their fields. Towards having a good user experience, expose an insertion option that when enabled dispatches dummy keyboard and change events when performing a text insertion.
Comment 1 Daniel Bates 2020-03-21 16:54:05 PDT
<rdar://problem/59445102>
Comment 2 Daniel Bates 2020-03-21 17:16:42 PDT
Created attachment 394184 [details]
Patch
Comment 3 Daniel Bates 2020-03-21 17:17:30 PDT
Created attachment 394185 [details]
Patch
Comment 4 Daniel Bates 2020-03-21 20:18:56 PDT
Comment on attachment 394185 [details]
Patch

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

> Tools/TestWebKitAPI/cocoa/TestCocoa.h:45
> +// This is a template instead of a macro to support passing arguments written in Objective-C

Yikes, this will not preserve original expressions....doesn't look like there is an exposed way  to retrieve stringified values of the passed args in C++. So, going to go back to using a macro for this and just surround the array literals with parens
Comment 5 Daniel Bates 2020-03-21 23:01:23 PDT
Created attachment 394195 [details]
Patch and unit tests

Now EXPECT_NS_EQUAL is a macro, again
Comment 6 Daniel Bates 2020-03-21 23:02:52 PDT
Created attachment 394196 [details]
Patch and unit tests
Comment 7 Daniel Bates 2020-03-21 23:33:18 PDT
Comment on attachment 394196 [details]
Patch and unit tests

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

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4716
> +    [self _shouldSimulateKeyboardInputOnTextInsertionInternal];

r-, this is wrong.
Comment 8 Daniel Bates 2020-03-21 23:34:37 PDT
Created attachment 394197 [details]
Patch and unit tests
Comment 9 Darin Adler 2020-03-22 09:50:20 PDT
Comment on attachment 394197 [details]
Patch and unit tests

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

> Source/WebKit/Shared/Cocoa/InsertTextOptions.h:37
> +    bool simulateKeyboardInput { false };

As you know, Cocoa programming style suggests naming boolean properties in a way that disambiguates from a function that would take action. So shouldSimulateKeyboardInput because simulateKeyboardInput reads like a command that would do something immediately rather than a setting for what should be done.

We should consider that style for the booleans in this structure.
Comment 10 Daniel Bates 2020-03-23 13:57:36 PDT
Created attachment 394300 [details]
To Land
Comment 11 Daniel Bates 2020-03-23 13:58:18 PDT
Comment on attachment 394197 [details]
Patch and unit tests

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

Thanks for the review.

>> Source/WebKit/Shared/Cocoa/InsertTextOptions.h:37
>> +    bool simulateKeyboardInput { false };
> 
> As you know, Cocoa programming style suggests naming boolean properties in a way that disambiguates from a function that would take action. So shouldSimulateKeyboardInput because simulateKeyboardInput reads like a command that would do something immediately rather than a setting for what should be done.
> 
> We should consider that style for the booleans in this structure.

Renamed.
Comment 12 Daniel Bates 2020-03-23 14:00:05 PDT
Comment on attachment 394300 [details]
To Land

Clearing flags on attachment: 394300

Committed r258873: <https://trac.webkit.org/changeset/258873>
Comment 13 Daniel Bates 2020-03-23 14:00:07 PDT
All reviewed patches have been landed.  Closing bug.