Pass KeyboardEvent by reference in more places
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 May 2019 23:04:09 +0000 (23:04 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 May 2019 23:04:09 +0000 (23:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197480

Reviewed by Wenson Hsieh.

Source/WebCore:

* editing/Editor.cpp:
(WebCore::Editor::handleKeyboardEvent):
(WebCore::Editor::handleInputMethodKeydown):
* loader/EmptyClients.cpp:
* page/EditorClient.h:

Source/WebKit:

* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::handleKeyboardEvent):
(WebKit::WebEditorClient::handleInputMethodKeydown):
* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
(WebKit::WebEditorClient::handleKeyboardEvent):
(WebKit::WebEditorClient::handleInputMethodKeydown):
* WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
(WebKit::WebEditorClient::handleKeyboardEvent):
(WebKit::WebEditorClient::handleInputMethodKeydown):
* WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
(WebKit::WebEditorClient::handleKeyboardEvent):
(WebKit::WebEditorClient::handleInputMethodKeydown):
* WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp:
(WebKit::WebEditorClient::handleKeyboardEvent):
(WebKit::WebEditorClient::handleInputMethodKeydown):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::handleEditingKeyboardEvent):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::handleEditingKeyboardEvent):
* WebProcess/WebPage/win/WebPageWin.cpp:
(WebKit::WebPage::handleEditingKeyboardEvent):

Source/WebKitLegacy/mac:

* WebCoreSupport/WebEditorClient.h:
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::handleKeyboardEvent):
(WebEditorClient::handleInputMethodKeydown):

Source/WebKitLegacy/win:

* WebCoreSupport/WebEditorClient.cpp:
(WebEditorClient::handleKeyboardEvent):
(WebEditorClient::handleInputMethodKeydown):
* WebCoreSupport/WebEditorClient.h:
* WebView.cpp:
(WebView::handleEditingKeyboardEvent):
* WebView.h:

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

23 files changed:
Source/WebCore/ChangeLog
Source/WebCore/editing/Editor.cpp
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/page/EditorClient.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h
Source/WebKit/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp
Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm
Source/WebKit/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
Source/WebKit/WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
Source/WebKit/WebProcess/WebPage/win/WebPageWin.cpp
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h
Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebEditorClient.cpp
Source/WebKitLegacy/win/WebCoreSupport/WebEditorClient.h
Source/WebKitLegacy/win/WebView.cpp
Source/WebKitLegacy/win/WebView.h

index 988c719..238958a 100644 (file)
@@ -1,3 +1,16 @@
+2019-05-03  Daniel Bates  <dabates@apple.com>
+
+        Pass KeyboardEvent by reference in more places
+        https://bugs.webkit.org/show_bug.cgi?id=197480
+
+        Reviewed by Wenson Hsieh.
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::handleKeyboardEvent):
+        (WebCore::Editor::handleInputMethodKeydown):
+        * loader/EmptyClients.cpp:
+        * page/EditorClient.h:
+
 2019-05-03  Chris Dumez  <cdumez@apple.com>
 
         [iOS Sim Debug] ASSERTION FAILED The atomic string comes from an other thread! Layout Test imported/w3c/web-platform-tests/workers/WorkerNavigator_appName.htm is a flaky crash
index 3c9f6d5..dc50b6c 100644 (file)
@@ -291,14 +291,14 @@ TextCheckerClient* Editor::textChecker() const
 
 void Editor::handleKeyboardEvent(KeyboardEvent& event)
 {
-    if (EditorClient* c = client())
-        c->handleKeyboardEvent(&event);
+    if (auto* client = this->client())
+        client->handleKeyboardEvent(event);
 }
 
 void Editor::handleInputMethodKeydown(KeyboardEvent& event)
 {
-    if (EditorClient* c = client())
-        c->handleInputMethodKeydown(&event);
+    if (auto* client = this->client())
+        client->handleInputMethodKeydown(event);
 }
 
 bool Editor::handleTextEvent(TextEvent& event)
index 0e7cfba..55d083e 100644 (file)
@@ -201,8 +201,8 @@ private:
     void undo() final { }
     void redo() final { }
 
-    void handleKeyboardEvent(KeyboardEvent*) final { }
-    void handleInputMethodKeydown(KeyboardEvent*) final { }
+    void handleKeyboardEvent(KeyboardEvent&) final { }
+    void handleInputMethodKeydown(KeyboardEvent&) final { }
 
     void textFieldDidBeginEditing(Element*) final { }
     void textFieldDidEndEditing(Element*) final { }
index 1d1c8d0..f9a6414 100644 (file)
@@ -119,8 +119,8 @@ public:
     virtual void undo() = 0;
     virtual void redo() = 0;
 
-    virtual void handleKeyboardEvent(KeyboardEvent*) = 0;
-    virtual void handleInputMethodKeydown(KeyboardEvent*) = 0;
+    virtual void handleKeyboardEvent(KeyboardEvent&) = 0;
+    virtual void handleInputMethodKeydown(KeyboardEvent&) = 0;
     
     virtual void textFieldDidBeginEditing(Element*) = 0;
     virtual void textFieldDidEndEditing(Element*) = 0;
index 38ce6dd..b2e36b8 100644 (file)
@@ -1,3 +1,34 @@
+2019-05-03  Daniel Bates  <dabates@apple.com>
+
+        Pass KeyboardEvent by reference in more places
+        https://bugs.webkit.org/show_bug.cgi?id=197480
+
+        Reviewed by Wenson Hsieh.
+
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::handleKeyboardEvent):
+        (WebKit::WebEditorClient::handleInputMethodKeydown):
+        * WebProcess/WebCoreSupport/WebEditorClient.h:
+        * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
+        (WebKit::WebEditorClient::handleKeyboardEvent):
+        (WebKit::WebEditorClient::handleInputMethodKeydown):
+        * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
+        (WebKit::WebEditorClient::handleKeyboardEvent):
+        (WebKit::WebEditorClient::handleInputMethodKeydown):
+        * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
+        (WebKit::WebEditorClient::handleKeyboardEvent):
+        (WebKit::WebEditorClient::handleInputMethodKeydown):
+        * WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp:
+        (WebKit::WebEditorClient::handleKeyboardEvent):
+        (WebKit::WebEditorClient::handleInputMethodKeydown):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::handleEditingKeyboardEvent):
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::handleEditingKeyboardEvent):
+        * WebProcess/WebPage/win/WebPageWin.cpp:
+        (WebKit::WebPage::handleEditingKeyboardEvent):
+
 2019-05-03  Youenn Fablet  <youenn@apple.com>
 
         Enable Fetch Keep Alive by default
index 49d5eb5..f428fd2 100644 (file)
@@ -361,13 +361,13 @@ WebCore::DOMPasteAccessResponse WebEditorClient::requestDOMPasteAccess(const Str
 }
 
 #if PLATFORM(WIN)
-void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
+void WebEditorClient::handleKeyboardEvent(KeyboardEvent& event)
 {
     if (m_page->handleEditingKeyboardEvent(event))
-        event->setDefaultHandled();
+        event.setDefaultHandled();
 }
 
-void WebEditorClient::handleInputMethodKeydown(KeyboardEvent*)
+void WebEditorClient::handleInputMethodKeydown(KeyboardEvent&)
 {
     notImplemented();
 }
index 30988ed..1964860 100644 (file)
@@ -102,8 +102,8 @@ private:
     void undo() final;
     void redo() final;
 
-    void handleKeyboardEvent(WebCore::KeyboardEvent*) final;
-    void handleInputMethodKeydown(WebCore::KeyboardEvent*) final;
+    void handleKeyboardEvent(WebCore::KeyboardEvent&) final;
+    void handleInputMethodKeydown(WebCore::KeyboardEvent&) final;
     
     void textFieldDidBeginEditing(WebCore::Element*) final;
     void textFieldDidEndEditing(WebCore::Element*) final;
index 1a63733..db99772 100644 (file)
@@ -52,9 +52,9 @@ bool WebEditorClient::executePendingEditorCommands(Frame* frame, const Vector<WT
     return true;
 }
 
-void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
+void WebEditorClient::handleKeyboardEvent(KeyboardEvent& event)
 {
-    auto* platformEvent = event->underlyingPlatformEvent();
+    auto* platformEvent = event.underlyingPlatformEvent();
     if (!platformEvent)
         return;
 
@@ -62,8 +62,8 @@ void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
     if (platformEvent->handledByInputMethod())
         return;
 
-    ASSERT(event->target());
-    auto* frame = downcast<Node>(event->target())->document().frame();
+    ASSERT(event.target());
+    auto* frame = downcast<Node>(event.target())->document().frame();
     ASSERT(frame);
 
     const Vector<String> pendingEditorCommands = platformEvent->commands();
@@ -74,14 +74,14 @@ void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
         // through the DOM first.
         if (platformEvent->type() == PlatformEvent::RawKeyDown) {
             if (executePendingEditorCommands(frame, pendingEditorCommands, false))
-                event->setDefaultHandled();
+                event.setDefaultHandled();
 
             return;
         }
 
         // Only allow text insertion commands if the current node is editable.
         if (executePendingEditorCommands(frame, pendingEditorCommands, frame->editor().canEdit())) {
-            event->setDefaultHandled();
+            event.setDefaultHandled();
             return;
         }
     }
@@ -93,26 +93,26 @@ void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
     // This is just a normal text insertion, so wait to execute the insertion
     // until a keypress event happens. This will ensure that the insertion will not
     // be reflected in the contents of the field until the keyup DOM event.
-    if (event->type() != eventNames().keypressEvent)
+    if (event.type() != eventNames().keypressEvent)
         return;
 
     // Don't insert null or control characters as they can result in unexpected behaviour
-    if (event->charCode() < ' ')
+    if (event.charCode() < ' ')
         return;
 
     // Don't insert anything if a modifier is pressed
     if (platformEvent->controlKey() || platformEvent->altKey())
         return;
 
-    if (frame->editor().insertText(platformEvent->text(), event))
-        event->setDefaultHandled();
+    if (frame->editor().insertText(platformEvent->text(), &event))
+        event.setDefaultHandled();
 }
 
-void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event)
+void WebEditorClient::handleInputMethodKeydown(KeyboardEvent& event)
 {
-    auto* platformEvent = event->underlyingPlatformEvent();
+    auto* platformEvent = event.underlyingPlatformEvent();
     if (platformEvent && platformEvent->handledByInputMethod())
-        event->setDefaultHandled();
+        event.setDefaultHandled();
 }
 
 void WebEditorClient::updateGlobalSelection(Frame* frame)
index 2a4a163..3b595ff 100644 (file)
 namespace WebKit {
 using namespace WebCore;
     
-void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
+void WebEditorClient::handleKeyboardEvent(KeyboardEvent& event)
 {
     if (m_page->handleEditingKeyboardEvent(event))
-        event->setDefaultHandled();
+        event.setDefaultHandled();
 }
 
-void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event)
+void WebEditorClient::handleInputMethodKeydown(KeyboardEvent&)
 {
     notImplemented();
 }
index 3d1ff84..3a79325 100644 (file)
 namespace WebKit {
 using namespace WebCore;
     
-void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
+void WebEditorClient::handleKeyboardEvent(KeyboardEvent& event)
 {
     if (m_page->handleEditingKeyboardEvent(event))
-        event->setDefaultHandled();
+        event.setDefaultHandled();
 }
 
-void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event)
+void WebEditorClient::handleInputMethodKeydown(KeyboardEvent& event)
 {
-    if (event->handledByInputMethod())
-        event->setDefaultHandled();
+    if (event.handledByInputMethod())
+        event.setDefaultHandled();
 }
 
 void WebEditorClient::setInsertionPasteboard(const String&)
index b6f65df..165dee4 100644 (file)
@@ -205,15 +205,15 @@ static void handleKeyDown(Frame& frame, KeyboardEvent& event, const PlatformKeyb
     event.setDefaultHandled();
 }
 
-void WebEditorClient::handleKeyboardEvent(WebCore::KeyboardEvent* event)
+void WebEditorClient::handleKeyboardEvent(WebCore::KeyboardEvent& event)
 {
-    ASSERT(event->target());
-    auto* frame = downcast<Node>(event->target())->document().frame();
+    ASSERT(event.target());
+    auto* frame = downcast<Node>(event.target())->document().frame();
     ASSERT(frame);
 
     // FIXME: Reorder the checks in a more sensible way.
 
-    auto* platformEvent = event->underlyingPlatformEvent();
+    auto* platformEvent = event.underlyingPlatformEvent();
     if (!platformEvent)
         return;
 
@@ -228,17 +228,17 @@ void WebEditorClient::handleKeyboardEvent(WebCore::KeyboardEvent* event)
     // This is just a normal text insertion, so wait to execute the insertion
     // until a keypress event happens. This will ensure that the insertion will not
     // be reflected in the contents of the field until the keyup DOM event.
-    if (event->type() == eventNames().keypressEvent)
-        return handleKeyPress(*frame, *event, *platformEvent);
-    if (event->type() == eventNames().keydownEvent)
-        return handleKeyDown(*frame, *event, *platformEvent);
+    if (event.type() == eventNames().keypressEvent)
+        return handleKeyPress(*frame, event, *platformEvent);
+    if (event.type() == eventNames().keydownEvent)
+        return handleKeyDown(*frame, event, *platformEvent);
 }
 
-void WebEditorClient::handleInputMethodKeydown(WebCore::KeyboardEvent* event)
+void WebEditorClient::handleInputMethodKeydown(WebCore::KeyboardEvent& event)
 {
-    auto* platformEvent = event->underlyingPlatformEvent();
+    auto* platformEvent = event.underlyingPlatformEvent();
     if (platformEvent && platformEvent->windowsVirtualKeyCode() == VK_PROCESSKEY)
-        event->preventDefault();
+        event.preventDefault();
 }
 
 } // namespace WebKit
index cc4d797..a719ae0 100644 (file)
@@ -344,7 +344,7 @@ public:
     void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect&);
 
     // -- Called from WebCore clients.
-    bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
+    bool handleEditingKeyboardEvent(WebCore::KeyboardEvent&);
 
     void didStartPageTransition();
     void didCompletePageTransition();
index 83f3126..535acbe 100644 (file)
@@ -414,9 +414,9 @@ bool WebPage::allowsUserScaling() const
     return m_viewportConfiguration.allowsUserScaling();
 }
 
-bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* event)
+bool WebPage::handleEditingKeyboardEvent(KeyboardEvent& event)
 {
-    auto* platformEvent = event->underlyingPlatformEvent();
+    auto* platformEvent = event.underlyingPlatformEvent();
     if (!platformEvent)
         return false;
 
index da54f2e..a07ca45 100644 (file)
@@ -275,14 +275,14 @@ bool WebPage::executeKeypressCommandsInternal(const Vector<WebCore::KeypressComm
     return eventWasHandled;
 }
 
-bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* event)
+bool WebPage::handleEditingKeyboardEvent(KeyboardEvent& event)
 {
-    Frame* frame = frameForEvent(event);
+    auto* frame = frameForEvent(&event);
     
-    auto* platformEvent = event->underlyingPlatformEvent();
+    auto* platformEvent = event.underlyingPlatformEvent();
     if (!platformEvent)
         return false;
-    auto& commands = event->keypressCommands();
+    auto& commands = event.keypressCommands();
 
     ASSERT(!platformEvent->macEvent()); // Cannot have a native event in WebProcess.
 
@@ -304,7 +304,7 @@ bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* event)
     // If there are no text insertion commands, default keydown handler is the right time to execute the commands.
     // Keypress (Char event) handler is the latest opportunity to execute.
     if (!haveTextInsertionCommands || platformEvent->type() == PlatformEvent::Char) {
-        eventWasHandled = executeKeypressCommandsInternal(commands, event);
+        eventWasHandled = executeKeypressCommandsInternal(commands, &event);
         commands.clear();
     }
 
index 31df42d..c94bd05 100644 (file)
@@ -238,16 +238,16 @@ const char* WebPage::interpretKeyEvent(const WebCore::KeyboardEvent* evt)
     return mapKey ? keyPressCommandsMap->get(mapKey) : 0;
 }
 
-bool WebPage::handleEditingKeyboardEvent(WebCore::KeyboardEvent* event)
+bool WebPage::handleEditingKeyboardEvent(WebCore::KeyboardEvent& event)
 {
-    auto* frame = downcast<Node>(event->target())->document().frame();
+    auto* frame = downcast<Node>(event.target())->document().frame();
     ASSERT(frame);
 
-    auto* keyEvent = event->underlyingPlatformEvent();
+    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));
+    auto command = frame->editor().command(interpretKeyEvent(&event));
 
     if (keyEvent->type() == PlatformEvent::RawKeyDown) {
         // WebKit doesn't have enough information about mode to decide
@@ -256,17 +256,17 @@ bool WebPage::handleEditingKeyboardEvent(WebCore::KeyboardEvent* event)
         // 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);
+        return !command.isTextInsertion() && command.execute(&event);
     }
 
-    if (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() < ' ')
+    if (event.charCode() < ' ')
         return false;
 
-    return frame->editor().insertText(keyEvent->text(), event);
+    return frame->editor().insertText(keyEvent->text(), &event);
 }
 
 } // namespace WebKit
index d924bdf..69e1577 100644 (file)
@@ -1,3 +1,15 @@
+2019-05-03  Daniel Bates  <dabates@apple.com>
+
+        Pass KeyboardEvent by reference in more places
+        https://bugs.webkit.org/show_bug.cgi?id=197480
+
+        Reviewed by Wenson Hsieh.
+
+        * WebCoreSupport/WebEditorClient.h:
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::handleKeyboardEvent):
+        (WebEditorClient::handleInputMethodKeydown):
+
 2019-05-02  Frederic Wang  <fwang@igalia.com>
 
         [GTK][WPE] Disable "thin", "thick", "medium" values of mfrac@linethickness at runtime
index f56cf2c..f1cf30f 100644 (file)
@@ -127,8 +127,8 @@ private:
     void undo() final;
     void redo() final;
     
-    void handleKeyboardEvent(WebCore::KeyboardEvent*) final;
-    void handleInputMethodKeydown(WebCore::KeyboardEvent*) final;
+    void handleKeyboardEvent(WebCore::KeyboardEvent&) final;
+    void handleInputMethodKeydown(WebCore::KeyboardEvent&) final;
 
     void textFieldDidBeginEditing(WebCore::Element*) final;
     void textFieldDidEndEditing(WebCore::Element*) final;
index 0fc814f..426595f 100644 (file)
@@ -684,28 +684,28 @@ void WebEditorClient::redo()
         [[m_webView undoManager] redo];    
 }
 
-void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
+void WebEditorClient::handleKeyboardEvent(KeyboardEvent& event)
 {
-    auto* frame = downcast<Node>(event->target())->document().frame();
+    auto* frame = downcast<Node>(event.target())->document().frame();
 #if !PLATFORM(IOS_FAMILY)
     WebHTMLView *webHTMLView = (WebHTMLView *)[[kit(frame) frameView] documentView];
-    if ([webHTMLView _interpretKeyEvent:event savingCommands:NO])
-        event->setDefaultHandled();
+    if ([webHTMLView _interpretKeyEvent:&event savingCommands:NO])
+        event.setDefaultHandled();
 #else
     WebHTMLView *webHTMLView = (WebHTMLView *)[[kit(frame) frameView] documentView];
-    if ([webHTMLView _handleEditingKeyEvent:event])
-        event->setDefaultHandled();
+    if ([webHTMLView _handleEditingKeyEvent:&event])
+        event.setDefaultHandled();
 #endif
 }
 
-void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event)
+void WebEditorClient::handleInputMethodKeydown(KeyboardEvent& event)
 {
 #if !PLATFORM(IOS_FAMILY)
     // FIXME: Switch to WebKit2 model, interpreting the event before it's sent down to WebCore.
-    auto* frame = downcast<Node>(event->target())->document().frame();
+    auto* frame = downcast<Node>(event.target())->document().frame();
     WebHTMLView *webHTMLView = (WebHTMLView *)[[kit(frame) frameView] documentView];
-    if ([webHTMLView _interpretKeyEvent:event savingCommands:YES])
-        event->setDefaultHandled();
+    if ([webHTMLView _interpretKeyEvent:&event savingCommands:YES])
+        event.setDefaultHandled();
 #else
     // iOS does not use input manager this way
 #endif
index 1c8ff84..3d5aded 100644 (file)
@@ -1,3 +1,18 @@
+2019-05-03  Daniel Bates  <dabates@apple.com>
+
+        Pass KeyboardEvent by reference in more places
+        https://bugs.webkit.org/show_bug.cgi?id=197480
+
+        Reviewed by Wenson Hsieh.
+
+        * WebCoreSupport/WebEditorClient.cpp:
+        (WebEditorClient::handleKeyboardEvent):
+        (WebEditorClient::handleInputMethodKeydown):
+        * WebCoreSupport/WebEditorClient.h:
+        * WebView.cpp:
+        (WebView::handleEditingKeyboardEvent):
+        * WebView.h:
+
 2019-05-02  Frederic Wang  <fwang@igalia.com>
 
         [GTK][WPE] Disable "thin", "thick", "medium" values of mfrac@linethickness at runtime
index f72b6b5..8f9a29d 100644 (file)
@@ -715,13 +715,13 @@ void WebEditorClient::redo()
     }
 }
 
-void WebEditorClient::handleKeyboardEvent(KeyboardEvent* evt)
+void WebEditorClient::handleKeyboardEvent(KeyboardEvent& event)
 {
-    if (m_webView->handleEditingKeyboardEvent(evt))
-        evt->setDefaultHandled();
+    if (m_webView->handleEditingKeyboardEvent(event))
+        event.setDefaultHandled();
 }
 
-void WebEditorClient::handleInputMethodKeydown(KeyboardEvent)
+void WebEditorClient::handleInputMethodKeydown(KeyboardEvent&)
 {
 }
 
index eea2735..bb83725 100644 (file)
@@ -95,8 +95,8 @@ private:
     void textDidChangeInTextArea(WebCore::Element*) final;
     void overflowScrollPositionChanged() final { }
 
-    void handleKeyboardEvent(WebCore::KeyboardEvent*) final;
-    void handleInputMethodKeydown(WebCore::KeyboardEvent*) final;
+    void handleKeyboardEvent(WebCore::KeyboardEvent&) final;
+    void handleInputMethodKeydown(WebCore::KeyboardEvent&) final;
 
     bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const final;
     void ignoreWordInSpellDocument(const WTF::String&) final;
index 10fad78..79fc46d 100644 (file)
@@ -2356,32 +2356,32 @@ const char* WebView::interpretKeyEvent(const KeyboardEvent* evt)
     return mapKey ? keyPressCommandsMap->get(mapKey) : 0;
 }
 
-bool WebView::handleEditingKeyboardEvent(KeyboardEvent* evt)
+bool WebView::handleEditingKeyboardEvent(KeyboardEvent& event)
 {
-    auto* frame = downcast<Node>(evt->target())->document().frame();
+    auto* frame = downcast<Node>(event.target())->document().frame();
     ASSERT(frame);
 
-    auto* keyEvent = evt->underlyingPlatformEvent();
+    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(evt));
+    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(evt);
+        return !command.isTextInsertion() && command.execute(&event);
     }
 
-    if (command.execute(evt))
+    if (command.execute(&event))
         return true;
 
     // Don't insert null or control characters as they can result in unexpected behaviour
-    if (evt->charCode() < ' ')
+    if (event.charCode() < ' ')
         return false;
 
-    return frame->editor().insertText(keyEvent->text(), evt);
+    return frame->editor().insertText(keyEvent->text(), &event);
 }
 
 bool WebView::keyDown(WPARAM virtualKeyCode, LPARAM keyData, bool systemKeyDown)
index c3eb08c..ad4e32d 100644 (file)
@@ -473,7 +473,7 @@ public:
     bool isBeingDestroyed() const { return m_isBeingDestroyed; }
 
     const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
-    bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
+    bool handleEditingKeyboardEvent(WebCore::KeyboardEvent&);
 
     bool isPainting() const { return m_paintCount > 0; }