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

hausmann at webkit.org hausmann at webkit.org
Thu Apr 8 00:32:32 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 5644f9be5aa9fc0a6180b6ce78a846c1a8051419
Author: hausmann at webkit.org <hausmann at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Dec 11 16:20:20 2009 +0000

    WebCore: Basic cross-platform implementation of mapping platform touch events
    to JavaScript touch events.
    
    Patch by Simon Hausmann  <hausmann at webkit.org>, Kim Grönholm <kim.gronholm at nomovok.com> on 2009-12-11
    Reviewed by Antti Koivisto.
    
    https://bugs.webkit.org/show_bug.cgi?id=32114
    
    Test: fast/events/basic-touch-events.html
    
    * page/EventHandler.cpp:
    (WebCore::EventHandler::handleTouchEvent):
    * page/EventHandler.h:
    
    WebKit/qt: Forward Qt touch events to the event handler as platform touch events.
    
    Patch by Simon Hausmann  <hausmann at webkit.org>, Kim Grönholm <kim.gronholm at nomovok.com> on 2009-12-11
    Reviewed by Antti Koivisto.
    
    https://bugs.webkit.org/show_bug.cgi?id=32114
    
    * Api/qwebpage.cpp:
    (QWebPagePrivate::touchEvent):
    (QWebPage::event):
    * Api/qwebpage_p.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51991 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4fffe66..6ce077f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2009-12-11  Simon Hausmann  <hausmann at webkit.org>, Kim Grönholm  <kim.gronholm at nomovok.com>
+
+        Reviewed by Antti Koivisto.
+
+        Basic cross-platform implementation of mapping platform touch events
+        to JavaScript touch events.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32114
+
+        Test: fast/events/basic-touch-events.html
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleTouchEvent):
+        * page/EventHandler.h:
+
 2009-12-11  Zoltan Horvath  <zoltan at webkit.org>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp
index 121a73f..278d87f 100644
--- a/WebCore/page/EventHandler.cpp
+++ b/WebCore/page/EventHandler.cpp
@@ -74,6 +74,11 @@
 #include "SVGUseElement.h"
 #endif
 
+#if ENABLE(TOUCH_EVENTS)
+#include "PlatformTouchEvent.h"
+#include "TouchEvent.h"
+#endif
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -2539,4 +2544,84 @@ void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, bool setL
     }
 }
 
+#if ENABLE(TOUCH_EVENTS)
+bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
+{
+    Document* doc = m_frame->document();
+    if (!doc)
+        return false;
+
+    if (!doc->hasListenerType(Document::TOUCH_LISTENER))
+        return false;
+
+    RefPtr<TouchList> touches = TouchList::create();
+    RefPtr<TouchList> changedTouches = TouchList::create();
+    RefPtr<TouchList> targetTouches = TouchList::create();
+
+    const Vector<PlatformTouchPoint>& points = event.touchPoints();
+    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);
+
+        Node* target = result.innerNode();
+        // Touch events should not go to text nodes
+        if (target && target->isTextNode())
+            target = target->parentNode();
+
+        RefPtr<Touch> touch = Touch::create(m_frame, target, point.id(),
+                                            point.screenPos().x(), point.screenPos().y(),
+                                            framePoint.x(), framePoint.y());
+
+        if (event.type() == TouchStart && !i) {
+            m_touchEventTarget = target;
+            m_firstTouchScreenPos = point.screenPos();
+            m_firstTouchPagePos = framePoint;
+        }
+
+        if (point.state() != PlatformTouchPoint::TouchReleased) {
+            touches->append(touch);
+
+            if (m_touchEventTarget == target)
+               targetTouches->append(touch);
+        }
+
+        if (point.state() != PlatformTouchPoint::TouchStationary)
+            changedTouches->append(touch);
+    }
+
+    AtomicString* eventName = 0;
+    switch (event.type()) {
+    case TouchStart:
+        eventName = &eventNames().touchstartEvent;
+        break;
+    case TouchMove:
+        eventName = &eventNames().touchmoveEvent;
+        break;
+    case TouchEnd:
+        eventName = &eventNames().touchendEvent;
+        break;
+    }
+
+    if (!m_touchEventTarget)
+        return false;
+
+    RefPtr<TouchEvent> ev = TouchEvent::create(touches.get(), targetTouches.get(), changedTouches.get(),
+                                               *eventName, m_touchEventTarget->document()->defaultView(),
+                                               m_firstTouchScreenPos.x(), m_firstTouchScreenPos.y(),
+                                               m_firstTouchPagePos.x(), m_firstTouchPagePos.y());
+
+    ExceptionCode ec = 0;
+    m_touchEventTarget->dispatchEvent(ev.get(), ec);
+
+    if (event.type() == TouchEnd)
+        m_touchEventTarget = 0;
+
+    m_previousTouchEvent = ev;
+
+    return ev->defaultPrevented();
+}
+#endif
+
 }
diff --git a/WebCore/page/EventHandler.h b/WebCore/page/EventHandler.h
index 2503686..420ff00 100644
--- a/WebCore/page/EventHandler.h
+++ b/WebCore/page/EventHandler.h
@@ -52,6 +52,7 @@ class KeyboardEvent;
 class MouseEventWithHitTestResults;
 class Node;
 class PlatformKeyboardEvent;
+class PlatformTouchEvent;
 class PlatformWheelEvent;
 class RenderLayer;
 class RenderObject;
@@ -60,6 +61,7 @@ class Scrollbar;
 class String;
 class SVGElementInstance;
 class TextEvent;
+class TouchEvent;
 class Widget;
     
 #if ENABLE(DRAG_SUPPORT)
@@ -191,6 +193,10 @@ public:
     static NSEvent *currentNSEvent();
 #endif
 
+#if ENABLE(TOUCH_EVENTS)
+    bool handleTouchEvent(const PlatformTouchEvent&);
+#endif
+
 private:
 #if ENABLE(DRAG_SUPPORT)
     enum DragAndDropHandleType {
@@ -398,6 +404,12 @@ private:
     bool m_sendingEventToSubview;
     int m_activationEventNumber;
 #endif
+#if ENABLE(TOUCH_EVENTS)
+    RefPtr<Node> m_touchEventTarget;
+    IntPoint m_firstTouchScreenPos;
+    IntPoint m_firstTouchPagePos;
+    RefPtr<TouchEvent> m_previousTouchEvent;
+#endif
 };
 
 } // namespace WebCore
diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp
index ba6b9f3..d3ba37a 100644
--- a/WebKit/qt/Api/qwebpage.cpp
+++ b/WebKit/qt/Api/qwebpage.cpp
@@ -108,6 +108,11 @@
 #include <QX11Info>
 #endif
 
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+#include <QTouchEvent>
+#include "PlatformTouchEvent.h"
+#endif
+
 using namespace WebCore;
 
 void QWEBKIT_EXPORT qt_drt_overwritePluginDirectories()
@@ -1334,6 +1339,18 @@ bool QWebPagePrivate::handleScrolling(QKeyEvent *ev, Frame *frame)
     return frame->eventHandler()->scrollRecursively(direction, granularity);
 }
 
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+void QWebPagePrivate::touchEvent(QTouchEvent* event)
+{
+    WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+    if (!frame->view())
+        return;
+
+    bool accepted = frame->eventHandler()->handleTouchEvent(PlatformTouchEvent(event));
+    event->setAccepted(accepted);
+}
+#endif
+
 /*!
   This method is used by the input method to query a set of properties of the page
   to be able to support complex input method operations as support for surrounding
@@ -2548,6 +2565,13 @@ bool QWebPage::event(QEvent *ev)
     case QEvent::Leave:
         d->leaveEvent(ev);
         break;
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+    case QEvent::TouchBegin:
+    case QEvent::TouchUpdate:
+    case QEvent::TouchEnd:
+        d->touchEvent(static_cast<QTouchEvent*>(ev));
+        break;
+#endif
     default:
         return QObject::event(ev);
     }
diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h
index 5d97da4..ffbdd51 100644
--- a/WebKit/qt/Api/qwebpage_p.h
+++ b/WebKit/qt/Api/qwebpage_p.h
@@ -114,6 +114,10 @@ public:
     void handleSoftwareInputPanel(Qt::MouseButton);
     bool handleScrolling(QKeyEvent*, WebCore::Frame*);
 
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+    void touchEvent(QTouchEvent*);
+#endif
+
     void setInspector(QWebInspector*);
     QWebInspector* getOrCreateInspector();
     WebCore::InspectorController* inspectorController();
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 2c2722b..8a95e61 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,16 @@
+2009-12-11  Simon Hausmann  <hausmann at webkit.org>, Kim Grönholm  <kim.gronholm at nomovok.com>
+
+        Reviewed by Antti Koivisto.
+
+        Forward Qt touch events to the event handler as platform touch events.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32114
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::touchEvent):
+        (QWebPage::event):
+        * Api/qwebpage_p.h:
+
 2009-12-07  Benjamin Poulain  <benjamin.poulain at nokia.com>
 
         Reviewed by Kenneth Rohde Christiansen.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list