Changeset 64086 in webkit


Ignore:
Timestamp:
Jul 26, 2010 4:06:34 PM (14 years ago)
Author:
weinig@apple.com
Message:

Patch for https://bugs.webkit.org/show_bug.cgi?id=43013
Part of <rdar://problem/8152434>
Add support for scrolling using the keyboard in WebKit2

Reviewed by Anders Carlsson.

WebCore:

Add a new export and make WindowsKeyboardCodes private.

  • WebCore.exp.in:
  • WebCore.xcodeproj/project.pbxproj:

WebKit2:

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::getScrollMapping):
(WebKit::WebPage::keyEvent):
Scroll the page in response to keyDown.

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/mac/WebPageMac.mm:

Use WindowsKeyboardCodes.h instead of redefining the constants.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r64085 r64086  
     12010-07-26  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Patch for https://bugs.webkit.org/show_bug.cgi?id=43013
     6        Part of <rdar://problem/8152434>
     7        Add support for scrolling using the keyboard in WebKit2
     8
     9        Add a new export and make WindowsKeyboardCodes private.
     10
     11        * WebCore.exp.in:
     12        * WebCore.xcodeproj/project.pbxproj:
     13
    1142010-07-26  Darin Adler  <darin@apple.com>
    215
  • trunk/WebCore/WebCore.exp.in

    r64070 r64086  
    216216__ZN7WebCore12EventHandler15sendScrollEventEv
    217217__ZN7WebCore12EventHandler16handleWheelEventERNS_18PlatformWheelEventE
     218__ZN7WebCore12EventHandler17scrollRecursivelyENS_15ScrollDirectionENS_17ScrollGranularityEPNS_4NodeE
    218219__ZN7WebCore12EventHandler20handleTextInputEventERKNS_6StringEPNS_5EventEbb
    219220__ZN7WebCore12EventHandler20hitTestResultAtPointERKNS_8IntPointEbbNS_17HitTestScrollbarsEj
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r64058 r64086  
    50965096                E1CA5CBC0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1CA5CBB0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp */; };
    50975097                E1CAA5C60E8BD23600A73ECA /* JSWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = E1CAA5C50E8BD23600A73ECA /* JSWorker.h */; };
    5098                 E1E1BF00115FF6FB006F52CA /* WindowsKeyboardCodes.h in Headers */ = {isa = PBXBuildFile; fileRef = E1E1BEFF115FF6FB006F52CA /* WindowsKeyboardCodes.h */; };
     5098                E1E1BF00115FF6FB006F52CA /* WindowsKeyboardCodes.h in Headers */ = {isa = PBXBuildFile; fileRef = E1E1BEFF115FF6FB006F52CA /* WindowsKeyboardCodes.h */; settings = {ATTRIBUTES = (Private, ); }; };
    50995099                E1E6EEA40B628DA8005F2F70 /* JSHTMLSelectElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1E6EEA30B628DA8005F2F70 /* JSHTMLSelectElement.cpp */; };
    51005100                E1E6EEA80B628DB3005F2F70 /* JSHTMLSelectElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E1E6EEA70B628DB3005F2F70 /* JSHTMLSelectElement.h */; };
  • trunk/WebKit2/ChangeLog

    r64079 r64086  
     12010-07-26  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Patch for https://bugs.webkit.org/show_bug.cgi?id=43013
     6        Part of <rdar://problem/8152434>
     7        Add support for scrolling using the keyboard in WebKit2
     8
     9        * WebProcess/WebPage/WebPage.cpp:
     10        (WebKit::getScrollMapping):
     11        (WebKit::WebPage::keyEvent):
     12        Scroll the page in response to keyDown.
     13        * WebProcess/WebPage/WebPage.h:
     14        * WebProcess/WebPage/mac/WebPageMac.mm:
     15        Use WindowsKeyboardCodes.h instead of redefining the constants.
     16
    1172010-07-26  Ada Chan  <adachan@apple.com>
    218
  • trunk/WebKit2/WebProcess/WebPage/WebPage.cpp

    r64063 r64086  
    5858#include <WebCore/ResourceRequest.h>
    5959#include <WebCore/Settings.h>
     60#include <WebCore/WindowsKeyboardCodes.h>
    6061#include <runtime/JSLock.h>
    6162#include <runtime/JSValue.h>
     
    344345}
    345346
     347static bool getScrollMapping(const WebKeyboardEvent& event, ScrollDirection& direction, ScrollGranularity& granularity)
     348{
     349    if (event.type() != WebEvent::KeyDown && event.type() != WebEvent::RawKeyDown)
     350        return false;
     351
     352    switch (event.windowsVirtualKeyCode()) {
     353    case VK_LEFT:
     354        granularity = ScrollByLine;
     355        direction = ScrollLeft;
     356        break;
     357    case VK_RIGHT:
     358        granularity = ScrollByLine;
     359        direction = ScrollRight;
     360        break;
     361    case VK_UP:
     362        granularity = ScrollByLine;
     363        direction = ScrollUp;
     364        break;
     365    case VK_DOWN:
     366        granularity = ScrollByLine;
     367        direction = ScrollDown;
     368        break;
     369    case VK_HOME:
     370        granularity = ScrollByDocument;
     371        direction = ScrollUp;
     372        break;
     373    case VK_END:
     374        granularity = ScrollByDocument;
     375        direction = ScrollDown;
     376        break;
     377    case VK_PRIOR:
     378        granularity = ScrollByPage;
     379        direction = ScrollUp;
     380        break;
     381    case VK_NEXT:
     382        granularity = ScrollByPage;
     383        direction = ScrollDown;
     384        break;
     385    default:
     386        return false;
     387    }
     388
     389    return true;
     390}
     391
    346392void WebPage::keyEvent(const WebKeyboardEvent& keyboardEvent)
    347393{
     
    354400
    355401    PlatformKeyboardEvent platformKeyboardEvent = platform(keyboardEvent);
    356     m_page->focusController()->focusedOrMainFrame()->eventHandler()->keyEvent(platformKeyboardEvent);
     402
     403    Frame* frame = m_page->focusController()->focusedOrMainFrame();
     404    frame->eventHandler()->keyEvent(platformKeyboardEvent);
     405
     406    ScrollDirection direction;
     407    ScrollGranularity granularity;
     408    if (getScrollMapping(keyboardEvent, direction, granularity))
     409        frame->eventHandler()->scrollRecursively(direction, granularity);
    357410}
    358411
  • trunk/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

    r57309 r64086  
    2929#include <WebCore/Page.h>
    3030#include <WebCore/PlatformKeyboardEvent.h>
     31#include <WebCore/WindowsKeyboardCodes.h>
    3132
    3233using namespace WebCore;
     
    4647static const unsigned MetaKey   = 1 << 3;
    4748
    48 static const unsigned VKEY_BACK         = 0x08;
    49 static const unsigned VKEY_TAB          = 0x09;
    50 static const unsigned VKEY_RETURN       = 0x0D;
    51 static const unsigned VKEY_ESCAPE       = 0x1B;
    52 static const unsigned VKEY_PRIOR        = 0x21;
    53 static const unsigned VKEY_NEXT         = 0x22;
    54 static const unsigned VKEY_END          = 0x23;
    55 static const unsigned VKEY_HOME         = 0x24;
    56 static const unsigned VKEY_LEFT         = 0x25;
    57 static const unsigned VKEY_UP           = 0x26;
    58 static const unsigned VKEY_RIGHT        = 0x27;
    59 static const unsigned VKEY_DOWN         = 0x28;
    60 static const unsigned VKEY_INSERT       = 0x2D;
    61 static const unsigned VKEY_DELETE       = 0x2E;
    62 static const unsigned VKEY_OEM_PERIOD   = 0xBE;
    63 
    6449// Keys with special meaning. These will be delegated to the editor using
    6550// the execCommand() method
     
    7762
    7863static const KeyDownEntry keyDownEntries[] = {
    79     { VKEY_LEFT,   0,                   "MoveLeft"                                      },
    80     { VKEY_LEFT,   ShiftKey,            "MoveLeftAndModifySelection"                    },
    81     { VKEY_LEFT,   AltKey,              "MoveWordLeft"                                  },
    82     { VKEY_LEFT,   AltKey | ShiftKey,   "MoveWordLeftAndModifySelection"                },
    83     { VKEY_RIGHT,  0,                   "MoveRight"                                     },
    84     { VKEY_RIGHT,  ShiftKey,            "MoveRightAndModifySelection"                   },
    85     { VKEY_RIGHT,  AltKey,              "MoveWordRight"                                 },
    86     { VKEY_RIGHT,  AltKey | ShiftKey,   "MoveWordRightAndModifySelection"               },
    87     { VKEY_UP,     0,                   "MoveUp"                                        },
    88     { VKEY_UP,     ShiftKey,            "MoveUpAndModifySelection"                      },
    89     { VKEY_PRIOR,  ShiftKey,            "MovePageUpAndModifySelection"                  },
    90     { VKEY_DOWN,   0,                   "MoveDown"                                      },
    91     { VKEY_DOWN,   ShiftKey,            "MoveDownAndModifySelection"                    },
    92     { VKEY_NEXT,   ShiftKey,            "MovePageDownAndModifySelection"                },
    93     { VKEY_PRIOR,  0,                   "MovePageUp"                                    },
    94     { VKEY_NEXT,   0,                   "MovePageDown"                                  },
     64    { VK_LEFT,     0,                   "MoveLeft"                                      },
     65    { VK_LEFT,     ShiftKey,            "MoveLeftAndModifySelection"                    },
     66    { VK_LEFT,     AltKey,              "MoveWordLeft"                                  },
     67    { VK_LEFT,     AltKey | ShiftKey,   "MoveWordLeftAndModifySelection"                },
     68    { VK_RIGHT,    0,                   "MoveRight"                                     },
     69    { VK_RIGHT,    ShiftKey,            "MoveRightAndModifySelection"                   },
     70    { VK_RIGHT,    AltKey,              "MoveWordRight"                                 },
     71    { VK_RIGHT,    AltKey | ShiftKey,   "MoveWordRightAndModifySelection"               },
     72    { VK_UP,       0,                   "MoveUp"                                        },
     73    { VK_UP,       ShiftKey,            "MoveUpAndModifySelection"                      },
     74    { VK_PRIOR,    ShiftKey,            "MovePageUpAndModifySelection"                  },
     75    { VK_DOWN,     0,                   "MoveDown"                                      },
     76    { VK_DOWN,     ShiftKey,            "MoveDownAndModifySelection"                    },
     77    { VK_NEXT,     ShiftKey,            "MovePageDownAndModifySelection"                },
     78    { VK_PRIOR,    0,                   "MovePageUp"                                    },
     79    { VK_NEXT,     0,                   "MovePageDown"                                  },
    9580
    96     { VKEY_HOME,   0,                   "MoveToBeginningOfLine"                         },
    97     { VKEY_HOME,   ShiftKey,            "MoveToBeginningOfLineAndModifySelection"       },
    98     { VKEY_LEFT,   MetaKey,             "MoveToBeginningOfLine"                         },
    99     { VKEY_LEFT,   MetaKey | ShiftKey,  "MoveToBeginningOfLineAndModifySelection"       },
    100     { VKEY_UP,     MetaKey,             "MoveToBeginningOfDocument"                     },
    101     { VKEY_UP,     MetaKey | ShiftKey,  "MoveToBeginningOfDocumentAndModifySelection"   },
     81    { VK_HOME,     0,                   "MoveToBeginningOfLine"                         },
     82    { VK_HOME,     ShiftKey,            "MoveToBeginningOfLineAndModifySelection"       },
     83    { VK_LEFT,     MetaKey,             "MoveToBeginningOfLine"                         },
     84    { VK_LEFT,     MetaKey | ShiftKey,  "MoveToBeginningOfLineAndModifySelection"       },
     85    { VK_UP,       MetaKey,             "MoveToBeginningOfDocument"                     },
     86    { VK_UP,       MetaKey | ShiftKey,  "MoveToBeginningOfDocumentAndModifySelection"   },
    10287
    103     { VKEY_END,    0,                   "MoveToEndOfLine"                               },
    104     { VKEY_END,    ShiftKey,            "MoveToEndOfLineAndModifySelection"             },
    105     { VKEY_DOWN,   MetaKey,             "MoveToEndOfDocument"                           },
    106     { VKEY_DOWN,   MetaKey | ShiftKey,  "MoveToEndOfDocumentAndModifySelection"         },
    107     { VKEY_RIGHT,  MetaKey,             "MoveToEndOfLine"                               },
    108     { VKEY_RIGHT,  MetaKey | ShiftKey,  "MoveToEndOfLineAndModifySelection"             },
     88    { VK_END,      0,                   "MoveToEndOfLine"                               },
     89    { VK_END,      ShiftKey,            "MoveToEndOfLineAndModifySelection"             },
     90    { VK_DOWN,     MetaKey,             "MoveToEndOfDocument"                           },
     91    { VK_DOWN,     MetaKey | ShiftKey,  "MoveToEndOfDocumentAndModifySelection"         },
     92    { VK_RIGHT,    MetaKey,             "MoveToEndOfLine"                               },
     93    { VK_RIGHT,    MetaKey | ShiftKey,  "MoveToEndOfLineAndModifySelection"             },
    10994
    110     { VKEY_BACK,   0,                   "DeleteBackward"                                },
    111     { VKEY_BACK,   ShiftKey,            "DeleteBackward"                                },
    112     { VKEY_DELETE, 0,                   "DeleteForward"                                 },
    113     { VKEY_BACK,   AltKey,              "DeleteWordBackward"                            },
    114     { VKEY_DELETE, AltKey,              "DeleteWordForward"                             },
     95    { VK_BACK,     0,                   "DeleteBackward"                                },
     96    { VK_BACK,     ShiftKey,            "DeleteBackward"                                },
     97    { VK_DELETE,  0,                   "DeleteForward"                                 },
     98    { VK_BACK,     AltKey,              "DeleteWordBackward"                            },
     99    { VK_DELETE,  AltKey,              "DeleteWordForward"                             },
    115100
    116101    { 'B',         CtrlKey,             "ToggleBold"                                    },
    117102    { 'I',         CtrlKey,             "ToggleItalic"                                  },
    118103
    119     { VKEY_ESCAPE, 0,                   "Cancel"                                        },
    120     { VKEY_OEM_PERIOD, CtrlKey,         "Cancel"                                        },
    121     { VKEY_TAB,    0,                   "InsertTab"                                     },
    122     { VKEY_TAB,    ShiftKey,            "InsertBacktab"                                 },
    123     { VKEY_RETURN, 0,                   "InsertNewline"                                 },
    124     { VKEY_RETURN, CtrlKey,             "InsertNewline"                                 },
    125     { VKEY_RETURN, AltKey,              "InsertNewline"                                 },
    126     { VKEY_RETURN, AltKey | ShiftKey,   "InsertNewline"                                 },
    127     { VKEY_RETURN, ShiftKey,            "InsertLineBreak"                               },
     104    { VK_ESCAPE,  0,                   "Cancel"                                        },
     105    { VK_OEM_PERIOD, CtrlKey,           "Cancel"                                        },
     106    { VK_TAB,      0,                   "InsertTab"                                     },
     107    { VK_TAB,      ShiftKey,            "InsertBacktab"                                 },
     108    { VK_RETURN,  0,                   "InsertNewline"                                 },
     109    { VK_RETURN,  CtrlKey,             "InsertNewline"                                 },
     110    { VK_RETURN,  AltKey,              "InsertNewline"                                 },
     111    { VK_RETURN,  AltKey | ShiftKey,   "InsertNewline"                                 },
     112    { VK_RETURN,  ShiftKey,            "InsertLineBreak"                               },
    128113
    129114    { 'C',         MetaKey,             "Copy"                                          },
     
    131116    { 'X',         MetaKey,             "Cut"                                           },
    132117    { 'A',         MetaKey,             "SelectAll"                                     },
    133     { VKEY_INSERT, CtrlKey,             "Copy"                                          },
    134     { VKEY_INSERT, ShiftKey,            "Paste"                                         },
    135     { VKEY_DELETE, ShiftKey,            "Cut"                                           },
     118    { VK_INSERT,  CtrlKey,             "Copy"                                          },
     119    { VK_INSERT,  ShiftKey,            "Paste"                                         },
     120    { VK_DELETE,  ShiftKey,            "Cut"                                           },
    136121    { 'Z',         MetaKey,             "Undo"                                          },
    137122    { 'Z',         MetaKey | ShiftKey,  "Redo"                                          },
Note: See TracChangeset for help on using the changeset viewer.