[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
benm at google.com
benm at google.com
Wed Mar 17 18:02:04 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 058b49956d13db9b33ae2d1ec289d05110607817
Author: benm at google.com <benm at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Feb 26 16:52:04 2010 +0000
The element that a touchevent is dispatched to isn't always right
https://bugs.webkit.org/show_bug.cgi?id=35431
Reviewed by Kenneth Rohde Christiansen.
WebCore:
The element that touch events are dispatched on is not always the
correct one, as the cached m_touchEventTarget member is only updated
when the first element of the PlatformTouchEvent touch list is in the
TouchPressed state.
This patch changes this behavior to dispatch the event to the target
of the touch that caused the event to be generated and eliminates the
m_touchEventTarget in favour of using the touch target hashmap. It also
simplifies the way in which the touchTargets list is generated as we
no longer have m_touchEventTarget (which was used previously to build
the list). The new behavior matches the observed behavior of the
iPhone and Android.
* page/EventHandler.cpp:
(WebCore::assembleTargetTouches): Added. new function to build the
targetTouches list. Filters a list of touches (passed) about
another given touch.
(WebCore::EventHandler::handleTouchEvent): Remove the
m_touchEventTarget member, and simplify the generation of the
TouchLists that are bundled with the TouchEVent object. Dispatch
the event to the target of the touch that caused the event to be
fired.
* page/EventHandler.h: Remove m_touchEventTarget.
LayoutTests:
* fast/events/touch/basic-single-touch-events-expected.txt: Updated
the targetTouches list expections.
* fast/events/touch/script-tests/basic-single-touch-events.js: ditto.
(verifyTouch):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55287 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 2187062..a7ae376 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-02-26 Ben Murdoch <benm at google.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ The element that a touchevent is dispatched to isn't always right
+ https://bugs.webkit.org/show_bug.cgi?id=35431
+
+ * fast/events/touch/basic-single-touch-events-expected.txt: Updated
+ the targetTouches list expections.
+ * fast/events/touch/script-tests/basic-single-touch-events.js: ditto.
+ (verifyTouch):
+
2010-02-26 Dirk Pranke <dpranke at chromium.org>
Reviewed by Darin Fisher.
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 02b00b5..ec168cb 100644
--- a/LayoutTests/fast/events/touch/basic-single-touch-events-expected.txt
+++ b/LayoutTests/fast/events/touch/basic-single-touch-events-expected.txt
@@ -64,7 +64,7 @@ PASS lastEvent.targetTouches[0].target.tagName is "DIV"
PASS lastEvent.type is "touchmove"
PASS lastEvent.touches.length is 1
PASS lastEvent.changedTouches.length is 1
-PASS lastEvent.targetTouches.length is 0
+PASS lastEvent.targetTouches.length is 1
PASS lastEvent.pageX is 0
PASS lastEvent.pageY is 0
PASS lastEvent.touches[0].target.tagName is "DIV"
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 1011577..9975c87 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
@@ -79,7 +79,7 @@ function verifyTouch(which) {
shouldBeEqualToString("lastEvent.targetTouches[0].target.tagName", "DIV");
break;
case 4:
- verifyTouchEvent("touchmove", 1, 1, 0);
+ verifyTouchEvent("touchmove", 1, 1, 1);
shouldBeEqualToString("lastEvent.touches[0].target.tagName", "DIV");
break;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3dd14bf..18c0c35 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,34 @@
+2010-02-26 Ben Murdoch <benm at google.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ The element that a touchevent is dispatched to isn't always right
+ https://bugs.webkit.org/show_bug.cgi?id=35431
+
+ The element that touch events are dispatched on is not always the
+ correct one, as the cached m_touchEventTarget member is only updated
+ when the first element of the PlatformTouchEvent touch list is in the
+ TouchPressed state.
+
+ This patch changes this behavior to dispatch the event to the target
+ of the touch that caused the event to be generated and eliminates the
+ m_touchEventTarget in favour of using the touch target hashmap. It also
+ simplifies the way in which the touchTargets list is generated as we
+ no longer have m_touchEventTarget (which was used previously to build
+ the list). The new behavior matches the observed behavior of the
+ iPhone and Android.
+
+ * page/EventHandler.cpp:
+ (WebCore::assembleTargetTouches): Added. new function to build the
+ targetTouches list. Filters a list of touches (passed) about
+ another given touch.
+ (WebCore::EventHandler::handleTouchEvent): Remove the
+ m_touchEventTarget member, and simplify the generation of the
+ TouchLists that are bundled with the TouchEVent object. Dispatch
+ the event to the target of the touch that caused the event to be
+ fired.
+ * page/EventHandler.h: Remove m_touchEventTarget.
+
2010-02-26 Dirk Pranke <dpranke at chromium.org>
Reviewed by Darin Fisher.
diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp
index faba906..c4a01f3 100644
--- a/WebCore/page/EventHandler.cpp
+++ b/WebCore/page/EventHandler.cpp
@@ -2547,13 +2547,25 @@ void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, bool setL
}
#if ENABLE(TOUCH_EVENTS)
+
+static PassRefPtr<TouchList> assembleTargetTouches(Touch* touchTarget, TouchList* touches)
+{
+ RefPtr<TouchList> targetTouches = TouchList::create();
+
+ for (int i = 0; i < touches->length(); ++i) {
+ if (touches->item(i)->target()->toNode()->isSameNode(touchTarget->target()->toNode()))
+ targetTouches->append(touches->item(i));
+ }
+
+ return targetTouches.release();
+}
+
bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
{
RefPtr<TouchList> touches = TouchList::create();
RefPtr<TouchList> pressedTouches = TouchList::create();
RefPtr<TouchList> releasedTouches = TouchList::create();
RefPtr<TouchList> movedTouches = TouchList::create();
- RefPtr<TouchList> targetTouches = TouchList::create();
RefPtr<TouchList> cancelTouches = TouchList::create();
const Vector<PlatformTouchPoint>& points = event.touchPoints();
@@ -2603,89 +2615,104 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
point.screenPos().x(), point.screenPos().y(),
adjustedPageX, adjustedPageY);
- if (event.type() == TouchStart && !i) {
- m_touchEventTarget = target;
- }
+ // touches should contain information about every touch currently on the screen.
+ if (point.state() != PlatformTouchPoint::TouchReleased)
+ touches->append(touch);
+ // Now build up the correct list for changedTouches.
if (point.state() == PlatformTouchPoint::TouchReleased)
releasedTouches->append(touch);
else if (point.state() == PlatformTouchPoint::TouchCancelled)
cancelTouches->append(touch);
- else {
- if (point.state() == PlatformTouchPoint::TouchPressed)
- pressedTouches->append(touch);
- else {
- touches->append(touch);
- if (m_touchEventTarget == target)
- targetTouches->append(touch);
- if (point.state() == PlatformTouchPoint::TouchMoved)
- movedTouches->append(touch);
- }
- }
+ else if (point.state() == PlatformTouchPoint::TouchPressed)
+ pressedTouches->append(touch);
+ else if (point.state() == PlatformTouchPoint::TouchMoved)
+ movedTouches->append(touch);
}
- if (!m_touchEventTarget)
- return false;
-
bool defaultPrevented = false;
+ Touch* changedTouch = 0;
+ EventTarget* touchEventTarget = 0;
+
+ if (cancelTouches->length() > 0) {
+ // We dispatch the event to the target of the touch that caused this touch event to be generated, i.e.
+ // we take it from the list that will be used as the changedTouches property of the event.
+ // The choice to use the touch at index 0 guarantees that there is a target (as we checked the length
+ // above). In the case that there are multiple touches in what becomes the changedTouches list, it is
+ // difficult to say how we should prioritise touches and as such, item 0 is an arbitrary choice.
+ changedTouch = cancelTouches->item(0);
+ ASSERT(changedTouch);
+ touchEventTarget = changedTouch->target();
+ ASSERT(touchEventTarget);
- if (event.type() == TouchCancel) {
eventName = &eventNames().touchcancelEvent;
RefPtr<TouchEvent> cancelEv =
TouchEvent::create(TouchList::create().get(), TouchList::create().get(), cancelTouches.get(),
- *eventName, m_touchEventTarget->document()->defaultView(),
+ *eventName, touchEventTarget->toNode()->document()->defaultView(),
0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(),
event.metaKey());
ExceptionCode ec = 0;
- m_touchEventTarget->dispatchEvent(cancelEv.get(), ec);
+ touchEventTarget->dispatchEvent(cancelEv.get(), ec);
defaultPrevented |= cancelEv->defaultPrevented();
}
if (releasedTouches->length() > 0) {
+ Touch* changedTouch = releasedTouches->item(0);
+ ASSERT(changedTouch);
+ touchEventTarget = changedTouch->target();
+ ASSERT(touchEventTarget);
+
+ RefPtr<TouchList> targetTouches = assembleTargetTouches(changedTouch, touches.get());
+
eventName = &eventNames().touchendEvent;
RefPtr<TouchEvent> endEv =
TouchEvent::create(touches.get(), targetTouches.get(), releasedTouches.get(),
- *eventName, m_touchEventTarget->document()->defaultView(),
+ *eventName, touchEventTarget->toNode()->document()->defaultView(),
0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(),
event.metaKey());
ExceptionCode ec = 0;
- m_touchEventTarget->dispatchEvent(endEv.get(), ec);
- defaultPrevented = endEv->defaultPrevented();
+ touchEventTarget->dispatchEvent(endEv.get(), ec);
+ defaultPrevented |= endEv->defaultPrevented();
}
if (pressedTouches->length() > 0) {
- // Add pressed touchpoints to touches and targetTouches
- for (int i = 0; i < pressedTouches->length(); ++i) {
- touches->append(pressedTouches->item(i));
- if (m_touchEventTarget == pressedTouches->item(i)->target())
- targetTouches->append(pressedTouches->item(i));
- }
+ Touch* changedTouch = pressedTouches->item(0);
+ ASSERT(changedTouch);
+ touchEventTarget = changedTouch->target();
+ ASSERT(touchEventTarget);
+
+ RefPtr<TouchList> targetTouches = assembleTargetTouches(changedTouch, touches.get());
eventName = &eventNames().touchstartEvent;
- RefPtr<TouchEvent> startEv =
+ RefPtr<TouchEvent> startEv =
TouchEvent::create(touches.get(), targetTouches.get(), pressedTouches.get(),
- *eventName, m_touchEventTarget->document()->defaultView(),
+ *eventName, touchEventTarget->toNode()->document()->defaultView(),
0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(),
event.metaKey());
ExceptionCode ec = 0;
- m_touchEventTarget->dispatchEvent(startEv.get(), ec);
+ touchEventTarget->dispatchEvent(startEv.get(), ec);
defaultPrevented |= startEv->defaultPrevented();
}
+
if (movedTouches->length() > 0) {
+ Touch* changedTouch = movedTouches->item(0);
+ ASSERT(changedTouch);
+ touchEventTarget = changedTouch->target();
+ ASSERT(touchEventTarget);
+
+ RefPtr<TouchList> targetTouches = assembleTargetTouches(changedTouch, touches.get());
+
eventName = &eventNames().touchmoveEvent;
RefPtr<TouchEvent> moveEv =
TouchEvent::create(touches.get(), targetTouches.get(), movedTouches.get(),
- *eventName, m_touchEventTarget->document()->defaultView(),
+ *eventName, touchEventTarget->toNode()->document()->defaultView(),
0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(),
event.metaKey());
ExceptionCode ec = 0;
- m_touchEventTarget->dispatchEvent(moveEv.get(), ec);
+ touchEventTarget->dispatchEvent(moveEv.get(), ec);
defaultPrevented |= moveEv->defaultPrevented();
}
- if (event.type() == TouchEnd || event.type() == TouchCancel)
- m_touchEventTarget = 0;
-
return defaultPrevented;
}
#endif
diff --git a/WebCore/page/EventHandler.h b/WebCore/page/EventHandler.h
index 28f1179..a268adb 100644
--- a/WebCore/page/EventHandler.h
+++ b/WebCore/page/EventHandler.h
@@ -415,7 +415,6 @@ private:
#if ENABLE(TOUCH_EVENTS)
typedef HashMap<int, RefPtr<EventTarget> > TouchTargetMap;
TouchTargetMap m_originatingTouchPointTargets;
- RefPtr<Node> m_touchEventTarget;
#endif
};
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list