Changeset 231853 in webkit


Ignore:
Timestamp:
May 16, 2018 10:54:50 AM (6 years ago)
Author:
Fujii Hironori
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.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r231850 r231853  
     12018-05-16  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [Win] Implement WebPage::handleEditingKeyboardEvent
     4        https://bugs.webkit.org/show_bug.cgi?id=185327
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * WebProcess/WebPage/win/WebPageWin.cpp:
     9        (WebKit::WebPage::handleEditingKeyboardEvent): Copied from WebKitLegacy.
     10
    1112018-05-16  Sihui Liu  <sihui_liu@apple.com>
    212
  • trunk/Source/WebKit/WebProcess/WebPage/win/WebPageWin.cpp

    r230509 r231853  
    3434#include "WebProcess.h"
    3535#include <WebCore/BackForwardController.h>
     36#include <WebCore/Editor.h>
    3637#include <WebCore/EventHandler.h>
    3738#include <WebCore/EventNames.h>
     
    261262    return mapKey ? keyPressCommandsMap->get(mapKey) : 0;
    262263}
     264
     265bool WebPage::handleEditingKeyboardEvent(WebCore::KeyboardEvent* event)
     266{
     267    auto* frame = downcast<Node>(event->target())->document().frame();
     268    ASSERT(frame);
     269
     270    auto* keyEvent = event->underlyingPlatformEvent();
     271    if (!keyEvent || keyEvent->isSystemKey()) // Do not treat this as text input if it's a system key event.
     272        return false;
     273
     274    auto command = frame->editor().command(interpretKeyEvent(event));
     275
     276    if (keyEvent->type() == PlatformEvent::RawKeyDown) {
     277        // WebKit doesn't have enough information about mode to decide
     278        // how commands that just insert text if executed via Editor
     279        // should be treated, so we leave it upon WebCore to either
     280        // handle them immediately (e.g. Tab that changes focus) or
     281        // let a keypress event be generated (e.g. Tab that inserts a
     282        // Tab character, or Enter).
     283        return !command.isTextInsertion() && command.execute(event);
     284    }
     285
     286    if (command.execute(event))
     287        return true;
     288
     289    // Don't insert null or control characters as they can result in unexpected behaviour.
     290    if (event->charCode() < ' ')
     291        return false;
     292
     293    return frame->editor().insertText(keyEvent->text(), event);
     294}
     295
    263296} // namespace WebKit
Note: See TracChangeset for help on using the changeset viewer.