Changeset 71388 in webkit


Ignore:
Timestamp:
Nov 4, 2010 9:31:22 PM (13 years ago)
Author:
tonikitoo@webkit.org
Message:

2010-10-20 Chang Shu <chang.shu@nokia.com>, Antonio Gomes <tonikitoo@webkit.org>

Reviewed by Simon Fraser.

Spatial Navigation: add support to <input type=text> and <textarea>
https://bugs.webkit.org/show_bug.cgi?id=37153

Before this patch, the focus cannot move away from input box once it is in. This patch allows focus
move to neighbor nodes when the caret reaches the edge of the texts. This patch does not support yet
cases where the focused <input> has a JS handler for the arrow keys.

WebCore:

Tests: fast/events/spatial-navigation/snav-input.html
fast/events/spatial-navigation/snav-textarea.html

  • editing/EditorCommand.cpp: (WebCore::executeMoveDown): (WebCore::executeMoveLeft): (WebCore::executeMoveRight): (WebCore::executeMoveUp):
  • editing/SelectionController.cpp: (WebCore::SelectionController::modify):

WebKit/qt:

  • WebCoreSupport/EditorClientQt.cpp: WebCore::EditorClientQt::handleKeyboardEvent):

LayoutTests:

  • fast/events/spatial-navigation/snav-input-expected.txt: Added.
  • fast/events/spatial-navigation/snav-input.html: Added.
  • fast/events/spatial-navigation/snav-textarea-expected.txt: Added.
  • fast/events/spatial-navigation/snav-textarea.html: Added.
Location:
trunk
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r71387 r71388  
     12010-10-20  Chang Shu  <chang.shu@nokia.com>, Antonio Gomes <tonikitoo@webkit.org>
     2
     3        Reviewed by Simon Fraser.
     4
     5        [Qt] Makes <input type=text> and <textarea> functional with
     6        Spatial Navigation enabled. Before this patch, the focus cannot
     7        move away from input box once it is in. This patch allows focus
     8        move to neighbor nodes when the caret reaches the edge of the texts.
     9        This patch does not support yet cases where the focused <input>
     10        has a JS handler for the arrow keys.
     11        https://bugs.webkit.org/show_bug.cgi?id=37153
     12
     13        * fast/events/spatial-navigation/snav-input-expected.txt: Added.
     14        * fast/events/spatial-navigation/snav-input.html: Added.
     15        * fast/events/spatial-navigation/snav-textarea-expected.txt: Added.
     16        * fast/events/spatial-navigation/snav-textarea.html: Added.
     17
    1182010-11-04  Martin Robinson  <mrobinson@igalia.com>
    219
  • trunk/LayoutTests/platform/gtk/Skipped

    r71387 r71388  
    49674967fast/loader/crash-copying-backforwardlist.html
    49684968
     4969# Spatial Navigation
    49694970# https://bugs.webkit.org/show_bug.cgi?id=47587
    49704971fast/events/spatial-navigation/snav-iframe-flattening-simple.html
     4972# https://bugs.webkit.org/show_bug.cgi?id=49056
     4973fast/events/spatial-navigation/snav-input.html
     4974fast/events/spatial-navigation/snav-textarea.html
    49714975
    49724976# Implement LayoutTestController::callShouldCloseOnWebView()
  • trunk/WebCore/ChangeLog

    r71386 r71388  
     12010-10-20  Chang Shu  <chang.shu@nokia.com>, Antonio Gomes <tonikitoo@webkit.org>
     2
     3        Reviewed by Simon Fraser.
     4
     5        [Qt] Makes <input type=text> and <textarea> functional with
     6        Spatial Navigation enabled. Before this patch, the focus cannot
     7        move away from input box once it is in. This patch allows focus
     8        move to neighbor nodes when the caret reaches the edge of the texts.
     9        This patch does not support yet cases where the focused <input>
     10        has a JS handler for the arrow keys.
     11        https://bugs.webkit.org/show_bug.cgi?id=37153
     12
     13        Tests: fast/events/spatial-navigation/snav-input.html
     14               fast/events/spatial-navigation/snav-textarea.html
     15
     16        * editing/EditorCommand.cpp:
     17        (WebCore::executeMoveDown):
     18        (WebCore::executeMoveLeft):
     19        (WebCore::executeMoveRight):
     20        (WebCore::executeMoveUp):
     21        * editing/SelectionController.cpp:
     22        (WebCore::SelectionController::modify):
     23
    1242010-11-04  Dan Bernstein  <mitz@apple.com>
    225
  • trunk/WebCore/editing/EditorCommand.cpp

    r71385 r71388  
    619619static bool executeMoveDown(Frame* frame, Event*, EditorCommandSource, const String&)
    620620{
    621     frame->selection()->modify(SelectionController::AlterationMove, SelectionController::DirectionForward, LineGranularity, true);
    622     return true;
     621    return frame->selection()->modify(SelectionController::AlterationMove, SelectionController::DirectionForward, LineGranularity, true);
    623622}
    624623
     
    643642static bool executeMoveLeft(Frame* frame, Event*, EditorCommandSource, const String&)
    644643{
    645     frame->selection()->modify(SelectionController::AlterationMove, SelectionController::DirectionLeft, CharacterGranularity, true);
    646     return true;
     644    return frame->selection()->modify(SelectionController::AlterationMove, SelectionController::DirectionLeft, CharacterGranularity, true);
    647645}
    648646
     
    687685static bool executeMoveRight(Frame* frame, Event*, EditorCommandSource, const String&)
    688686{
    689     frame->selection()->modify(SelectionController::AlterationMove, SelectionController::DirectionRight, CharacterGranularity, true);
    690     return true;
     687    return frame->selection()->modify(SelectionController::AlterationMove, SelectionController::DirectionRight, CharacterGranularity, true);
    691688}
    692689
     
    807804static bool executeMoveUp(Frame* frame, Event*, EditorCommandSource, const String&)
    808805{
    809     frame->selection()->modify(SelectionController::AlterationMove, SelectionController::DirectionBackward, LineGranularity, true);
    810     return true;
     806    return frame->selection()->modify(SelectionController::AlterationMove, SelectionController::DirectionBackward, LineGranularity, true);
    811807}
    812808
  • trunk/WebCore/editing/SelectionController.cpp

    r70143 r71388  
    643643    willBeModified(alter, direction);
    644644
     645    bool wasRange = m_selection.isRange();
     646    Position originalStartPosition = m_selection.start();
    645647    VisiblePosition position;
    646648    switch (direction) {
     
    673675    if (position.isNull())
    674676        return false;
     677
     678    if (m_frame && m_frame->settings() && m_frame->settings()->isSpatialNavigationEnabled())
     679        if (!wasRange && alter == AlterationMove && position == originalStartPosition)
     680            return false;
    675681
    676682    // Some of the above operations set an xPosForVerticalArrowNavigation.
  • trunk/WebKit/qt/ChangeLog

    r71352 r71388  
     12010-10-20  Chang Shu  <chang.shu@nokia.com>, Antonio Gomes <tonikitoo@webkit.org>
     2
     3        Reviewed by Simon Fraser.
     4
     5        [Qt] Makes <input type=text> and <textarea> functional with
     6        Spatial Navigation enabled. Before this patch, the focus cannot
     7        move away from input box once it is in. This patch allows focus
     8        move to neighbor nodes when the caret reaches the edge of the texts.
     9        This patch does not support yet cases where the focused <input>
     10        has a JS handler for the arrow keys.
     11        https://bugs.webkit.org/show_bug.cgi?id=37153
     12
     13        * WebCoreSupport/EditorClientQt.cpp:
     14        (WebCore::EditorClientQt::handleKeyboardEvent):
     15
    1162010-11-04  Kenneth Rohde Christiansen  <kenneth@webkit.org>
    217
  • trunk/WebKit/qt/WebCoreSupport/EditorClientQt.cpp

    r69582 r71388  
    4747#include "QWebPageClient.h"
    4848#include "Range.h"
     49#include "Settings.h"
    4950#include "WindowsKeyboardCodes.h"
    5051#include "qwebpage.h"
     
    361362    // FIXME: refactor all of this to use Actions or something like them
    362363    if (start->isContentEditable()) {
     364        bool doSpatialNavigation = false;
     365        if (frame->settings() && frame->settings()->isSpatialNavigationEnabled()) {
     366            if (!kevent->modifiers()) {
     367                switch (kevent->windowsVirtualKeyCode()) {
     368                case VK_LEFT:
     369                case VK_RIGHT:
     370                case VK_UP:
     371                case VK_DOWN:
     372                    doSpatialNavigation = true;
     373                }
     374            }
     375        }
    363376#ifndef QT_NO_SHORTCUT
    364377        QWebPage::WebAction action = QWebPagePrivate::editorActionForKeyEvent(kevent->qtEvent());
    365         if (action != QWebPage::NoWebAction) {
     378        if (action != QWebPage::NoWebAction && !doSpatialNavigation) {
    366379            const char* cmd = QWebPagePrivate::editorCommandForWebActions(action);
    367380            // WebKit doesn't have enough information about mode to decide how commands that just insert text if executed via Editor should be treated,
     
    387400            if (kevent->shiftKey())
    388401                frame->editor()->command("MoveLeftAndModifySelection").execute();
    389             else
    390                 frame->editor()->command("MoveLeft").execute();
     402            else if (!frame->editor()->command("MoveLeft").execute())
     403                return;
    391404            break;
    392405        case VK_RIGHT:
    393406            if (kevent->shiftKey())
    394407                frame->editor()->command("MoveRightAndModifySelection").execute();
    395             else
    396                 frame->editor()->command("MoveRight").execute();
     408            else if (!frame->editor()->command("MoveRight").execute())
     409                return;
    397410            break;
    398411        case VK_UP:
    399412            if (kevent->shiftKey())
    400413                frame->editor()->command("MoveUpAndModifySelection").execute();
    401             else
    402                 frame->editor()->command("MoveUp").execute();
     414            else if (!frame->editor()->command("MoveUp").execute())
     415                return;
    403416            break;
    404417        case VK_DOWN:
    405418            if (kevent->shiftKey())
    406419                frame->editor()->command("MoveDownAndModifySelection").execute();
    407             else
    408                 frame->editor()->command("MoveDown").execute();
     420            else if (!frame->editor()->command("MoveDown").execute())
     421                return;
    409422            break;
    410423        case VK_PRIOR: // PageUp
Note: See TracChangeset for help on using the changeset viewer.