Changeset 54293 in webkit


Ignore:
Timestamp:
Feb 3, 2010 12:58:11 PM (14 years ago)
Author:
bweinstein@apple.com
Message:

Scroll does not work with IBM Thinkpad.
<https://bugs.webkit.org/show_bug.cgi?id=14227>
<rdar://7142545>

Reviewed by Steve Falkenburg.

When initializing the WebView, add two scrollbar Windows inside of
our WebView, to allow it to receive WM_VSCROLL and WM_HSCROLL events.
(similar to what Firefox did in: <https://bugzilla.mozilla.org/show_bug.cgi?id=507222>.

Only do this if the user has installed some kind of Trackpoint driver, using an algorithm
like <https://bugzilla.mozilla.org/show_bug.cgi?id=514927>.

Also, add code to handle WM_HSCROLL and WM_VSCROLL messages to scroll
the WebView.

  • WebView.cpp:

(WebView::verticalScroll): Handle the WM_VSCROLL messages, and scroll up and down

by lines or pages.

(WebView::horizontalScroll): Handle the WM_HSCROLL messages, and scroll left or right

by lines or pages.

(WebView::WebViewWndProc): Add cases for WM_VSCROLL and WM_HSCROLL.
(WebView::initWithFrame): Call shouldInitializeTrackPointHack, and if we should, create

vertical and horizontal scrollbars to receive WM_VSCROLL and WM_HSCROLL messages.

(WebView::shouldInitializeTrackPointHack): Check if there is a registry key for

the some kind of IBM Trackpoint driver.

  • WebView.h:
Location:
trunk/WebKit/win
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/win/ChangeLog

    r54263 r54293  
     12010-02-03  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Steve Falkenburg.
     4
     5        Scroll does not work with IBM Thinkpad.
     6        <https://bugs.webkit.org/show_bug.cgi?id=14227>
     7        <rdar://7142545>
     8       
     9        When initializing the WebView, add two scrollbar Windows inside of
     10        our WebView, to allow it to receive WM_VSCROLL and WM_HSCROLL events.
     11        (similar to what Firefox did in: <https://bugzilla.mozilla.org/show_bug.cgi?id=507222>.
     12       
     13        Only do this if the user has installed some kind of Trackpoint driver, using an algorithm
     14        like <https://bugzilla.mozilla.org/show_bug.cgi?id=514927>.
     15       
     16        Also, add code to handle WM_HSCROLL and WM_VSCROLL messages to scroll
     17        the WebView.
     18
     19        * WebView.cpp:
     20        (WebView::verticalScroll): Handle the WM_VSCROLL messages, and scroll up and down
     21            by lines or pages.
     22        (WebView::horizontalScroll): Handle the WM_HSCROLL messages, and scroll left or right
     23            by lines or pages.
     24        (WebView::WebViewWndProc): Add cases for WM_VSCROLL and WM_HSCROLL.
     25        (WebView::initWithFrame): Call shouldInitializeTrackPointHack, and if we should, create
     26            vertical and horizontal scrollbars to receive WM_VSCROLL and WM_HSCROLL messages.
     27        (WebView::shouldInitializeTrackPointHack): Check if there is a registry key for
     28            the some kind of IBM Trackpoint driver.
     29        * WebView.h:
     30
    1312010-02-02  Steve Falkenburg  <sfalken@apple.com>
    232
  • trunk/WebKit/win/WebView.cpp

    r53423 r54293  
    15891589    return coreFrame->eventHandler()->handleWheelEvent(wheelEvent);
    15901590}
     1591
     1592bool WebView::verticalScroll(WPARAM wParam, LPARAM /*lParam*/)
     1593{
     1594    ScrollDirection direction;
     1595    ScrollGranularity granularity;
     1596    switch (LOWORD(wParam)) {
     1597    case SB_LINEDOWN:
     1598        granularity = ScrollByLine;
     1599        direction = ScrollDown;
     1600        break;
     1601    case SB_LINEUP:
     1602        granularity = ScrollByLine;
     1603        direction = ScrollUp;
     1604        break;
     1605    case SB_PAGEDOWN:
     1606        granularity = ScrollByDocument;
     1607        direction = ScrollDown;
     1608        break;
     1609    case SB_PAGEUP:
     1610        granularity = ScrollByDocument;
     1611        direction = ScrollUp;
     1612        break;
     1613    default:
     1614        return false;
     1615        break;
     1616    }
     1617   
     1618    Frame* frame = m_page->focusController()->focusedOrMainFrame();
     1619    return frame->eventHandler()->scrollRecursively(direction, granularity);
     1620}
     1621
     1622bool WebView::horizontalScroll(WPARAM wParam, LPARAM /*lParam*/)
     1623{
     1624    ScrollDirection direction;
     1625    ScrollGranularity granularity;
     1626    switch (LOWORD(wParam)) {
     1627    case SB_LINELEFT:
     1628        granularity = ScrollByLine;
     1629        direction = ScrollLeft;
     1630        break;
     1631    case SB_LINERIGHT:
     1632        granularity = ScrollByLine;
     1633        direction = ScrollRight;
     1634        break;
     1635    case SB_PAGELEFT:
     1636        granularity = ScrollByDocument;
     1637        direction = ScrollLeft;
     1638        break;
     1639    case SB_PAGERIGHT:
     1640        granularity = ScrollByDocument;
     1641        direction = ScrollRight;
     1642        break;
     1643    default:
     1644        return false;
     1645    }
     1646
     1647    Frame* frame = m_page->focusController()->focusedOrMainFrame();
     1648    return frame->eventHandler()->scrollRecursively(direction, granularity);
     1649}
     1650
    15911651
    15921652bool WebView::execCommand(WPARAM wParam, LPARAM /*lParam*/)
     
    21562216
    21572217            __fallthrough;
     2218        case WM_VSCROLL:
     2219            handled = webView->verticalScroll(wParam, lParam);
     2220            break;
     2221        case WM_HSCROLL:
     2222            handled = webView->horizontalScroll(wParam, lParam);
     2223            break;
    21582224        default:
    21592225            handled = false;
     
    23882454    initialized = true;
    23892455}
     2456
     2457bool WebView::shouldInitializeTrackPointHack()
     2458{
     2459    static bool shouldCreateScrollbars;
     2460    static bool hasRunTrackPointCheck;
     2461
     2462    if (hasRunTrackPointCheck)
     2463        return shouldCreateScrollbars;
     2464
     2465    hasRunTrackPointCheck = true;
     2466    const TCHAR trackPointKeys[][50] = { TEXT("Software\\Lenovo\\TrackPoint"),
     2467        TEXT("Software\\Lenovo\\UltraNav"),
     2468        TEXT("Software\\Alps\\Apoint\\TrackPoint"),
     2469        TEXT("Software\\Synaptics\\SynTPEnh\\UltraNavUSB"),
     2470        TEXT("Software\\Synaptics\\SynTPEnh\\UltraNavPS2") };
     2471
     2472    for (int i = 0; i < 5; ++i) {
     2473        HKEY trackPointKey;
     2474        int readKeyResult = ::RegOpenKeyEx(HKEY_CURRENT_USER, trackPointKeys[i], 0, KEY_READ, &trackPointKey);
     2475        ::RegCloseKey(trackPointKey);
     2476        if (readKeyResult == ERROR_SUCCESS) {
     2477            shouldCreateScrollbars = true;
     2478            return shouldCreateScrollbars;
     2479        }
     2480    }
     2481
     2482    return shouldCreateScrollbars;
     2483}
    23902484   
    23912485HRESULT STDMETHODCALLTYPE WebView::initWithFrame(
     
    24042498        frame.left, frame.top, frame.right - frame.left, frame.bottom - frame.top, m_hostWindow ? m_hostWindow : HWND_MESSAGE, 0, gInstance, 0);
    24052499    ASSERT(::IsWindow(m_viewWindow));
     2500
     2501    if (shouldInitializeTrackPointHack()) {
     2502        // If we detected a registry key belonging to a TrackPoint driver, then create fake trackpoint
     2503        // scrollbars, so the WebView will receive WM_VSCROLL and WM_HSCROLL messages. We create one
     2504        // vertical scrollbar and one horizontal to allow for receiving both types of messages.
     2505        ::CreateWindow(TEXT("SCROLLBAR"), TEXT("FAKETRACKPOINTHSCROLLBAR"), WS_CHILD | WS_VISIBLE | SBS_HORZ, 0, 0, 0, 0, m_viewWindow, 0, gInstance, 0);
     2506        ::CreateWindow(TEXT("SCROLLBAR"), TEXT("FAKETRACKPOINTVSCROLLBAR"), WS_CHILD | WS_VISIBLE | SBS_VERT, 0, 0, 0, 0, m_viewWindow, 0, gInstance, 0);
     2507    }
    24062508
    24072509    hr = registerDragDrop();
  • trunk/WebKit/win/WebView.h

    r53423 r54293  
    794794    void performContextMenuAction(WPARAM, LPARAM, bool byPosition);
    795795    bool mouseWheel(WPARAM, LPARAM, bool isMouseHWheel);
     796    bool verticalScroll(WPARAM, LPARAM);
     797    bool horizontalScroll(WPARAM, LPARAM);
    796798    bool gesture(WPARAM, LPARAM);
    797799    bool gestureNotify(WPARAM, LPARAM);
     
    919921    LRESULT onIMERequestReconvertString(WebCore::Frame*, RECONVERTSTRING*);
    920922    bool developerExtrasEnabled() const;
     923
     924    bool shouldInitializeTrackPointHack();
    921925
    922926    // AllWebViewSet functions
Note: See TracChangeset for help on using the changeset viewer.