Changeset 81895 in webkit
- Timestamp:
- Mar 24, 2011, 1:47:49 PM (14 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r81890 r81895 1 2011-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 1 36 2011-03-24 Sam Weinig <sam@webkit.org> 2 37 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r81847 r81895 840 840 #endif 841 841 842 void 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 842 850 void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy* frame, uint64_t listenerID) 843 851 { -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r81847 r81895 49 49 #include "WebResourceLoadClient.h" 50 50 #include "WebUIClient.h" 51 #include <WebCore/ScrollTypes.h> 51 52 #include <wtf/HashMap.h> 52 53 #include <wtf/HashSet.h> … … 277 278 void handleTouchEvent(const WebTouchEvent&); 278 279 #endif 280 281 void scrollBy(WebCore::ScrollDirection, WebCore::ScrollGranularity); 279 282 280 283 String pageTitle() const; -
trunk/Source/WebKit2/UIProcess/win/WebView.cpp
r81082 r81895 152 152 lResult = onWheelEvent(hWnd, message, wParam, lParam, handled); 153 153 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; 154 160 case WM_SYSKEYDOWN: 155 161 case WM_KEYDOWN: … … 283 289 { 284 290 ::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 } 285 300 } 286 301 … … 402 417 } 403 418 419 LRESULT 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 451 LRESULT 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 404 483 LRESULT WebView::onKeyEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled) 405 484 { … … 646 725 647 726 ::TrackMouseEvent(&trackMouseEvent); 727 } 728 729 bool 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; 648 757 } 649 758 -
trunk/Source/WebKit2/UIProcess/win/WebView.h
r81082 r81895 96 96 LRESULT onMouseEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); 97 97 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); 98 100 LRESULT onKeyEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); 99 101 LRESULT onPaintEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); … … 129 131 void startTrackingMouseLeave(); 130 132 void stopTrackingMouseLeave(); 133 134 bool shouldInitializeTrackPointHack(); 131 135 132 136 void close(); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r81880 r81895 1057 1057 #endif 1058 1058 1059 void WebPage::scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity) 1060 { 1061 page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity); 1062 } 1063 1064 void WebPage::logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity) 1065 { 1066 page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity); 1067 } 1068 1069 void WebPage::scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity) 1070 { 1071 scroll(m_page.get(), static_cast<ScrollDirection>(scrollDirection), static_cast<ScrollGranularity>(scrollGranularity)); 1072 } 1073 1059 1074 void WebPage::setActive(bool isActive) 1060 1075 { -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r81890 r81895 47 47 #include <WebCore/FrameLoaderTypes.h> 48 48 #include <WebCore/IntRect.h> 49 #include <WebCore/ScrollTypes.h> 49 50 #include <WebCore/WebCoreKeyboardUIMode.h> 50 51 #include <wtf/HashMap.h> … … 142 143 void scrollMainFrameIfNotAtMaxScrollPosition(const WebCore::IntSize& scrollOffset); 143 144 145 void scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity); 146 144 147 #if ENABLE(INSPECTOR) 145 148 WebInspector* inspector(); … … 416 419 #endif 417 420 421 static void scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity); 422 static void logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity); 423 418 424 uint64_t restoreSession(const SessionState&); 419 425 void restoreSessionAndNavigateToCurrentItem(const SessionState&, const SandboxExtension::Handle&); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r81847 r81895 43 43 #endif 44 44 45 ScrollBy(uint32_t scrollDirection, uint32_t scrollGranularity) 46 45 47 GoBack(uint64_t backForwardItemID, WebKit::SandboxExtension::Handle sandboxExtensionHandle) 46 48 GoForward(uint64_t backForwardItemID, WebKit::SandboxExtension::Handle sandboxExtensionHandle) -
trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
r81890 r81895 384 384 } 385 385 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 396 386 bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent) 397 387 { -
trunk/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
r81416 r81895 193 193 } 194 194 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 205 195 bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent) 206 196 {
Note:
See TracChangeset
for help on using the changeset viewer.