[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Thu Apr 8 01:59:00 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit d72a19c136f772b71add34bb35bf1a48fec17f97
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Feb 25 13:24:12 2010 +0000

    2010-02-25  Ben Murdoch  <benm at 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 at 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 at 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.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55230 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index e5c7949..360da4e 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2010-02-25  Ben Murdoch  <benm at 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  Xan Lopez  <xlopez at igalia.com>
 
         Reviewed by Gustavo Noronha.
diff --git a/LayoutTests/fast/events/touch/basic-single-touch-events-expected.txt b/LayoutTests/fast/events/touch/basic-single-touch-events-expected.txt
index c424a09..02b00b5 100644
--- a/LayoutTests/fast/events/touch/basic-single-touch-events-expected.txt
+++ b/LayoutTests/fast/events/touch/basic-single-touch-events-expected.txt
@@ -67,7 +67,7 @@ PASS lastEvent.changedTouches.length is 1
 PASS lastEvent.targetTouches.length is 0
 PASS lastEvent.pageX is 0
 PASS lastEvent.pageY is 0
-PASS lastEvent.touches[0].target.tagName is "HTML"
+PASS lastEvent.touches[0].target.tagName is "DIV"
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/fast/events/touch/script-tests/basic-single-touch-events.js b/LayoutTests/fast/events/touch/script-tests/basic-single-touch-events.js
index 1c33458..1011577 100644
--- a/LayoutTests/fast/events/touch/script-tests/basic-single-touch-events.js
+++ b/LayoutTests/fast/events/touch/script-tests/basic-single-touch-events.js
@@ -80,7 +80,7 @@ function verifyTouch(which) {
         break;
         case 4:
             verifyTouchEvent("touchmove", 1, 1, 0);
-            shouldBeEqualToString("lastEvent.touches[0].target.tagName", "HTML");
+            shouldBeEqualToString("lastEvent.touches[0].target.tagName", "DIV");
         break;
 
         default: testFailed("Wrong number of touch events! (" + which + ")");
diff --git a/LayoutTests/fast/events/touch/script-tests/touch-target.js b/LayoutTests/fast/events/touch/script-tests/touch-target.js
new file mode 100644
index 0000000..0623811
--- /dev/null
+++ b/LayoutTests/fast/events/touch/script-tests/touch-target.js
@@ -0,0 +1,97 @@
+var div1 = document.createElement("div");
+div1.id = "targetA";
+div1.style.width = "100px";
+div1.style.height = "100px";
+div1.style.backgroundColor = "blue";
+
+var div2 = document.createElement("div");
+div2.id = "targetB";
+div2.style.width = "100px";
+div2.style.height = "100px";
+div2.style.backgroundColor = "green";
+
+var touchStartCount = 0;
+var touchMoveCount = 0;
+
+document.getElementById('targetsDiv').appendChild(div1);
+document.getElementById('targetsDiv').appendChild(document.createElement('br'));
+document.getElementById('targetsDiv').appendChild(div2);
+
+function touchStartHandler()
+{
+    shouldBeEqualToString('event.type', 'touchstart');
+    switch (touchStartCount) {
+        case 0:
+            shouldBeEqualToString('event.touches[0].target.id', div1.id);
+            shouldBeEqualToString('event.touches[1].target.id', div2.id);
+            break;
+        case 1:
+            shouldBeEqualToString('event.touches[0].target.id', div2.id);
+            shouldBeEqualToString('event.touches[1].target.id', div1.id);
+            break;
+    }
+
+    touchStartCount++;
+}
+
+function touchMoveHandler()
+{
+    shouldBeEqualToString('event.type', 'touchmove');
+    switch (touchMoveCount) {
+        case 0:
+        case 1:
+            shouldBeEqualToString('event.touches[0].target.id', div1.id);
+            shouldBeEqualToString('event.touches[1].target.id', div2.id);
+            break;
+        case 2:
+            shouldBeEqualToString('event.touches[0].target.id', div2.id);
+            shouldBeEqualToString('event.touches[1].target.id', div1.id);
+            break;
+    }
+
+    if (++touchMoveCount == 3)
+    {
+        successfullyParsed = true;
+        layoutTestController.notifyDone();
+        isSuccessfullyParsed();
+    }
+}
+
+div1.addEventListener("touchstart", touchStartHandler, false);
+div1.addEventListener("touchmove", touchMoveHandler, false);
+
+div2.addEventListener("touchstart", touchStartHandler, false);
+div2.addEventListener("touchmove", touchMoveHandler, false);
+
+description("Tests that the target of touches match the element where the event originated, not where the touch is currently occurring.");
+
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+}
+
+if (window.eventSender) {
+    eventSender.clearTouchPoints();
+    eventSender.addTouchPoint(50, 150);
+    eventSender.addTouchPoint(50, 250);
+    eventSender.touchStart();
+
+    eventSender.updateTouchPoint(0, 50, 250);
+    eventSender.updateTouchPoint(1, 50, 150);
+    eventSender.touchMove();
+
+    eventSender.updateTouchPoint(0, 1000, 1000);
+    eventSender.updateTouchPoint(1, 1000, 1000);
+    eventSender.touchMove();
+
+    eventSender.releaseTouchPoint(0);
+    eventSender.touchEnd();
+
+    eventSender.addTouchPoint(50,150);
+    eventSender.touchStart();
+
+    eventSender.updateTouchPoint(0, 500, 500);
+    eventSender.updateTouchPoint(1, 500, 500);
+    eventSender.touchMove();
+} else
+    debug('This test requires DRT.');
+
diff --git a/LayoutTests/fast/events/touch/touch-target-expected.txt b/LayoutTests/fast/events/touch/touch-target-expected.txt
new file mode 100644
index 0000000..60a4c37
--- /dev/null
+++ b/LayoutTests/fast/events/touch/touch-target-expected.txt
@@ -0,0 +1,25 @@
+Tests that the target of touches match the element where the event originated, not where the touch is currently occurring.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+PASS event.type is "touchstart"
+PASS event.touches[0].target.id is "targetA"
+PASS event.touches[1].target.id is "targetB"
+PASS event.type is "touchmove"
+PASS event.touches[0].target.id is "targetA"
+PASS event.touches[1].target.id is "targetB"
+PASS event.type is "touchmove"
+PASS event.touches[0].target.id is "targetA"
+PASS event.touches[1].target.id is "targetB"
+PASS event.type is "touchstart"
+PASS event.touches[0].target.id is "targetB"
+PASS event.touches[1].target.id is "targetA"
+PASS event.type is "touchmove"
+PASS event.touches[0].target.id is "targetB"
+PASS event.touches[1].target.id is "targetA"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/events/touch/touch-target.html b/LayoutTests/fast/events/touch/touch-target.html
new file mode 100644
index 0000000..dfd8dab
--- /dev/null
+++ b/LayoutTests/fast/events/touch/touch-target.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="../../js/resources/js-test-post-function.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="targetsDiv"></div>
+<div id="console"></div>
+<script src="script-tests/touch-target.js"></script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 848bcbe..57f72a8 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,30 @@
+2010-02-25  Ben Murdoch  <benm at 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-24  Antonio Gomes  <tonikitoo at webkit.org>
 
         Reviewed by Simon Fraser.
diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp
index c3d1e5c..faba906 100644
--- a/WebCore/page/EventHandler.cpp
+++ b/WebCore/page/EventHandler.cpp
@@ -2583,7 +2583,23 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
         int adjustedPageX = lroundf(pagePoint.x() / m_frame->pageZoomFactor());
         int adjustedPageY = lroundf(pagePoint.y() / m_frame->pageZoomFactor());
 
-        RefPtr<Touch> touch = Touch::create(doc->frame(), target, point.id(),
+        // Increment the platform touch id by 1 to avoid storing a key of 0 in the hashmap.
+        unsigned touchPointTargetKey = point.id() + 1;
+        EventTarget* touchTarget = 0;
+        if (point.state() == PlatformTouchPoint::TouchPressed) {
+            m_originatingTouchPointTargets.set(touchPointTargetKey, target);
+            touchTarget = target;
+        } else if (point.state() == PlatformTouchPoint::TouchReleased || point.state() == PlatformTouchPoint::TouchCancelled) {
+            // The target should be the original target for this touch, so get it from the hashmap. As it's a release or cancel
+            // we also remove it from the map.
+            touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKey).get();
+        } else
+            touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey).get();
+
+        if (!touchTarget)
+            continue;
+
+        RefPtr<Touch> touch = Touch::create(doc->frame(), touchTarget, point.id(),
                                             point.screenPos().x(), point.screenPos().y(),
                                             adjustedPageX, adjustedPageY);
 
diff --git a/WebCore/page/EventHandler.h b/WebCore/page/EventHandler.h
index 72a10f7..28f1179 100644
--- a/WebCore/page/EventHandler.h
+++ b/WebCore/page/EventHandler.h
@@ -37,12 +37,17 @@
 class NSView;
 #endif
 
+#if ENABLE(TOUCH_EVENTS)
+#include <wtf/HashMap.h>
+#endif
+
 namespace WebCore {
 
 class AtomicString;
 class Clipboard;
 class Cursor;
 class Event;
+class EventTarget;
 class FloatPoint;
 class Frame;
 class HitTestRequest;
@@ -408,6 +413,8 @@ private:
     int m_activationEventNumber;
 #endif
 #if ENABLE(TOUCH_EVENTS)
+    typedef HashMap<int, RefPtr<EventTarget> > TouchTargetMap;
+    TouchTargetMap m_originatingTouchPointTargets;
     RefPtr<Node> m_touchEventTarget;
 #endif
 };
diff --git a/WebCore/platform/PlatformTouchPoint.h b/WebCore/platform/PlatformTouchPoint.h
index 2df9e31..d4f855e 100644
--- a/WebCore/platform/PlatformTouchPoint.h
+++ b/WebCore/platform/PlatformTouchPoint.h
@@ -50,13 +50,13 @@ public:
     PlatformTouchPoint(const IntPoint& windowPos, State);
 #endif
 
-    int id() const { return m_id; }
+    unsigned id() const { return m_id; }
     State state() const { return m_state; }
     IntPoint screenPos() const { return m_screenPos; }
     IntPoint pos() const { return m_pos; }
     
 private:
-    int m_id;
+    unsigned m_id;
     State m_state;
     IntPoint m_screenPos;
     IntPoint m_pos;
diff --git a/WebCore/platform/qt/PlatformTouchPointQt.cpp b/WebCore/platform/qt/PlatformTouchPointQt.cpp
index 1788cef..c293212 100644
--- a/WebCore/platform/qt/PlatformTouchPointQt.cpp
+++ b/WebCore/platform/qt/PlatformTouchPointQt.cpp
@@ -29,7 +29,8 @@ namespace WebCore {
 
 PlatformTouchPoint::PlatformTouchPoint(const QTouchEvent::TouchPoint& point)
 {
-    m_id = point.id();
+    // The QTouchEvent::TouchPoint API states that ids will be >= 0.
+    m_id = static_cast<unsigned>(point.id());
     switch (point.state()) {
     case Qt::TouchPointReleased: m_state = TouchReleased; break;
     case Qt::TouchPointMoved: m_state = TouchMoved; break;
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 9a4435c..1ad872c 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,13 @@
+2010-02-25  Ben Murdoch  <benm at 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.
+
 2010-02-24  Jesus Sanchez-Palencia  <jesus.palencia at openbossa.org>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp b/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp
index 1ef2d3f..c42d65e 100644
--- a/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp
+++ b/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp
@@ -289,11 +289,15 @@ void EventSender::scheduleAsynchronousClick()
 void EventSender::addTouchPoint(int x, int y)
 {
 #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
-    int id = m_touchPoints.count();
+    // Use index to refer to the position in the vector that this touch
+    // is stored. We then create a unique id for the touch that will be
+    // passed into WebCore.
+    int index = m_touchPoints.count();
+    int id = m_touchPoints.isEmpty() ? 0 : m_touchPoints.last().id() + 1;
     QTouchEvent::TouchPoint point(id);
     m_touchPoints.append(point);
-    updateTouchPoint(id, x, y);
-    m_touchPoints[id].setState(Qt::TouchPointPressed);
+    updateTouchPoint(index, x, y);
+    m_touchPoints[index].setState(Qt::TouchPointPressed);
 #endif
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list