Changeset 142808 in webkit


Ignore:
Timestamp:
Feb 13, 2013 2:54:39 PM (11 years ago)
Author:
aelias@chromium.org
Message:

[chromium] Fix scaling in WebViewImpl::handleGestureEvent
https://bugs.webkit.org/show_bug.cgi?id=109671

Reviewed by James Robinson.

My last patch broke a bunch of things in handleGestureEvent that
assumed the event came in scaled, most notably tap highlight and
double-tap zoom. Switch those to PlatformGestureEvent.

  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::handleGestureEvent):
(WebKit::WebViewImpl::bestTapNode):
(WebKit::WebViewImpl::enableTapHighlight):

  • src/WebViewImpl.h:

(WebViewImpl):

  • tests/LinkHighlightTest.cpp:

(WebCore::TEST):

Location:
trunk/Source/WebKit/chromium
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/chromium/ChangeLog

    r142782 r142808  
     12013-02-13  Alexandre Elias  <aelias@chromium.org>
     2
     3        [chromium] Fix scaling in WebViewImpl::handleGestureEvent
     4        https://bugs.webkit.org/show_bug.cgi?id=109671
     5
     6        Reviewed by James Robinson.
     7
     8        My last patch broke a bunch of things in handleGestureEvent that
     9        assumed the event came in scaled, most notably tap highlight and
     10        double-tap zoom. Switch those to PlatformGestureEvent.
     11
     12        * src/WebViewImpl.cpp:
     13        (WebKit::WebViewImpl::handleGestureEvent):
     14        (WebKit::WebViewImpl::bestTapNode):
     15        (WebKit::WebViewImpl::enableTapHighlight):
     16        * src/WebViewImpl.h:
     17        (WebViewImpl):
     18        * tests/LinkHighlightTest.cpp:
     19        (WebCore::TEST):
     20
    1212013-02-13  Eberhard Graether  <egraether@google.com>
    222
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r142782 r142808  
    697697    bool eventCancelled = false; // for disambiguation
    698698
     699    PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
     700
    699701    // Handle link highlighting outside the main switch to avoid getting lost in the
    700702    // complicated set of cases handled below.
     
    704706#if OS(LINUX)
    705707        if (settingsImpl()->gestureTapHighlightEnabled())
    706             enableTouchHighlight(event);
     708            enableTapHighlight(platformEvent);
    707709#endif
    708710        break;
     
    722724            break;
    723725        m_client->cancelScheduledContentIntents();
    724         m_positionOnFlingStart = WebPoint(event.x, event.y);
    725         m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY);
     726        m_positionOnFlingStart = platformEvent.position();
     727        m_globalPositionOnFlingStart = platformEvent.globalPosition();
    726728        m_flingModifier = event.modifiers;
    727729        m_flingSourceDevice = event.sourceDevice;
     
    742744    case WebInputEvent::GestureTap: {
    743745        m_client->cancelScheduledContentIntents();
    744         if (detectContentOnTouch(WebPoint(event.x, event.y))) {
     746        if (detectContentOnTouch(platformEvent.position())) {
    745747            eventSwallowed = true;
    746748            break;
     
    757759            // FIXME: didTapMultipleTargets should just take a rect instead of
    758760            // an event.
    759             WebGestureEvent scaledEvent;
     761            WebGestureEvent scaledEvent = event;
    760762            scaledEvent.x = event.x / pageScaleFactor();
    761763            scaledEvent.y = event.y / pageScaleFactor();
     
    774776        }
    775777
    776         PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
    777778        eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
    778779
     
    796797        m_page->contextMenuController()->clearContextMenu();
    797798        m_contextMenuAllowed = true;
    798         PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
    799799        eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
    800800        m_contextMenuAllowed = false;
     
    804804    case WebInputEvent::GestureTapDown: {
    805805        m_client->cancelScheduledContentIntents();
    806         PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
    807806        eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
    808807        break;
     
    811810        if (m_webSettings->doubleTapToZoomEnabled() && m_minimumPageScaleFactor != m_maximumPageScaleFactor) {
    812811            m_client->cancelScheduledContentIntents();
    813             animateZoomAroundPoint(WebPoint(event.x, event.y), DoubleTap);
     812            animateZoomAroundPoint(platformEvent.position(), DoubleTap);
    814813            eventSwallowed = true;
    815814            break;
     
    824823    case WebInputEvent::GesturePinchEnd:
    825824    case WebInputEvent::GesturePinchUpdate: {
    826         PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
    827825        eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
    828826        break;
     
    12711269}
    12721270
    1273 Node* WebViewImpl::bestTouchLinkNode(const WebGestureEvent& touchEvent)
     1271Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent)
    12741272{
    12751273    if (!m_page || !m_page->mainFrame())
     
    12781276    Node* bestTouchNode = 0;
    12791277
    1280     IntSize touchEventSearchRegionSize(touchEvent.data.tapDown.width / 2, touchEvent.data.tapDown.height / 2);
    1281     IntPoint touchEventLocation(touchEvent.x, touchEvent.y);
     1278    IntPoint touchEventLocation(tapEvent.position());
    12821279#if ENABLE(TOUCH_ADJUSTMENT)
    1283     m_page->mainFrame()->eventHandler()->adjustGesturePosition(PlatformGestureEventBuilder(mainFrameImpl()->frameView(), touchEvent), touchEventLocation);
     1280    m_page->mainFrame()->eventHandler()->adjustGesturePosition(tapEvent, touchEventLocation);
    12841281#endif
    12851282
     
    12911288    // Make sure our highlight candidate uses a hand cursor as a heuristic to
    12921289    // choose appropriate targets.
    1293     bool shiftKey = touchEvent.modifiers & WebGestureEvent::ShiftKey;
    1294     while (bestTouchNode && !invokesHandCursor(bestTouchNode, shiftKey, m_page->mainFrame()))
     1290    while (bestTouchNode && !invokesHandCursor(bestTouchNode, false, m_page->mainFrame()))
    12951291        bestTouchNode = bestTouchNode->parentNode();
    12961292
    12971293    // We should pick the largest enclosing node with hand cursor set.
    1298     while (bestTouchNode && bestTouchNode->parentNode() && invokesHandCursor(bestTouchNode->parentNode(), shiftKey, m_page->mainFrame()))
     1294    while (bestTouchNode && bestTouchNode->parentNode() && invokesHandCursor(bestTouchNode->parentNode(), false, m_page->mainFrame()))
    12991295        bestTouchNode = bestTouchNode->parentNode();
    13001296
     
    13021298}
    13031299
    1304 void WebViewImpl::enableTouchHighlight(const WebGestureEvent& touchEvent)
     1300void WebViewImpl::enableTapHighlight(const PlatformGestureEvent& tapEvent)
    13051301{
    13061302    // Always clear any existing highlight when this is invoked, even if we don't get a new target to highlight.
    13071303    m_linkHighlight.clear();
    13081304
    1309     Node* touchNode = bestTouchLinkNode(touchEvent);
     1305    Node* touchNode = bestTapNode(tapEvent);
    13101306
    13111307    if (!touchNode || !touchNode->renderer() || !touchNode->renderer()->enclosingLayer())
  • trunk/Source/WebKit/chromium/src/WebViewImpl.h

    r142782 r142808  
    577577#if ENABLE(GESTURE_EVENTS)
    578578    void computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZoomType, float& scale, WebPoint& scroll, bool& isAnchor);
    579     WebCore::Node* bestTouchLinkNode(const WebGestureEvent& touchEvent);
    580     void enableTouchHighlight(const WebGestureEvent& touchEvent);
     579    WebCore::Node* bestTapNode(const WebCore::PlatformGestureEvent& tapEvent);
     580    void enableTapHighlight(const WebCore::PlatformGestureEvent& tapEvent);
    581581    void computeScaleAndScrollForFocusedNode(WebCore::Node* focusedNode, float& scale, WebCore::IntPoint& scroll, bool& needAnimation);
    582582#endif
  • trunk/Source/WebKit/chromium/tests/LinkHighlightTest.cpp

    r139904 r142808  
    2828
    2929#include "FrameTestHelpers.h"
     30#include "FrameView.h"
    3031#include "IntRect.h"
    3132#include "Node.h"
     
    3334#include "WebCompositorInitializer.h"
    3435#include "WebFrame.h"
     36#include "WebFrameImpl.h"
    3537#include "WebInputEvent.h"
     38#include "WebInputEventConversion.h"
    3639#include "WebViewImpl.h"
    3740#include <gtest/gtest.h>
     
    6770    touchEvent.x = 20;
    6871    touchEvent.y = 20;
    69     Node* touchNode = webViewImpl->bestTouchLinkNode(touchEvent);
    70     ASSERT_TRUE(touchNode);
     72
     73    {
     74        PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent);
     75        Node* touchNode = webViewImpl->bestTapNode(platformEvent);
     76        ASSERT_TRUE(touchNode);
     77    }
    7178
    7279    touchEvent.y = 40;
    73     EXPECT_FALSE(webViewImpl->bestTouchLinkNode(touchEvent));
     80    {
     81        PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent);
     82        EXPECT_FALSE(webViewImpl->bestTapNode(platformEvent));
     83    }
    7484
    7585    touchEvent.y = 20;
    7686    // Shouldn't crash.
    7787
    78     webViewImpl->enableTouchHighlight(touchEvent);
     88    {
     89        PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent);
     90        webViewImpl->enableTapHighlight(platformEvent);
     91    }
     92
    7993    EXPECT_TRUE(webViewImpl->linkHighlight());
    8094    EXPECT_TRUE(webViewImpl->linkHighlight()->contentLayer());
     
    8498
    8599    touchEvent.y = 100;
    86     webViewImpl->enableTouchHighlight(touchEvent);
     100    {
     101        PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent);
     102        webViewImpl->enableTapHighlight(platformEvent);
     103    }
     104
    87105    ASSERT_TRUE(webViewImpl->linkHighlight());
    88106
    89107    // Don't highlight if no "hand cursor"
    90108    touchEvent.y = 220; // An A-link with cross-hair cursor.
    91     webViewImpl->enableTouchHighlight(touchEvent);
     109    {
     110        PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent);
     111        webViewImpl->enableTapHighlight(platformEvent);
     112    }
    92113    ASSERT_FALSE(webViewImpl->linkHighlight());
    93114
    94115    touchEvent.y = 260; // A text input box.
    95     webViewImpl->enableTouchHighlight(touchEvent);
     116    {
     117        PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent);
     118        webViewImpl->enableTapHighlight(platformEvent);
     119    }
    96120    ASSERT_FALSE(webViewImpl->linkHighlight());
    97121
Note: See TracChangeset for help on using the changeset viewer.