Changeset 221234 in webkit


Ignore:
Timestamp:
Aug 27, 2017 10:12:56 PM (7 years ago)
Author:
Wenson Hsieh
Message:

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):

Location:
trunk
Files:
1 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r221232 r221234  
     12017-08-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Picking an emoji via the emoji dialog (Ctrl+Cmd+Space) fires inconsistent beforeinput events.
     4        https://bugs.webkit.org/show_bug.cgi?id=170955
     5        <rdar://problem/31697653>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Augments two existing layout tests to check for additional cases of inserting text with replacement ranges.
     10        Also enables this test for WebKit1 on Mac. Both these tests are currently enabled only for WebKit2, and also only
     11        check the case where we're replacing an existing non-empty range of text.
     12
     13        * fast/events/before-input-prevent-insert-replacement-expected.txt:
     14        * fast/events/before-input-prevent-insert-replacement.html:
     15        * fast/events/input-event-insert-replacement-expected.txt:
     16        * fast/events/input-event-insert-replacement.html:
     17
     18        Tests for cases of replacing existing text ranges, and inserting text at a position.
     19
     20        * platform/mac-wk1/TestExpectations:
     21        * resources/ui-helper.js:
     22
     23        Add a new UIHelper function to insert text at a given replacement range. This codepath is taken when selecting
     24        an emoji using the emoji picker menu on Mac, and also when selecting a dead key option after holding down on a
     25        vowel key.
     26
     27        (window.UIHelper.replaceTextAtRange):
     28
    1292017-08-27  Devin Rousso  <webkit@devinrousso.com>
    230
  • trunk/LayoutTests/fast/events/before-input-prevent-insert-replacement-expected.txt

    r208143 r221234  
    1 a
    2 Typing 'a'...
    3 (editable): type=beforeinput, inputType=insertText, data=`a`, dataTransfer=`null`
    4 (editable): type=input, inputType=insertText, data=`a`, dataTransfer=`null`
    5 Attempting to replace 'a' with 'b'...
    6 (editable): type=beforeinput, inputType=insertReplacementText, data=`null`, dataTransfer=`plain:"b", html:"b"`
     1To manually test, press and hold down 'a' and select one of the accented characters.
     2You should observe that the replacement accented character does not replace 'a'.
     3Then insert an emoji using the emoji picker. This should insert something into the editor.
     4Finally, select all the content and attempt to replace it with an emoji. This should do nothing.
     5ac
     6(1) Typing 'a'...
     7(editable): type=beforeinput, inputType=insertText, data=a, dataTransfer=(null)
     8(editable): type=input, inputType=insertText, data=a, dataTransfer=(null)
     9The editor now has text content: a
     10(2) Preventing default when replacing 'a' with 'b'...
     11(editable): type=beforeinput, inputType=insertReplacementText, data=null, dataTransfer=plain:"b", html:"b"
     12The editor now has text content: a
     13(3) Inserting 'c' after 'a'...
     14(editable): type=beforeinput, inputType=insertText, data=c, dataTransfer=(null)
     15(editable): type=input, inputType=insertText, data=c, dataTransfer=(null)
     16The editor now has text content: ac
     17(4) Selecting all and preventing replacement with 'd'...
     18(editable): type=beforeinput, inputType=insertReplacementText, data=null, dataTransfer=plain:"d", html:"d"
     19The editor now has text content: ac
    720
  • trunk/LayoutTests/fast/events/before-input-prevent-insert-replacement.html

    r208143 r221234  
    11<!DOCTYPE html>
    22<html>
    3 <body>
    4     <div id="editable" onbeforeinput=handleInputEvent(event) oninput=handleInputEvent(event) contenteditable></div>
    5     <div id="output"></div>
    6     <script type="text/javascript">
    7         let write = s => output.innerHTML += s + "<br>";
    8         var progress = 0;
    9         editable.focus();
     3<head>
     4<script src="../../resources/ui-helper.js"></script>
     5</head>
    106
    11         if (window.internals && window.testRunner) {
    12             internals.settings.setInputEventsEnabled(true);
    13             testRunner.dumpAsText();
    14             testRunner.waitUntilDone();
    15             if (window.eventSender && testRunner.runUIScript) {
    16                 write("Typing 'a'...");
    17                 eventSender.keyDown("a");
    18                 write("Attempting to replace 'a' with 'b'...");
    19                 testRunner.runUIScript(getUIScript(), (result) => incrementProgress());
    20             }
    21         } else {
    22             write("To manually test, press and hold down 'a' and select one of the accented characters.");
    23             write("You should observe that the replacement accented character does not replace 'a'.");
    24         }
     7<div>To manually test, press and hold down 'a' and select one of the accented characters.</div>
     8<div>You should observe that the replacement accented character does not replace 'a'.</div>
     9<div>Then insert an emoji using the emoji picker. This should insert something into the editor.</div>
     10<div>Finally, select all the content and attempt to replace it with an emoji. This should do nothing.</div>
     11<div id="editable" onbeforeinput=handleInputEvent(event) oninput=handleInputEvent(event) contenteditable></div>
     12<div id="output"></div>
    2513
    26         function incrementProgress()
    27         {
    28             progress++;
    29             if (progress == 2)
    30                 testRunner.notifyDone();
    31         }
     14<script type="text/javascript">
     15    let write = s => output.innerHTML += s + "<br>";
     16    editable.focus();
    3217
    33         function handleInputEvent(event)
    34         {
    35             write(`(${event.target.id}): type=${event.type}, inputType=${event.inputType}, data=\`${event.data}\`, dataTransfer=\`${dataTransferAsString(event.dataTransfer)}\``);
    36             if (event.inputType === "insertReplacementText") {
    37                 event.preventDefault();
    38                 incrementProgress();
    39             }
    40         }
     18    if (window.testRunner && window.eventSender && testRunner.runUIScript) {
     19        testRunner.dumpAsText();
     20        testRunner.waitUntilDone();
     21        runTest();
     22    }
    4123
    42         function dataTransferAsString(dataTransfer)
    43         {
    44             if (!dataTransfer)
    45                 return "null";
     24    async function runTest() {
     25        write("(1) Typing 'a'...");
     26        eventSender.keyDown("a");
     27        write(`The editor now has text content: ${editable.textContent}`);
     28        write("(2) Preventing default when replacing 'a' with 'b'...");
     29        await UIHelper.replaceTextAtRange("b", 0, 1)
     30        write(`The editor now has text content: ${editable.textContent}`);
     31        write("(3) Inserting 'c' after 'a'...");
     32        await UIHelper.replaceTextAtRange("c", 1, 0);
     33        write(`The editor now has text content: ${editable.textContent}`);
     34        write("(4) Selecting all and preventing replacement with 'd'...");
     35        document.execCommand("SelectAll")
     36        await UIHelper.replaceTextAtRange("d", 0, 2);
     37        write(`The editor now has text content: ${editable.textContent}`);
    4638
    47             return `plain:"${dataTransfer.getData('text/plain')}", html:"${dataTransfer.getData('text/html')}"`;
    48         }
     39        testRunner.notifyDone();
     40    }
    4941
    50         function getUIScript()
    51         {
    52             return `
    53             (function() {
    54                 uiController.insertText("b", 0, 1);
    55                 uiController.uiScriptComplete();
    56             })();`
    57         }
    58     </script>
     42    function handleInputEvent(event)
     43    {
     44        let dataTransferString = event.dataTransfer ? `plain:"${event.dataTransfer.getData('text/plain')}", html:"${event.dataTransfer.getData('text/html')}"` : "(null)";
     45        write(`(${event.target.id}): type=${event.type}, inputType=${event.inputType}, data=${event.data}, dataTransfer=${dataTransferString}`);
     46
     47        if (event.type === "beforeinput" && event.inputType === "insertReplacementText")
     48            event.preventDefault();
     49    }
     50</script>
    5951</body>
    6052</html>
  • trunk/LayoutTests/fast/events/input-event-insert-replacement-expected.txt

    r208143 r221234  
     1To manually test, press and hold down 'a' and select one of the accented characters."
     2You should observe a pair of beforeinput/input events for both 'a' and the replacement accented character."
     3Importantly, the inputType of these four events should be 'insertReplacementText'."
     4Then insert a single emoji character. You should observe beforeinput/input events for the inserted emoji."
     5Importantly, the inputType of these two events should be 'insertText'."
    16
    2 Typing 'a'...
    3 (editable): type=beforeinput, inputType=insertText, data=`a`, dataTransfer=`null`
    4 (editable): type=input, inputType=insertText, data=`a`, dataTransfer=`null`
     7(1) Typing 'a'...
     8(editable): type=beforeinput, inputType=insertText, data=a, dataTransfer=null
     9(editable): type=input, inputType=insertText, data=a, dataTransfer=null
    510The value of the input is now: a
     11(2) Replacing 'a' with 'b'...
     12(editable): type=beforeinput, inputType=insertReplacementText, data=b, dataTransfer=null
     13(editable): type=input, inputType=insertReplacementText, data=b, dataTransfer=null
     14The value of the input is now: b
     15(3) Inserting 'c' after 'b'...
     16(editable): type=beforeinput, inputType=insertText, data=c, dataTransfer=null
     17(editable): type=input, inputType=insertText, data=c, dataTransfer=null
     18The value of the input is now: bc
     19(4) Selecting all and replacing with 'd'...
     20(editable): type=beforeinput, inputType=insertReplacementText, data=d, dataTransfer=null
     21(editable): type=input, inputType=insertReplacementText, data=d, dataTransfer=null
     22The value of the input is now: d
    623
    7 Replacing 'a' with 'b'...
    8 (editable): type=beforeinput, inputType=insertReplacementText, data=`b`, dataTransfer=`null`
    9 (editable): type=input, inputType=insertReplacementText, data=`b`, dataTransfer=`null`
    10 The value of the input is now: b
    11 
  • trunk/LayoutTests/fast/events/input-event-insert-replacement.html

    r208143 r221234  
    11<!DOCTYPE html>
    22<html>
    3 <body>
    4     <input id="editable" onbeforeinput=logInputEvent(event) oninput=logInputEvent(event)></input>
    5     <div id="output"></div>
    6     <script type="text/javascript">
    7         let write = s => output.innerHTML += s + "<br>";
    8         var progress = 0;
    9         editable.focus();
     3<head>
     4<script src="../../resources/ui-helper.js"></script>
     5</head>
    106
    11         if (window.internals && window.testRunner) {
    12             internals.settings.setInputEventsEnabled(true);
    13             testRunner.dumpAsText();
    14             testRunner.waitUntilDone();
    15             if (window.eventSender && testRunner.runUIScript) {
    16                 write("Typing 'a'...");
    17                 eventSender.keyDown("a");
    18                 write(`The value of the input is now: ${editable.value}`);
    19                 write("");
    20                 write("Replacing 'a' with 'b'...");
    21                 testRunner.runUIScript(getUIScript(), (result) => incrementProgress());
    22             }
    23         } else {
    24             write("To manually test, press and hold down 'a' and select one of the accented characters.");
    25             write("You should observe a pair of beforeinput/input events for both 'a' and the replacement accented character.");
    26             write("Importantly, the inputType of the last two events should be 'insertReplacementText'.");
    27         }
     7<div>To manually test, press and hold down 'a' and select one of the accented characters."</div>
     8<div>You should observe a pair of beforeinput/input events for both 'a' and the replacement accented character."</div>
     9<div>Importantly, the inputType of these four events should be 'insertReplacementText'."</div>
     10<div>Then insert a single emoji character. You should observe beforeinput/input events for the inserted emoji."</div>
     11<div>Importantly, the inputType of these two events should be 'insertText'."</div>
    2812
    29         function incrementProgress()
    30         {
    31             progress++;
    32             if (progress != 5)
    33                 return;
     13<input id="editable" onbeforeinput=logInputEvent(event) oninput=logInputEvent(event)></input>
     14<div id="output"></div>
     15<script type="text/javascript">
     16    let write = s => output.innerHTML += s + "<br>";
     17    editable.focus();
     18    if (window.testRunner && window.eventSender && testRunner.runUIScript) {
     19        testRunner.dumpAsText();
     20        testRunner.waitUntilDone();
     21        runTest();
     22    }
    3423
    35             write(`The value of the input is now: ${editable.value}`);
    36             testRunner.notifyDone();
    37         }
     24    function logInputEvent(event)
     25    {
     26        write(`(${event.target.id}): type=${event.type}, inputType=${event.inputType}, data=${event.data}, dataTransfer=${event.dataTransfer}`);
     27    }
    3828
    39         function logInputEvent(event)
    40         {
    41             write(`(${event.target.id}): type=${event.type}, inputType=${event.inputType}, data=\`${event.data}\`, dataTransfer=\`${event.dataTransfer}\``);
    42             incrementProgress();
    43         }
     29    async function runTest() {
     30        write("(1) Typing 'a'...");
     31        eventSender.keyDown("a");
     32        write(`The value of the input is now: ${editable.value}`);
     33        write("(2) Replacing 'a' with 'b'...");
     34        await UIHelper.replaceTextAtRange("b", 0, 1);
     35        write(`The value of the input is now: ${editable.value}`);
     36        write("(3) Inserting 'c' after 'b'...");
     37        await UIHelper.replaceTextAtRange("c", 1, 0);
     38        write(`The value of the input is now: ${editable.value}`);
     39        write("(4) Selecting all and replacing with 'd'...");
     40        document.execCommand("SelectAll")
     41        await UIHelper.replaceTextAtRange("d", 0, 2);
     42        write(`The value of the input is now: ${editable.value}`);
    4443
    45         function getUIScript()
    46         {
    47             return `
    48             (function() {
    49                 uiController.insertText("b", 0, 1);
    50                 uiController.uiScriptComplete();
    51             })();`
    52         }
    53     </script>
    54 </body>
     44        testRunner.notifyDone();
     45    }
     46</script>
    5547</html>
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r221024 r221234  
    8585# WK1 and WK2 mousemove events are subtly different in ways that break this test on WK1.
    8686fast/events/ghostly-mousemoves-in-subframe.html [ Skip ]
    87 
    88 # Test support for inserting special characters is not yet implemented on WK1.
    89 fast/events/before-input-prevent-insert-replacement.html [ Skip ]
    90 fast/events/input-event-insert-replacement.html [ Skip ]
    9187
    9288# Media Stream API testing is not supported for WK1 yet.
  • trunk/LayoutTests/resources/ui-helper.js

    r221064 r221234  
    111111    }
    112112
     113    static replaceTextAtRange(text, location, length) {
     114        return new Promise(resolve => {
     115            testRunner.runUIScript(`(() => {
     116                uiController.replaceTextAtRange("${text}", ${location}, ${length});
     117                uiController.uiScriptComplete('Done');
     118            })()`, resolve);
     119        });
     120    }
     121
    113122    static wait(promise)
    114123    {
  • trunk/Source/WebKit/ChangeLog

    r221233 r221234  
     12017-08-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Picking an emoji via the emoji dialog (Ctrl+Cmd+Space) fires inconsistent beforeinput events.
     4        https://bugs.webkit.org/show_bug.cgi?id=170955
     5        <rdar://problem/31697653>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Currently, we insert text with TextEventInputAutocompletion as the text event input type if any text range to
     10        replace was specified by the platform. Instead, limit this only to when the text replacement range is not empty.
     11        This more closely matches the intention of the spec, which states that the "insertReplacementText" inputType
     12        should be used when "[replacing] existing text by means of a spell checker, auto-correct or similar".
     13
     14        * WebProcess/WebPage/WebPage.cpp:
     15        (WebKit::WebPage::insertTextAsync):
     16
    1172017-08-27  Wenson Hsieh  <wenson_hsieh@apple.com>
    218
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r221216 r221234  
    48444844    bool replacesText = false;
    48454845    if (replacementEditingRange.location != notFound) {
    4846         RefPtr<Range> replacementRange = rangeFromEditingRange(frame, replacementEditingRange, static_cast<EditingRangeIsRelativeTo>(editingRangeIsRelativeTo));
    4847         if (replacementRange) {
     4846        if (auto replacementRange = rangeFromEditingRange(frame, replacementEditingRange, static_cast<EditingRangeIsRelativeTo>(editingRangeIsRelativeTo))) {
    48484847            SetForScope<bool> isSelectingTextWhileInsertingAsynchronously(m_isSelectingTextWhileInsertingAsynchronously, suppressSelectionUpdate);
    48494848            frame.selection().setSelection(VisibleSelection(*replacementRange, SEL_DEFAULT_AFFINITY));
    4850             replacesText = true;
     4849            replacesText = replacementEditingRange.length;
    48514850        }
    48524851    }
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r221177 r221234  
     12017-08-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Picking an emoji via the emoji dialog (Ctrl+Cmd+Space) fires inconsistent beforeinput events.
     4        https://bugs.webkit.org/show_bug.cgi?id=170955
     5        <rdar://problem/31697653>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Tweak -insertText: to pass TextEventInputAutocompletion to Editor::insertText when inserting text, if existing
     10        text is being replaced.
     11
     12        * WebView/WebHTMLView.mm:
     13        (-[WebHTMLView insertText:]):
     14
    1152017-08-24  Chris Dumez  <cdumez@apple.com>
    216
  • trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm

    r220979 r221234  
    71557155#endif
    71567156
     7157    bool replacesText = false;
    71577158    if (replacementRange.location != NSNotFound) {
    71587159        WebRangeIsRelativeTo rangeIsRelativeTo = needToRemoveSoftSpace ? WebRangeIsRelativeTo::Paragraph : WebRangeIsRelativeTo::EditableRoot;
    7159         RefPtr<Range> domRange = [[self _frame] _convertToDOMRange:replacementRange rangeIsRelativeTo:rangeIsRelativeTo];
    7160         if (domRange)
     7160        if (auto domRange = [[self _frame] _convertToDOMRange:replacementRange rangeIsRelativeTo:rangeIsRelativeTo]) {
    71617161            coreFrame->selection().setSelection(VisibleSelection(*domRange, SEL_DEFAULT_AFFINITY));
     7162            replacesText = replacementRange.length;
     7163        }
    71627164    }
    71637165
     
    71727174            eventHandled = coreFrame->editor().insertDictatedText(eventText, dictationAlternativeLocations, event);
    71737175        else
    7174             eventHandled = coreFrame->editor().insertText(eventText, event);
     7176            eventHandled = coreFrame->editor().insertText(eventText, event, replacesText ? TextEventInputAutocompletion : TextEventInputKeyboard);
    71757177       
    71767178#if USE(INSERTION_UNDO_GROUPING)
  • trunk/Tools/ChangeLog

    r221233 r221234  
     12017-08-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Picking an emoji via the emoji dialog (Ctrl+Cmd+Space) fires inconsistent beforeinput events.
     4        https://bugs.webkit.org/show_bug.cgi?id=170955
     5        <rdar://problem/31697653>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Replace UIScriptController.insertText with UIScriptController.replaceTextAtRange, and implement
     10        replaceTextAtRange in WebKit1. See corresponding layout tests (input-event-insert-replacement.html and
     11        before-input-prevent-insert-replacement.html) for more detail.
     12
     13        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
     14        * DumpRenderTree/mac/AppKitTestSPI.h: Added.
     15
     16        Introduce an SPI header for private AppKit headers needed to support DumpRenderTree.
     17
     18        * DumpRenderTree/mac/UIScriptControllerMac.mm:
     19        (WTR::UIScriptController::replaceTextAtRange):
     20        (WTR::UIScriptController::insertText): Deleted.
     21        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
     22        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
     23        (WTR::UIScriptController::replaceTextAtRange):
     24        (WTR::UIScriptController::insertText): Deleted.
     25        * TestRunnerShared/UIScriptContext/UIScriptController.h:
     26        * WebKitTestRunner/mac/UIScriptControllerMac.mm:
     27        (WTR::UIScriptController::replaceTextAtRange):
     28        (WTR::UIScriptController::insertText): Deleted.
     29
     30        Replace UIScriptController.insertText with UIScriptController.replaceTextAtRange, which better describes the
     31        behavior of this function.
     32
    1332017-08-27  Wenson Hsieh  <wenson_hsieh@apple.com>
    234
  • trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj

    r218275 r221234  
    285285                2DA2E3A31E1BA54100A3BBD0 /* DumpRenderTreeSpellChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DumpRenderTreeSpellChecker.h; path = mac/DumpRenderTreeSpellChecker.h; sourceTree = "<group>"; };
    286286                2DA2E3A41E1BA54100A3BBD0 /* DumpRenderTreeSpellChecker.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DumpRenderTreeSpellChecker.mm; path = mac/DumpRenderTreeSpellChecker.mm; sourceTree = "<group>"; };
     287                2EDE0DAA1F5131DE00D5F8DF /* AppKitTestSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AppKitTestSPI.h; path = mac/AppKitTestSPI.h; sourceTree = "<group>"; };
    287288                31117B3A15D9A56A00163BC8 /* MockWebNotificationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MockWebNotificationProvider.h; path = mac/MockWebNotificationProvider.h; sourceTree = "<group>"; };
    288289                31117B3B15D9A56A00163BC8 /* MockWebNotificationProvider.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MockWebNotificationProvider.mm; path = mac/MockWebNotificationProvider.mm; sourceTree = "<group>"; };
     
    546547                        isa = PBXGroup;
    547548                        children = (
     549                                2EDE0DAA1F5131DE00D5F8DF /* AppKitTestSPI.h */,
    548550                                0F18E70E1D6BACB60027E547 /* UIScriptControllerMac.mm */,
    549551                        );
     
    604606                                BCA18B2F0C9B01B400114369 /* ObjCController.h */,
    605607                                BCA18B300C9B01B400114369 /* ObjCController.m */,
    606                                 F4D423601DD5046900678290 /* TextInputController.h */,
    607608                                BC0131D80C9772010087317D /* TestRunner.cpp */,
    608609                                BC0131D90C9772010087317D /* TestRunner.h */,
    609610                                BCA18B220C9B014B00114369 /* TestRunnerMac.mm */,
     611                                F4D423601DD5046900678290 /* TextInputController.h */,
    610612                        );
    611613                        name = Controllers;
     
    10621064                                A134E53618905EFF00901D06 /* AccessibilityCommonMac.mm in Sources */,
    10631065                                BCD08B3A0E1057EF00A7D0C1 /* AccessibilityController.cpp in Sources */,
    1064                                 2DA2E3A51E1BA54100A3BBD0 /* DumpRenderTreeSpellChecker.mm in Sources */,
    10651066                                AA5A15EF16E15CD000F7C561 /* AccessibilityControllerIOS.mm in Sources */,
    10661067                                BCD08B710E1059D200A7D0C1 /* AccessibilityControllerMac.mm in Sources */,
     
    10811082                                A8D79CEB0FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.m in Sources */,
    10821083                                A8B91ADA0CF3B32F008F91FF /* DumpRenderTreePasteboard.mm in Sources */,
     1084                                2DA2E3A51E1BA54100A3BBD0 /* DumpRenderTreeSpellChecker.mm in Sources */,
    10831085                                A8B91ADC0CF3B32F008F91FF /* DumpRenderTreeWindow.mm in Sources */,
    10841086                                BCA18B620C9B08C200114369 /* EditingDelegate.mm in Sources */,
     
    10881090                                BCA18B230C9B014B00114369 /* GCControllerMac.mm in Sources */,
    10891091                                5185F6B210714E07007AA393 /* HistoryDelegate.mm in Sources */,
     1092                                312943F91E71F2B4001EE2CC /* IOSLayoutTestCommunication.cpp in Sources */,
    10901093                                2CE88FA217124D8C00734FC0 /* JavaScriptThreading.cpp in Sources */,
    10911094                                0F18E7061D6BA0230027E547 /* JSUIScriptController.cpp in Sources */,
     
    10991102                                8465E2C70FFA8DF2003B8342 /* PixelDumpSupport.cpp in Sources */,
    11001103                                BCB284CD0CFA83C8007E533E /* PixelDumpSupportCG.cpp in Sources */,
    1101                                 F4D423611DD5048200678290 /* TextInputControllerIOS.m in Sources */,
    11021104                                A1158D59189274360088C17B /* PixelDumpSupportIOS.mm in Sources */,
    11031105                                BCB284D60CFA83D1007E533E /* PixelDumpSupportMac.mm in Sources */,
    11041106                                BCA18B660C9B08C200114369 /* PolicyDelegate.mm in Sources */,
    11051107                                BCA18B680C9B08C200114369 /* ResourceLoadDelegate.mm in Sources */,
     1108                                7CBBC3231DDFCF9A00786B9D /* TestOptions.mm in Sources */,
    11061109                                BC0131DA0C9772010087317D /* TestRunner.cpp in Sources */,
    11071110                                BCA18B240C9B014B00114369 /* TestRunnerMac.mm in Sources */,
     1111                                F4D423611DD5048200678290 /* TextInputControllerIOS.m in Sources */,
    11081112                                BCA18B490C9B02C400114369 /* TextInputControllerMac.m in Sources */,
    11091113                                BCA18B6A0C9B08C200114369 /* UIDelegate.mm in Sources */,
     
    11111115                                0F18E6ED1D6B9C070027E547 /* UIScriptController.cpp in Sources */,
    11121116                                0F18E70D1D6BAC8C0027E547 /* UIScriptControllerIOS.mm in Sources */,
    1113                                 7CBBC3231DDFCF9A00786B9D /* TestOptions.mm in Sources */,
    11141117                                0F18E70F1D6BACB60027E547 /* UIScriptControllerMac.mm in Sources */,
    11151118                                BC9D90240C97472E0099A4A3 /* WorkQueue.cpp in Sources */,
    1116                                 312943F91E71F2B4001EE2CC /* IOSLayoutTestCommunication.cpp in Sources */,
    11171119                                BCA18B260C9B015C00114369 /* WorkQueueItemMac.mm in Sources */,
    11181120                        );
  • trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm

    r216291 r221234  
    3737#if PLATFORM(MAC)
    3838
     39#import "AppKitTestSPI.h"
     40
    3941namespace WTR {
    4042
     
    6567}
    6668
    67 void UIScriptController::insertText(JSStringRef, int, int)
     69void UIScriptController::replaceTextAtRange(JSStringRef text, int location, int length)
    6870{
     71    auto textToInsert = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, text));
     72    auto rangeAttribute = adoptNS([[NSDictionary alloc] initWithObjectsAndKeys:NSStringFromRange(NSMakeRange(location == -1 ? NSNotFound : location, length)), NSTextInputReplacementRangeAttributeName, nil]);
     73    auto textAndRange = adoptNS([[NSAttributedString alloc] initWithString:(NSString *)textToInsert.get() attributes:rangeAttribute.get()]);
     74
     75    [mainFrame.webView insertText:textAndRange.get()];
    6976}
    7077
  • trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl

    r217587 r221234  
    227227    readonly attribute object inputViewBounds;
    228228
    229     void insertText(DOMString text, long location, long length);
     229    void replaceTextAtRange(DOMString text, long location, long length);
    230230    void removeAllDynamicDictionaries();
    231231
  • trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp

    r217587 r221234  
    462462}
    463463
    464 void UIScriptController::insertText(JSStringRef, int, int)
     464void UIScriptController::replaceTextAtRange(JSStringRef, int, int)
    465465{
    466466}
  • trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h

    r217587 r221234  
    152152    JSObjectRef inputViewBounds() const;
    153153
    154     void insertText(JSStringRef, int location, int length);
     154    void replaceTextAtRange(JSStringRef, int location, int length);
    155155    void removeAllDynamicDictionaries();
    156156   
  • trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm

    r216291 r221234  
    7676}
    7777
    78 void UIScriptController::insertText(JSStringRef text, int location, int length)
     78void UIScriptController::replaceTextAtRange(JSStringRef text, int location, int length)
    7979{
    8080#if WK_API_ENABLED
Note: See TracChangeset for help on using the changeset viewer.