Title: [206796] trunk
Revision
206796
Author
[email protected]
Date
2016-10-04 17:02:48 -0700 (Tue, 04 Oct 2016)

Log Message

Add support for KeyboardEvent.isComposing attribute
https://bugs.webkit.org/show_bug.cgi?id=162921

Reviewed by Darin Adler.

Source/WebCore:

Add support for KeyboardEvent.isComposing attribute:
- https://www.w3.org/TR/uievents/#dom-keyboardevent-iscomposing
- https://www.w3.org/TR/uievents/#ref-for-dom-keyboardevent-iscomposing-3

Manual test: https://jsfiddle.net/ay92sr08/9/

No new tests, extended existing tests.

* dom/KeyboardEvent.cpp:
(WebCore::KeyboardEvent::KeyboardEvent):
* dom/KeyboardEvent.h:
* dom/KeyboardEvent.idl:

LayoutTests:

Extend layout test coverage to test KeyboardEvent.isComposing.

* editing/mac/input/kotoeri-enter-to-confirm-and-newline-expected.txt:
* editing/mac/input/kotoeri-enter-to-confirm-and-newline.html:
* fast/events/constructors/keyboard-event-constructor-expected.txt:
* fast/events/constructors/keyboard-event-constructor.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (206795 => 206796)


--- trunk/LayoutTests/ChangeLog	2016-10-04 23:42:18 UTC (rev 206795)
+++ trunk/LayoutTests/ChangeLog	2016-10-05 00:02:48 UTC (rev 206796)
@@ -1,3 +1,17 @@
+2016-10-04  Chris Dumez  <[email protected]>
+
+        Add support for KeyboardEvent.isComposing attribute
+        https://bugs.webkit.org/show_bug.cgi?id=162921
+
+        Reviewed by Darin Adler.
+
+        Extend layout test coverage to test KeyboardEvent.isComposing.
+
+        * editing/mac/input/kotoeri-enter-to-confirm-and-newline-expected.txt:
+        * editing/mac/input/kotoeri-enter-to-confirm-and-newline.html:
+        * fast/events/constructors/keyboard-event-constructor-expected.txt:
+        * fast/events/constructors/keyboard-event-constructor.html:
+
 2016-10-03  Ryosuke Niwa  <[email protected]>
 
         ShadowRoot interface should have elementFromPoint

Modified: trunk/LayoutTests/editing/mac/input/kotoeri-enter-to-confirm-and-newline-expected.txt (206795 => 206796)


--- trunk/LayoutTests/editing/mac/input/kotoeri-enter-to-confirm-and-newline-expected.txt	2016-10-04 23:42:18 UTC (rev 206795)
+++ trunk/LayoutTests/editing/mac/input/kotoeri-enter-to-confirm-and-newline-expected.txt	2016-10-05 00:02:48 UTC (rev 206796)
@@ -4,14 +4,41 @@
 To test this manually switch to the Kotoeri/Hiragana input method, and type 'toukyou'<enter><enter>.
 You should see only a single keypress event, as the very last reported event.
 
+compositionstart
+compositionupdate
+keydown : keyCode == 229, key: t, isComposing: true
 Received valid keydown event
+keyup : keyCode == 84, key: t, isComposing: true
+compositionupdate
+keydown : keyCode == 229, key: o, isComposing: true
 Received valid keydown event
+keyup : keyCode == 79, key: o, isComposing: true
+compositionupdate
+keydown : keyCode == 229, key: u, isComposing: true
 Received valid keydown event
+keyup : keyCode == 85, key: u, isComposing: true
+compositionupdate
+keydown : keyCode == 229, key: k, isComposing: true
 Received valid keydown event
+keyup : keyCode == 75, key: k, isComposing: true
+compositionupdate
+keydown : keyCode == 229, key: y, isComposing: true
 Received valid keydown event
+keyup : keyCode == 89, key: y, isComposing: true
+compositionupdate
+keydown : keyCode == 229, key: o, isComposing: true
 Received valid keydown event
+keyup : keyCode == 79, key: o, isComposing: true
+compositionupdate
+keydown : keyCode == 229, key: u, isComposing: true
 Received valid keydown event
+keyup : keyCode == 85, key: u, isComposing: true
+compositionend
+keydown : keyCode == 229, key: Enter, isComposing: false
 Received valid keydown event
+keyup : keyCode == 13, key: Enter, isComposing: false
+keydown : keyCode == 13, key: Enter, isComposing: false
 Received valid keydown event
 Received valid keypress event
+keyup : keyCode == 13, key: Enter, isComposing: false
 PASSED: Successfully typed 'toukyou'

Modified: trunk/LayoutTests/editing/mac/input/kotoeri-enter-to-confirm-and-newline.html (206795 => 206796)


--- trunk/LayoutTests/editing/mac/input/kotoeri-enter-to-confirm-and-newline.html	2016-10-04 23:42:18 UTC (rev 206795)
+++ trunk/LayoutTests/editing/mac/input/kotoeri-enter-to-confirm-and-newline.html	2016-10-05 00:02:48 UTC (rev 206796)
@@ -7,7 +7,7 @@
     To test this manually switch to the Kotoeri/Hiragana input method, and type 'toukyou'&lt;enter&gt;&lt;enter&gt;.<br />
     You should see only a single keypress event, as the very last reported event.
 </div>
-<input id="targetInput" _onkeydown_="keyDown()" _onkeypress_="keyPress()">
+<input id="targetInput" _onkeydown_="keyDown()" _onkeyup_="keyUp()" _onkeypress_="keyPress()">
 <ul id="console"></console>
 
 <script src=""
@@ -15,10 +15,10 @@
 <script>
     var shouldBeCompositionEvent = false;
     function keyDown() {
-        if (!window.testRunner) {
-            log("keydown : keyCode == " + event.keyCode);
+        log("keydown : keyCode == " + event.keyCode + ", key: " + event.key + ", isComposing: " + event.isComposing);
+        if (!window.testRunner)
             return;
-        }
+
         if (shouldBeCompositionEvent && event.keyCode != 229)
             log("FAILURE: received keyCode " + event.keyCode + " in a keydown when VK_PROCESSKEY is expected");
         else if (!shouldBeCompositionEvent && event.keyCode == 229)
@@ -26,6 +26,10 @@
         else
             log("Received valid keydown event");
     }
+
+    function keyUp() {
+        log("keyup : keyCode == " + event.keyCode + ", key: " + event.key + ", isComposing: " + event.isComposing);
+    }
     
     function keyPress() {
         if (!window.testRunner) {
@@ -39,6 +43,9 @@
     }
     
     var targetInput = document.getElementById('targetInput');
+    targetInput.addEventListener("compositionstart", function() { log("compositionstart"); });
+    targetInput.addEventListener("compositionupdate", function() { log("compositionupdate"); });
+    targetInput.addEventListener("compositionend", function() { log("compositionend"); });
     targetInput.focus();
     if (window.testRunner) {
         testRunner.dumpAsText();

Modified: trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor-expected.txt (206795 => 206796)


--- trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor-expected.txt	2016-10-04 23:42:18 UTC (rev 206795)
+++ trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor-expected.txt	2016-10-05 00:02:48 UTC (rev 206796)
@@ -22,6 +22,9 @@
 PASS new KeyboardEvent('eventType', { }).repeat is false
 PASS new KeyboardEvent('eventType', { repeat: false }).repeat is false
 PASS new KeyboardEvent('eventType', { repeat: true }).repeat is true
+PASS new KeyboardEvent('eventType', { }).isComposing is false
+PASS new KeyboardEvent('eventType', { isComposing: false }).isComposing is false
+PASS new KeyboardEvent('eventType', { isComposing: true }).isComposing is true
 PASS new KeyboardEvent('eventType', { view: testObject }).view threw exception TypeError: Dictionary member is not of type Window.
 PASS new KeyboardEvent('eventType', { view: document }).view threw exception TypeError: Dictionary member is not of type Window.
 PASS new KeyboardEvent('eventType', { view: undefined }).view is null

Modified: trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor.html (206795 => 206796)


--- trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor.html	2016-10-04 23:42:18 UTC (rev 206795)
+++ trunk/LayoutTests/fast/events/constructors/keyboard-event-constructor.html	2016-10-05 00:02:48 UTC (rev 206796)
@@ -40,6 +40,11 @@
 shouldBe("new KeyboardEvent('eventType', { repeat: false }).repeat", "false");
 shouldBe("new KeyboardEvent('eventType', { repeat: true }).repeat", "true");
 
+// isCompositing is passed.
+shouldBe("new KeyboardEvent('eventType', { }).isComposing", "false");
+shouldBe("new KeyboardEvent('eventType', { isComposing: false }).isComposing", "false");
+shouldBe("new KeyboardEvent('eventType', { isComposing: true }).isComposing", "true");
+
 // Non-window objects.
 shouldThrowErrorName("new KeyboardEvent('eventType', { view: testObject }).view", "TypeError");
 shouldThrowErrorName("new KeyboardEvent('eventType', { view: document }).view", "TypeError");

Modified: trunk/Source/WebCore/ChangeLog (206795 => 206796)


--- trunk/Source/WebCore/ChangeLog	2016-10-04 23:42:18 UTC (rev 206795)
+++ trunk/Source/WebCore/ChangeLog	2016-10-05 00:02:48 UTC (rev 206796)
@@ -1,3 +1,23 @@
+2016-10-04  Chris Dumez  <[email protected]>
+
+        Add support for KeyboardEvent.isComposing attribute
+        https://bugs.webkit.org/show_bug.cgi?id=162921
+
+        Reviewed by Darin Adler.
+
+        Add support for KeyboardEvent.isComposing attribute:
+        - https://www.w3.org/TR/uievents/#dom-keyboardevent-iscomposing
+        - https://www.w3.org/TR/uievents/#ref-for-dom-keyboardevent-iscomposing-3
+
+        Manual test: https://jsfiddle.net/ay92sr08/9/
+
+        No new tests, extended existing tests.
+
+        * dom/KeyboardEvent.cpp:
+        (WebCore::KeyboardEvent::KeyboardEvent):
+        * dom/KeyboardEvent.h:
+        * dom/KeyboardEvent.idl:
+
 2016-10-03  Ryosuke Niwa  <[email protected]>
 
         ShadowRoot interface should have elementFromPoint

Modified: trunk/Source/WebCore/dom/KeyboardEvent.cpp (206795 => 206796)


--- trunk/Source/WebCore/dom/KeyboardEvent.cpp	2016-10-04 23:42:18 UTC (rev 206795)
+++ trunk/Source/WebCore/dom/KeyboardEvent.cpp	2016-10-05 00:02:48 UTC (rev 206796)
@@ -24,6 +24,7 @@
 #include "KeyboardEvent.h"
 
 #include "Document.h"
+#include "Editor.h"
 #include "EventDispatcher.h"
 #include "EventHandler.h"
 #include "EventNames.h"
@@ -91,14 +92,7 @@
     }
 }
 
-KeyboardEvent::KeyboardEvent()
-    : m_location(DOM_KEY_LOCATION_STANDARD)
-    , m_altGraphKey(false)
-#if PLATFORM(COCOA)
-    , m_handledByInputMethod(false)
-#endif
-{
-}
+KeyboardEvent::KeyboardEvent() = default;
 
 KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, DOMWindow* view)
     : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()),
@@ -111,6 +105,7 @@
     , m_location(keyLocationCode(key))
     , m_repeat(key.isAutoRepeat())
     , m_altGraphKey(false)
+    , m_isComposing(view && view->frame() && view->frame()->editor().hasComposition())
 #if PLATFORM(COCOA)
 #if USE(APPKIT)
     , m_handledByInputMethod(key.handledByInputMethod())
@@ -137,6 +132,7 @@
     , m_location(initializer.location)
     , m_repeat(initializer.repeat)
     , m_altGraphKey(false)
+    , m_isComposing(initializer.isComposing)
 #if PLATFORM(COCOA)
     , m_handledByInputMethod(false)
 #endif

Modified: trunk/Source/WebCore/dom/KeyboardEvent.h (206795 => 206796)


--- trunk/Source/WebCore/dom/KeyboardEvent.h	2016-10-04 23:42:18 UTC (rev 206795)
+++ trunk/Source/WebCore/dom/KeyboardEvent.h	2016-10-05 00:02:48 UTC (rev 206796)
@@ -40,6 +40,7 @@
     String keyIdentifier;
     unsigned location { 0 };
     bool repeat { false };
+    bool isComposing { false };
 };
 
 class KeyboardEvent final : public UIEventWithKeyState {
@@ -100,6 +101,8 @@
     bool isKeyboardEvent() const final;
     int which() const final;
 
+    bool isComposing() const { return m_isComposing; }
+
 #if PLATFORM(COCOA)
     bool handledByInputMethod() const { return m_handledByInputMethod; }
     const Vector<KeypressCommand>& keypressCommands() const { return m_keypressCommands; }
@@ -121,13 +124,14 @@
     String m_key;
 #endif
     String m_keyIdentifier;
-    unsigned m_location;
-    bool m_repeat : 1;
-    bool m_altGraphKey : 1;
+    unsigned m_location { DOM_KEY_LOCATION_STANDARD };
+    bool m_repeat { false };
+    bool m_altGraphKey { false };
+    bool m_isComposing { false };
 
 #if PLATFORM(COCOA)
     // Commands that were sent by AppKit when interpreting the event. Doesn't include input method commands.
-    bool m_handledByInputMethod;
+    bool m_handledByInputMethod { false };
     Vector<KeypressCommand> m_keypressCommands;
 #endif
 };

Modified: trunk/Source/WebCore/dom/KeyboardEvent.idl (206795 => 206796)


--- trunk/Source/WebCore/dom/KeyboardEvent.idl	2016-10-04 23:42:18 UTC (rev 206795)
+++ trunk/Source/WebCore/dom/KeyboardEvent.idl	2016-10-05 00:02:48 UTC (rev 206796)
@@ -41,8 +41,7 @@
     [InitializedByEventConstructor] readonly attribute boolean metaKey;
     [InitializedByEventConstructor] readonly attribute boolean repeat;
 
-    // FIXME: We should support this.
-    // readonly attribute boolean isComposing;
+    [InitializedByEventConstructor] readonly attribute boolean isComposing;
 
     boolean getModifierState(DOMString keyArg);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to