summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-01-22 10:40:22 +0000
committerBen Murdoch <benm@google.com>2010-01-26 10:27:58 +0000
commit9c3f8716aa3ce8ca612b4200c02a8530cfd599ba (patch)
tree0bd79bee3e85d0ce37cb8eee4f19d365b8a885b0
parent09cf43c86944667327521b6be03733519a63a6e0 (diff)
downloadexternal_webkit-9c3f8716aa3ce8ca612b4200c02a8530cfd599ba.zip
external_webkit-9c3f8716aa3ce8ca612b4200c02a8530cfd599ba.tar.gz
external_webkit-9c3f8716aa3ce8ca612b4200c02a8530cfd599ba.tar.bz2
absoluteToLocal works with a page co-ordinate that is relative to the top left of the containing frame's document, so fix a bug in the WebCore touch event handler where the wrong page co-ordinates were being passed to the Touch construtor. This part of the change should be upstreamed to webkit.
Also fix a crash when a touchCancel event is sent to a plugin because touchCancel, like touchend is not guaranteed to have data in touches, but will have data in changedTouches. Change-Id: I5345d7baf4e4325b24fbc5fbe60132dafb80e006
-rw-r--r--WebCore/page/EventHandler.cpp17
-rw-r--r--WebCore/platform/PlatformTouchEvent.h2
-rw-r--r--WebCore/platform/PlatformTouchPoint.h2
-rw-r--r--WebCore/platform/android/PlatformTouchEventAndroid.cpp4
-rw-r--r--WebCore/platform/android/PlatformTouchPointAndroid.cpp6
-rw-r--r--WebCore/plugins/android/PluginViewAndroid.cpp6
6 files changed, 21 insertions, 16 deletions
diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp
index a7dc13a..1d5941b 100644
--- a/WebCore/page/EventHandler.cpp
+++ b/WebCore/page/EventHandler.cpp
@@ -2589,8 +2589,8 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
for (int i = 0; i < points.size(); ++i) {
const PlatformTouchPoint& point = points[i];
- IntPoint framePoint = documentPointForWindowPoint(m_frame, point.pos());
- HitTestResult result = hitTestResultAtPoint(framePoint, /*allowShadowContent*/ false);
+ IntPoint pagePoint = documentPointForWindowPoint(m_frame, point.pos());
+ HitTestResult result = hitTestResultAtPoint(pagePoint, /*allowShadowContent*/ false);
Node* target = result.innerNode();
// Touch events should not go to text nodes
@@ -2603,8 +2603,13 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
if (!doc->hasListenerType(Document::TOUCH_LISTENER))
continue;
- int adjustedPageX = lroundf(framePoint.x() / m_frame->pageZoomFactor());
- int adjustedPageY = lroundf(framePoint.y() / m_frame->pageZoomFactor());
+ if (m_frame != doc->frame()) {
+ // pagePoint should always be relative to the target elements containing frame.
+ pagePoint = documentPointForWindowPoint(doc->frame(), point.pos());
+ }
+
+ int adjustedPageX = lroundf(pagePoint.x() / m_frame->pageZoomFactor());
+ int adjustedPageY = lroundf(pagePoint.y() / m_frame->pageZoomFactor());
if ( (event.type() == TouchStart
#if PLATFORM(ANDROID)
@@ -2614,10 +2619,10 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
) && !i) {
m_touchEventTarget = target;
m_firstTouchScreenPos = point.screenPos();
- m_firstTouchPagePos = framePoint;
+ m_firstTouchPagePos = pagePoint;
}
- RefPtr<Touch> touch = Touch::create(m_frame, m_touchEventTarget.get(), point.id(),
+ RefPtr<Touch> touch = Touch::create(doc->frame(), m_touchEventTarget.get(), point.id(),
point.screenPos().x(), point.screenPos().y(),
adjustedPageX, adjustedPageY);
diff --git a/WebCore/platform/PlatformTouchEvent.h b/WebCore/platform/PlatformTouchEvent.h
index 5371a40..1f071ce 100644
--- a/WebCore/platform/PlatformTouchEvent.h
+++ b/WebCore/platform/PlatformTouchEvent.h
@@ -60,7 +60,7 @@ public:
#if PLATFORM(QT)
PlatformTouchEvent(QTouchEvent*);
#elif PLATFORM(ANDROID)
- PlatformTouchEvent(const IntPoint& absolutePagePos, TouchEventType, PlatformTouchPoint::State);
+ PlatformTouchEvent(const IntPoint& windowPos, TouchEventType, PlatformTouchPoint::State);
#endif
TouchEventType type() const { return m_type; }
diff --git a/WebCore/platform/PlatformTouchPoint.h b/WebCore/platform/PlatformTouchPoint.h
index 53bd8ae..2df9e31 100644
--- a/WebCore/platform/PlatformTouchPoint.h
+++ b/WebCore/platform/PlatformTouchPoint.h
@@ -47,7 +47,7 @@ public:
#if PLATFORM(QT)
PlatformTouchPoint(const QTouchEvent::TouchPoint&);
#elif PLATFORM(ANDROID)
- PlatformTouchPoint(const IntPoint& absolutePagePos, State);
+ PlatformTouchPoint(const IntPoint& windowPos, State);
#endif
int id() const { return m_id; }
diff --git a/WebCore/platform/android/PlatformTouchEventAndroid.cpp b/WebCore/platform/android/PlatformTouchEventAndroid.cpp
index e4af8a3..65d787d 100644
--- a/WebCore/platform/android/PlatformTouchEventAndroid.cpp
+++ b/WebCore/platform/android/PlatformTouchEventAndroid.cpp
@@ -30,14 +30,14 @@
namespace WebCore {
-PlatformTouchEvent::PlatformTouchEvent(const IntPoint& absolutePagePos, TouchEventType type, PlatformTouchPoint::State state)
+PlatformTouchEvent::PlatformTouchEvent(const IntPoint& windowPos, TouchEventType type, PlatformTouchPoint::State state)
: m_type(type)
, m_ctrlKey(false)
, m_altKey(false)
, m_shiftKey(false)
, m_metaKey(false)
{
- m_touchPoints.append(PlatformTouchPoint(absolutePagePos, state));
+ m_touchPoints.append(PlatformTouchPoint(windowPos, state));
}
}
diff --git a/WebCore/platform/android/PlatformTouchPointAndroid.cpp b/WebCore/platform/android/PlatformTouchPointAndroid.cpp
index d790855..f134c0e 100644
--- a/WebCore/platform/android/PlatformTouchPointAndroid.cpp
+++ b/WebCore/platform/android/PlatformTouchPointAndroid.cpp
@@ -30,11 +30,11 @@
namespace WebCore {
-PlatformTouchPoint::PlatformTouchPoint(const IntPoint& absolutePagePos, State state)
+PlatformTouchPoint::PlatformTouchPoint(const IntPoint& windowPos, State state)
: m_id(0)
, m_state(state)
- , m_screenPos(absolutePagePos)
- , m_pos(absolutePagePos) { }
+ , m_screenPos(windowPos)
+ , m_pos(windowPos) { }
}
diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp
index 41dc668..88e7f0b 100644
--- a/WebCore/plugins/android/PluginViewAndroid.cpp
+++ b/WebCore/plugins/android/PluginViewAndroid.cpp
@@ -208,10 +208,10 @@ void PluginView::handleTouchEvent(TouchEvent* event)
evt.data.touch.modifiers = 0; // todo
- // In the event of a touchend (up) event, we must ask the changedTouch for the
+ // In the event of a touchend (up) or touchcancel event, we must ask the changedTouch for the
// co-ordinates as there is no touch in touches anymore.
- TouchList* touches = (evt.data.touch.action == kUp_ANPTouchAction) ?
- event->changedTouches() : event->touches();
+ TouchList* touches = (evt.data.touch.action == kUp_ANPTouchAction
+ || evt.data.touch.action == kCancel_ANPTouchAction) ? event->changedTouches() : event->touches();
// Convert to coordinates that are relative to the plugin.
// We only support single touch points at the moment, so we want to look at index 0 only.