Picking an emoji via the emoji dialog (Ctrl+Cmd+Space) fires inconsistent beforeinput...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Aug 2017 05:12:56 +0000 (05:12 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Aug 2017 05:12:56 +0000 (05:12 +0000)
commitf82d3141f66120e604665e2e725089aee3a10417
tree644d73f0a065c4f4a9d4979a952d9749807f9658
parent63f9a7f47c232ddc31ad893f75673f8dedfe82e5
Picking an emoji via the emoji dialog (Ctrl+Cmd+Space) fires inconsistent beforeinput events.
https://bugs.webkit.org/show_bug.cgi?id=170955
<rdar://problem/31697653>

Reviewed by Ryosuke Niwa.

Source/WebKit:

Currently, we insert text with TextEventInputAutocompletion as the text event input type if any text range to
replace was specified by the platform. Instead, limit this only to when the text replacement range is not empty.
This more closely matches the intention of the spec, which states that the "insertReplacementText" inputType
should be used when "[replacing] existing text by means of a spell checker, auto-correct or similar".

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::insertTextAsync):

Source/WebKitLegacy/mac:

Tweak -insertText: to pass TextEventInputAutocompletion to Editor::insertText when inserting text, if existing
text is being replaced.

* WebView/WebHTMLView.mm:
(-[WebHTMLView insertText:]):

Tools:

Replace UIScriptController.insertText with UIScriptController.replaceTextAtRange, and implement
replaceTextAtRange in WebKit1. See corresponding layout tests (input-event-insert-replacement.html and
before-input-prevent-insert-replacement.html) for more detail.

* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
* DumpRenderTree/mac/AppKitTestSPI.h: Added.

Introduce an SPI header for private AppKit headers needed to support DumpRenderTree.

* DumpRenderTree/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::replaceTextAtRange):
(WTR::UIScriptController::insertText): Deleted.
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::replaceTextAtRange):
(WTR::UIScriptController::insertText): Deleted.
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::replaceTextAtRange):
(WTR::UIScriptController::insertText): Deleted.

Replace UIScriptController.insertText with UIScriptController.replaceTextAtRange, which better describes the
behavior of this function.

LayoutTests:

Augments two existing layout tests to check for additional cases of inserting text with replacement ranges.
Also enables this test for WebKit1 on Mac. Both these tests are currently enabled only for WebKit2, and also only
check the case where we're replacing an existing non-empty range of text.

* fast/events/before-input-prevent-insert-replacement-expected.txt:
* fast/events/before-input-prevent-insert-replacement.html:
* fast/events/input-event-insert-replacement-expected.txt:
* fast/events/input-event-insert-replacement.html:

Tests for cases of replacing existing text ranges, and inserting text at a position.

* platform/mac-wk1/TestExpectations:
* resources/ui-helper.js:

Add a new UIHelper function to insert text at a given replacement range. This codepath is taken when selecting
an emoji using the emoji picker menu on Mac, and also when selecting a dead key option after holding down on a
vowel key.

(window.UIHelper.replaceTextAtRange):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221234 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/before-input-prevent-insert-replacement-expected.txt
LayoutTests/fast/events/before-input-prevent-insert-replacement.html
LayoutTests/fast/events/input-event-insert-replacement-expected.txt
LayoutTests/fast/events/input-event-insert-replacement.html
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/resources/ui-helper.js
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
Tools/ChangeLog
Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
Tools/DumpRenderTree/mac/AppKitTestSPI.h [new file with mode: 0644]
Tools/DumpRenderTree/mac/UIScriptControllerMac.mm
Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm