[Qt][WK2] Remove direct references to WebPageProxy from QQuickWebPage.
authormichael.bruning@digia.com <michael.bruning@digia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Apr 2013 11:53:26 +0000 (11:53 +0000)
committermichael.bruning@digia.com <michael.bruning@digia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Apr 2013 11:53:26 +0000 (11:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=112850

Reviewed by Andreas Kling.

Removes direct references to WebPageProxy from QQuickWebPage and prepares the
class for the move to QRawWebView. The access to the device scale factor and
CoordinatedGraphicsScene is provided through QQuickWebViewPrivate, and therefore
accessors to these properties are temporarily added. Eventually, this access will
be provided through QRawWebView when the move is complete.

This also moves the pointer to QtWebPageEventHandler from QQuickWebPagePrivate
to QQuickWebViewPrivate as it is mainly used from there.

* UIProcess/API/qt/qquickwebpage.cpp:
(QQuickWebPagePrivate::QQuickWebPagePrivate):
(QQuickWebPagePrivate::paint):
(QQuickWebPage::updatePaintNode):
* UIProcess/API/qt/qquickwebpage_p.h:
* UIProcess/API/qt/qquickwebpage_p_p.h:
(QQuickWebPagePrivate):
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::initialize):
(QQuickWebViewPrivate::handleMouseEvent):
(QQuickWebViewPrivate::processDidCrash):
(QQuickWebViewPrivate::coordinatedGraphicsScene):
(QQuickWebViewPrivate::deviceScaleFactor):
(QQuickWebViewPrivate::setIntrinsicDeviceScaleFactor):
(QQuickWebViewFlickablePrivate::onComponentComplete):
(QQuickWebView::keyPressEvent):
(QQuickWebView::keyReleaseEvent):
(QQuickWebView::inputMethodEvent):
(QQuickWebView::focusInEvent):
(QQuickWebView::itemChange):
(QQuickWebView::touchEvent):
(QQuickWebView::wheelEvent):
(QQuickWebView::hoverEnterEvent):
(QQuickWebView::hoverMoveEvent):
(QQuickWebView::hoverLeaveEvent):
(QQuickWebView::dragMoveEvent):
(QQuickWebView::dragEnterEvent):
(QQuickWebView::dragLeaveEvent):
(QQuickWebView::dropEvent):
* UIProcess/API/qt/qquickwebview_p_p.h:
(WebCore):
(WebKit):
(QQuickWebViewPrivate):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@148011 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h
Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h
Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h

index 0eaefa5..74a4488 100644 (file)
@@ -1,5 +1,55 @@
 2013-04-09  Michael BrĂ¼ning  <michael.bruning@digia.com>
 
+        [Qt][WK2] Remove direct references to WebPageProxy from QQuickWebPage.
+        https://bugs.webkit.org/show_bug.cgi?id=112850
+
+        Reviewed by Andreas Kling.
+
+        Removes direct references to WebPageProxy from QQuickWebPage and prepares the
+        class for the move to QRawWebView. The access to the device scale factor and
+        CoordinatedGraphicsScene is provided through QQuickWebViewPrivate, and therefore
+        accessors to these properties are temporarily added. Eventually, this access will
+        be provided through QRawWebView when the move is complete.
+
+        This also moves the pointer to QtWebPageEventHandler from QQuickWebPagePrivate
+        to QQuickWebViewPrivate as it is mainly used from there.
+
+        * UIProcess/API/qt/qquickwebpage.cpp:
+        (QQuickWebPagePrivate::QQuickWebPagePrivate):
+        (QQuickWebPagePrivate::paint):
+        (QQuickWebPage::updatePaintNode):
+        * UIProcess/API/qt/qquickwebpage_p.h:
+        * UIProcess/API/qt/qquickwebpage_p_p.h:
+        (QQuickWebPagePrivate):
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewPrivate::initialize):
+        (QQuickWebViewPrivate::handleMouseEvent):
+        (QQuickWebViewPrivate::processDidCrash):
+        (QQuickWebViewPrivate::coordinatedGraphicsScene):
+        (QQuickWebViewPrivate::deviceScaleFactor):
+        (QQuickWebViewPrivate::setIntrinsicDeviceScaleFactor):
+        (QQuickWebViewFlickablePrivate::onComponentComplete):
+        (QQuickWebView::keyPressEvent):
+        (QQuickWebView::keyReleaseEvent):
+        (QQuickWebView::inputMethodEvent):
+        (QQuickWebView::focusInEvent):
+        (QQuickWebView::itemChange):
+        (QQuickWebView::touchEvent):
+        (QQuickWebView::wheelEvent):
+        (QQuickWebView::hoverEnterEvent):
+        (QQuickWebView::hoverMoveEvent):
+        (QQuickWebView::hoverLeaveEvent):
+        (QQuickWebView::dragMoveEvent):
+        (QQuickWebView::dragEnterEvent):
+        (QQuickWebView::dragLeaveEvent):
+        (QQuickWebView::dropEvent):
+        * UIProcess/API/qt/qquickwebview_p_p.h:
+        (WebCore):
+        (WebKit):
+        (QQuickWebViewPrivate):
+
+2013-04-09  Michael BrĂ¼ning  <michael.bruning@digia.com>
+
         [Qt][WK2] Use C API to enable Navigator Qt Object.
         https://bugs.webkit.org/show_bug.cgi?id=112810
 
index 4f196e1..02dd604 100644 (file)
 #include "config.h"
 #include "qquickwebpage_p.h"
 
-#include "CoordinatedLayerTreeHostProxy.h"
 #include "QtWebPageEventHandler.h"
 #include "QtWebPageSGNode.h"
 #include "TransformationMatrix.h"
-#include "WebPageProxy.h"
 #include "qquickwebpage_p_p.h"
 #include "qquickwebview_p.h"
+#include "qquickwebview_p_p.h"
 #include "qwebkittest_p.h"
 #include <QQuickWindow>
 #include <WebCore/CoordinatedGraphicsScene.h>
@@ -54,49 +53,33 @@ QQuickWebPage::~QQuickWebPage()
 QQuickWebPagePrivate::QQuickWebPagePrivate(QQuickWebPage* q, QQuickWebView* viewportItem)
     : q(q)
     , viewportItem(viewportItem)
-    , webPageProxy(0)
     , paintingIsInitialized(false)
     , contentsScale(1)
 {
 }
 
-void QQuickWebPagePrivate::initialize(WebKit::WebPageProxy* webPageProxy)
-{
-    this->webPageProxy = webPageProxy;
-    eventHandler.reset(new QtWebPageEventHandler(toAPI(webPageProxy), q, viewportItem));
-}
-
 void QQuickWebPagePrivate::paint(QPainter* painter)
 {
-    if (!webPageProxy->drawingArea())
-        return;
-
-    if (coordinatedLayerTreeHostProxy()->coordinatedGraphicsScene())
-        coordinatedLayerTreeHostProxy()->coordinatedGraphicsScene()->paintToGraphicsContext(painter);
+    if (WebCore::CoordinatedGraphicsScene* scene = QQuickWebViewPrivate::get(viewportItem)->coordinatedGraphicsScene())
+        scene->paintToGraphicsContext(painter);
 }
 
-CoordinatedLayerTreeHostProxy* QQuickWebPagePrivate::coordinatedLayerTreeHostProxy()
-{
-    if (webPageProxy->drawingArea())
-        return webPageProxy->drawingArea()->coordinatedLayerTreeHostProxy();
-
-    return 0;
-}
 
 QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*)
 {
-    if (!d->webPageProxy->drawingArea())
-        return oldNode;
+    QQuickWebViewPrivate* webViewPrivate = QQuickWebViewPrivate::get(d->viewportItem);
 
-    WebCore::CoordinatedGraphicsScene* scene = d->coordinatedLayerTreeHostProxy()->coordinatedGraphicsScene();
+    WebCore::CoordinatedGraphicsScene* scene = webViewPrivate->coordinatedGraphicsScene();
+    if (!scene)
+        return oldNode;
 
     QtWebPageSGNode* node = static_cast<QtWebPageSGNode*>(oldNode);
 
     const QWindow* window = this->window();
     ASSERT(window);
 
-    if (window && d->webPageProxy->deviceScaleFactor() != window->devicePixelRatio()) {
-        d->webPageProxy->setIntrinsicDeviceScaleFactor(window->devicePixelRatio());
+    if (window && webViewPrivate->deviceScaleFactor() != window->devicePixelRatio()) {
+        webViewPrivate->setIntrinsicDeviceScaleFactor(window->devicePixelRatio());
         // This signal is queued since if we are running a threaded renderer. This might cause failures
         // if tests are reading the new value between the property change and the signal emission.
         emit d->viewportItem->experimental()->test()->devicePixelRatioChanged();
@@ -109,18 +92,13 @@ QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*)
 
     node->setScale(d->contentsScale);
     node->setDevicePixelRatio(window->devicePixelRatio());
-    QColor backgroundColor = d->webPageProxy->drawsTransparentBackground() ? Qt::transparent : Qt::white;
+    QColor backgroundColor = webViewPrivate->transparentBackground() ? Qt::transparent : Qt::white;
     QRectF backgroundRect(QPointF(0, 0), d->contentsSize);
     node->setBackground(backgroundRect, backgroundColor);
 
     return node;
 }
 
-QtWebPageEventHandler* QQuickWebPage::eventHandler() const
-{
-    return d->eventHandler.data();
-}
-
 void QQuickWebPage::setContentsSize(const QSizeF& size)
 {
     if (size.isEmpty() || d->contentsSize == size)
index 3a112d6..e2aaa6c 100644 (file)
 
 class QQuickWebPagePrivate;
 class QQuickWebView;
-class QWebPreferences;
-
-namespace WebKit {
-class QtWebPageEventHandler;
-}
 
 class QWEBKIT_EXPORT QQuickWebPage : public QQuickItem {
     Q_OBJECT
@@ -48,8 +43,6 @@ public:
     QTransform transformFromItem() const;
     QTransform transformToItem() const;
 
-    WebKit::QtWebPageEventHandler* eventHandler() const;
-
 protected:
     virtual QSGNode* updatePaintNode(QSGNode*, UpdatePaintNodeData*);
 
index 70c4e7a..9a04b3f 100644 (file)
 #include "qquickwebpage_p.h"
 #include <QTransform>
 
-namespace WebKit {
-class WebPageProxy;
-class QtWebPageEventHandler;
-class CoordinatedLayerTreeHostProxy;
-}
+class QQuickWebViewPrivate;
 
 class QQuickWebPagePrivate {
 public:
     QQuickWebPagePrivate(QQuickWebPage* q, QQuickWebView* viewportItem);
     ~QQuickWebPagePrivate();
 
-    void initialize(WebKit::WebPageProxy*);
-
     void updateSize();
 
     void paint(QPainter*);
     void resetPaintNode();
-    WebKit::CoordinatedLayerTreeHostProxy* coordinatedLayerTreeHostProxy();
-
-    QScopedPointer<WebKit::QtWebPageEventHandler> eventHandler;
     QQuickWebPage* const q;
     QQuickWebView* const viewportItem;
-    WebKit::WebPageProxy* webPageProxy;
     bool paintingIsInitialized;
 
     QSizeF contentsSize;
index f72f8d6..8ff90c9 100644 (file)
@@ -23,6 +23,7 @@
 #include "config.h"
 #include "qquickwebview_p.h"
 
+#include "CoordinatedLayerTreeHostProxy.h"
 #include "DownloadProxy.h"
 #include "DrawingAreaProxyImpl.h"
 #include "PageViewportControllerClientQt.h"
@@ -74,6 +75,7 @@
 #include <WKString.h>
 #include <WKStringQt.h>
 #include <WKURLQt.h>
+#include <WebCore/CoordinatedGraphicsScene.h>
 #include <WebCore/IntPoint.h>
 #include <WebCore/IntRect.h>
 #include <limits>
@@ -333,8 +335,7 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa
     webPageProxy->fullScreenManager()->setWebView(q_ptr);
 #endif
 
-    QQuickWebPagePrivate* const pageViewPrivate = pageView.data()->d;
-    pageViewPrivate->initialize(webPageProxy.get());
+    pageEventHandler.reset(new QtWebPageEventHandler(webPage.get(), pageView.data(), q_ptr));
 
     {
         WKPageFindClient findClient;
@@ -383,7 +384,7 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa
     WKPreferencesSetWebGLEnabled(preferencesRef, true);
     webPageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
 
-    pageClient.initialize(q_ptr, pageViewPrivate->eventHandler.data(), &undoController);
+    pageClient.initialize(q_ptr, pageEventHandler.data(), &undoController);
     webPageProxy->initializeWebPage();
     webPageProxy->registerApplicationScheme(ASCIILiteral("qrc"));
 
@@ -539,13 +540,13 @@ void QQuickWebViewPrivate::handleMouseEvent(QMouseEvent* event)
 {
     switch (event->type()) {
     case QEvent::MouseButtonPress:
-        pageView->eventHandler()->handleMousePressEvent(event);
+        pageEventHandler->handleMousePressEvent(event);
         break;
     case QEvent::MouseMove:
-        pageView->eventHandler()->handleMouseMoveEvent(event);
+        pageEventHandler->handleMouseMoveEvent(event);
         break;
     case QEvent::MouseButtonRelease:
-        pageView->eventHandler()->handleMouseReleaseEvent(event);
+        pageEventHandler->handleMouseReleaseEvent(event);
         break;
     case QEvent::MouseButtonDblClick:
         // If a MouseButtonDblClick was received then we got a MouseButtonPress before.
@@ -588,7 +589,7 @@ void QQuickWebViewPrivate::processDidCrash()
     QUrl url(KURL(WebCore::ParsedURLString, webPageProxy->urlAtProcessExit()));
     qWarning("WARNING: The web process experienced a crash on '%s'.", qPrintable(url.toString(QUrl::RemoveUserInfo)));
 
-    pageView->eventHandler()->resetGestureRecognizers();
+    pageEventHandler->resetGestureRecognizers();
 
     // Check if loading was ongoing, when process crashed.
     if (m_loadProgress > 0 && m_loadProgress < 100) {
@@ -936,6 +937,24 @@ void QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtObject(WKStringRef me
     emit q_ptr->experimental()->messageReceived(variantMap);
 }
 
+CoordinatedGraphicsScene* QQuickWebViewPrivate::coordinatedGraphicsScene()
+{
+    if (webPageProxy && webPageProxy->drawingArea() && webPageProxy->drawingArea()->coordinatedLayerTreeHostProxy())
+        return webPageProxy->drawingArea()->coordinatedLayerTreeHostProxy()->coordinatedGraphicsScene();
+
+    return 0;
+}
+
+float QQuickWebViewPrivate::deviceScaleFactor()
+{
+    return webPageProxy->deviceScaleFactor();
+}
+
+void QQuickWebViewPrivate::setIntrinsicDeviceScaleFactor(float scaleFactor)
+{
+    webPageProxy->setIntrinsicDeviceScaleFactor(scaleFactor);
+}
+
 QQuickWebViewLegacyPrivate::QQuickWebViewLegacyPrivate(QQuickWebView* viewport)
     : QQuickWebViewPrivate(viewport)
 {
@@ -996,7 +1015,7 @@ void QQuickWebViewFlickablePrivate::onComponentComplete()
     Q_Q(QQuickWebView);
     m_pageViewportControllerClient.reset(new PageViewportControllerClientQt(q, pageView.data()));
     m_pageViewportController.reset(new PageViewportController(webPageProxy.get(), m_pageViewportControllerClient.data()));
-    pageView->eventHandler()->setViewportController(m_pageViewportControllerClient.data());
+    pageEventHandler->setViewportController(m_pageViewportControllerClient.data());
 
     // Trigger setting of correct visibility flags after everything was allocated and initialized.
     _q_onVisibleChanged();
@@ -1943,25 +1962,25 @@ void QQuickWebView::componentComplete()
 void QQuickWebView::keyPressEvent(QKeyEvent* event)
 {
     Q_D(QQuickWebView);
-    d->pageView->eventHandler()->handleKeyPressEvent(event);
+    d->pageEventHandler->handleKeyPressEvent(event);
 }
 
 void QQuickWebView::keyReleaseEvent(QKeyEvent* event)
 {
     Q_D(QQuickWebView);
-    d->pageView->eventHandler()->handleKeyReleaseEvent(event);
+    d->pageEventHandler->handleKeyReleaseEvent(event);
 }
 
 void QQuickWebView::inputMethodEvent(QInputMethodEvent* event)
 {
     Q_D(QQuickWebView);
-    d->pageView->eventHandler()->handleInputMethodEvent(event);
+    d->pageEventHandler->handleInputMethodEvent(event);
 }
 
 void QQuickWebView::focusInEvent(QFocusEvent* event)
 {
     Q_D(QQuickWebView);
-    d->pageView->eventHandler()->handleFocusInEvent(event);
+    d->pageEventHandler->handleFocusInEvent(event);
 }
 
 void QQuickWebView::itemChange(ItemChange change, const ItemChangeData &value)
@@ -1970,7 +1989,7 @@ void QQuickWebView::itemChange(ItemChange change, const ItemChangeData &value)
     if (change == ItemActiveFocusHasChanged) {
         bool focus = value.boolValue;
         if (!focus)
-            d->pageView->eventHandler()->handleFocusLost();
+            d->pageEventHandler->handleFocusLost();
     }
     QQuickFlickable::itemChange(change, value);
 }
@@ -1990,7 +2009,7 @@ void QQuickWebView::touchEvent(QTouchEvent* event)
         d->axisLocker.reset();
 
     forceActiveFocus();
-    d->pageView->eventHandler()->handleTouchEvent(event);
+    d->pageEventHandler->handleTouchEvent(event);
 }
 
 void QQuickWebView::mousePressEvent(QMouseEvent* event)
@@ -2022,50 +2041,50 @@ void QQuickWebView::mouseDoubleClickEvent(QMouseEvent* event)
 void QQuickWebView::wheelEvent(QWheelEvent* event)
 {
     Q_D(QQuickWebView);
-    d->pageView->eventHandler()->handleWheelEvent(event);
+    d->pageEventHandler->handleWheelEvent(event);
 }
 
 void QQuickWebView::hoverEnterEvent(QHoverEvent* event)
 {
     Q_D(QQuickWebView);
     // Map HoverEnter to Move, for WebKit the distinction doesn't matter.
-    d->pageView->eventHandler()->handleHoverMoveEvent(event);
+    d->pageEventHandler->handleHoverMoveEvent(event);
 }
 
 void QQuickWebView::hoverMoveEvent(QHoverEvent* event)
 {
     Q_D(QQuickWebView);
-    d->pageView->eventHandler()->handleHoverMoveEvent(event);
+    d->pageEventHandler->handleHoverMoveEvent(event);
 }
 
 void QQuickWebView::hoverLeaveEvent(QHoverEvent* event)
 {
     Q_D(QQuickWebView);
-    d->pageView->eventHandler()->handleHoverLeaveEvent(event);
+    d->pageEventHandler->handleHoverLeaveEvent(event);
 }
 
 void QQuickWebView::dragMoveEvent(QDragMoveEvent* event)
 {
     Q_D(QQuickWebView);
-    d->pageView->eventHandler()->handleDragMoveEvent(event);
+    d->pageEventHandler->handleDragMoveEvent(event);
 }
 
 void QQuickWebView::dragEnterEvent(QDragEnterEvent* event)
 {
     Q_D(QQuickWebView);
-    d->pageView->eventHandler()->handleDragEnterEvent(event);
+    d->pageEventHandler->handleDragEnterEvent(event);
 }
 
 void QQuickWebView::dragLeaveEvent(QDragLeaveEvent* event)
 {
     Q_D(QQuickWebView);
-    d->pageView->eventHandler()->handleDragLeaveEvent(event);
+    d->pageEventHandler->handleDragLeaveEvent(event);
 }
 
 void QQuickWebView::dropEvent(QDropEvent* event)
 {
     Q_D(QQuickWebView);
-    d->pageView->eventHandler()->handleDropEvent(event);
+    d->pageEventHandler->handleDropEvent(event);
 }
 
 bool QQuickWebView::event(QEvent* ev)
index 94936e8..434f411 100644 (file)
 #include <wtf/OwnPtr.h>
 #include <wtf/RefPtr.h>
 
+namespace WebCore {
+class CoordinatedGraphicsScene;
+}
+
 namespace WebKit {
 class DownloadProxy;
 class DrawingAreaProxy;
@@ -44,6 +48,7 @@ class QtDialogRunner;
 class PageViewportControllerClientQt;
 class QtWebContext;
 class QtWebError;
+class QtWebPageEventHandler;
 class QtWebPagePolicyClient;
 class WebPageProxy;
 }
@@ -133,6 +138,10 @@ public:
 
     void didReceiveMessageFromNavigatorQtObject(WKStringRef message);
 
+    WebCore::CoordinatedGraphicsScene* coordinatedGraphicsScene();
+    float deviceScaleFactor();
+    void setIntrinsicDeviceScaleFactor(float);
+
 protected:
     class FlickableAxisLocker {
         QQuickFlickable::FlickableDirection m_allowedDirection;
@@ -180,6 +189,7 @@ protected:
     QScopedPointer<WebKit::QtWebPageUIClient> pageUIClient;
 
     QScopedPointer<QQuickWebPage> pageView;
+    QScopedPointer<WebKit::QtWebPageEventHandler> pageEventHandler;
     QQuickWebView* q_ptr;
     QQuickWebViewExperimental* experimental;
     WebKit::QtWebContext* context;