compositionstart event should contain the text to be replaced
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Jul 2013 23:28:50 +0000 (23:28 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Jul 2013 23:28:50 +0000 (23:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=118684

Reviewed by Alexey Proskuryakov.

Source/WebCore:

Merge https://chromium.googlesource.com/chromium/blink/+/9e04f728a95ad7d4783b1d31c3cdc1412dd6cc4d.

DOM3 level 3 specifies compositionstart event's data to be the text to be replaced.
http://www.w3.org/TR/DOM-Level-3-Events/#event-type-compositionstart

According to the author of the Blink change, IE10 on Windows and Firefox22 on Linux confirms
to the specified behavior.

Test: fast/events/ime-composition-events-001.html

* editing/Editor.cpp:
(WebCore::Editor::setComposition):

LayoutTests:

Add a test case.

* fast/events/ime-composition-events-001-expected.txt:
* fast/events/ime-composition-events-001.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@152668 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/events/ime-composition-events-001-expected.txt
LayoutTests/fast/events/ime-composition-events-001.html
Source/WebCore/ChangeLog
Source/WebCore/editing/Editor.cpp

index 813ee0e5697986c0724cd78ee73447d46970eed3..c0ec05ae8b8990c6544a4daba3e1e94b0dc3af65 100644 (file)
@@ -1,3 +1,15 @@
+2013-07-15  Ryosuke Niwa  <rniwa@webkit.org>
+
+        compositionstart event should contain the text to be replaced
+        https://bugs.webkit.org/show_bug.cgi?id=118684
+
+        Reviewed by Alexey Proskuryakov.
+
+        Add a test case.
+
+        * fast/events/ime-composition-events-001-expected.txt:
+        * fast/events/ime-composition-events-001.html:
+
 2013-07-15  Antoine Quint  <graouts@apple.com>
 
         Text with "text-overflow:ellipsis" and an SVG font do not render correctly
index 15ab407d0fabdbff0765bfe209b2d37446fe6de0..6d462b64bf0c190c5c30d7c0027f3f4b1db1ee44 100644 (file)
@@ -3,19 +3,24 @@ This tests that calling input-method functions sends Composition Events and Text
 To test manually, enable an IME, input CJK characters, and see this page doesn't show 'FAILED' lines.
 
 
-SUCCESS: INPUT - compositionstart - "1"
+SUCCESS: INPUT - compositionstart - ""
 SUCCESS: INPUT - compositionupdate - "1"
 SUCCESS: INPUT - compositionupdate - "2"
 SUCCESS: INPUT - compositionupdate - "3"
 SUCCESS: INPUT - compositionend - "4"
 SUCCESS: INPUT - textInput - "4"
-SUCCESS: INPUT - compositionstart - "5"
+SUCCESS: INPUT - compositionstart - ""
 SUCCESS: INPUT - compositionupdate - "5"
 SUCCESS: INPUT - compositionupdate - "6"
 SUCCESS: INPUT - compositionupdate - "7"
 SUCCESS: INPUT - compositionend - ""
 SUCCESS: INPUT - textInput - "8"
-SUCCESS: INPUT - compositionstart - "9"
+SUCCESS: INPUT - compositionstart - ""
 SUCCESS: INPUT - compositionupdate - "9"
 SUCCESS: INPUT - compositionend - "9"
 SUCCESS: INPUT - textInput - "9"
+SUCCESS: INPUT - compositionstart - "have"
+SUCCESS: INPUT - compositionupdate - "lost"
+SUCCESS: INPUT - compositionend - "made"
+SUCCESS: INPUT - textInput - "made"
+SUCCESS: I made a pen
index 8b232f67e73c42bf91a20c864257467747d9108d..114a4d478dd2cef59b58392434f11c5eeb4388e2 100644 (file)
@@ -57,6 +57,17 @@ if (window.testRunner) {
         textInputController.setMarkedText('9', 0, 1);
         textInputController.unmarkText();
     }
+
+    // Case 5: Compose a text on selection and commit it.
+    test.value = 'I have a pen';
+    test.selectionStart = 2;
+    test.selectionEnd = 6;
+    textInputController.setMarkedText('lost', 0, 1);
+    textInputController.insertText('made');
+    if (test.value == 'I made a pen')
+        log('SUCCESS: ' + test.value);
+    else
+        log('FAILURE: ' + test.value + ' is not "I made a pen".');
 }
 </script>
 </body>
index 36ab95782807a1fd341cd873a4200b622510ff56..273c53185309c5b0490335f8d8721e46d0d0f670 100644 (file)
@@ -1,3 +1,23 @@
+2013-07-15  Ryosuke Niwa  <rniwa@webkit.org>
+
+        compositionstart event should contain the text to be replaced
+        https://bugs.webkit.org/show_bug.cgi?id=118684
+
+        Reviewed by Alexey Proskuryakov.
+
+        Merge https://chromium.googlesource.com/chromium/blink/+/9e04f728a95ad7d4783b1d31c3cdc1412dd6cc4d.
+
+        DOM3 level 3 specifies compositionstart event's data to be the text to be replaced.
+        http://www.w3.org/TR/DOM-Level-3-Events/#event-type-compositionstart
+
+        According to the author of the Blink change, IE10 on Windows and Firefox22 on Linux confirms
+        to the specified behavior.
+
+        Test: fast/events/ime-composition-events-001.html
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::setComposition):
+
 2013-07-15  Ryosuke Niwa  <rniwa@webkit.org>
 
         xmlDocPtrForString shouldn't upconvert 8-bit string
index de0605d38fdf00d1c4a9215a0b9f6139f2bb8f26..21e71cf5e18c75a99176fa78a71811966853f00f 100644 (file)
@@ -1541,7 +1541,7 @@ void Editor::setComposition(const String& text, const Vector<CompositionUnderlin
             // We should send a compositionstart event only when the given text is not empty because this
             // function doesn't create a composition node when the text is empty.
             if (!text.isEmpty()) {
-                target->dispatchEvent(CompositionEvent::create(eventNames().compositionstartEvent, m_frame->document()->domWindow(), text));
+                target->dispatchEvent(CompositionEvent::create(eventNames().compositionstartEvent, m_frame->document()->domWindow(), selectedText()));
                 event = CompositionEvent::create(eventNames().compositionupdateEvent, m_frame->document()->domWindow(), text);
             }
         } else {