Changeset 35558

Show
Ignore:
Timestamp:
08/05/08 06:40:57 (4 months ago)
Author:
vestbo@webkit.org
Message:

2008-08-05 Tor Arne Vestbø <tavestbo@trolltech.com>

Reviewed by Simon.

Move event handling of the return-key from EditorClientQt to QWebPage.

https://bugs.webkit.org/show_bug.cgi?id=20191

This is a first step in refactoring the big switch block
in EditorClientQt::handleKeyboardEvent to using WebActions
instead.

The new logic uses two new StandardKeys from QKeySequence:

  • InsertParagraphSeparator
  • InsertLineSeparator

Which translate to the commands InsertNewline and InsertLineBreak
respectivly. On Windows/X11 pressing the shift modifier will invoke
the latter action. For Mac this is triggered by pressing the meta
modifier (Ctrl).

Initial patch by: Erik Bunce

Location:
trunk/WebKit/qt
Files:
4 modified

Legend:

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

    r35537 r35558  
    155155    0, // InspectElement, 
    156156 
     157    "InsertNewline", // InsertParagraphSeparator 
     158    "InsertLineBreak", // InsertLineSeparator 
     159 
    157160    0 // WebActionCount 
    158161}; 
     
    593596        QKeySequence::StandardKey standardKey; 
    594597        QWebPage::WebAction action; 
    595     } editorActions[32] = { 
     598    } editorActions[] = { 
    596599        { QKeySequence::Cut, QWebPage::Cut }, 
    597600        { QKeySequence::Copy, QWebPage::Copy }, 
     
    625628        { QKeySequence::DeleteStartOfWord, QWebPage::DeleteStartOfWord }, 
    626629        { QKeySequence::DeleteEndOfWord, QWebPage::DeleteEndOfWord }, 
     630#if QT_VERSION >= 0x040500 
     631        { QKeySequence::InsertParagraphSeparator, QWebPage::InsertParagraphSeparator }, 
     632        { QKeySequence::InsertLineSeparator, QWebPage::InsertLineSeparator }, 
     633#endif 
    627634        { QKeySequence::UnknownKey, QWebPage::NoWebAction } 
    628635    }; 
     
    10431050    \value ToggleUnderline Toggle underlining. 
    10441051    \value InspectElement Show the Web Inspector with the currently highlighted HTML element. 
     1052    \value InsertParagraphSeparator Insert a new paragraph. 
     1053    \value InsertLineSeparator Insert a new line. 
    10451054    \omitvalue WebActionCount 
    10461055 
  • trunk/WebKit/qt/Api/qwebpage.h

    r34738 r35558  
    143143        InspectElement, 
    144144 
     145        InsertParagraphSeparator, 
     146        InsertLineSeparator, 
     147 
    145148        WebActionCount 
    146149    }; 
  • trunk/WebKit/qt/ChangeLog

    r35537 r35558  
     12008-08-05  Tor Arne VestbÞ  <tavestbo@trolltech.com> 
     2 
     3        Reviewed by Simon. 
     4 
     5        Move event handling of the return-key from EditorClientQt to QWebPage. 
     6         
     7        https://bugs.webkit.org/show_bug.cgi?id=20191 
     8         
     9        This is a first step in refactoring the big switch block 
     10        in EditorClientQt::handleKeyboardEvent to using WebActions 
     11        instead. 
     12         
     13        The new logic uses two new StandardKeys from QKeySequence: 
     14         
     15        - InsertParagraphSeparator 
     16        - InsertLineSeparator 
     17         
     18        Which translate to the commands InsertNewline and InsertLineBreak 
     19        respectivly. On Windows/X11 pressing the shift modifier will invoke 
     20        the latter action. For Mac this is triggered by pressing the meta 
     21        modifier (Ctrl). 
     22         
     23        Initial patch by: Erik Bunce 
     24 
     25        * Api/qwebpage.cpp: 
     26        (editorActionForKeyEvent): 
     27        * Api/qwebpage.h: 
     28        * WebCoreSupport/EditorClientQt.cpp: 
     29        (WebCore::EditorClientQt::handleKeyboardEvent): 
     30 
    1312008-08-04  Erik Bunce  <elbunce@thehive.com> 
    232 
  • trunk/WebKit/qt/WebCoreSupport/EditorClientQt.cpp

    r35481 r35558  
    345345    if (start->isContentEditable()) { 
    346346        switch (kevent->windowsVirtualKeyCode()) { 
     347#if QT_VERSION < 0x040500 
    347348            case VK_RETURN: 
    348                 frame->editor()->command("InsertLineBreak").execute(); 
    349                 break; 
     349#ifdef QT_WS_MAC 
     350                if (kevent->shiftKey() || kevent->metaKey()) 
     351#else 
     352                if (kevent->shiftKey()) 
     353#endif 
     354                    frame->editor()->command("InsertLineBreak").execute(); 
     355                else 
     356                    frame->editor()->command("InsertNewline").execute(); 
     357                break; 
     358#endif 
    350359            case VK_BACK: 
    351360                frame->editor()->deleteWithDirection(SelectionController::BACKWARD,