Changeset 55230 in webkit


Ignore:
Timestamp:
Feb 25, 2010 5:24:12 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-02-25 Ben Murdoch <benm@google.com>

Reviewed by Kenneth Rohde Christiansen.

The target element of a Touch should be the target where that touch originated, not where it is now.
https://bugs.webkit.org/show_bug.cgi?id=34585

  • fast/events/touch/basic-single-touch-events-expected.txt: Update expected target element.
  • fast/events/touch/script-tests/basic-single-touch-events.js: ditto.
  • fast/events/touch/script-tests/touch-target.js: Added.
  • fast/events/touch/touch-target-expected.txt: Added.
  • fast/events/touch/touch-target.html: Added.

2010-02-25 Ben Murdoch <benm@google.com>

Reviewed by Kenneth Rohde Christiansen.

The target element of a Touch should be the target where that touch originated, not where it is now.
https://bugs.webkit.org/show_bug.cgi?id=34585

Currently the target of a touch is set to the resulting node of the hit test where the touch currently
is. This does not match the behavior of iPhone or Android. This patch uses a hashmap on the EventHandler
to keep track of the target element when a touch is first started. This target is then used as the target
for subsequent touches with the same id. This matches observed behavior on iPhone and Android.

Tests:
fast/events/touch/touch-target.html: Added.
fast/events/touch/basic-single-touch-events.html: Updated.

  • page/EventHandler.cpp: (WebCore::EventHandler::handleTouchEvent): Store the originating target element of a touch in a hashmap

so that we can reuse that target for future events caused by that touch. This matches observed behavior
on iPhone and Android.

  • page/EventHandler.h: Add hashmap as a member.
  • platform/PlatformTouchPoint.h: (WebCore::PlatformTouchPoint::id): Store the touch point id as unsigned.
  • platform/qt/PlatformTouchPointQt.cpp: (WebCore::PlatformTouchPoint::PlatformTouchPoint): Cast platform touch id from signed to unsigned. Qt API

docs state that it will always be >= 0.

2010-02-25 Ben Murdoch <benm@google.com>

Reviewed by Kenneth Rohde Christiansen.

The target element of a Touch should be the target where that touch originated, not where it is now.
https://bugs.webkit.org/show_bug.cgi?id=34585

  • DumpRenderTree/qt/EventSenderQt.cpp: (EventSender::addTouchPoint): Fix a bug where touch points were not being given unique ids.
Location:
trunk
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r55229 r55230  
     12010-02-25  Ben Murdoch  <benm@google.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        The target element of a Touch should be the target where that touch originated, not where it is now.
     6        https://bugs.webkit.org/show_bug.cgi?id=34585
     7
     8        * fast/events/touch/basic-single-touch-events-expected.txt: Update expected target element.
     9        * fast/events/touch/script-tests/basic-single-touch-events.js: ditto.
     10        * fast/events/touch/script-tests/touch-target.js: Added.
     11        * fast/events/touch/touch-target-expected.txt: Added.
     12        * fast/events/touch/touch-target.html: Added.
     13
    1142010-02-25  Xan Lopez  <xlopez@igalia.com>
    215
  • trunk/LayoutTests/fast/events/touch/basic-single-touch-events-expected.txt

    r55146 r55230  
    6868PASS lastEvent.pageX is 0
    6969PASS lastEvent.pageY is 0
    70 PASS lastEvent.touches[0].target.tagName is "HTML"
     70PASS lastEvent.touches[0].target.tagName is "DIV"
    7171PASS successfullyParsed is true
    7272
  • trunk/LayoutTests/fast/events/touch/script-tests/basic-single-touch-events.js

    r55146 r55230  
    8181        case 4:
    8282            verifyTouchEvent("touchmove", 1, 1, 0);
    83             shouldBeEqualToString("lastEvent.touches[0].target.tagName", "HTML");
     83            shouldBeEqualToString("lastEvent.touches[0].target.tagName", "DIV");
    8484        break;
    8585
  • trunk/WebCore/ChangeLog

    r55228 r55230  
     12010-02-25  Ben Murdoch  <benm@google.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        The target element of a Touch should be the target where that touch originated, not where it is now.
     6        https://bugs.webkit.org/show_bug.cgi?id=34585
     7
     8        Currently the target of a touch is set to the resulting node of the hit test where the touch currently
     9        is. This does not match the behavior of iPhone or Android. This patch uses a hashmap on the EventHandler
     10        to keep track of the target element when a touch is first started. This target is then used as the target
     11        for subsequent touches with the same id. This matches observed behavior on iPhone and Android.
     12
     13        Tests:
     14        fast/events/touch/touch-target.html: Added.
     15        fast/events/touch/basic-single-touch-events.html: Updated.
     16
     17        * page/EventHandler.cpp:
     18        (WebCore::EventHandler::handleTouchEvent): Store the originating target element of a touch in a hashmap
     19            so that we can reuse that target for future events caused by that touch. This matches observed behavior
     20            on iPhone and Android.
     21        * page/EventHandler.h: Add hashmap as a member.
     22        * platform/PlatformTouchPoint.h:
     23        (WebCore::PlatformTouchPoint::id): Store the touch point id as unsigned.
     24        * platform/qt/PlatformTouchPointQt.cpp:
     25        (WebCore::PlatformTouchPoint::PlatformTouchPoint): Cast platform touch id from signed to unsigned. Qt API
     26            docs state that it will always be >= 0.
     27
    1282010-02-24  Antonio Gomes  <tonikitoo@webkit.org>
    229
  • trunk/WebCore/page/EventHandler.cpp

    r55146 r55230  
    25842584        int adjustedPageY = lroundf(pagePoint.y() / m_frame->pageZoomFactor());
    25852585
    2586         RefPtr<Touch> touch = Touch::create(doc->frame(), target, point.id(),
     2586        // Increment the platform touch id by 1 to avoid storing a key of 0 in the hashmap.
     2587        unsigned touchPointTargetKey = point.id() + 1;
     2588        EventTarget* touchTarget = 0;
     2589        if (point.state() == PlatformTouchPoint::TouchPressed) {
     2590            m_originatingTouchPointTargets.set(touchPointTargetKey, target);
     2591            touchTarget = target;
     2592        } else if (point.state() == PlatformTouchPoint::TouchReleased || point.state() == PlatformTouchPoint::TouchCancelled) {
     2593            // The target should be the original target for this touch, so get it from the hashmap. As it's a release or cancel
     2594            // we also remove it from the map.
     2595            touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKey).get();
     2596        } else
     2597            touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey).get();
     2598
     2599        if (!touchTarget)
     2600            continue;
     2601
     2602        RefPtr<Touch> touch = Touch::create(doc->frame(), touchTarget, point.id(),
    25872603                                            point.screenPos().x(), point.screenPos().y(),
    25882604                                            adjustedPageX, adjustedPageY);
  • trunk/WebCore/page/EventHandler.h

    r55146 r55230  
    3838#endif
    3939
     40#if ENABLE(TOUCH_EVENTS)
     41#include <wtf/HashMap.h>
     42#endif
     43
    4044namespace WebCore {
    4145
     
    4448class Cursor;
    4549class Event;
     50class EventTarget;
    4651class FloatPoint;
    4752class Frame;
     
    409414#endif
    410415#if ENABLE(TOUCH_EVENTS)
     416    typedef HashMap<int, RefPtr<EventTarget> > TouchTargetMap;
     417    TouchTargetMap m_originatingTouchPointTargets;
    411418    RefPtr<Node> m_touchEventTarget;
    412419#endif
  • trunk/WebCore/platform/PlatformTouchPoint.h

    r53994 r55230  
    5151#endif
    5252
    53     int id() const { return m_id; }
     53    unsigned id() const { return m_id; }
    5454    State state() const { return m_state; }
    5555    IntPoint screenPos() const { return m_screenPos; }
     
    5757   
    5858private:
    59     int m_id;
     59    unsigned m_id;
    6060    State m_state;
    6161    IntPoint m_screenPos;
  • trunk/WebCore/platform/qt/PlatformTouchPointQt.cpp

    r51981 r55230  
    3030PlatformTouchPoint::PlatformTouchPoint(const QTouchEvent::TouchPoint& point)
    3131{
    32     m_id = point.id();
     32    // The QTouchEvent::TouchPoint API states that ids will be >= 0.
     33    m_id = static_cast<unsigned>(point.id());
    3334    switch (point.state()) {
    3435    case Qt::TouchPointReleased: m_state = TouchReleased; break;
  • trunk/WebKitTools/ChangeLog

    r55218 r55230  
     12010-02-25  Ben Murdoch  <benm@google.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        The target element of a Touch should be the target where that touch originated, not where it is now.
     6        https://bugs.webkit.org/show_bug.cgi?id=34585
     7
     8        * DumpRenderTree/qt/EventSenderQt.cpp:
     9        (EventSender::addTouchPoint): Fix a bug where touch points were not being given unique ids.
     10
    1112010-02-24  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
    212
  • trunk/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp

    r55019 r55230  
    290290{
    291291#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
    292     int id = m_touchPoints.count();
     292    // Use index to refer to the position in the vector that this touch
     293    // is stored. We then create a unique id for the touch that will be
     294    // passed into WebCore.
     295    int index = m_touchPoints.count();
     296    int id = m_touchPoints.isEmpty() ? 0 : m_touchPoints.last().id() + 1;
    293297    QTouchEvent::TouchPoint point(id);
    294298    m_touchPoints.append(point);
    295     updateTouchPoint(id, x, y);
    296     m_touchPoints[id].setState(Qt::TouchPointPressed);
     299    updateTouchPoint(index, x, y);
     300    m_touchPoints[index].setState(Qt::TouchPointPressed);
    297301#endif
    298302}
Note: See TracChangeset for help on using the changeset viewer.