Changeset 81895 in webkit


Ignore:
Timestamp:
Mar 24, 2011 1:47:49 PM (13 years ago)
Author:
bweinstein@apple.com
Message:

WebKit2: Add Trackpoint driver hack to support IBM trackpads
https://bugs.webkit.org/show_bug.cgi?id=49830
<rdar://problem/8705951>

Reviewed by Adam Roben.

Copy code from WebKit1 to WebKit2 to handle initializing fake scrollbars so
IBM machines with a trackpad send us WM_VSCROLL and WM_HSCROLL messages.

Listen for the WM_VSCROLL and WM_HSCROLL messages, and turn the values into
ScrollDirection and ScrollGranularity, and send a scroll command to the
WebProcess.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::scrollBy): Send a message to the WebProcess.

  • UIProcess/WebPageProxy.h:
  • UIProcess/win/WebView.cpp:

(WebKit::WebView::wndProc): Add WM_VSCROLL and WM_HSCROLL message handling.
(WebKit::WebView::initialize): Call shouldInitializeTrackPointHack.
(WebKit::WebView::onHorizontalScroll): Turn wParam into a ScrollDirection and ScrollGranularity.
(WebKit::WebView::onVerticalScroll): Ditto.
(WebKit::WebView::shouldInitializeTrackPointHack): Check the registry for keys that indicate

the machine has a IBM Trackpoint driver.

  • UIProcess/win/WebView.h:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::scrollBy): Call scroll method.
(WebKit::WebPage::scroll): Moved from WebPageMac and WebPageWin.
(WebKit::WebPage::logicalScroll): Ditto.

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in: Add a new scrollBy message.
  • WebProcess/WebPage/mac/WebPageMac.mm: Remove scroll and logicalScroll, they are now in WebPage.cpp.
  • WebProcess/WebPage/win/WebPageWin.cpp: Ditto.
Location:
trunk/Source/WebKit2
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r81890 r81895  
     12011-03-24  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Adam Roben.
     4
     5        WebKit2: Add Trackpoint driver hack to support IBM trackpads
     6        https://bugs.webkit.org/show_bug.cgi?id=49830
     7        <rdar://problem/8705951>
     8
     9        Copy code from WebKit1 to WebKit2 to handle initializing fake scrollbars so
     10        IBM machines with a trackpad send us WM_VSCROLL and WM_HSCROLL messages.
     11
     12        Listen for the WM_VSCROLL and WM_HSCROLL messages, and turn the values into
     13        ScrollDirection and ScrollGranularity, and send a scroll command to the
     14        WebProcess.
     15
     16        * UIProcess/WebPageProxy.cpp:
     17        (WebKit::WebPageProxy::scrollBy): Send a message to the WebProcess.
     18        * UIProcess/WebPageProxy.h:
     19        * UIProcess/win/WebView.cpp:
     20        (WebKit::WebView::wndProc): Add WM_VSCROLL and WM_HSCROLL message handling.
     21        (WebKit::WebView::initialize): Call shouldInitializeTrackPointHack.
     22        (WebKit::WebView::onHorizontalScroll): Turn wParam into a ScrollDirection and ScrollGranularity.
     23        (WebKit::WebView::onVerticalScroll): Ditto.
     24        (WebKit::WebView::shouldInitializeTrackPointHack): Check the registry for keys that indicate
     25            the machine has a IBM Trackpoint driver.
     26        * UIProcess/win/WebView.h:
     27        * WebProcess/WebPage/WebPage.cpp:
     28        (WebKit::WebPage::scrollBy): Call scroll method.
     29        (WebKit::WebPage::scroll): Moved from WebPageMac and WebPageWin.
     30        (WebKit::WebPage::logicalScroll): Ditto.
     31        * WebProcess/WebPage/WebPage.h:
     32        * WebProcess/WebPage/WebPage.messages.in: Add a new scrollBy message.
     33        * WebProcess/WebPage/mac/WebPageMac.mm: Remove scroll and logicalScroll, they are now in WebPage.cpp.
     34        * WebProcess/WebPage/win/WebPageWin.cpp: Ditto.
     35
    1362011-03-24  Sam Weinig  <sam@webkit.org>
    237
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r81847 r81895  
    840840#endif
    841841
     842void WebPageProxy::scrollBy(ScrollDirection direction, ScrollGranularity granularity)
     843{
     844    if (!isValid())
     845        return;
     846
     847    process()->send(Messages::WebPage::ScrollBy(direction, granularity), m_pageID);
     848}
     849
    842850void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy* frame, uint64_t listenerID)
    843851{
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r81847 r81895  
    4949#include "WebResourceLoadClient.h"
    5050#include "WebUIClient.h"
     51#include <WebCore/ScrollTypes.h>
    5152#include <wtf/HashMap.h>
    5253#include <wtf/HashSet.h>
     
    277278    void handleTouchEvent(const WebTouchEvent&);
    278279#endif
     280
     281    void scrollBy(WebCore::ScrollDirection, WebCore::ScrollGranularity);
    279282
    280283    String pageTitle() const;
  • trunk/Source/WebKit2/UIProcess/win/WebView.cpp

    r81082 r81895  
    152152        lResult = onWheelEvent(hWnd, message, wParam, lParam, handled);
    153153        break;
     154    case WM_HSCROLL:
     155        lResult = onHorizontalScroll(hWnd, message, wParam, lParam, handled);
     156        break;
     157    case WM_VSCROLL:
     158        lResult = onVerticalScroll(hWnd, message, wParam, lParam, handled);
     159        break;
    154160    case WM_SYSKEYDOWN:
    155161    case WM_KEYDOWN:
     
    283289{
    284290    ::RegisterDragDrop(m_window, this);
     291
     292    if (shouldInitializeTrackPointHack()) {
     293        // If we detected a registry key belonging to a TrackPoint driver, then create fake
     294        // scrollbars, so the WebView will receive WM_VSCROLL and WM_HSCROLL messages.
     295        // We create an invisible vertical scrollbar and an invisible horizontal scrollbar to allow
     296        // for receiving both types of messages.
     297        ::CreateWindow(TEXT("SCROLLBAR"), TEXT("FAKETRACKPOINTHSCROLLBAR"), WS_CHILD | WS_VISIBLE | SBS_HORZ, 0, 0, 0, 0, m_window, 0, instanceHandle(), 0);
     298        ::CreateWindow(TEXT("SCROLLBAR"), TEXT("FAKETRACKPOINTVSCROLLBAR"), WS_CHILD | WS_VISIBLE | SBS_VERT, 0, 0, 0, 0, m_window, 0, instanceHandle(), 0);
     299    }
    285300}
    286301
     
    402417}
    403418
     419LRESULT WebView::onHorizontalScroll(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
     420{
     421    ScrollDirection direction;
     422    ScrollGranularity granularity;
     423    switch (LOWORD(wParam)) {
     424    case SB_LINELEFT:
     425        granularity = ScrollByLine;
     426        direction = ScrollLeft;
     427        break;
     428    case SB_LINERIGHT:
     429        granularity = ScrollByLine;
     430        direction = ScrollRight;
     431        break;
     432    case SB_PAGELEFT:
     433        granularity = ScrollByDocument;
     434        direction = ScrollLeft;
     435        break;
     436    case SB_PAGERIGHT:
     437        granularity = ScrollByDocument;
     438        direction = ScrollRight;
     439        break;
     440    default:
     441        handled = false;
     442        return 0;
     443    }
     444
     445    m_page->scrollBy(direction, granularity);
     446
     447    handled = true;
     448    return 0;
     449}
     450
     451LRESULT WebView::onVerticalScroll(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
     452{
     453    ScrollDirection direction;
     454    ScrollGranularity granularity;
     455    switch (LOWORD(wParam)) {
     456    case SB_LINEDOWN:
     457        granularity = ScrollByLine;
     458        direction = ScrollDown;
     459        break;
     460    case SB_LINEUP:
     461        granularity = ScrollByLine;
     462        direction = ScrollUp;
     463        break;
     464    case SB_PAGEDOWN:
     465        granularity = ScrollByDocument;
     466        direction = ScrollDown;
     467        break;
     468    case SB_PAGEUP:
     469        granularity = ScrollByDocument;
     470        direction = ScrollUp;
     471        break;
     472    default:
     473        handled = false;
     474        return 0;
     475    }
     476
     477    m_page->scrollBy(direction, granularity);
     478
     479    handled = true;
     480    return 0;
     481}
     482
    404483LRESULT WebView::onKeyEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
    405484{
     
    646725
    647726    ::TrackMouseEvent(&trackMouseEvent);
     727}
     728
     729bool WebView::shouldInitializeTrackPointHack()
     730{
     731    static bool shouldCreateScrollbars;
     732    static bool hasRunTrackPointCheck;
     733
     734    if (hasRunTrackPointCheck)
     735        return shouldCreateScrollbars;
     736
     737    hasRunTrackPointCheck = true;
     738    const wchar_t* trackPointKeys[] = {
     739        L"Software\\Lenovo\\TrackPoint",
     740        L"Software\\Lenovo\\UltraNav",
     741        L"Software\\Alps\\Apoint\\TrackPoint",
     742        L"Software\\Synaptics\\SynTPEnh\\UltraNavUSB",
     743        L"Software\\Synaptics\\SynTPEnh\\UltraNavPS2"
     744    };
     745
     746    for (size_t i = 0; i < WTF_ARRAY_LENGTH(trackPointKeys); ++i) {
     747        HKEY trackPointKey;
     748        int readKeyResult = ::RegOpenKeyExW(HKEY_CURRENT_USER, trackPointKeys[i], 0, KEY_READ, &trackPointKey);
     749        ::RegCloseKey(trackPointKey);
     750        if (readKeyResult == ERROR_SUCCESS) {
     751            shouldCreateScrollbars = true;
     752            return shouldCreateScrollbars;
     753        }
     754    }
     755
     756    return shouldCreateScrollbars;
    648757}
    649758
  • trunk/Source/WebKit2/UIProcess/win/WebView.h

    r81082 r81895  
    9696    LRESULT onMouseEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
    9797    LRESULT onWheelEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
     98    LRESULT onHorizontalScroll(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
     99    LRESULT onVerticalScroll(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
    98100    LRESULT onKeyEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
    99101    LRESULT onPaintEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
     
    129131    void startTrackingMouseLeave();
    130132    void stopTrackingMouseLeave();
     133
     134    bool shouldInitializeTrackPointHack();
    131135
    132136    void close();
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r81880 r81895  
    10571057#endif
    10581058
     1059void WebPage::scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity)
     1060{
     1061    page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity);
     1062}
     1063
     1064void WebPage::logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity)
     1065{
     1066    page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity);
     1067}
     1068
     1069void WebPage::scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity)
     1070{
     1071    scroll(m_page.get(), static_cast<ScrollDirection>(scrollDirection), static_cast<ScrollGranularity>(scrollGranularity));
     1072}
     1073
    10591074void WebPage::setActive(bool isActive)
    10601075{
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r81890 r81895  
    4747#include <WebCore/FrameLoaderTypes.h>
    4848#include <WebCore/IntRect.h>
     49#include <WebCore/ScrollTypes.h>
    4950#include <WebCore/WebCoreKeyboardUIMode.h>
    5051#include <wtf/HashMap.h>
     
    142143    void scrollMainFrameIfNotAtMaxScrollPosition(const WebCore::IntSize& scrollOffset);
    143144
     145    void scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity);
     146
    144147#if ENABLE(INSPECTOR)
    145148    WebInspector* inspector();
     
    416419#endif
    417420
     421    static void scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
     422    static void logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
     423
    418424    uint64_t restoreSession(const SessionState&);
    419425    void restoreSessionAndNavigateToCurrentItem(const SessionState&, const SandboxExtension::Handle&);
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r81847 r81895  
    4343#endif
    4444
     45    ScrollBy(uint32_t scrollDirection, uint32_t scrollGranularity)
     46
    4547    GoBack(uint64_t backForwardItemID, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
    4648    GoForward(uint64_t backForwardItemID, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

    r81890 r81895  
    384384}
    385385
    386 static inline void scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity)
    387 {
    388     page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity);
    389 }
    390 
    391 static inline void logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity)
    392 {
    393     page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity);
    394 }
    395 
    396386bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent)
    397387{
  • trunk/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp

    r81416 r81895  
    193193}
    194194
    195 static inline void scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity)
    196 {
    197     page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity);
    198 }
    199 
    200 static inline void logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity)
    201 {
    202     page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity);
    203 }
    204 
    205195bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent)
    206196{
Note: See TracChangeset for help on using the changeset viewer.