Changeset 65788 in webkit
- Timestamp:
- Aug 22, 2010 3:42:41 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r65787 r65788 1 2010-08-22 Juha Savolainen <juha.savolainen@weego.fi> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] Add QTouchEvents support for WebKit2 6 https://bugs.webkit.org/show_bug.cgi?id=44330 7 8 This patch adds support for QTouchEvents in WebKit2. A new WebEvent-class 9 is created for touchevents, WebTouchEvent. Also touchpoints needed a new 10 class, WebPlatformTouchPoint. This is similar solution like in other 11 events(like MouseEvent) on WebKit2. These classes are introduced in WebEvent.h 12 Also there was a need to create an empty constructor to PlatformTouchPoint-class. 13 14 * platform/PlatformTouchPoint.h: 15 (WebCore::PlatformTouchPoint::PlatformTouchPoint): 16 1 17 2010-08-22 Daniel Bates <dbates@rim.com> 2 18 -
trunk/WebCore/platform/PlatformTouchPoint.h
r57655 r65788 46 46 #if PLATFORM(QT) 47 47 PlatformTouchPoint(const QTouchEvent::TouchPoint&); 48 PlatformTouchPoint() {}; 48 49 #elif PLATFORM(ANDROID) 49 50 PlatformTouchPoint(const IntPoint& windowPos, State); -
trunk/WebKit2/ChangeLog
r65780 r65788 1 2010-08-22 Juha Savolainen <juha.savolainen@weego.fi> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] Add QTouchEvents support for WebKit2 6 https://bugs.webkit.org/show_bug.cgi?id=44330 7 8 This patch adds support for QTouchEvents in WebKit2. A new WebEvent-class 9 is created for touchevents, WebTouchEvent. Also touchpoints needed a new 10 class, WebPlatformTouchPoint. This is similar solution like in other 11 events(like MouseEvent) on WebKit2. These classes are introduced in WebEvent.h 12 Also there was a need to create an empty constructor to PlatformTouchPoint-class. 13 14 * DerivedSources.pro: 15 * Shared/CoreIPCSupport/WebPageMessageKinds.h: 16 (WebPageMessage::): 17 * Shared/WebEvent.h: 18 (WebKit::WebEvent::): 19 (WebKit::WebTouchPoint::): 20 (WebKit::WebTouchPoint::WebTouchPoint): 21 (WebKit::WebTouchPoint::id): 22 (WebKit::WebTouchPoint::state): 23 (WebKit::WebTouchPoint::screenPosX): 24 (WebKit::WebTouchPoint::screenPosY): 25 (WebKit::WebTouchPoint::posX): 26 (WebKit::WebTouchPoint::posY): 27 (WebKit::WebTouchPoint::setState): 28 (WebKit::WebTouchPoint::encode): 29 (WebKit::WebTouchPoint::decode): 30 (WebKit::WebTouchEvent::WebTouchEvent): 31 (WebKit::WebTouchEvent::type): 32 (WebKit::WebTouchEvent::touchPoints): 33 (WebKit::WebTouchEvent::encode): 34 (WebKit::WebTouchEvent::decode): 35 (WebKit::WebTouchEvent::isTouchEventType): 36 * Shared/WebEventConversion.cpp: 37 (WebKit::WebKit2PlatformTouchPoint::WebKit2PlatformTouchPoint): 38 (WebKit::WebKit2PlatformTouchEvent::WebKit2PlatformTouchEvent): 39 (WebKit::platform): 40 * Shared/WebEventConversion.h: 41 * Shared/qt/WebEventFactoryQt.cpp: 42 (WebKit::webEventTypeForEvent): 43 (WebKit::WebEventFactory::createWebTouchEvent): 44 * Shared/qt/WebEventFactoryQt.h: 45 * UIProcess/API/qt/qgraphicswkview.cpp: 46 (QGraphicsWKView::event): 47 (QGraphicsWKView::touchEvent): 48 * UIProcess/API/qt/qgraphicswkview.h: 49 * UIProcess/API/qt/qwkpage.cpp: 50 (QWKPagePrivate::touchEvent): 51 * UIProcess/API/qt/qwkpage_p.h: 52 * UIProcess/WebPageProxy.cpp: 53 (WebKit::WebPageProxy::touchEvent): 54 * UIProcess/WebPageProxy.h: 55 * WebProcess/WebPage/WebPage.cpp: 56 (WebKit::WebPage::touchEvent): 57 (WebKit::WebPage::didReceiveMessage): 58 * WebProcess/WebPage/WebPage.h: 59 1 60 2010-08-21 Sam Weinig <sam@webkit.org> 2 61 -
trunk/WebKit2/DerivedSources.pro
r65158 r65788 81 81 platform/PlatformMouseEvent.h \ 82 82 platform/PlatformStrategies.h \ 83 platform/PlatformTouchPoint.h \ 84 platform/PlatformTouchEvent.h \ 83 85 platform/PlatformWheelEvent.h \ 84 86 platform/PopupMenu.h \ -
trunk/WebKit2/Shared/CoreIPCSupport/WebPageMessageKinds.h
r65644 r65788 53 53 TryClose, 54 54 WheelEvent 55 #if ENABLE(TOUCH_EVENTS) 56 , TouchEvent 57 #endif 55 58 }; 56 59 -
trunk/WebKit2/Shared/WebEvent.h
r65465 r65788 53 53 RawKeyDown, 54 54 Char 55 #if ENABLE(TOUCH_EVENTS) 56 , 57 TouchStart, 58 TouchMove, 59 TouchEnd, 60 TouchCancel 61 #endif 55 62 }; 56 63 … … 328 335 }; 329 336 337 #if ENABLE(TOUCH_EVENTS) 338 339 class WebPlatformTouchPoint { 340 public: 341 enum TouchPointState { 342 TouchReleased, 343 TouchPressed, 344 TouchMoved, 345 TouchStationary, 346 TouchCancelled 347 }; 348 349 WebPlatformTouchPoint() 350 { 351 } 352 353 WebPlatformTouchPoint(unsigned id, TouchPointState state, int screenPosX, int screenPosY, int posX, int posY) 354 : m_id(id) 355 , m_state(state) 356 , m_screenPosX(screenPosX) 357 , m_screenPosY(screenPosY) 358 , m_posX(posX) 359 , m_posY(posY) 360 { 361 } 362 363 unsigned id() const { return m_id; } 364 TouchPointState state() const { return m_state; } 365 366 int screenPosX() const { return m_screenPosX; } 367 int screenPosY() const { return m_screenPosY; } 368 int32_t posX() const { return m_posX; } 369 int32_t posY() const { return m_posY; } 370 371 void setState(TouchPointState state) { m_state = state; } 372 373 void encode(CoreIPC::ArgumentEncoder* encoder) const 374 { 375 encoder->encodeBytes(reinterpret_cast<const uint8_t*>(this), sizeof(*this)); 376 } 377 378 static bool decode(CoreIPC::ArgumentDecoder* decoder, WebPlatformTouchPoint& t) 379 { 380 return decoder->decodeBytes(reinterpret_cast<uint8_t*>(&t), sizeof(t)); 381 } 382 383 private: 384 unsigned m_id; 385 TouchPointState m_state; 386 int m_screenPosX, m_screenPosY; 387 int32_t m_posX, m_posY; 388 389 }; 390 391 class WebTouchEvent : public WebEvent { 392 public: 393 394 WebTouchEvent() 395 { 396 } 397 398 WebTouchEvent(WebEvent::Type type, Vector<WebPlatformTouchPoint> touchPoints, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, Modifiers modifiers, double timestamp) 399 : WebEvent(type, modifiers, timestamp) 400 , m_type(type) 401 , m_touchPoints(touchPoints) 402 , m_ctrlKey(ctrlKey) 403 , m_altKey(altKey) 404 , m_shiftKey(shiftKey) 405 , m_metaKey(metaKey) 406 { 407 ASSERT(isTouchEventType(type)); 408 } 409 410 const Vector<WebPlatformTouchPoint> touchPoints() const { return m_touchPoints; } 411 412 void encode(CoreIPC::ArgumentEncoder* encoder) const 413 { 414 WebEvent::encode(encoder); 415 encoder->encode(m_touchPoints); 416 } 417 418 static bool decode(CoreIPC::ArgumentDecoder* decoder, WebTouchEvent& t) 419 { 420 if (!WebEvent::decode(decoder, t)) 421 return false; 422 423 if (!decoder->decode(t.m_touchPoints)) 424 return false; 425 426 return true; 427 } 428 429 private: 430 static bool isTouchEventType(Type type) 431 { 432 return type == TouchStart || type == TouchMove || type == TouchEnd; 433 } 434 435 Type m_type; 436 Vector<WebPlatformTouchPoint> m_touchPoints; 437 bool m_ctrlKey; 438 bool m_altKey; 439 bool m_shiftKey; 440 bool m_metaKey; 441 double m_timestamp; 442 }; 443 #endif 444 330 445 } // namespace WebKit 331 446 -
trunk/WebKit2/Shared/WebEventConversion.cpp
r57308 r65788 152 152 } 153 153 154 #if ENABLE(TOUCH_EVENTS) 155 class WebKit2PlatformTouchPoint : public WebCore::PlatformTouchPoint { 156 public: 157 WebKit2PlatformTouchPoint(const WebPlatformTouchPoint& webTouchPoint) 158 { 159 m_id = webTouchPoint.id(); 160 161 switch (webTouchPoint.state()) { 162 case WebPlatformTouchPoint::TouchReleased: 163 m_state = PlatformTouchPoint::TouchReleased; 164 break; 165 case WebPlatformTouchPoint::TouchPressed: 166 m_state = PlatformTouchPoint::TouchPressed; 167 break; 168 case WebPlatformTouchPoint::TouchMoved: 169 m_state = PlatformTouchPoint::TouchMoved; 170 break; 171 case WebPlatformTouchPoint::TouchStationary: 172 m_state = PlatformTouchPoint::TouchStationary; 173 break; 174 default: 175 ASSERT_NOT_REACHED(); 176 } 177 178 WebCore::IntPoint screen(webTouchPoint.screenPosX(), webTouchPoint.screenPosY()); 179 WebCore::IntPoint position(webTouchPoint.posX(), webTouchPoint.posY()); 180 181 m_screenPos = screen; 182 m_pos = position; 183 } 184 }; 185 186 class WebKit2PlatformTouchEvent : public WebCore::PlatformTouchEvent { 187 public: 188 WebKit2PlatformTouchEvent(const WebTouchEvent& webEvent) 189 { 190 switch (webEvent.type()) { 191 case WebEvent::TouchStart: 192 m_type = WebCore::TouchStart; 193 break; 194 case WebEvent::TouchMove: 195 m_type = WebCore::TouchMove; 196 break; 197 case WebEvent::TouchEnd: 198 m_type = WebCore::TouchEnd; 199 break; 200 default: 201 ASSERT_NOT_REACHED(); 202 } 203 204 for (int i = 0; i < webEvent.touchPoints().size(); ++i) 205 m_touchPoints.append(WebKit2PlatformTouchPoint(webEvent.touchPoints().at(i))); 206 207 m_ctrlKey = webEvent.controlKey(); 208 m_altKey = webEvent.altKey(); 209 m_shiftKey = webEvent.shiftKey(); 210 m_metaKey = webEvent.metaKey(); 211 } 212 }; 213 214 WebCore::PlatformTouchEvent platform(const WebTouchEvent& webEvent) 215 { 216 return WebKit2PlatformTouchEvent(webEvent); 217 } 218 #endif 219 154 220 } // namespace WebKit -
trunk/WebKit2/Shared/WebEventConversion.h
r57308 r65788 30 30 #include <WebCore/PlatformMouseEvent.h> 31 31 #include <WebCore/PlatformWheelEvent.h> 32 #if ENABLE(TOUCH_EVENTS) 33 #include <WebCore/PlatformTouchEvent.h> 34 #include <WebCore/PlatformTouchPoint.h> 35 #endif 32 36 33 37 namespace WebKit { … … 36 40 class WebWheelEvent; 37 41 class WebKeyboardEvent; 38 42 #if ENABLE(TOUCH_EVENTS) 43 class WebTouchEvent; 44 class WebTouchPoint; 45 #endif 39 46 WebCore::PlatformMouseEvent platform(const WebMouseEvent&); 40 47 WebCore::PlatformWheelEvent platform(const WebWheelEvent&); 41 48 WebCore::PlatformKeyboardEvent platform(const WebKeyboardEvent&); 42 49 #if ENABLE(TOUCH_EVENTS) 50 WebCore::PlatformTouchEvent platform(const WebTouchEvent&); 51 WebCore::PlatformTouchPoint platform(const WebTouchPoint&); 52 #endif 43 53 } // namespace WebKit 44 54 -
trunk/WebKit2/Shared/qt/WebEventFactoryQt.cpp
r64127 r65788 26 26 27 27 #include "WebEventFactoryQt.h" 28 29 28 #include <qgraphicssceneevent.h> 30 29 #include <QApplication> … … 65 64 case QEvent::KeyRelease: 66 65 return WebEvent::KeyUp; 66 #if ENABLE(TOUCH_EVENTS) 67 case QEvent::TouchBegin: 68 return WebEvent::TouchStart; 69 case QEvent::TouchUpdate: 70 return WebEvent::TouchMove; 71 case QEvent::TouchEnd: 72 return WebEvent::TouchEnd; 73 #endif 67 74 default: 68 75 // assert … … 162 169 } 163 170 171 #if ENABLE(TOUCH_EVENTS) 172 173 WebTouchEvent WebEventFactory::createWebTouchEvent(QTouchEvent* event) 174 { 175 WebEvent::Type type = webEventTypeForEvent(event); 176 WebPlatformTouchPoint::TouchPointState state; 177 unsigned int id; 178 WebEvent::Modifiers modifiers = modifiersForEvent(event->modifiers()); 179 double timestamp = WTF::currentTime(); 180 181 const QList<QTouchEvent::TouchPoint>& points = event->touchPoints(); 182 183 Vector<WebPlatformTouchPoint> m_touchPoints; 184 for (int i = 0; i < points.count(); ++i) { 185 id = static_cast<unsigned>(points.at(i).id()); 186 switch (points.at(i).state()) { 187 case Qt::TouchPointReleased: 188 state = WebPlatformTouchPoint::TouchReleased; 189 break; 190 case Qt::TouchPointMoved: 191 state = WebPlatformTouchPoint::TouchMoved; 192 break; 193 case Qt::TouchPointPressed: 194 state = WebPlatformTouchPoint::TouchPressed; 195 break; 196 case Qt::TouchPointStationary: 197 state = WebPlatformTouchPoint::TouchStationary; 198 break; 199 } 200 201 m_touchPoints.append(WebPlatformTouchPoint(id, state, points.at(i).screenPos().toPoint().x(), 202 points.at(i).screenPos().toPoint().y(), 203 points.at(i).pos().toPoint().x(), 204 points.at(i).pos().toPoint().y())); 205 } 206 207 bool m_ctrlKey = (event->modifiers() & Qt::ControlModifier); 208 bool m_altKey = (event->modifiers() & Qt::AltModifier); 209 bool m_shiftKey = (event->modifiers() & Qt::ShiftModifier); 210 bool m_metaKey = (event->modifiers() & Qt::MetaModifier); 211 212 return WebTouchEvent(type, m_touchPoints, m_ctrlKey, m_altKey, m_shiftKey, m_metaKey, modifiers, timestamp); 213 } 214 #endif 215 164 216 } // namespace WebKit -
trunk/WebKit2/Shared/qt/WebEventFactoryQt.h
r62263 r65788 30 30 #include "WebEvent.h" 31 31 32 #if ENABLE(TOUCH_EVENTS) 33 class QTouchEvent; 34 #endif 35 32 36 class QGraphicsSceneMouseEvent; 33 37 class QGraphicsSceneWheelEvent; … … 41 45 static WebWheelEvent createWebWheelEvent(QGraphicsSceneWheelEvent* event); 42 46 static WebKeyboardEvent createWebKeyboardEvent(QKeyEvent* event); 47 #if ENABLE(TOUCH_EVENTS) 48 static WebTouchEvent createWebTouchEvent(QTouchEvent* event); 49 #endif 43 50 }; 44 51 -
trunk/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp
r65751 r65788 156 156 bool QGraphicsWKView::event(QEvent* event) 157 157 { 158 #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) 159 if (event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchUpdate) { 160 touchEvent(static_cast<QTouchEvent*>(event)); 161 return true; 162 } 163 #endif 164 158 165 // Here so that it can be reimplemented without breaking ABI. 159 166 return QGraphicsWidget::event(event); … … 237 244 QGraphicsItem::wheelEvent(ev); 238 245 } 246 247 #if ENABLE(TOUCH_EVENTS) 248 void QGraphicsWKView::touchEvent(QTouchEvent* ev) 249 { 250 page()->d->touchEvent(ev); 251 } 252 #endif 239 253 240 254 QGraphicsWKViewPrivate::QGraphicsWKViewPrivate(QGraphicsWKView* view) -
trunk/WebKit2/UIProcess/API/qt/qgraphicswkview.h
r65751 r65788 71 71 virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*); 72 72 virtual void wheelEvent(QGraphicsSceneWheelEvent*); 73 virtual void touchEvent(QTouchEvent*); 73 74 74 75 virtual void hoverMoveEvent(QGraphicsSceneHoverEvent*); -
trunk/WebKit2/UIProcess/API/qt/qwkpage.cpp
r65751 r65788 35 35 #include <WebKit2/WKRetainPtr.h> 36 36 37 #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) 38 #include <QTouchEvent> 39 #endif 40 37 41 using namespace WebKit; 38 42 using namespace WebCore; … … 201 205 } 202 206 #endif // QT_NO_ACTION 207 208 #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) 209 210 void QWKPagePrivate::touchEvent(QTouchEvent* event) 211 { 212 WebTouchEvent touchEvent = WebEventFactory::createWebTouchEvent(event); 213 page->touchEvent(touchEvent); 214 } 215 216 #endif 203 217 204 218 QWKPage::QWKPage(WKPageNamespaceRef namespaceRef) -
trunk/WebKit2/UIProcess/API/qt/qwkpage_p.h
r65751 r65788 68 68 void _q_webActionTriggered(bool checked); 69 69 70 #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) 71 void touchEvent(QTouchEvent*); 72 #endif 73 70 74 QAction* actions[QWKPage::WebActionCount]; 71 75 -
trunk/WebKit2/UIProcess/WebPageProxy.cpp
r65699 r65788 333 333 } 334 334 335 #if ENABLE(TOUCH_EVENTS) 336 void WebPageProxy::touchEvent(const WebTouchEvent& event) 337 { 338 if (!isValid()) 339 return; 340 process()->send(WebPageMessage::TouchEvent, m_pageID, CoreIPC::In(event)); 341 } 342 #endif 343 335 344 void WebPageProxy::receivedPolicyDecision(WebCore::PolicyAction action, WebFrameProxy* frame, uint64_t listenerID) 336 345 { -
trunk/WebKit2/UIProcess/WebPageProxy.h
r65699 r65788 127 127 void wheelEvent(const WebWheelEvent&); 128 128 void keyEvent(const WebKeyboardEvent&); 129 #if ENABLE(TOUCH_EVENTS) 130 void touchEvent(const WebTouchEvent&); 131 #endif 129 132 130 133 const WTF::String& pageTitle() const { return m_pageTitle; } -
trunk/WebKit2/WebProcess/WebPage/WebPage.cpp
r65644 r65788 420 420 } 421 421 422 #if ENABLE(TOUCH_EVENTS) 423 void WebPage::touchEvent(const WebTouchEvent& touchEvent) 424 { 425 CurrentEvent currentEvent(touchEvent); 426 WebProcess::shared().connection()->send(WebPageProxyMessage::DidReceiveEvent, m_pageID, CoreIPC::In(static_cast<uint32_t>(touchEvent.type()))); 427 428 if (!m_mainFrame->coreFrame()->view()) 429 return; 430 431 PlatformTouchEvent platformTouchEvent = platform(touchEvent); 432 m_mainFrame->coreFrame()->eventHandler()->handleTouchEvent(platformTouchEvent); 433 } 434 #endif 435 422 436 void WebPage::setActive(bool isActive) 423 437 { … … 589 603 return; 590 604 } 605 #if ENABLE(TOUCH_EVENTS) 606 case WebPageMessage::TouchEvent: { 607 WebTouchEvent event; 608 if (!arguments->decode(event)) 609 return; 610 touchEvent(event); 611 } 612 #endif 591 613 case WebPageMessage::LoadURL: { 592 614 String url; -
trunk/WebKit2/WebProcess/WebPage/WebPage.h
r65644 r65788 41 41 #include <wtf/RefPtr.h> 42 42 #include <wtf/text/WTFString.h> 43 #if ENABLE(TOUCH_EVENTS) 44 #include <WebCore/PlatformTouchEvent.h> 45 #endif 43 46 44 47 namespace CoreIPC { … … 62 65 class WebMouseEvent; 63 66 class WebWheelEvent; 67 #if ENABLE(TOUCH_EVENTS) 68 class WebTouchEvent; 69 #endif 64 70 struct WebPreferencesStore; 65 71 … … 153 159 void wheelEvent(const WebWheelEvent&); 154 160 void keyEvent(const WebKeyboardEvent&); 161 #if ENABLE(TOUCH_EVENTS) 162 void touchEvent(const WebTouchEvent&); 163 #endif 155 164 void runJavaScriptInMainFrame(const WTF::String&, uint64_t callbackID); 156 165 void getRenderTreeExternalRepresentation(uint64_t callbackID);
Note: See TracChangeset
for help on using the changeset viewer.