Changeset 96399 in webkit


Ignore:
Timestamp:
Sep 30, 2011 4:58:30 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[Qt][WK2] Event delivery in QDesktopWebView is broken after merge of Qt5 refactor
https://bugs.webkit.org/show_bug.cgi?id=69105

This changes QDesktopWebView and QDesktopWebPageProxy to use QMouseEvent instead
of QGraphicsSceneMouseEvent.
Further it removes an endless loop introduced by the QSGItem::event() function
delivering inputMethodEvents but no other events.

Patch by Zeno Albisser <zeno.albisser@nokia.com> on 2011-09-30
Reviewed by Andreas Kling.

  • Shared/NativeWebMouseEvent.h:

(WebKit::NativeWebMouseEvent::nativeEvent):

  • Shared/NativeWebWheelEvent.h:

(WebKit::NativeWebWheelEvent::nativeEvent):

  • Shared/qt/NativeWebMouseEventQt.cpp:

(WebKit::NativeWebMouseEvent::NativeWebMouseEvent):

  • Shared/qt/NativeWebWheelEventQt.cpp:

(WebKit::NativeWebWheelEvent::NativeWebWheelEvent):

  • Shared/qt/WebEventFactoryQt.cpp:

(WebKit::mouseButtonForEvent):
(WebKit::webEventTypeForEvent):
(WebKit::WebEventFactory::createWebMouseEvent):
(WebKit::WebEventFactory::createWebWheelEvent):

  • Shared/qt/WebEventFactoryQt.h:
  • UIProcess/API/qt/qdesktopwebview.cpp:

(QDesktopWebView::mousePressEvent):
(QDesktopWebView::mouseMoveEvent):
(QDesktopWebView::mouseReleaseEvent):
(QDesktopWebView::mouseDoubleClickEvent):
(QDesktopWebView::wheelEvent):
(QDesktopWebView::event):

  • UIProcess/API/qt/qdesktopwebview.h:
  • UIProcess/qt/qdesktopwebpageproxy.cpp:

(QDesktopWebPageProxy::handleEvent):
(QDesktopWebPageProxy::handleMouseMoveEvent):
(QDesktopWebPageProxy::handleMousePressEvent):
(QDesktopWebPageProxy::handleMouseReleaseEvent):
(QDesktopWebPageProxy::handleMouseDoubleClickEvent):
(QDesktopWebPageProxy::handleWheelEvent):
(QDesktopWebPageProxy::handleHoverMoveEvent):

  • UIProcess/qt/qdesktopwebpageproxy.h:
Location:
trunk/Source/WebKit2
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r96383 r96399  
     12011-09-30  Zeno Albisser  <zeno.albisser@nokia.com>
     2
     3        [Qt][WK2] Event delivery in QDesktopWebView is broken after merge of Qt5 refactor
     4        https://bugs.webkit.org/show_bug.cgi?id=69105
     5
     6        This changes QDesktopWebView and QDesktopWebPageProxy to use QMouseEvent instead
     7        of QGraphicsSceneMouseEvent.
     8        Further it removes an endless loop introduced by the QSGItem::event() function
     9        delivering inputMethodEvents but no other events.
     10
     11        Reviewed by Andreas Kling.
     12
     13        * Shared/NativeWebMouseEvent.h:
     14        (WebKit::NativeWebMouseEvent::nativeEvent):
     15        * Shared/NativeWebWheelEvent.h:
     16        (WebKit::NativeWebWheelEvent::nativeEvent):
     17        * Shared/qt/NativeWebMouseEventQt.cpp:
     18        (WebKit::NativeWebMouseEvent::NativeWebMouseEvent):
     19        * Shared/qt/NativeWebWheelEventQt.cpp:
     20        (WebKit::NativeWebWheelEvent::NativeWebWheelEvent):
     21        * Shared/qt/WebEventFactoryQt.cpp:
     22        (WebKit::mouseButtonForEvent):
     23        (WebKit::webEventTypeForEvent):
     24        (WebKit::WebEventFactory::createWebMouseEvent):
     25        (WebKit::WebEventFactory::createWebWheelEvent):
     26        * Shared/qt/WebEventFactoryQt.h:
     27        * UIProcess/API/qt/qdesktopwebview.cpp:
     28        (QDesktopWebView::mousePressEvent):
     29        (QDesktopWebView::mouseMoveEvent):
     30        (QDesktopWebView::mouseReleaseEvent):
     31        (QDesktopWebView::mouseDoubleClickEvent):
     32        (QDesktopWebView::wheelEvent):
     33        (QDesktopWebView::event):
     34        * UIProcess/API/qt/qdesktopwebview.h:
     35        * UIProcess/qt/qdesktopwebpageproxy.cpp:
     36        (QDesktopWebPageProxy::handleEvent):
     37        (QDesktopWebPageProxy::handleMouseMoveEvent):
     38        (QDesktopWebPageProxy::handleMousePressEvent):
     39        (QDesktopWebPageProxy::handleMouseReleaseEvent):
     40        (QDesktopWebPageProxy::handleMouseDoubleClickEvent):
     41        (QDesktopWebPageProxy::handleWheelEvent):
     42        (QDesktopWebPageProxy::handleHoverMoveEvent):
     43        * UIProcess/qt/qdesktopwebpageproxy.h:
     44
    1452011-09-29  Ravi Phaneendra Kasibhatla  <ravi.kasibhatla@motorola.com>
    246
  • trunk/Source/WebKit2/Shared/NativeWebMouseEvent.h

    r95901 r96399  
    3333OBJC_CLASS NSView;
    3434#elif PLATFORM(QT)
    35 #include <qgraphicssceneevent.h>
     35#include <qevent.h>
    3636#elif PLATFORM(GTK)
    3737#include <GOwnPtrGtk.h>
     
    5050    NativeWebMouseEvent(HWND, UINT message, WPARAM, LPARAM, bool);
    5151#elif PLATFORM(QT)
    52     explicit NativeWebMouseEvent(QGraphicsSceneMouseEvent*, int);
     52    explicit NativeWebMouseEvent(QMouseEvent*, int);
    5353#elif PLATFORM(GTK)
    5454    NativeWebMouseEvent(const NativeWebMouseEvent&);
     
    6565    const MSG* nativeEvent() const { return &m_nativeEvent; }
    6666#elif PLATFORM(QT)
    67     const QGraphicsSceneMouseEvent* nativeEvent() const { return m_nativeEvent; }
     67    const QMouseEvent* nativeEvent() const { return m_nativeEvent; }
    6868#elif PLATFORM(GTK)
    6969    const GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
     
    7878    MSG m_nativeEvent;
    7979#elif PLATFORM(QT)
    80     QGraphicsSceneMouseEvent* m_nativeEvent;
     80    QMouseEvent* m_nativeEvent;
    8181#elif PLATFORM(GTK)
    8282    GOwnPtr<GdkEvent> m_nativeEvent;
  • trunk/Source/WebKit2/Shared/NativeWebWheelEvent.h

    r89211 r96399  
    3333OBJC_CLASS NSView;
    3434#elif PLATFORM(QT)
    35 #include <qgraphicssceneevent.h>
     35#include <qevent.h>
    3636#elif PLATFORM(GTK)
    3737#include <GOwnPtrGtk.h>
     
    5050    NativeWebWheelEvent(HWND, UINT message, WPARAM, LPARAM);
    5151#elif PLATFORM(QT)
    52     explicit NativeWebWheelEvent(QGraphicsSceneWheelEvent*);
     52    explicit NativeWebWheelEvent(QWheelEvent*);
    5353#elif PLATFORM(GTK)
    5454    NativeWebWheelEvent(const NativeWebWheelEvent&);
     
    6363    const MSG* nativeEvent() const { return &m_nativeEvent; }
    6464#elif PLATFORM(QT)
    65     const QGraphicsSceneWheelEvent* nativeEvent() const { return m_nativeEvent; }
     65    const QWheelEvent* nativeEvent() const { return m_nativeEvent; }
    6666#elif PLATFORM(GTK)
    6767    const GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
     
    7676    MSG m_nativeEvent;
    7777#elif PLATFORM(QT)
    78     QGraphicsSceneWheelEvent* m_nativeEvent;
     78    QWheelEvent* m_nativeEvent;
    7979#elif PLATFORM(GTK)
    8080    GOwnPtr<GdkEvent> m_nativeEvent;
  • trunk/Source/WebKit2/Shared/qt/NativeWebMouseEventQt.cpp

    r95901 r96399  
    3131namespace WebKit {
    3232
    33 NativeWebMouseEvent::NativeWebMouseEvent(QGraphicsSceneMouseEvent* event, int eventClickCount)
     33NativeWebMouseEvent::NativeWebMouseEvent(QMouseEvent* event, int eventClickCount)
    3434    : WebMouseEvent(WebEventFactory::createWebMouseEvent(event, eventClickCount))
    3535    , m_nativeEvent(event)
  • trunk/Source/WebKit2/Shared/qt/NativeWebWheelEventQt.cpp

    r85756 r96399  
    3131namespace WebKit {
    3232
    33 NativeWebWheelEvent::NativeWebWheelEvent(QGraphicsSceneWheelEvent* event)
     33NativeWebWheelEvent::NativeWebWheelEvent(QWheelEvent* event)
    3434    : WebWheelEvent(WebEventFactory::createWebWheelEvent(event))
    3535    , m_nativeEvent(event)
  • trunk/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp

    r95901 r96399  
    4040namespace WebKit {
    4141
    42 static WebMouseEvent::Button mouseButtonForEvent(QGraphicsSceneMouseEvent *event)
     42static WebMouseEvent::Button mouseButtonForEvent(QMouseEvent *event)
    4343{
    4444    if (event->button() == Qt::LeftButton || (event->buttons() & Qt::LeftButton))
     
    5454{
    5555    switch (event->type()) {
    56         case QEvent::GraphicsSceneMouseDoubleClick:
    57         case QEvent::GraphicsSceneMousePress:
    58             return WebEvent::MouseDown;
    59         case QEvent::GraphicsSceneMouseRelease:
    60             return WebEvent::MouseUp;
    61         case QEvent::GraphicsSceneMouseMove:
    62             return WebEvent::MouseMove;
    63         case QEvent::Wheel:
    64             return WebEvent::Wheel;
    65         case QEvent::KeyPress:
    66             return WebEvent::KeyDown;
    67         case QEvent::KeyRelease:
    68             return WebEvent::KeyUp;
     56    case QEvent::MouseButtonDblClick:
     57    case QEvent::MouseButtonPress:
     58        return WebEvent::MouseDown;
     59    case QEvent::MouseButtonRelease:
     60        return WebEvent::MouseUp;
     61    case QEvent::MouseMove:
     62        return WebEvent::MouseMove;
     63    case QEvent::Wheel:
     64        return WebEvent::Wheel;
     65    case QEvent::KeyPress:
     66        return WebEvent::KeyDown;
     67    case QEvent::KeyRelease:
     68        return WebEvent::KeyUp;
    6969#if ENABLE(TOUCH_EVENTS)
    70         case QEvent::TouchBegin:
    71             return WebEvent::TouchStart;
    72         case QEvent::TouchUpdate:
    73             return WebEvent::TouchMove;
    74         case QEvent::TouchEnd:
    75             return WebEvent::TouchEnd;
     70    case QEvent::TouchBegin:
     71        return WebEvent::TouchStart;
     72    case QEvent::TouchUpdate:
     73        return WebEvent::TouchMove;
     74    case QEvent::TouchEnd:
     75        return WebEvent::TouchEnd;
    7676#endif
    77         default:
    78             // assert
    79             return WebEvent::MouseMove;
     77    default:
     78        // assert
     79        return WebEvent::MouseMove;
    8080    }
    8181}
     
    9595}
    9696
    97 WebMouseEvent WebEventFactory::createWebMouseEvent(QGraphicsSceneMouseEvent* event, int eventClickCount)
    98 {
    99     FloatPoint delta(event->pos().x() - event->lastPos().x(), event->pos().y() - event->lastPos().y());
     97WebMouseEvent WebEventFactory::createWebMouseEvent(QMouseEvent* event, int eventClickCount)
     98{
     99    static FloatPoint lastPos = FloatPoint(0, 0);
    100100
    101101    WebEvent::Type type             = webEventTypeForEvent(event);
    102102    WebMouseEvent::Button button    = mouseButtonForEvent(event);
    103     float deltaX                    = delta.x();
    104     float deltaY                    = delta.y();
     103    float deltaX                    = event->pos().x() - lastPos.x();
     104    float deltaY                    = event->pos().y() - lastPos.y();
    105105    int clickCount                  = eventClickCount;
    106106    WebEvent::Modifiers modifiers   = modifiersForEvent(event->modifiers());
    107107    double timestamp                = WTF::currentTime();
    108 
    109     return WebMouseEvent(type, button, event->pos().toPoint(), event->screenPos(), deltaX, deltaY, 0.0f, clickCount, modifiers, timestamp);
    110 }
    111 
    112 WebWheelEvent WebEventFactory::createWebWheelEvent(QGraphicsSceneWheelEvent* e)
     108    lastPos.set(event->localPos().x(), event->localPos().y());
     109
     110    return WebMouseEvent(type, button, event->localPos().toPoint(), event->screenPos().toPoint(), deltaX, deltaY, 0.0f, clickCount, modifiers, timestamp);
     111}
     112
     113WebWheelEvent WebEventFactory::createWebWheelEvent(QWheelEvent* e)
    113114{
    114115    float deltaX                            = 0;
     
    139140    deltaY *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1;
    140141
    141     return WebWheelEvent(WebEvent::Wheel, e->pos().toPoint(), e->screenPos(), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, modifiers, timestamp);
     142    return WebWheelEvent(WebEvent::Wheel, e->posF().toPoint(), e->globalPosF().toPoint(), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, modifiers, timestamp);
    142143}
    143144
  • trunk/Source/WebKit2/Shared/qt/WebEventFactoryQt.h

    r95901 r96399  
    3434#endif
    3535
    36 class QGraphicsSceneMouseEvent;
    37 class QGraphicsSceneWheelEvent;
     36class QMouseEvent;
     37class QWheelEvent;
    3838class QKeyEvent;
    3939
     
    4242class WebEventFactory {
    4343public:
    44     static WebMouseEvent createWebMouseEvent(QGraphicsSceneMouseEvent* event, int eventClickCount);
    45     static WebWheelEvent createWebWheelEvent(QGraphicsSceneWheelEvent* event);
    46     static WebKeyboardEvent createWebKeyboardEvent(QKeyEvent* event);
     44    static WebMouseEvent createWebMouseEvent(QMouseEvent*, int eventClickCount);
     45    static WebWheelEvent createWebWheelEvent(QWheelEvent*);
     46    static WebKeyboardEvent createWebKeyboardEvent(QKeyEvent*);
    4747#if ENABLE(TOUCH_EVENTS)
    4848    static WebTouchEvent createWebTouchEvent(const QTouchEvent*);
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp

    r96345 r96399  
    270270}
    271271
    272 void QDesktopWebView::mousePressEvent(QGraphicsSceneMouseEvent* event)
    273 {
    274     this->event(event);
    275 }
    276 
    277 void QDesktopWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
    278 {
    279     this->event(event);
    280 }
    281 
    282 void QDesktopWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
    283 {
    284     this->event(event);
    285 }
    286 
    287 void QDesktopWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
     272void QDesktopWebView::mousePressEvent(QMouseEvent* event)
     273{
     274    this->event(event);
     275}
     276
     277void QDesktopWebView::mouseMoveEvent(QMouseEvent* event)
     278{
     279    this->event(event);
     280}
     281
     282void QDesktopWebView::mouseReleaseEvent(QMouseEvent* event)
     283{
     284    this->event(event);
     285}
     286
     287void QDesktopWebView::mouseDoubleClickEvent(QMouseEvent* event)
    288288{
    289289    this->event(event);
     
    292292void QDesktopWebView::wheelEvent(QWheelEvent* event)
    293293{
    294     // FIXME: for some reason, the scene graph delivers QWheelEvent instead of QGraphicsSceneWheelEvent.
    295     // We transform them in QGraphicsSceneWheelEvent for consistency. Otherwise the position would be complete magic.
    296     // We shoud modify the scenegraph to get the correct type of events.
    297     QGraphicsSceneWheelEvent graphicsEvent(QEvent::GraphicsSceneWheel);
    298     graphicsEvent.setPos(event->pos());
    299     graphicsEvent.setButtons(event->buttons());
    300     graphicsEvent.setDelta(event->delta());
    301     graphicsEvent.setModifiers(event->modifiers());
    302     graphicsEvent.setOrientation(event->orientation());
    303     graphicsEvent.setScenePos(mapToScene(event->pos()));
    304     graphicsEvent.setScreenPos(event->globalPos());
    305     this->event(&graphicsEvent);
     294    this->event(event);
    306295}
    307296
     
    368357    if (d->page.handleEvent(ev))
    369358        return true;
     359    if (ev->type() == QEvent::InputMethod)
     360        return false; // This is necessary to avoid an endless loop in connection with QSGItem::event().
    370361    return QSGItem::event(ev);
    371362}
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h

    r96345 r96399  
    3333QT_BEGIN_NAMESPACE
    3434class QFocusEvent;
    35 class QGraphicsSceneMouseEvent;
     35class QMouseEvent;
    3636class QHoverEvent;
    3737class QInputMethodEvent;
     
    9797    virtual void focusInEvent(QFocusEvent*);
    9898    virtual void focusOutEvent(QFocusEvent*);
    99     virtual void mousePressEvent(QGraphicsSceneMouseEvent*);
    100     virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
    101     virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
    102     virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
     99    virtual void mousePressEvent(QMouseEvent *);
     100    virtual void mouseMoveEvent(QMouseEvent *);
     101    virtual void mouseReleaseEvent(QMouseEvent *);
     102    virtual void mouseDoubleClickEvent(QMouseEvent *);
    103103    virtual void wheelEvent(QWheelEvent*);
    104104    virtual void touchEvent(QTouchEvent*);
  • trunk/Source/WebKit2/UIProcess/qt/qdesktopwebpageproxy.cpp

    r95901 r96399  
    9191{
    9292    switch (ev->type()) {
    93     case QEvent::GraphicsSceneMouseMove:
    94         return handleMouseMoveEvent(reinterpret_cast<QGraphicsSceneMouseEvent*>(ev));
    95     case QEvent::GraphicsSceneMousePress:
    96         return handleMousePressEvent(reinterpret_cast<QGraphicsSceneMouseEvent*>(ev));
    97     case QEvent::GraphicsSceneMouseRelease:
    98         return handleMouseReleaseEvent(reinterpret_cast<QGraphicsSceneMouseEvent*>(ev));
    99     case QEvent::GraphicsSceneMouseDoubleClick:
    100         return handleMouseDoubleClickEvent(reinterpret_cast<QGraphicsSceneMouseEvent*>(ev));
    101     case QEvent::GraphicsSceneWheel:
    102         return handleWheelEvent(reinterpret_cast<QGraphicsSceneWheelEvent*>(ev));
     93    case QEvent::MouseMove:
     94        return handleMouseMoveEvent(reinterpret_cast<QMouseEvent*>(ev));
     95    case QEvent::MouseButtonPress:
     96        return handleMousePressEvent(reinterpret_cast<QMouseEvent*>(ev));
     97    case QEvent::MouseButtonRelease:
     98        return handleMouseReleaseEvent(reinterpret_cast<QMouseEvent*>(ev));
     99    case QEvent::MouseButtonDblClick:
     100        return handleMouseDoubleClickEvent(reinterpret_cast<QMouseEvent*>(ev));
     101    case QEvent::Wheel:
     102        return handleWheelEvent(reinterpret_cast<QWheelEvent*>(ev));
    103103    case QEvent::HoverMove:
    104104        return handleHoverMoveEvent(reinterpret_cast<QHoverEvent*>(ev));
     
    115115}
    116116
    117 bool QDesktopWebPageProxy::handleMouseMoveEvent(QGraphicsSceneMouseEvent* ev)
     117bool QDesktopWebPageProxy::handleMouseMoveEvent(QMouseEvent* ev)
    118118{
    119119    // For some reason mouse press results in mouse hover (which is
     
    132132}
    133133
    134 bool QDesktopWebPageProxy::handleMousePressEvent(QGraphicsSceneMouseEvent* ev)
     134bool QDesktopWebPageProxy::handleMousePressEvent(QMouseEvent* ev)
    135135{
    136136    if (m_tripleClickTimer.isActive() && (ev->pos() - m_tripleClick).manhattanLength() < QApplication::startDragDistance()) {
     
    143143}
    144144
    145 bool QDesktopWebPageProxy::handleMouseReleaseEvent(QGraphicsSceneMouseEvent* ev)
     145bool QDesktopWebPageProxy::handleMouseReleaseEvent(QMouseEvent* ev)
    146146{
    147147    m_webPageProxy->handleMouseEvent(NativeWebMouseEvent(ev, /*eventClickCount=*/0));
     
    149149}
    150150
    151 bool QDesktopWebPageProxy::handleMouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev)
     151bool QDesktopWebPageProxy::handleMouseDoubleClickEvent(QMouseEvent* ev)
    152152{
    153153    m_webPageProxy->handleMouseEvent(NativeWebMouseEvent(ev, /*eventClickCount=*/2));
    154154
    155155    m_tripleClickTimer.start(QApplication::doubleClickInterval(), this);
    156     m_tripleClick = ev->pos().toPoint();
    157     return ev->isAccepted();
    158 }
    159 
    160 bool QDesktopWebPageProxy::handleWheelEvent(QGraphicsSceneWheelEvent* ev)
     156    m_tripleClick = ev->localPos().toPoint();
     157    return ev->isAccepted();
     158}
     159
     160bool QDesktopWebPageProxy::handleWheelEvent(QWheelEvent* ev)
    161161{
    162162    m_webPageProxy->handleWheelEvent(NativeWebWheelEvent(ev));
     
    166166bool QDesktopWebPageProxy::handleHoverMoveEvent(QHoverEvent* ev)
    167167{
    168     QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMouseMove);
    169     me.setPos(ev->pos());
     168    QMouseEvent me(QEvent::MouseMove, ev->pos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
    170169    me.setAccepted(ev->isAccepted());
    171170
  • trunk/Source/WebKit2/UIProcess/qt/qdesktopwebpageproxy.h

    r95901 r96399  
    5252    virtual void timerEvent(QTimerEvent*);
    5353
    54     bool handleMouseMoveEvent(QGraphicsSceneMouseEvent*);
    55     bool handleMousePressEvent(QGraphicsSceneMouseEvent*);
    56     bool handleMouseReleaseEvent(QGraphicsSceneMouseEvent*);
    57     bool handleMouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
    58     bool handleWheelEvent(QGraphicsSceneWheelEvent*);
     54    bool handleMouseMoveEvent(QMouseEvent*);
     55    bool handleMousePressEvent(QMouseEvent*);
     56    bool handleMouseReleaseEvent(QMouseEvent*);
     57    bool handleMouseDoubleClickEvent(QMouseEvent*);
     58    bool handleWheelEvent(QWheelEvent*);
    5959    bool handleHoverMoveEvent(QHoverEvent*);
    6060    bool handleDragEnterEvent(QGraphicsSceneDragDropEvent*);
Note: See TracChangeset for help on using the changeset viewer.