Changeset 44883 in webkit


Ignore:
Timestamp:
Jun 19, 2009 5:35:10 PM (15 years ago)
Author:
bweinstein@apple.com
Message:

2009-06-19 Brian Weinstein <bweinstein@apple.com>

Reviewed by Steve Falkenburg.


https://bugs.webkit.org/show_bug.cgi?id=26488
No Support for Single Finger or Two Finger Panning in Windows 7


The code in WebCore allows us to interpret a Pan gesture as
a mousewheel event, and we are able to reuse the scrolling code.
Another constructor was created in WheelEventWin which takes data
better suited to the pan guesture than what was currently there.


Unable to add tests to simulate touch behavior/gestures.

  • platform/PlatformWheelEvent.h:
  • platform/win/WheelEventWin.cpp:

2009-06-19 Brian Weinstein <bweinstein@apple.com>

Reviewed by Steve Falkenburg.


https://bugs.webkit.org/show_bug.cgi?id=26488
No Support for Single Finger or Two Finger Panning in Windows 7


The code in WebCore allows us to interpret a Pan gesture as
a mousewheel event, and we are able to reuse the scrolling code.
Another constructor was created in WheelEventWin which takes data
better suited to the pan guesture than what was currently there.


Unable to add tests to simulate touch behavior/gestures.

  • platform/PlatformWheelEvent.h:
  • platform/win/WheelEventWin.cpp:
Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r44881 r44883  
     12009-06-19  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Steve Falkenburg.
     4       
     5        https://bugs.webkit.org/show_bug.cgi?id=26488
     6        No Support for Single Finger or Two Finger Panning in Windows 7
     7       
     8        The code in WebCore allows us to interpret a Pan gesture as
     9        a mousewheel event, and we are able to reuse the scrolling code.
     10        Another constructor was created in WheelEventWin which takes data
     11        better suited to the pan guesture than what was currently there.
     12       
     13        Unable to add tests to simulate touch behavior/gestures.
     14
     15        * platform/PlatformWheelEvent.h:
     16        * platform/win/WheelEventWin.cpp:
     17
    1182009-06-19  Chris Marrin  <cmarrin@apple.com>
    219
  • trunk/WebCore/platform/PlatformWheelEvent.h

    r44404 r44883  
    100100#if PLATFORM(WIN)
    101101        PlatformWheelEvent(HWND, WPARAM, LPARAM, bool isMouseHWheel);
     102        PlatformWheelEvent(HWND, float deltaX, float deltaY, float xLoc, float yLoc);
    102103#endif
    103104
  • trunk/WebCore/platform/win/WheelEventWin.cpp

    r41746 r44883  
    6363}
    6464
     65PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, float deltaX, float deltaY, float xLoc, float yLoc)
     66    : m_isAccepted(false)
     67    , m_shiftKey(false)
     68    , m_ctrlKey(false)
     69    , m_altKey(false)
     70    , m_metaKey(false)
     71{
     72    m_deltaX = deltaX;
     73    m_deltaY = deltaY;
     74
     75    m_wheelTicksX = m_deltaX;
     76    m_wheelTicksY = m_deltaY;
     77
     78    // Global Position is just x, y location of event
     79    POINT point = {xLoc, yLoc};
     80    m_globalPosition = point;
     81
     82    // Position needs to be translated to our client
     83    ScreenToClient(hWnd, &point);
     84    m_position = point;
     85}
     86
    6587PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam, bool isMouseHWheel)
    6688    : m_position(positionForEvent(hWnd, lParam))
  • trunk/WebKit/win/ChangeLog

    r44846 r44883  
     12009-06-19  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Steve Falkenburg.
     4       
     5        https://bugs.webkit.org/show_bug.cgi?id=26488
     6        No Support for Single Finger or Two Finger Panning in Windows 7
     7       
     8        The code in WebCore allows us to interpret a Pan gesture as
     9        a mousewheel event, and we are able to reuse the scrolling code.
     10        Another constructor was created in WheelEventWin which takes data
     11        better suited to the pan guesture than what was currently there.
     12       
     13        Unable to add tests to simulate touch behavior/gestures.
     14
     15        * platform/PlatformWheelEvent.h:
     16        * platform/win/WheelEventWin.cpp:
     17       
    1182009-06-18  Adam Barth  <abarth@webkit.org>
    219
  • trunk/WebKit/win/WebKit.vcproj/WebKit.vcproj

    r44399 r44883  
    738738                                >
    739739                        </File>
     740                        <File
     741                                RelativePath="..\WindowsTouch.h"
     742                                >
     743                        </File>
    740744                </Filter>
    741745                <Filter
  • trunk/WebKit/win/WebView.cpp

    r44846 r44883  
    3131#include "DOMCoreClasses.h"
    3232#include "MarshallingHelpers.h"
     33#include "SoftLinking.h"
    3334#include "WebDatabaseManager.h"
    3435#include "WebDocumentLoader.h"
     
    5152#include "WebNotificationCenter.h"
    5253#include "WebPreferences.h"
     54#include "WindowsTouch.h"
    5355#pragma warning( push, 0 )
    5456#include <WebCore/ApplicationCacheStorage.h>
     
    9799#include <WebCore/ResourceHandleClient.h>
    98100#include <WebCore/ScriptValue.h>
     101#include <WebCore/Scrollbar.h>
    99102#include <WebCore/ScrollbarTheme.h>
    100103#include <WebCore/SecurityOrigin.h>
     
    129132#include <tchar.h>
    130133#include <windowsx.h>
     134
     135// Soft link functions for gestures and panning feedback
     136SOFT_LINK_LIBRARY(USER32);
     137SOFT_LINK_OPTIONAL(USER32, GetGestureInfo, BOOL, WINAPI, (HGESTUREINFO, PGESTUREINFO));
     138SOFT_LINK_OPTIONAL(USER32, SetGestureConfig, BOOL, WINAPI, (HWND, DWORD, UINT, PGESTURECONFIG, UINT));
     139SOFT_LINK_OPTIONAL(USER32, CloseGestureInfoHandle, BOOL, WINAPI, (HGESTUREINFO));
     140SOFT_LINK_LIBRARY(Uxtheme);
     141SOFT_LINK_OPTIONAL(Uxtheme, BeginPanningFeedback, BOOL, WINAPI, (HWND));
     142SOFT_LINK_OPTIONAL(Uxtheme, EndPanningFeedback, BOOL, WINAPI, (HWND, BOOL));
     143SOFT_LINK_OPTIONAL(Uxtheme, UpdatePanningFeedback, BOOL, WINAPI, (HWND, LONG, LONG, BOOL));
    131144
    132145using namespace WebCore;
     
    300313, m_transparent(false)
    301314, m_selectTrailingWhitespaceEnabled(false)
     315, m_lastPanX(0)
     316, m_lastPanY(0)
     317, m_xOverpan(0)
     318, m_yOverpan(0)
    302319{
    303320    JSC::initializeThreading();
     
    13161333}
    13171334
     1335bool WebView::gestureNotify(WPARAM wParam, LPARAM lParam)
     1336{
     1337    GESTURENOTIFYSTRUCT* gn = reinterpret_cast<GESTURENOTIFYSTRUCT*>(lParam);
     1338
     1339    Frame* coreFrame = core(m_mainFrame);
     1340    if (!coreFrame)
     1341        return false;
     1342
     1343    ScrollView* view = coreFrame->view();
     1344    if (!view)
     1345        return false;
     1346
     1347    // If we don't have this function, we shouldn't be receiving this message
     1348    ASSERT(SetGestureConfigPtr());
     1349
     1350    DWORD dwPanWant;
     1351    DWORD dwPanBlock;
     1352
     1353    // Translate gesture location to client to hit test on scrollbars
     1354    POINT gestureBeginPoint = {gn->ptsLocation.x, gn->ptsLocation.y};
     1355    ScreenToClient(m_viewWindow, &gestureBeginPoint);
     1356
     1357    if (gestureBeginPoint.x > view->visibleWidth()) {
     1358        // We are in the scrollbar, turn off panning, need to be able to drag the scrollbar
     1359        dwPanWant = GC_PAN  | GC_PAN_WITH_INERTIA | GC_PAN_WITH_GUTTER;
     1360        dwPanBlock = GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY | GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
     1361    } else {
     1362        dwPanWant = GC_PAN  | GC_PAN_WITH_SINGLE_FINGER_VERTICALLY | GC_PAN_WITH_INERTIA | GC_PAN_WITH_GUTTER;
     1363        dwPanBlock = GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
     1364    }
     1365
     1366    GESTURECONFIG gc = { GID_PAN, dwPanWant , dwPanBlock } ;
     1367    return SetGestureConfigPtr()(m_viewWindow, 0, 1, &gc, sizeof(GESTURECONFIG));
     1368}
     1369
     1370bool WebView::gesture(WPARAM wParam, LPARAM lParam)
     1371{
     1372    // We want to bail out if we don't have either of these functions
     1373    if (!GetGestureInfoPtr() || !CloseGestureInfoHandlePtr())
     1374        return false;
     1375
     1376    HGESTUREINFO gestureHandle = reinterpret_cast<HGESTUREINFO>(lParam);
     1377   
     1378    GESTUREINFO gi = {0};
     1379    gi.cbSize = sizeof(GESTUREINFO);
     1380
     1381    if (!GetGestureInfoPtr()(gestureHandle, reinterpret_cast<PGESTUREINFO>(&gi)))
     1382        return false;
     1383
     1384    switch (gi.dwID) {
     1385    case GID_BEGIN:
     1386        m_lastPanX = gi.ptsLocation.x;
     1387        m_lastPanY = gi.ptsLocation.y;
     1388
     1389        CloseGestureInfoHandlePtr()(gestureHandle);
     1390        break;
     1391    case GID_PAN: {
     1392        Frame* coreFrame = core(m_mainFrame);
     1393        if (!coreFrame) {
     1394            CloseGestureInfoHandlePtr()(gestureHandle);
     1395            return false;
     1396        }
     1397
     1398        ScrollView* view = coreFrame->view();
     1399        if (!view) {
     1400            CloseGestureInfoHandlePtr()(gestureHandle);
     1401            return false;
     1402        }
     1403
     1404        Scrollbar* vertScrollbar = view->verticalScrollbar();
     1405        if (!vertScrollbar) {
     1406            CloseGestureInfoHandlePtr()(gestureHandle);
     1407            return true;    //No panning of any kind when no vertical scrollbar, matches IE8
     1408        }
     1409
     1410        // Where are the fingers currently?
     1411        long currentX = gi.ptsLocation.x;
     1412        long currentY = gi.ptsLocation.y;
     1413       
     1414        // How far did we pan in each direction?
     1415        long deltaX = currentX - m_lastPanX;
     1416        long deltaY = currentY - m_lastPanY;
     1417       
     1418        // Calculate the overpan for window bounce
     1419        m_yOverpan -= m_lastPanY - currentY;
     1420        m_xOverpan -= m_lastPanX - currentX;
     1421       
     1422        // Update our class variables with updated values
     1423        m_lastPanX = currentX;
     1424        m_lastPanY = currentY;
     1425
     1426        // Represent the pan gesture as a mouse wheel event
     1427        PlatformWheelEvent wheelEvent(m_viewWindow, deltaX, deltaY, currentX, currentY);
     1428        coreFrame->eventHandler()->handleWheelEvent(wheelEvent);
     1429
     1430        if (!(UpdatePanningFeedbackPtr() && BeginPanningFeedbackPtr() && EndPanningFeedbackPtr())) {
     1431            CloseGestureInfoHandlePtr()(gestureHandle);
     1432            return true;
     1433        }
     1434
     1435        // FIXME: Support Horizontal Window Bounce
     1436        if (vertScrollbar->currentPos() == 0)
     1437            UpdatePanningFeedbackPtr()(m_viewWindow, 0, m_yOverpan, gi.dwFlags & GF_INERTIA);
     1438        else if (vertScrollbar->currentPos() >= vertScrollbar->maximum())
     1439            UpdatePanningFeedbackPtr()(m_viewWindow, 0, m_yOverpan, gi.dwFlags & GF_INERTIA);
     1440       
     1441        if (gi.dwFlags & GF_BEGIN) {
     1442            BeginPanningFeedbackPtr()(m_viewWindow);
     1443            m_yOverpan = 0;
     1444        } else if (gi.dwFlags & GF_END) {
     1445            EndPanningFeedbackPtr()(m_viewWindow, true);
     1446            m_yOverpan = 0;
     1447        }
     1448
     1449        CloseGestureInfoHandlePtr()(gestureHandle);
     1450        break;
     1451    }
     1452    default:
     1453        // We have encountered an unknown gesture - return false to pass it to DefWindowProc
     1454        CloseGestureInfoHandlePtr()(gestureHandle);
     1455        break;
     1456    }
     1457
     1458    return true;
     1459}
     1460
    13181461bool WebView::mouseWheel(WPARAM wParam, LPARAM lParam, bool isMouseHWheel)
    13191462{
     
    16991842            webView->setIsBeingDestroyed();
    17001843            webView->revokeDragDrop();
     1844            break;
     1845        case WM_GESTURENOTIFY:
     1846            handled = webView->gestureNotify(wParam, lParam);
     1847            break;
     1848        case WM_GESTURE:
     1849            handled = webView->gesture(wParam, lParam);
    17011850            break;
    17021851        case WM_MOUSEMOVE:
  • trunk/WebKit/win/WebView.h

    r44271 r44883  
    743743    void performContextMenuAction(WPARAM, LPARAM, bool byPosition);
    744744    bool mouseWheel(WPARAM, LPARAM, bool isMouseHWheel);
     745    bool gesture(WPARAM, LPARAM);
     746    bool gestureNotify(WPARAM, LPARAM);
    745747    bool execCommand(WPARAM wParam, LPARAM lParam);
    746748    bool keyDown(WPARAM, LPARAM, bool systemKeyDown = false);
     
    912914
    913915    OwnPtr<HashSet<WebCore::String> > m_embeddedViewMIMETypes;
     916
     917    //Variables needed to store gesture information
     918    long m_lastPanX;
     919    long m_lastPanY;
     920    long m_xOverpan;
     921    long m_yOverpan;
    914922};
    915923
Note: See TracChangeset for help on using the changeset viewer.