MacViews: Convert Cocoa action messages into editing commands for text fields
On Mac, events need to be mapped to "Action" messages by an NSResponder
to obey platform behaviour and user customizations (e.g. a "Home"
keypress should be interpreted as beginning of document, not beginning
of line). Action messages are also the manner by which a user on Mac can
add custom keybindings, by making entries in
~/Library/KeyBindings/DefaultKeyBinding.dict
ActionMessages map well to editing commands for text fields, but not as
well for other controls. For example, MenuController needs to catch the
action message "cancel:" to handle the escape key.
The approach in this CL is for BridgedContentView, an NSResponder, to
map Action Messages to the editing command as well as the KeyCode that
toolkit-views expects for that action.
To test, textfield_unittests are updated to allow two kinds of event
dispatch. Before this CL, all the TextfieldTest views_unittests were
already passing on a toolkit-views Mac build. This is because the tests
send KeyCodes directly to the InputMethod rather than to the window.
However, this meant that action messages didn't come into play.
To test "real" keystrokes on Mac and get good coverage of the action
message overloads, the ui::test::EventGenerator is now used in
textfield_unittest.cc to generate platform-specific events that are
dispatched to the Window. Previously, all keyboard events were
redirected to the InputMethod.
BUG=378134
Review URL: https://codereview.chromium.org/
879253002
Cr-Commit-Position: refs/heads/master@{#314268}