Changeset 52922 in webkit


Ignore:
Timestamp:
Jan 7, 2010 6:37:26 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-01-07 Kim Grönholm <kim.gronholm@nomovok.com>

Reviewed by Antti Koivisto.

Wrong state and TouchLists in TouchEvents
https://bugs.webkit.org/show_bug.cgi?id=32878

Touch event tests changed to match the API and semantics of iPhone and
Android. Each new touch point press dispatches a touchstart event with
the pressed touch point(s) in the changedTouches list, and a release
dispatches a touchend event with the released touch point(s) in
changedTouches. Moved points dispatch a touchmove event, with the moved
points in changedTouches. Old behaviour emitted only one touchstart when
the first point was pressed and one touchend when the last point was
released, and any events in between were touchmoves. New presses or
releases could only be detected by comparing the lists touches and
changedTouches.

  • fast/events/basic-touch-events-expected.txt:
  • fast/events/script-tests/basic-touch-events.js: (singleTouchSequence): (multiTouchSequence):

2010-01-07 Kim Grönholm <kim.gronholm@nomovok.com>

Reviewed by Antti Koivisto.

Wrong state and TouchLists in TouchEvents
https://bugs.webkit.org/show_bug.cgi?id=32878

Touch events changed to match the API and semantics of iPhone and
Android. Each new touch point press dispatches a touchstart event with
the pressed touch point(s) in the changedTouches list, and a release
dispatches a touchend event with the released touch point(s) in
changedTouches. Moved points dispatch a touchmove event, with the moved
points in changedTouches. Old behaviour emitted only one touchstart when
the first point was pressed and one touchend when the last point was
released, and any events in between were touchmoves. New presses or
releases could only be detected by comparing the lists touches and
changedTouches.

  • page/EventHandler.cpp: (WebCore::EventHandler::handleTouchEvent):
  • page/EventHandler.h:

2010-01-07 Kim Grönholm <kim.gronholm@nomovok.com>

Reviewed by Antti Koivisto.

Wrong state and TouchLists in TouchEvents
https://bugs.webkit.org/show_bug.cgi?id=32878

  • DumpRenderTree/qt/EventSenderQt.cpp: (EventSender::touchStart): (EventSender::touchEnd): (EventSender::clearTouchPoints):
  • DumpRenderTree/qt/EventSenderQt.h:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r52904 r52922  
     12010-01-07  Kim Grönholm  <kim.gronholm@nomovok.com>
     2
     3        Reviewed by Antti Koivisto.
     4
     5        Wrong state and TouchLists in TouchEvents
     6        https://bugs.webkit.org/show_bug.cgi?id=32878
     7
     8        Touch event tests changed to match the API and semantics of iPhone and
     9        Android. Each new touch point press dispatches a touchstart event with
     10        the pressed touch point(s) in the changedTouches list, and a release
     11        dispatches a touchend event with the released touch point(s) in
     12        changedTouches. Moved points dispatch a touchmove event, with the moved
     13        points in changedTouches. Old behaviour emitted only one touchstart when
     14        the first point was pressed and one touchend when the last point was
     15        released, and any events in between were touchmoves. New presses or
     16        releases could only be detected by comparing the lists touches and
     17        changedTouches.
     18
     19        * fast/events/basic-touch-events-expected.txt:
     20        * fast/events/script-tests/basic-touch-events.js:
     21        (singleTouchSequence):
     22        (multiTouchSequence):
     23
    1242010-01-06  MORITA Hajime  <morrita@gmail.com>
    225
  • trunk/LayoutTests/fast/events/basic-touch-events-expected.txt

    r52113 r52922  
    1212PASS lastEvent.touches[0].clientY is 10
    1313PASS lastEvent.touches[0].identifier is 0
     14PASS lastEvent.changedTouches[0].pageX is 10
     15PASS lastEvent.changedTouches[0].pageY is 10
     16PASS lastEvent.changedTouches[0].clientX is 10
     17PASS lastEvent.changedTouches[0].clientY is 10
     18PASS lastEvent.changedTouches[0].identifier is 0
     19PASS lastEvent.targetTouches[0].pageX is 10
     20PASS lastEvent.targetTouches[0].pageY is 10
     21PASS lastEvent.targetTouches[0].clientX is 10
     22PASS lastEvent.targetTouches[0].clientY is 10
     23PASS lastEvent.targetTouches[0].identifier is 0
    1424PASS lastEvent.type is "touchmove"
    1525PASS lastEvent.touches.length is 1
     
    3747PASS lastEvent.altKey is false
    3848multi touch sequence
     49Two touchpoints pressed
    3950PASS lastEvent.type is "touchstart"
    40 PASS lastEvent.touches.length is 1
    41 PASS lastEvent.changedTouches.length is 1
    42 PASS lastEvent.targetTouches.length is 1
    43 PASS lastEvent.touches[0].target.id is "touchtarget"
    44 PASS lastEvent.touches[0].pageX is 10
    45 PASS lastEvent.touches[0].pageY is 10
    46 PASS lastEvent.touches[0].clientX is 10
    47 PASS lastEvent.touches[0].clientY is 10
    48 PASS lastEvent.touches[0].identifier is 0
    49 PASS lastEvent.type is "touchmove"
    5051PASS lastEvent.touches.length is 2
    51 PASS lastEvent.changedTouches.length is 1
     52PASS lastEvent.changedTouches.length is 2
    5253PASS lastEvent.targetTouches.length is 2
    5354PASS lastEvent.touches[0].pageX is 10
     
    6162PASS lastEvent.touches[1].clientY is 30
    6263PASS lastEvent.touches[1].identifier is 1
    63 PASS lastEvent.changedTouches[0].pageX is 20
    64 PASS lastEvent.changedTouches[0].pageY is 30
    65 PASS lastEvent.changedTouches[0].clientX is 20
    66 PASS lastEvent.changedTouches[0].clientY is 30
    67 PASS lastEvent.changedTouches[0].identifier is 1
     64PASS lastEvent.changedTouches[0].pageX is 10
     65PASS lastEvent.changedTouches[0].pageY is 10
     66PASS lastEvent.changedTouches[0].clientX is 10
     67PASS lastEvent.changedTouches[0].clientY is 10
     68PASS lastEvent.changedTouches[0].identifier is 0
     69PASS lastEvent.changedTouches[1].pageX is 20
     70PASS lastEvent.changedTouches[1].pageY is 30
     71PASS lastEvent.changedTouches[1].clientX is 20
     72PASS lastEvent.changedTouches[1].clientY is 30
     73PASS lastEvent.changedTouches[1].identifier is 1
     74PASS lastEvent.targetTouches[0].pageX is 10
     75PASS lastEvent.targetTouches[0].pageY is 10
     76PASS lastEvent.targetTouches[0].clientX is 10
     77PASS lastEvent.targetTouches[0].clientY is 10
     78PASS lastEvent.targetTouches[0].identifier is 0
     79PASS lastEvent.targetTouches[1].pageX is 20
     80PASS lastEvent.targetTouches[1].pageY is 30
     81PASS lastEvent.targetTouches[1].clientX is 20
     82PASS lastEvent.targetTouches[1].clientY is 30
     83PASS lastEvent.targetTouches[1].identifier is 1
     84First touchpoint moved
    6885PASS lastEvent.type is "touchmove"
    6986PASS lastEvent.touches.length is 2
     
    85102PASS lastEvent.touches[1].clientY is 30
    86103PASS lastEvent.touches[1].identifier is 1
    87 PASS lastEvent.type is "touchmove"
     104First touchpoint is released
     105PASS lastEvent.type is "touchend"
    88106PASS lastEvent.touches.length is 1
    89107PASS lastEvent.changedTouches.length is 1
     
    99117PASS lastEvent.changedTouches[0].clientY is 15
    100118PASS lastEvent.changedTouches[0].identifier is 0
     119PASS lastEvent.targetTouches[0].pageX is 20
     120PASS lastEvent.targetTouches[0].pageY is 30
     121PASS lastEvent.targetTouches[0].clientX is 20
     122PASS lastEvent.targetTouches[0].clientY is 30
     123PASS lastEvent.targetTouches[0].identifier is 1
     124Last remaining touchpoint is released
    101125PASS lastEvent.type is "touchend"
    102126PASS lastEvent.touches.length is 0
  • trunk/LayoutTests/fast/events/script-tests/basic-touch-events.js

    r52113 r52922  
    5050    shouldBeEqualToString("lastEvent.touches[0].target.id", "touchtarget");
    5151    verifyTouchPoint("touches", 0, 10, 10, 0);
     52    verifyTouchPoint("changedTouches", 0, 10, 10, 0);
     53    verifyTouchPoint("targetTouches", 0, 10, 10, 0);
    5254
    5355    eventSender.updateTouchPoint(0, 20, 15);
     
    6668    eventSender.setTouchModifier("alt", false);
    6769
     70    eventSender.releaseTouchPoint(0);
    6871    eventSender.touchEnd();
    6972
     
    7881    debug("multi touch sequence");
    7982
     83    debug("Two touchpoints pressed");
    8084    eventSender.addTouchPoint(10, 10);
     85    eventSender.addTouchPoint(20, 30);
    8186    eventSender.touchStart();
    82 
    83     verifyTouchEvent("touchstart", 1, 1, 1);
    84     shouldBeEqualToString("lastEvent.touches[0].target.id", "touchtarget");
    85     verifyTouchPoint("touches", 0, 10, 10, 0);
    86 
    87     eventSender.addTouchPoint(20, 30);
    88     eventSender.touchMove();
    89 
    90     verifyTouchEvent("touchmove", 2, 1, 2);
     87    verifyTouchEvent("touchstart", 2, 2, 2);
    9188    verifyTouchPoint("touches", 0, 10, 10, 0);
    9289    verifyTouchPoint("touches", 1, 20, 30, 1);
    93     verifyTouchPoint("changedTouches", 0, 20, 30, 1);
     90    verifyTouchPoint("changedTouches", 0, 10, 10, 0);
     91    verifyTouchPoint("changedTouches", 1, 20, 30, 1);
     92    verifyTouchPoint("targetTouches", 0, 10, 10, 0);
     93    verifyTouchPoint("targetTouches", 1, 20, 30, 1);
    9494
     95    debug("First touchpoint moved");
    9596    eventSender.updateTouchPoint(0, 15, 15);
    9697    eventSender.touchMove();
    97 
    9898    verifyTouchEvent("touchmove", 2, 1, 2);
    9999    verifyTouchPoint("touches", 0, 15, 15, 0);
     
    101101    verifyTouchPoint("touches", 1, 20, 30, 1);
    102102
     103    debug("First touchpoint is released");
    103104    eventSender.releaseTouchPoint(0);
    104     eventSender.touchMove();
    105 
    106     verifyTouchEvent("touchmove", 1, 1, 1);
     105    eventSender.touchEnd();
     106    verifyTouchEvent("touchend", 1, 1, 1);
    107107    verifyTouchPoint("touches", 0, 20, 30, 1);
    108108    verifyTouchPoint("changedTouches", 0, 15, 15, 0);
     109    verifyTouchPoint("targetTouches", 0, 20, 30, 1);
    109110
     111    debug("Last remaining touchpoint is released");
     112    eventSender.releaseTouchPoint(0);
    110113    eventSender.touchEnd();
    111 
    112114    verifyTouchEvent("touchend", 0, 1, 0);
    113115    verifyTouchPoint("changedTouches", 0, 20, 30, 1);
  • trunk/WebCore/ChangeLog

    r52921 r52922  
     12010-01-07  Kim Grönholm  <kim.gronholm@nomovok.com>
     2
     3        Reviewed by Antti Koivisto.
     4
     5        Wrong state and TouchLists in TouchEvents
     6        https://bugs.webkit.org/show_bug.cgi?id=32878
     7
     8        Touch events changed to match the API and semantics of iPhone and
     9        Android. Each new touch point press dispatches a touchstart event with
     10        the pressed touch point(s) in the changedTouches list, and a release
     11        dispatches a touchend event with the released touch point(s) in
     12        changedTouches. Moved points dispatch a touchmove event, with the moved
     13        points in changedTouches. Old behaviour emitted only one touchstart when
     14        the first point was pressed and one touchend when the last point was
     15        released, and any events in between were touchmoves. New presses or
     16        releases could only be detected by comparing the lists touches and
     17        changedTouches.
     18
     19        * page/EventHandler.cpp:
     20        (WebCore::EventHandler::handleTouchEvent):
     21        * page/EventHandler.h:
     22
    1232010-01-07  Kent Tamura  <tkent@chromium.org>
    224
  • trunk/WebCore/page/EventHandler.cpp

    r52791 r52922  
    25462546
    25472547    RefPtr<TouchList> touches = TouchList::create();
    2548     RefPtr<TouchList> changedTouches = TouchList::create();
     2548    RefPtr<TouchList> pressedTouches = TouchList::create();
     2549    RefPtr<TouchList> releasedTouches = TouchList::create();
     2550    RefPtr<TouchList> movedTouches = TouchList::create();
    25492551    RefPtr<TouchList> targetTouches = TouchList::create();
    25502552
    25512553    const Vector<PlatformTouchPoint>& points = event.touchPoints();
     2554    AtomicString* eventName = 0;
     2555
    25522556    for (int i = 0; i < points.size(); ++i) {
    25532557        const PlatformTouchPoint& point = points[i];
    2554 
    25552558        IntPoint framePoint = documentPointForWindowPoint(m_frame, point.pos());
    25562559        HitTestResult result = hitTestResultAtPoint(framePoint, /*allowShadowContent*/ false);
    2557 
    25582560        Node* target = result.innerNode();
     2561
    25592562        // Touch events should not go to text nodes
    25602563        if (target && target->isTextNode())
     
    25712574        }
    25722575
    2573         if (point.state() != PlatformTouchPoint::TouchReleased) {
    2574             touches->append(touch);
    2575 
    2576             if (m_touchEventTarget == target)
    2577                targetTouches->append(touch);
    2578         }
    2579 
    2580         if (point.state() != PlatformTouchPoint::TouchStationary)
    2581             changedTouches->append(touch);
    2582     }
    2583 
    2584     AtomicString* eventName = 0;
    2585     switch (event.type()) {
    2586     case TouchStart:
     2576        if (point.state() == PlatformTouchPoint::TouchReleased)
     2577            releasedTouches->append(touch);
     2578        else {
     2579            if (point.state() == PlatformTouchPoint::TouchPressed)
     2580                pressedTouches->append(touch);
     2581            else {
     2582                touches->append(touch);
     2583                if (m_touchEventTarget == target)
     2584                    targetTouches->append(touch);
     2585                if (point.state() == PlatformTouchPoint::TouchMoved)
     2586                    movedTouches->append(touch);
     2587            }
     2588        }
     2589    }
     2590
     2591    if (!m_touchEventTarget)
     2592        return false;
     2593
     2594    bool defaultPrevented = false;
     2595
     2596    if (releasedTouches->length() > 0) {
     2597        eventName = &eventNames().touchendEvent;
     2598        RefPtr<TouchEvent> endEv =
     2599            TouchEvent::create(touches.get(), targetTouches.get(), releasedTouches.get(),
     2600                                                   *eventName, m_touchEventTarget->document()->defaultView(),
     2601                                                   m_firstTouchScreenPos.x(), m_firstTouchScreenPos.y(),
     2602                                                   m_firstTouchPagePos.x(), m_firstTouchPagePos.y(),
     2603                                                   event.ctrlKey(), event.altKey(), event.shiftKey(),
     2604                                                   event.metaKey());
     2605        ExceptionCode ec = 0;
     2606        m_touchEventTarget->dispatchEvent(endEv.get(), ec);
     2607        defaultPrevented = endEv->defaultPrevented();
     2608    }
     2609    if (pressedTouches->length() > 0) {
     2610        // Add pressed touchpoints to touches and targetTouches
     2611        for (int i = 0; i < pressedTouches->length(); ++i) {
     2612            touches->append(pressedTouches->item(i));
     2613            if (m_touchEventTarget == pressedTouches->item(i)->target())
     2614                targetTouches->append(pressedTouches->item(i));
     2615        }
     2616
    25872617        eventName = &eventNames().touchstartEvent;
    2588         break;
    2589     case TouchMove:
     2618        RefPtr<TouchEvent> startEv =
     2619            TouchEvent::create(touches.get(), targetTouches.get(), pressedTouches.get(),
     2620                                                   *eventName, m_touchEventTarget->document()->defaultView(),
     2621                                                   m_firstTouchScreenPos.x(), m_firstTouchScreenPos.y(),
     2622                                                   m_firstTouchPagePos.x(), m_firstTouchPagePos.y(),
     2623                                                   event.ctrlKey(), event.altKey(), event.shiftKey(),
     2624                                                   event.metaKey());
     2625        ExceptionCode ec = 0;
     2626        m_touchEventTarget->dispatchEvent(startEv.get(), ec);
     2627        defaultPrevented |= startEv->defaultPrevented();
     2628    }
     2629    if (movedTouches->length() > 0) {
    25902630        eventName = &eventNames().touchmoveEvent;
    2591         break;
    2592     case TouchEnd:
    2593         eventName = &eventNames().touchendEvent;
    2594         break;
    2595     }
    2596 
    2597     if (!m_touchEventTarget)
    2598         return false;
    2599 
    2600     RefPtr<TouchEvent> ev = TouchEvent::create(touches.get(), targetTouches.get(), changedTouches.get(),
    2601                                                *eventName, m_touchEventTarget->document()->defaultView(),
    2602                                                m_firstTouchScreenPos.x(), m_firstTouchScreenPos.y(),
    2603                                                m_firstTouchPagePos.x(), m_firstTouchPagePos.y(),
    2604                                                event.ctrlKey(), event.altKey(), event.shiftKey(),
    2605                                                event.metaKey());
    2606 
    2607     ExceptionCode ec = 0;
    2608     m_touchEventTarget->dispatchEvent(ev.get(), ec);
     2631        RefPtr<TouchEvent> moveEv =
     2632            TouchEvent::create(touches.get(), targetTouches.get(), movedTouches.get(),
     2633                                                   *eventName, m_touchEventTarget->document()->defaultView(),
     2634                                                   m_firstTouchScreenPos.x(), m_firstTouchScreenPos.y(),
     2635                                                   m_firstTouchPagePos.x(), m_firstTouchPagePos.y(),
     2636                                                   event.ctrlKey(), event.altKey(), event.shiftKey(),
     2637                                                   event.metaKey());
     2638        ExceptionCode ec = 0;
     2639        m_touchEventTarget->dispatchEvent(moveEv.get(), ec);
     2640        defaultPrevented |= moveEv->defaultPrevented();
     2641    }
    26092642
    26102643    if (event.type() == TouchEnd)
    26112644        m_touchEventTarget = 0;
    26122645
    2613     m_previousTouchEvent = ev;
    2614 
    2615     return ev->defaultPrevented();
    2616 }
    2617 #endif
    2618 
    2619 }
     2646    return defaultPrevented;
     2647}
     2648#endif
     2649
     2650}
  • trunk/WebCore/page/EventHandler.h

    r52008 r52922  
    410410    IntPoint m_firstTouchScreenPos;
    411411    IntPoint m_firstTouchPagePos;
    412     RefPtr<TouchEvent> m_previousTouchEvent;
    413412#endif
    414413};
  • trunk/WebKitTools/ChangeLog

    r52917 r52922  
     12010-01-07  Kim Grönholm  <kim.gronholm@nomovok.com>
     2
     3        Reviewed by Antti Koivisto.
     4
     5        Wrong state and TouchLists in TouchEvents
     6        https://bugs.webkit.org/show_bug.cgi?id=32878
     7
     8        * DumpRenderTree/qt/EventSenderQt.cpp:
     9        (EventSender::touchStart):
     10        (EventSender::touchEnd):
     11        (EventSender::clearTouchPoints):
     12        * DumpRenderTree/qt/EventSenderQt.h:
     13
    1142010-01-07  Andras Becsi  <abecsi@inf.u-szeged.hu>
    215
  • trunk/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp

    r52902 r52922  
    331331{
    332332#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
    333     sendTouchEvent(QEvent::TouchBegin);
     333    if (!m_touchActive) {
     334        sendTouchEvent(QEvent::TouchBegin);
     335        m_touchActive = true;
     336    } else
     337        sendTouchEvent(QEvent::TouchUpdate);
    334338#endif
    335339}
     
    346350#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
    347351    for (int i = 0; i < m_touchPoints.count(); ++i)
    348         m_touchPoints[i].setState(Qt::TouchPointReleased);
     352        if (m_touchPoints[i].state() != Qt::TouchPointReleased) {
     353            sendTouchEvent(QEvent::TouchUpdate);
     354            return;
     355        }
    349356    sendTouchEvent(QEvent::TouchEnd);
     357    m_touchActive = false;
    350358#endif
    351359}
     
    356364    m_touchPoints.clear();
    357365    m_touchModifiers = Qt::KeyboardModifiers();
     366    m_touchActive = false;
    358367#endif
    359368}
  • trunk/WebKitTools/DumpRenderTree/qt/EventSenderQt.h

    r52902 r52922  
    8787    QList<QTouchEvent::TouchPoint> m_touchPoints;
    8888    Qt::KeyboardModifiers m_touchModifiers;
     89    bool m_touchActive;
    8990#endif
    9091};
Note: See TracChangeset for help on using the changeset viewer.