Title: [231853] trunk/Source/WebKit
Revision
231853
Author
hironori.fu...@sony.com
Date
2018-05-16 10:54:50 -0700 (Wed, 16 May 2018)

Log Message

[Win] Implement WebPage::handleEditingKeyboardEvent
https://bugs.webkit.org/show_bug.cgi?id=185327

Reviewed by Alexey Proskuryakov.

* WebProcess/WebPage/win/WebPageWin.cpp:
(WebKit::WebPage::handleEditingKeyboardEvent): Copied from WebKitLegacy.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (231852 => 231853)


--- trunk/Source/WebKit/ChangeLog	2018-05-16 17:50:38 UTC (rev 231852)
+++ trunk/Source/WebKit/ChangeLog	2018-05-16 17:54:50 UTC (rev 231853)
@@ -1,3 +1,13 @@
+2018-05-16  Fujii Hironori  <hironori.fu...@sony.com>
+
+        [Win] Implement WebPage::handleEditingKeyboardEvent
+        https://bugs.webkit.org/show_bug.cgi?id=185327
+
+        Reviewed by Alexey Proskuryakov.
+
+        * WebProcess/WebPage/win/WebPageWin.cpp:
+        (WebKit::WebPage::handleEditingKeyboardEvent): Copied from WebKitLegacy.
+
 2018-05-16  Sihui Liu  <sihui_...@apple.com>
 
         Session cookies aren't reliably set when using default WKWebSiteDataStore

Modified: trunk/Source/WebKit/WebProcess/WebPage/win/WebPageWin.cpp (231852 => 231853)


--- trunk/Source/WebKit/WebProcess/WebPage/win/WebPageWin.cpp	2018-05-16 17:50:38 UTC (rev 231852)
+++ trunk/Source/WebKit/WebProcess/WebPage/win/WebPageWin.cpp	2018-05-16 17:54:50 UTC (rev 231853)
@@ -33,6 +33,7 @@
 #include "WebPageProxyMessages.h"
 #include "WebProcess.h"
 #include <WebCore/BackForwardController.h>
+#include <WebCore/Editor.h>
 #include <WebCore/EventHandler.h>
 #include <WebCore/EventNames.h>
 #include <WebCore/FocusController.h>
@@ -260,4 +261,36 @@
     int mapKey = modifiers << 16 | evt->charCode();
     return mapKey ? keyPressCommandsMap->get(mapKey) : 0;
 }
+
+bool WebPage::handleEditingKeyboardEvent(WebCore::KeyboardEvent* event)
+{
+    auto* frame = downcast<Node>(event->target())->document().frame();
+    ASSERT(frame);
+
+    auto* keyEvent = event->underlyingPlatformEvent();
+    if (!keyEvent || keyEvent->isSystemKey()) // Do not treat this as text input if it's a system key event.
+        return false;
+
+    auto command = frame->editor().command(interpretKeyEvent(event));
+
+    if (keyEvent->type() == PlatformEvent::RawKeyDown) {
+        // WebKit doesn't have enough information about mode to decide
+        // how commands that just insert text if executed via Editor
+        // should be treated, so we leave it upon WebCore to either
+        // handle them immediately (e.g. Tab that changes focus) or
+        // let a keypress event be generated (e.g. Tab that inserts a
+        // Tab character, or Enter).
+        return !command.isTextInsertion() && command.execute(event);
+    }
+
+    if (command.execute(event))
+        return true;
+
+    // Don't insert null or control characters as they can result in unexpected behaviour.
+    if (event->charCode() < ' ')
+        return false;
+
+    return frame->editor().insertText(keyEvent->text(), event);
+}
+
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to