Changeset 39239 in webkit


Ignore:
Timestamp:
Dec 12, 2008, 5:49:40 AM (16 years ago)
Author:
Simon Hausmann
Message:

2008-12-12 Simon Hausmann <Simon Hausmann>

Reviewed by Tor Arne Vestbø.

Fix pressing return/enter not triggering any action on web sites
that define event handlers, such as the JS console in the web
inspector.

Process the key events in the DOM first and if not handled map them
to editor actions.

Location:
trunk/WebKit/qt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/qt/Api/qwebpage.cpp

    r39232 r39239  
    619619
    620620#ifndef QT_NO_SHORTCUT
    621 static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event)
     621QWebPage::WebAction QWebPagePrivate::editorActionForKeyEvent(QKeyEvent* event)
    622622{
    623623    static struct {
     
    676676    WebCore::Frame* frame = page->focusController()->focusedOrMainFrame();
    677677    WebCore::Editor* editor = frame->editor();
    678 #ifndef QT_NO_SHORTCUT
    679     if (editor->canEdit()) {
    680         QWebPage::WebAction action = editorActionForKeyEvent(ev);
    681         if (action != QWebPage::NoWebAction) {
    682             q->triggerAction(action);
    683             handled = true;
    684         }
    685     } else {
    686         if (ev == QKeySequence::Copy) {
    687             q->triggerAction(QWebPage::Copy);
    688             handled = true;
    689         }
    690     }
    691 #endif // QT_NO_SHORTCUT
     678    // we forward the key event to WebCore first to handle potential DOM
     679    // defined event handlers and later on end up in EditorClientQt::handleKeyboardEvent
     680    // to trigger editor commands via triggerAction().
    692681    if (!handled)
    693682        handled = frame->eventHandler()->keyEvent(ev);
  • trunk/WebKit/qt/Api/qwebpage_p.h

    r37061 r39239  
    113113    bool handleScrolling(QKeyEvent*);
    114114
     115#ifndef QT_NO_SHORTCUT
     116    static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event);
     117#endif
     118
    115119    WebCore::ChromeClientQt *chromeClient;
    116120    WebCore::ContextMenuClientQt *contextMenuClient;
  • trunk/WebKit/qt/ChangeLog

    r39234 r39239  
     12008-12-12  Simon Hausmann  <hausmann@webkit.org>
     2
     3        Reviewed by Tor Arne Vestbø.
     4
     5        Fix pressing return/enter not triggering any action on web sites
     6        that define event handlers, such as the JS console in the web
     7        inspector.
     8
     9        Process the key events in the DOM first and if not handled map them
     10        to editor actions.
     11
     12        * Api/qwebpage.cpp:
     13        (QWebPagePrivate::editorActionForKeyEvent): Made a class method.
     14        (QWebPagePrivate::keyPressEvent): Pass the key event first to the DOM.
     15        * WebCoreSupport/EditorClientQt.cpp:
     16        (WebCore::EditorClientQt::handleKeyboardEvent): Map the key event to
     17        actions and trigger them.
     18
    1192008-12-12  Ariya Hidayat  <ariya.hidayat@trolltech.com>
    220
  • trunk/WebKit/qt/WebCoreSupport/EditorClientQt.cpp

    r39173 r39239  
    366366    // FIXME: refactor all of this to use Actions or something like them
    367367    if (start->isContentEditable()) {
     368#ifndef QT_NO_SHORTCUT
     369        QWebPage::WebAction action = QWebPagePrivate::editorActionForKeyEvent(kevent->qtEvent());
     370        if (action != QWebPage::NoWebAction) {
     371            m_page->triggerAction(action);
     372        } else
     373#endif // QT_NO_SHORTCUT
    368374        switch (kevent->windowsVirtualKeyCode()) {
    369375#if QT_VERSION < 0x040500
     
    431437                            frame->editor()->command("ToggleBold").execute();
    432438                            break;
    433                         case VK_C:
    434                             frame->editor()->command("Copy").execute();
    435                             break;
    436439                        case VK_I:
    437440                            frame->editor()->command("ToggleItalic").execute();
    438                             break;
    439                         case VK_V:
    440                             frame->editor()->command("Paste").execute();
    441                             break;
    442                         case VK_X:
    443                             frame->editor()->command("Cut").execute();
    444                             break;
    445                         case VK_Y:
    446                             frame->editor()->command("Redo").execute();
    447                             break;
    448                         case VK_Z:
    449                             frame->editor()->command("Undo").execute();
    450441                            break;
    451442                        default:
     
    460451        }
    461452    } else {
     453#ifndef QT_NO_SHORTCUT
     454        if (kevent->qtEvent() == QKeySequence::Copy) {
     455            m_page->triggerAction(QWebPage::Copy);
     456        } else
     457#endif // QT_NO_SHORTCUT
    462458        switch (kevent->windowsVirtualKeyCode()) {
    463459            case VK_UP:
     
    487483                            frame->editor()->command("SelectAll").execute();
    488484                            break;
    489                         case VK_C: case VK_X:
    490                             frame->editor()->command("Copy").execute();
    491                             break;
    492485                        default:
    493486                            return;
Note: See TracChangeset for help on using the changeset viewer.