Changeset 142571 in webkit


Ignore:
Timestamp:
Feb 11, 2013 8:23:05 PM (11 years ago)
Author:
aelias@chromium.org
Message:

[chromium] Apply page scale to all WebInputEvent types
https://bugs.webkit.org/show_bug.cgi?id=109370

Reviewed by James Robinson.

Previously we only adjusted a few common input event types by page
scale, but in fact almost every position and size in WebInputEvents
requires it.

I also took the opportunity to change some WebGestureEvent members to
floats (which I checked causes no warnings in Chromium-side code with
GCC or Clang).

New WebInputEventConversionTest: InputEventsScaling

  • public/WebInputEvent.h:

(WebKit::WebGestureEvent::WebGestureEvent):

  • src/WebInputEventConversion.cpp:

(WebKit::widgetScaleFactor):
(WebKit):
(WebKit::PlatformMouseEventBuilder::PlatformMouseEventBuilder):
(WebKit::PlatformWheelEventBuilder::PlatformWheelEventBuilder):
(WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder):
(WebKit::PlatformTouchPointBuilder::PlatformTouchPointBuilder):
(WebKit::updateWebMouseEventFromWebCoreMouseEvent):
(WebKit::WebMouseEventBuilder::WebMouseEventBuilder):
(WebKit::addTouchPoints):
(WebKit::WebTouchEventBuilder::WebTouchEventBuilder):
(WebKit::WebGestureEventBuilder::WebGestureEventBuilder):

  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::handleGestureEvent):
(WebKit::WebViewImpl::hasTouchEventHandlersAt):
(WebKit::WebViewImpl::handleInputEvent):

  • tests/WebInputEventConversionTest.cpp:

(WebCore::TEST):
(WebCore):

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

Legend:

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

    r142569 r142571  
     12013-02-11  Alexandre Elias  <aelias@chromium.org>
     2
     3        [chromium] Apply page scale to all WebInputEvent types
     4        https://bugs.webkit.org/show_bug.cgi?id=109370
     5
     6        Reviewed by James Robinson.
     7
     8        Previously we only adjusted a few common input event types by page
     9        scale, but in fact almost every position and size in WebInputEvents
     10        requires it.
     11
     12        I also took the opportunity to change some WebGestureEvent members to
     13        floats (which I checked causes no warnings in Chromium-side code with
     14        GCC or Clang).
     15
     16        New WebInputEventConversionTest: InputEventsScaling
     17
     18        * public/WebInputEvent.h:
     19        (WebKit::WebGestureEvent::WebGestureEvent):
     20        * src/WebInputEventConversion.cpp:
     21        (WebKit::widgetScaleFactor):
     22        (WebKit):
     23        (WebKit::PlatformMouseEventBuilder::PlatformMouseEventBuilder):
     24        (WebKit::PlatformWheelEventBuilder::PlatformWheelEventBuilder):
     25        (WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder):
     26        (WebKit::PlatformTouchPointBuilder::PlatformTouchPointBuilder):
     27        (WebKit::updateWebMouseEventFromWebCoreMouseEvent):
     28        (WebKit::WebMouseEventBuilder::WebMouseEventBuilder):
     29        (WebKit::addTouchPoints):
     30        (WebKit::WebTouchEventBuilder::WebTouchEventBuilder):
     31        (WebKit::WebGestureEventBuilder::WebGestureEventBuilder):
     32        * src/WebViewImpl.cpp:
     33        (WebKit::WebViewImpl::handleGestureEvent):
     34        (WebKit::WebViewImpl::hasTouchEventHandlersAt):
     35        (WebKit::WebViewImpl::handleInputEvent):
     36        * tests/WebInputEventConversionTest.cpp:
     37        (WebCore::TEST):
     38        (WebCore):
     39
    1402013-02-11  Sheriff Bot  <webkit.review.bot@gmail.com>
    241
  • trunk/Source/WebKit/chromium/public/WebInputEvent.h

    r142057 r142571  
    408408        struct {
    409409            int tapCount;
    410             int width;
    411             int height;
     410            float width;
     411            float height;
    412412        } tap;
    413413
    414414        struct {
    415             int width;
    416             int height;
     415            float width;
     416            float height;
    417417        } tapDown;
    418418
    419419        struct {
    420             int width;
    421             int height;
     420            float width;
     421            float height;
    422422        } longPress;
    423423
    424424        struct {
    425             int firstFingerWidth;
    426             int firstFingerHeight;
     425            float firstFingerWidth;
     426            float firstFingerHeight;
    427427        } twoFingerTap;
    428428
     
    444444            float scale;
    445445        } pinchUpdate;
    446     } data; 
     446    } data;
    447447
    448448    WebGestureEvent(unsigned sizeParam = sizeof(WebGestureEvent))
     
    453453        , globalY(0)
    454454    {
    455       memset(&data, 0, sizeof(data));
     455        memset(&data, 0, sizeof(data));
    456456    }
    457457};
  • trunk/Source/WebKit/chromium/src/WebInputEventConversion.cpp

    r142057 r142571  
    5555static const double millisPerSecond = 1000.0;
    5656
     57static float widgetScaleFactor(const Widget* widget)
     58{
     59    if (!widget)
     60        return 1;
     61
     62    ScrollView* rootView = widget->root();
     63    if (!rootView)
     64        return 1;
     65
     66    return rootView->visibleContentScaleFactor();
     67}
     68
    5769// MakePlatformMouseEvent -----------------------------------------------------
    5870
    5971PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMouseEvent& e)
    6072{
     73    float scale = widgetScaleFactor(widget);
    6174    // FIXME: widget is always toplevel, unless it's a popup.  We may be able
    6275    // to get rid of this once we abstract popups into a WebKit API.
    63     m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y));
     76    m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale));
    6477    m_globalPosition = IntPoint(e.globalX, e.globalY);
    6578#if ENABLE(POINTER_LOCK)
    66     m_movementDelta = IntPoint(e.movementX, e.movementY);
     79    m_movementDelta = IntPoint(e.movementX / scale, e.movementY / scale);
    6780#endif
    6881    m_button = static_cast<MouseButton>(e.button);
     
    105118PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMouseWheelEvent& e)
    106119{
    107     m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y));
     120    float scale = widgetScaleFactor(widget);
     121    m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale));
    108122    m_globalPosition = IntPoint(e.globalX, e.globalY);
    109123    m_deltaX = e.deltaX;
     
    142156PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const WebGestureEvent& e)
    143157{
     158    float scale = widgetScaleFactor(widget);
    144159    switch (e.type) {
    145160    case WebInputEvent::GestureScrollBegin:
     
    151166    case WebInputEvent::GestureScrollUpdate:
    152167        m_type = PlatformEvent::GestureScrollUpdate;
    153         m_deltaX = e.data.scrollUpdate.deltaX;
    154         m_deltaY = e.data.scrollUpdate.deltaY;
     168        m_deltaX = e.data.scrollUpdate.deltaX / scale;
     169        m_deltaY = e.data.scrollUpdate.deltaY / scale;
    155170        break;
    156171    case WebInputEvent::GestureScrollUpdateWithoutPropagation:
    157172        m_type = PlatformEvent::GestureScrollUpdateWithoutPropagation;
    158         m_deltaX = e.data.scrollUpdate.deltaX;
    159         m_deltaY = e.data.scrollUpdate.deltaY;
     173        m_deltaX = e.data.scrollUpdate.deltaX / scale;
     174        m_deltaY = e.data.scrollUpdate.deltaY / scale;
    160175        break;
    161176    case WebInputEvent::GestureTap:
    162177        m_type = PlatformEvent::GestureTap;
    163         m_area = IntSize(e.data.tap.width, e.data.tap.height);
     178        m_area = expandedIntSize(FloatSize(e.data.tap.width / scale, e.data.tap.height / scale));
    164179        // FIXME: PlatformGestureEvent deltaX is overloaded - wkb.ug/93123
    165180        m_deltaX = static_cast<int>(e.data.tap.tapCount);
     
    167182    case WebInputEvent::GestureTapDown:
    168183        m_type = PlatformEvent::GestureTapDown;
    169         m_area = IntSize(e.data.tapDown.width, e.data.tapDown.height);
     184        m_area = expandedIntSize(FloatSize(e.data.tapDown.width / scale, e.data.tapDown.height / scale));
    170185        break;
    171186    case WebInputEvent::GestureTapCancel:
     
    177192    case WebInputEvent::GestureTwoFingerTap:
    178193        m_type = PlatformEvent::GestureTwoFingerTap;
    179         m_area = IntSize(e.data.twoFingerTap.firstFingerWidth, e.data.twoFingerTap.firstFingerHeight);
     194        m_area = expandedIntSize(FloatSize(e.data.twoFingerTap.firstFingerWidth / scale, e.data.twoFingerTap.firstFingerHeight / scale));
    180195        break;
    181196    case WebInputEvent::GestureLongPress:
    182197        m_type = PlatformEvent::GestureLongPress;
    183         m_area = IntSize(e.data.longPress.width, e.data.longPress.height);
     198        m_area = expandedIntSize(FloatSize(e.data.longPress.width / scale, e.data.longPress.height / scale));
    184199        break;
    185200    case WebInputEvent::GestureLongTap:
    186201        m_type = PlatformEvent::GestureLongTap;
    187         m_area = IntSize(e.data.longPress.width, e.data.longPress.height);
     202        m_area = expandedIntSize(FloatSize(e.data.longPress.width / scale, e.data.longPress.height / scale));
    188203        break;
    189204    case WebInputEvent::GesturePinchBegin:
     
    201216        ASSERT_NOT_REACHED();
    202217    }
    203     m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y));
     218    m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale));
    204219    m_globalPosition = IntPoint(e.globalX, e.globalY);
    205220    m_timestamp = e.timeStampSeconds;
     
    363378PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTouchPoint& point)
    364379{
     380    float scale = widgetScaleFactor(widget);
    365381    m_id = point.id;
    366382    m_state = toPlatformTouchPointState(point.state);
    367     m_pos = widget->convertFromContainingWindow(point.position);
     383    m_pos = widget->convertFromContainingWindow(IntPoint(point.position.x / scale, point.position.y / scale));
    368384    m_screenPos = point.screenPosition;
    369     m_radiusY = point.radiusY;
    370     m_radiusX = point.radiusX;
     385    m_radiusY = point.radiusY / scale;
     386    m_radiusX = point.radiusX / scale;
    371387    m_rotationAngle = point.rotationAngle;
    372388    m_force = point.force;
     
    415431static void updateWebMouseEventFromWebCoreMouseEvent(const MouseRelatedEvent& event, const Widget& widget, const WebCore::RenderObject& renderObject, WebMouseEvent& webEvent)
    416432{
     433    float scale = widgetScaleFactor(&widget);
    417434    webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond;
    418435    webEvent.modifiers = getWebInputModifiers(event);
    419436
    420     ScrollView* view = widget.parent();
     437    ScrollView* view = widget.root();
    421438    IntPoint windowPoint = view->contentsToWindow(IntPoint(event.absoluteLocation().x(), event.absoluteLocation().y()));
    422439    webEvent.globalX = event.screenX();
    423440    webEvent.globalY = event.screenY();
    424     webEvent.windowX = windowPoint.x();
    425     webEvent.windowY = windowPoint.y();
     441    webEvent.windowX = windowPoint.x() * scale;
     442    webEvent.windowY = windowPoint.y() * scale;
    426443    IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteLocation(), renderObject);
    427     webEvent.x = localPoint.x();
    428     webEvent.y = localPoint.y();
     444    webEvent.x = localPoint.x() * scale;
     445    webEvent.y = localPoint.y() * scale;
    429446}
    430447
     
    473490    }
    474491#if ENABLE(POINTER_LOCK)
    475     movementX = event.webkitMovementX();
    476     movementY = event.webkitMovementY();
     492    float scale = widgetScaleFactor(widget);
     493    movementX = event.webkitMovementX() * scale;
     494    movementY = event.webkitMovementY() * scale;
    477495#endif
    478496    clickCount = event.detail();
     
    481499WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const TouchEvent& event)
    482500{
     501    float scale = widgetScaleFactor(widget);
    483502    if (!event.touches())
    484503        return;
     
    508527
    509528    IntPoint localPoint = convertAbsoluteLocationForRenderObject(touch->absoluteLocation(), *renderObject);
    510     x = localPoint.x();
    511     y = localPoint.y();
     529    x = localPoint.x() * scale;
     530    y = localPoint.y() * scale;
    512531}
    513532
     
    563582#if ENABLE(TOUCH_EVENTS)
    564583
    565 static void addTouchPoints(const AtomicString& touchType, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, const WebCore::RenderObject* renderObject)
    566 {
     584static void addTouchPoints(const Widget* widget, const AtomicString& touchType, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, const WebCore::RenderObject* renderObject)
     585{
     586    float scale = widgetScaleFactor(widget);
    567587    unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>(WebTouchEvent::touchesLengthCap));
    568588    for (unsigned i = 0; i < numberOfTouches; ++i) {
     
    573593        point.screenPosition = WebPoint(touch->screenX(), touch->screenY());
    574594        point.position = convertAbsoluteLocationForRenderObject(touch->absoluteLocation(), *renderObject);
    575         point.radiusX = touch->webkitRadiusX();
    576         point.radiusY = touch->webkitRadiusY();
     595        point.position.x *= scale;
     596        point.position.y *= scale;
     597        point.radiusX = touch->webkitRadiusX() * scale;
     598        point.radiusY = touch->webkitRadiusY() * scale;
    577599        point.rotationAngle = touch->webkitRotationAngle();
    578600        point.force = touch->webkitForce();
     
    603625    timeStampSeconds = event.timeStamp() / millisPerSecond;
    604626
    605     addTouchPoints(event.type(), event.touches(), touches, &touchesLength, renderObject);
    606     addTouchPoints(event.type(), event.changedTouches(), changedTouches, &changedTouchesLength, renderObject);
    607     addTouchPoints(event.type(), event.targetTouches(), targetTouches, &targetTouchesLength, renderObject);
     627    addTouchPoints(widget, event.type(), event.touches(), touches, &touchesLength, renderObject);
     628    addTouchPoints(widget, event.type(), event.changedTouches(), changedTouches, &changedTouchesLength, renderObject);
     629    addTouchPoints(widget, event.type(), event.targetTouches(), targetTouches, &targetTouchesLength, renderObject);
    608630}
    609631
     
    613635WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const GestureEvent& event)
    614636{
     637    float scale = widgetScaleFactor(widget);
    615638    if (event.type() == eventNames().gesturetapEvent)
    616639        type = GestureTap;
     
    623646    else if (event.type() == eventNames().gesturescrollupdateEvent) {
    624647        type = GestureScrollUpdate;
    625         data.scrollUpdate.deltaX = event.deltaX();
    626         data.scrollUpdate.deltaY = event.deltaY();
     648        data.scrollUpdate.deltaX = event.deltaX() * scale;
     649        data.scrollUpdate.deltaY = event.deltaY() * scale;
    627650    }
    628651
     
    633656    globalY = event.screenY();
    634657    IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteLocation(), *renderObject);
    635     x = localPoint.x();
    636     y = localPoint.y();
     658    x = localPoint.x() * scale;
     659    y = localPoint.y() * scale;
    637660}
    638661#endif // ENABLE(GESTURE_EVENTS)
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r142197 r142571  
    756756        // Instead, assume that the page has been designed with big enough buttons and links.
    757757        if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds()) {
    758             IntRect boundingBox(event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, event.data.tap.width, event.data.tap.height);
     758            // FIXME: didTapMultipleTargets should just take a rect instead of
     759            // an event.
     760            WebGestureEvent scaledEvent;
     761            scaledEvent.x = event.x / pageScaleFactor();
     762            scaledEvent.y = event.y / pageScaleFactor();
     763            scaledEvent.data.tap.width = event.data.tap.width / pageScaleFactor();
     764            scaledEvent.data.tap.height = event.data.tap.height / pageScaleFactor();
     765            IntRect boundingBox(scaledEvent.x - scaledEvent.data.tap.width / 2, scaledEvent.y - scaledEvent.data.tap.height / 2, scaledEvent.data.tap.width, scaledEvent.data.tap.height);
    759766            Vector<IntRect> goodTargets;
    760767            findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTargets);
    761768            // FIXME: replace touch adjustment code when numberOfGoodTargets == 1?
    762769            // Single candidate case is currently handled by: https://bugs.webkit.org/show_bug.cgi?id=85101
    763             if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleTargets(event, goodTargets)) {
     770            if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleTargets(scaledEvent, goodTargets)) {
    764771                eventSwallowed = true;
    765772                eventCancelled = true;
     
    13551362bool WebViewImpl::hasTouchEventHandlersAt(const WebPoint& point)
    13561363{
     1364    // FIXME: Implement this. Note that the point must be divided by pageScaleFactor.
    13571365    return true;
    13581366}
     
    20842092    }
    20852093
    2086     const WebInputEvent* inputEventTransformed = &inputEvent;
    2087     if (m_page->settings()->applyPageScaleFactorInCompositor()) {
    2088         WebMouseEvent mouseEvent;
    2089         WebGestureEvent gestureEvent;
    2090         if (WebInputEvent::isMouseEventType(inputEvent.type)) {
    2091             mouseEvent = *static_cast<const WebMouseEvent*>(&inputEvent);
    2092             mouseEvent.x = mouseEvent.x / pageScaleFactor();
    2093             mouseEvent.y = mouseEvent.y / pageScaleFactor();
    2094             inputEventTransformed = static_cast<const WebInputEvent*>(&mouseEvent);
    2095         } else if (WebInputEvent::isGestureEventType(inputEvent.type)) {
    2096             gestureEvent = *static_cast<const WebGestureEvent*>(&inputEvent);
    2097             gestureEvent.x = gestureEvent.x / pageScaleFactor();
    2098             gestureEvent.y = gestureEvent.y / pageScaleFactor();
    2099             gestureEvent.data.tap.width /= pageScaleFactor();
    2100             gestureEvent.data.tap.height /= pageScaleFactor();
    2101             inputEventTransformed = static_cast<const WebInputEvent*>(&gestureEvent);
    2102         }
    2103     }
    2104 
    2105     return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, *inputEventTransformed);
     2094    return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, inputEvent);
    21062095}
    21072096
  • trunk/Source/WebKit/chromium/tests/WebInputEventConversionTest.cpp

    r141346 r142571  
    3333#include "WebInputEventConversion.h"
    3434
     35#include "Frame.h"
     36#include "FrameTestHelpers.h"
     37#include "FrameView.h"
     38#include "GestureEvent.h"
    3539#include "KeyboardEvent.h"
     40#include "MouseEvent.h"
     41#include "Touch.h"
    3642#include "TouchEvent.h"
     43#include "TouchList.h"
     44#include "URLTestHelpers.h"
     45#include "WebFrame.h"
     46#include "WebSettings.h"
     47#include "WebViewImpl.h"
    3748#include <gtest/gtest.h>
    3849
    39 using WebKit::WebInputEvent;
    40 using WebKit::WebKeyboardEvent;
    41 using WebKit::WebKeyboardEventBuilder;
    42 using WebKit::WebMouseEventBuilder;
     50using namespace WebKit;
     51using namespace WebCore;
    4352
    4453namespace {
     
    8291}
    8392
     93TEST(WebInputEventConversionTest, InputEventsScaling)
     94{
     95    const std::string baseURL("http://www.test.com/");
     96    const std::string fileName("fixed_layout.html");
     97
     98    URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8("fixed_layout.html"));
     99    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(baseURL + fileName, true));
     100    webViewImpl->settings()->setApplyDeviceScaleFactorInCompositor(true);
     101    webViewImpl->settings()->setApplyPageScaleFactorInCompositor(true);
     102    webViewImpl->enableFixedLayoutMode(true);
     103    webViewImpl->settings()->setViewportEnabled(true);
     104    int pageWidth = 640;
     105    int pageHeight = 480;
     106    webViewImpl->resize(WebSize(pageWidth, pageHeight));
     107    webViewImpl->layout();
     108
     109    webViewImpl->setPageScaleFactor(2, WebPoint());
     110
     111    FrameView* view = webViewImpl->page()->mainFrame()->view();
     112    RefPtr<Document> document = webViewImpl->page()->mainFrame()->document();
     113    DOMWindow* domWindow = webViewImpl->page()->mainFrame()->document()->defaultView();
     114    RenderObject* docRenderer = webViewImpl->page()->mainFrame()->document()->renderer();
     115
     116    {
     117        WebMouseEvent webMouseEvent;
     118        webMouseEvent.type = WebInputEvent::MouseMove;
     119        webMouseEvent.x = 10;
     120        webMouseEvent.y = 10;
     121        webMouseEvent.windowX = 10;
     122        webMouseEvent.windowY = 10;
     123        webMouseEvent.globalX = 10;
     124        webMouseEvent.globalY = 10;
     125        webMouseEvent.movementX = 10;
     126        webMouseEvent.movementY = 10;
     127
     128        PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent);
     129        EXPECT_EQ(5, platformMouseBuilder.position().x());
     130        EXPECT_EQ(5, platformMouseBuilder.position().y());
     131        EXPECT_EQ(10, platformMouseBuilder.globalPosition().x());
     132        EXPECT_EQ(10, platformMouseBuilder.globalPosition().y());
     133        EXPECT_EQ(5, platformMouseBuilder.movementDelta().x());
     134        EXPECT_EQ(5, platformMouseBuilder.movementDelta().y());
     135    }
     136
     137    {
     138        WebGestureEvent webGestureEvent;
     139        webGestureEvent.type = WebInputEvent::GestureScrollUpdate;
     140        webGestureEvent.x = 10;
     141        webGestureEvent.y = 10;
     142        webGestureEvent.globalX = 10;
     143        webGestureEvent.globalY = 10;
     144        webGestureEvent.data.scrollUpdate.deltaX = 10;
     145        webGestureEvent.data.scrollUpdate.deltaY = 10;
     146
     147        PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent);
     148        EXPECT_EQ(5, platformGestureBuilder.position().x());
     149        EXPECT_EQ(5, platformGestureBuilder.position().y());
     150        EXPECT_EQ(10, platformGestureBuilder.globalPosition().x());
     151        EXPECT_EQ(10, platformGestureBuilder.globalPosition().y());
     152        EXPECT_EQ(5, platformGestureBuilder.deltaX());
     153        EXPECT_EQ(5, platformGestureBuilder.deltaY());
     154    }
     155
     156    {
     157        WebGestureEvent webGestureEvent;
     158        webGestureEvent.type = WebInputEvent::GestureTap;
     159        webGestureEvent.data.tap.width = 10;
     160        webGestureEvent.data.tap.height = 10;
     161
     162        PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent);
     163        EXPECT_EQ(5, platformGestureBuilder.area().width());
     164        EXPECT_EQ(5, platformGestureBuilder.area().height());
     165    }
     166
     167    {
     168        WebGestureEvent webGestureEvent;
     169        webGestureEvent.type = WebInputEvent::GestureTapDown;
     170        webGestureEvent.data.tapDown.width = 10;
     171        webGestureEvent.data.tapDown.height = 10;
     172
     173        PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent);
     174        EXPECT_EQ(5, platformGestureBuilder.area().width());
     175        EXPECT_EQ(5, platformGestureBuilder.area().height());
     176    }
     177
     178    {
     179        WebGestureEvent webGestureEvent;
     180        webGestureEvent.type = WebInputEvent::GestureLongPress;
     181        webGestureEvent.data.longPress.width = 10;
     182        webGestureEvent.data.longPress.height = 10;
     183
     184        PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent);
     185        EXPECT_EQ(5, platformGestureBuilder.area().width());
     186        EXPECT_EQ(5, platformGestureBuilder.area().height());
     187    }
     188
     189    {
     190        WebGestureEvent webGestureEvent;
     191        webGestureEvent.type = WebInputEvent::GestureTwoFingerTap;
     192        webGestureEvent.data.twoFingerTap.firstFingerWidth = 10;
     193        webGestureEvent.data.twoFingerTap.firstFingerHeight = 10;
     194
     195        PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent);
     196        EXPECT_EQ(5, platformGestureBuilder.area().width());
     197        EXPECT_EQ(5, platformGestureBuilder.area().height());
     198    }
     199
     200    {
     201        WebTouchEvent webTouchEvent;
     202        webTouchEvent.type = WebInputEvent::TouchMove;
     203        webTouchEvent.touchesLength = 1;
     204        webTouchEvent.touches[0].state = WebTouchPoint::StateMoved;
     205        webTouchEvent.touches[0].screenPosition.x = 10;
     206        webTouchEvent.touches[0].screenPosition.y = 10;
     207        webTouchEvent.touches[0].position.x = 10;
     208        webTouchEvent.touches[0].position.y = 10;
     209        webTouchEvent.touches[0].radiusX = 10;
     210        webTouchEvent.touches[0].radiusY = 10;
     211
     212        PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent);
     213        EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].screenPos().x());
     214        EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].screenPos().y());
     215        EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].pos().x());
     216        EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].pos().y());
     217        EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].radiusX());
     218        EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].radiusY());
     219    }
     220
     221    {
     222        PlatformMouseEvent platformMouseEvent(IntPoint(10, 10), IntPoint(10, 10), LeftButton, PlatformEvent::MouseMoved, 1, false, false, false, false, 0);
     223        RefPtr<MouseEvent> mouseEvent = MouseEvent::create(WebCore::eventNames().mousemoveEvent, domWindow, platformMouseEvent, 0, document);
     224        WebMouseEventBuilder webMouseBuilder(view, docRenderer, *mouseEvent);
     225
     226        EXPECT_EQ(20, webMouseBuilder.x);
     227        EXPECT_EQ(20, webMouseBuilder.y);
     228        EXPECT_EQ(10, webMouseBuilder.globalX);
     229        EXPECT_EQ(10, webMouseBuilder.globalY);
     230        EXPECT_EQ(20, webMouseBuilder.windowX);
     231        EXPECT_EQ(20, webMouseBuilder.windowY);
     232    }
     233
     234    {
     235        PlatformGestureEvent platformGestureEvent(PlatformEvent::GestureScrollUpdate, IntPoint(10, 10), IntPoint(10, 10), 0, IntSize(10, 10), FloatPoint(10, 10), false, false, false, false);
     236        RefPtr<GestureEvent> gestureEvent = GestureEvent::create(domWindow, platformGestureEvent);
     237        WebGestureEventBuilder webGestureBuilder(view, docRenderer, *gestureEvent);
     238
     239        EXPECT_EQ(20, webGestureBuilder.x);
     240        EXPECT_EQ(20, webGestureBuilder.y);
     241        EXPECT_EQ(10, webGestureBuilder.globalX);
     242        EXPECT_EQ(10, webGestureBuilder.globalY);
     243        EXPECT_EQ(20, webGestureBuilder.data.scrollUpdate.deltaX);
     244        EXPECT_EQ(20, webGestureBuilder.data.scrollUpdate.deltaY);
     245    }
     246
     247    {
     248        RefPtr<Touch> touch = Touch::create(webViewImpl->page()->mainFrame(), document.get(), 0, 10, 10, 10, 10, 10, 10, 0, 0);
     249        RefPtr<TouchList> touchList = TouchList::create();
     250        touchList->append(touch);
     251        RefPtr<TouchEvent> touchEvent = TouchEvent::create(touchList.get(), touchList.get(), touchList.get(), WebCore::eventNames().touchmoveEvent, domWindow, 10, 10, 10, 10, false, false, false, false);
     252
     253        WebTouchEventBuilder webTouchBuilder(view, docRenderer, *touchEvent);
     254        ASSERT_EQ(1u, webTouchBuilder.touchesLength);
     255        EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x);
     256        EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.y);
     257        EXPECT_EQ(20, webTouchBuilder.touches[0].position.x);
     258        EXPECT_EQ(20, webTouchBuilder.touches[0].position.y);
     259        EXPECT_EQ(20, webTouchBuilder.touches[0].radiusX);
     260        EXPECT_EQ(20, webTouchBuilder.touches[0].radiusY);
     261    }
     262
     263    webViewImpl->close();
     264}
     265
    84266} // anonymous namespace
Note: See TracChangeset for help on using the changeset viewer.