Changeset 96399 in webkit
- Timestamp:
- Sep 30, 2011 4:58:30 AM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r96383 r96399 1 2011-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 1 45 2011-09-29 Ravi Phaneendra Kasibhatla <ravi.kasibhatla@motorola.com> 2 46 -
trunk/Source/WebKit2/Shared/NativeWebMouseEvent.h
r95901 r96399 33 33 OBJC_CLASS NSView; 34 34 #elif PLATFORM(QT) 35 #include <q graphicssceneevent.h>35 #include <qevent.h> 36 36 #elif PLATFORM(GTK) 37 37 #include <GOwnPtrGtk.h> … … 50 50 NativeWebMouseEvent(HWND, UINT message, WPARAM, LPARAM, bool); 51 51 #elif PLATFORM(QT) 52 explicit NativeWebMouseEvent(Q GraphicsSceneMouseEvent*, int);52 explicit NativeWebMouseEvent(QMouseEvent*, int); 53 53 #elif PLATFORM(GTK) 54 54 NativeWebMouseEvent(const NativeWebMouseEvent&); … … 65 65 const MSG* nativeEvent() const { return &m_nativeEvent; } 66 66 #elif PLATFORM(QT) 67 const Q GraphicsSceneMouseEvent* nativeEvent() const { return m_nativeEvent; }67 const QMouseEvent* nativeEvent() const { return m_nativeEvent; } 68 68 #elif PLATFORM(GTK) 69 69 const GdkEvent* nativeEvent() const { return m_nativeEvent.get(); } … … 78 78 MSG m_nativeEvent; 79 79 #elif PLATFORM(QT) 80 Q GraphicsSceneMouseEvent* m_nativeEvent;80 QMouseEvent* m_nativeEvent; 81 81 #elif PLATFORM(GTK) 82 82 GOwnPtr<GdkEvent> m_nativeEvent; -
trunk/Source/WebKit2/Shared/NativeWebWheelEvent.h
r89211 r96399 33 33 OBJC_CLASS NSView; 34 34 #elif PLATFORM(QT) 35 #include <q graphicssceneevent.h>35 #include <qevent.h> 36 36 #elif PLATFORM(GTK) 37 37 #include <GOwnPtrGtk.h> … … 50 50 NativeWebWheelEvent(HWND, UINT message, WPARAM, LPARAM); 51 51 #elif PLATFORM(QT) 52 explicit NativeWebWheelEvent(Q GraphicsSceneWheelEvent*);52 explicit NativeWebWheelEvent(QWheelEvent*); 53 53 #elif PLATFORM(GTK) 54 54 NativeWebWheelEvent(const NativeWebWheelEvent&); … … 63 63 const MSG* nativeEvent() const { return &m_nativeEvent; } 64 64 #elif PLATFORM(QT) 65 const Q GraphicsSceneWheelEvent* nativeEvent() const { return m_nativeEvent; }65 const QWheelEvent* nativeEvent() const { return m_nativeEvent; } 66 66 #elif PLATFORM(GTK) 67 67 const GdkEvent* nativeEvent() const { return m_nativeEvent.get(); } … … 76 76 MSG m_nativeEvent; 77 77 #elif PLATFORM(QT) 78 Q GraphicsSceneWheelEvent* m_nativeEvent;78 QWheelEvent* m_nativeEvent; 79 79 #elif PLATFORM(GTK) 80 80 GOwnPtr<GdkEvent> m_nativeEvent; -
trunk/Source/WebKit2/Shared/qt/NativeWebMouseEventQt.cpp
r95901 r96399 31 31 namespace WebKit { 32 32 33 NativeWebMouseEvent::NativeWebMouseEvent(Q GraphicsSceneMouseEvent* event, int eventClickCount)33 NativeWebMouseEvent::NativeWebMouseEvent(QMouseEvent* event, int eventClickCount) 34 34 : WebMouseEvent(WebEventFactory::createWebMouseEvent(event, eventClickCount)) 35 35 , m_nativeEvent(event) -
trunk/Source/WebKit2/Shared/qt/NativeWebWheelEventQt.cpp
r85756 r96399 31 31 namespace WebKit { 32 32 33 NativeWebWheelEvent::NativeWebWheelEvent(Q GraphicsSceneWheelEvent* event)33 NativeWebWheelEvent::NativeWebWheelEvent(QWheelEvent* event) 34 34 : WebWheelEvent(WebEventFactory::createWebWheelEvent(event)) 35 35 , m_nativeEvent(event) -
trunk/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp
r95901 r96399 40 40 namespace WebKit { 41 41 42 static WebMouseEvent::Button mouseButtonForEvent(Q GraphicsSceneMouseEvent *event)42 static WebMouseEvent::Button mouseButtonForEvent(QMouseEvent *event) 43 43 { 44 44 if (event->button() == Qt::LeftButton || (event->buttons() & Qt::LeftButton)) … … 54 54 { 55 55 switch (event->type()) { 56 case QEvent::GraphicsSceneMouseDoubleClick:57 case QEvent::GraphicsSceneMousePress:58 59 case QEvent::GraphicsSceneMouseRelease:60 61 case QEvent::GraphicsSceneMouseMove:62 63 64 65 66 67 68 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; 69 69 #if ENABLE(TOUCH_EVENTS) 70 71 72 73 74 75 70 case QEvent::TouchBegin: 71 return WebEvent::TouchStart; 72 case QEvent::TouchUpdate: 73 return WebEvent::TouchMove; 74 case QEvent::TouchEnd: 75 return WebEvent::TouchEnd; 76 76 #endif 77 78 79 77 default: 78 // assert 79 return WebEvent::MouseMove; 80 80 } 81 81 } … … 95 95 } 96 96 97 WebMouseEvent WebEventFactory::createWebMouseEvent(Q GraphicsSceneMouseEvent* event, int eventClickCount)98 { 99 FloatPoint delta(event->pos().x() - event->lastPos().x(), event->pos().y() - event->lastPos().y());97 WebMouseEvent WebEventFactory::createWebMouseEvent(QMouseEvent* event, int eventClickCount) 98 { 99 static FloatPoint lastPos = FloatPoint(0, 0); 100 100 101 101 WebEvent::Type type = webEventTypeForEvent(event); 102 102 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(); 105 105 int clickCount = eventClickCount; 106 106 WebEvent::Modifiers modifiers = modifiersForEvent(event->modifiers()); 107 107 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 113 WebWheelEvent WebEventFactory::createWebWheelEvent(QWheelEvent* e) 113 114 { 114 115 float deltaX = 0; … … 139 140 deltaY *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1; 140 141 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); 142 143 } 143 144 -
trunk/Source/WebKit2/Shared/qt/WebEventFactoryQt.h
r95901 r96399 34 34 #endif 35 35 36 class Q GraphicsSceneMouseEvent;37 class Q GraphicsSceneWheelEvent;36 class QMouseEvent; 37 class QWheelEvent; 38 38 class QKeyEvent; 39 39 … … 42 42 class WebEventFactory { 43 43 public: 44 static WebMouseEvent createWebMouseEvent(Q GraphicsSceneMouseEvent* event, int eventClickCount);45 static WebWheelEvent createWebWheelEvent(Q GraphicsSceneWheelEvent* event);46 static WebKeyboardEvent createWebKeyboardEvent(QKeyEvent* event);44 static WebMouseEvent createWebMouseEvent(QMouseEvent*, int eventClickCount); 45 static WebWheelEvent createWebWheelEvent(QWheelEvent*); 46 static WebKeyboardEvent createWebKeyboardEvent(QKeyEvent*); 47 47 #if ENABLE(TOUCH_EVENTS) 48 48 static WebTouchEvent createWebTouchEvent(const QTouchEvent*); -
trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp
r96345 r96399 270 270 } 271 271 272 void QDesktopWebView::mousePressEvent(Q GraphicsSceneMouseEvent* event)273 { 274 this->event(event); 275 } 276 277 void QDesktopWebView::mouseMoveEvent(Q GraphicsSceneMouseEvent* event)278 { 279 this->event(event); 280 } 281 282 void QDesktopWebView::mouseReleaseEvent(Q GraphicsSceneMouseEvent* event)283 { 284 this->event(event); 285 } 286 287 void QDesktopWebView::mouseDoubleClickEvent(Q GraphicsSceneMouseEvent* event)272 void QDesktopWebView::mousePressEvent(QMouseEvent* event) 273 { 274 this->event(event); 275 } 276 277 void QDesktopWebView::mouseMoveEvent(QMouseEvent* event) 278 { 279 this->event(event); 280 } 281 282 void QDesktopWebView::mouseReleaseEvent(QMouseEvent* event) 283 { 284 this->event(event); 285 } 286 287 void QDesktopWebView::mouseDoubleClickEvent(QMouseEvent* event) 288 288 { 289 289 this->event(event); … … 292 292 void QDesktopWebView::wheelEvent(QWheelEvent* event) 293 293 { 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); 306 295 } 307 296 … … 368 357 if (d->page.handleEvent(ev)) 369 358 return true; 359 if (ev->type() == QEvent::InputMethod) 360 return false; // This is necessary to avoid an endless loop in connection with QSGItem::event(). 370 361 return QSGItem::event(ev); 371 362 } -
trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h
r96345 r96399 33 33 QT_BEGIN_NAMESPACE 34 34 class QFocusEvent; 35 class Q GraphicsSceneMouseEvent;35 class QMouseEvent; 36 36 class QHoverEvent; 37 37 class QInputMethodEvent; … … 97 97 virtual void focusInEvent(QFocusEvent*); 98 98 virtual void focusOutEvent(QFocusEvent*); 99 virtual void mousePressEvent(Q GraphicsSceneMouseEvent*);100 virtual void mouseMoveEvent(Q GraphicsSceneMouseEvent*);101 virtual void mouseReleaseEvent(Q GraphicsSceneMouseEvent*);102 virtual void mouseDoubleClickEvent(Q GraphicsSceneMouseEvent*);99 virtual void mousePressEvent(QMouseEvent *); 100 virtual void mouseMoveEvent(QMouseEvent *); 101 virtual void mouseReleaseEvent(QMouseEvent *); 102 virtual void mouseDoubleClickEvent(QMouseEvent *); 103 103 virtual void wheelEvent(QWheelEvent*); 104 104 virtual void touchEvent(QTouchEvent*); -
trunk/Source/WebKit2/UIProcess/qt/qdesktopwebpageproxy.cpp
r95901 r96399 91 91 { 92 92 switch (ev->type()) { 93 case QEvent:: GraphicsSceneMouseMove:94 return handleMouseMoveEvent(reinterpret_cast<Q GraphicsSceneMouseEvent*>(ev));95 case QEvent:: GraphicsSceneMousePress:96 return handleMousePressEvent(reinterpret_cast<Q GraphicsSceneMouseEvent*>(ev));97 case QEvent:: GraphicsSceneMouseRelease:98 return handleMouseReleaseEvent(reinterpret_cast<Q GraphicsSceneMouseEvent*>(ev));99 case QEvent:: GraphicsSceneMouseDoubleClick:100 return handleMouseDoubleClickEvent(reinterpret_cast<Q GraphicsSceneMouseEvent*>(ev));101 case QEvent:: GraphicsSceneWheel:102 return handleWheelEvent(reinterpret_cast<Q GraphicsSceneWheelEvent*>(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)); 103 103 case QEvent::HoverMove: 104 104 return handleHoverMoveEvent(reinterpret_cast<QHoverEvent*>(ev)); … … 115 115 } 116 116 117 bool QDesktopWebPageProxy::handleMouseMoveEvent(Q GraphicsSceneMouseEvent* ev)117 bool QDesktopWebPageProxy::handleMouseMoveEvent(QMouseEvent* ev) 118 118 { 119 119 // For some reason mouse press results in mouse hover (which is … … 132 132 } 133 133 134 bool QDesktopWebPageProxy::handleMousePressEvent(Q GraphicsSceneMouseEvent* ev)134 bool QDesktopWebPageProxy::handleMousePressEvent(QMouseEvent* ev) 135 135 { 136 136 if (m_tripleClickTimer.isActive() && (ev->pos() - m_tripleClick).manhattanLength() < QApplication::startDragDistance()) { … … 143 143 } 144 144 145 bool QDesktopWebPageProxy::handleMouseReleaseEvent(Q GraphicsSceneMouseEvent* ev)145 bool QDesktopWebPageProxy::handleMouseReleaseEvent(QMouseEvent* ev) 146 146 { 147 147 m_webPageProxy->handleMouseEvent(NativeWebMouseEvent(ev, /*eventClickCount=*/0)); … … 149 149 } 150 150 151 bool QDesktopWebPageProxy::handleMouseDoubleClickEvent(Q GraphicsSceneMouseEvent* ev)151 bool QDesktopWebPageProxy::handleMouseDoubleClickEvent(QMouseEvent* ev) 152 152 { 153 153 m_webPageProxy->handleMouseEvent(NativeWebMouseEvent(ev, /*eventClickCount=*/2)); 154 154 155 155 m_tripleClickTimer.start(QApplication::doubleClickInterval(), this); 156 m_tripleClick = ev-> pos().toPoint();157 return ev->isAccepted(); 158 } 159 160 bool QDesktopWebPageProxy::handleWheelEvent(Q GraphicsSceneWheelEvent* ev)156 m_tripleClick = ev->localPos().toPoint(); 157 return ev->isAccepted(); 158 } 159 160 bool QDesktopWebPageProxy::handleWheelEvent(QWheelEvent* ev) 161 161 { 162 162 m_webPageProxy->handleWheelEvent(NativeWebWheelEvent(ev)); … … 166 166 bool QDesktopWebPageProxy::handleHoverMoveEvent(QHoverEvent* ev) 167 167 { 168 QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMouseMove); 169 me.setPos(ev->pos()); 168 QMouseEvent me(QEvent::MouseMove, ev->pos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); 170 169 me.setAccepted(ev->isAccepted()); 171 170 -
trunk/Source/WebKit2/UIProcess/qt/qdesktopwebpageproxy.h
r95901 r96399 52 52 virtual void timerEvent(QTimerEvent*); 53 53 54 bool handleMouseMoveEvent(Q GraphicsSceneMouseEvent*);55 bool handleMousePressEvent(Q GraphicsSceneMouseEvent*);56 bool handleMouseReleaseEvent(Q GraphicsSceneMouseEvent*);57 bool handleMouseDoubleClickEvent(Q GraphicsSceneMouseEvent*);58 bool handleWheelEvent(Q GraphicsSceneWheelEvent*);54 bool handleMouseMoveEvent(QMouseEvent*); 55 bool handleMousePressEvent(QMouseEvent*); 56 bool handleMouseReleaseEvent(QMouseEvent*); 57 bool handleMouseDoubleClickEvent(QMouseEvent*); 58 bool handleWheelEvent(QWheelEvent*); 59 59 bool handleHoverMoveEvent(QHoverEvent*); 60 60 bool handleDragEnterEvent(QGraphicsSceneDragDropEvent*);
Note: See TracChangeset
for help on using the changeset viewer.