[Qt][WK2] Split the QtWebPageProxy into PageClient and QtPageProxy
authorjesus@webkit.org <jesus@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Dec 2011 13:37:20 +0000 (13:37 +0000)
committerjesus@webkit.org <jesus@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Dec 2011 13:37:20 +0000 (13:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=66668

Reviewed by Simon Hausmann.

Split QtPageClient out of QtWebPageProxy.
This client will live in QQuickWebViewPrivate and communicate directly
with QtWebPageProxy and QtWebPageEventHandler. The functions that need
anything else than these entities will need to call the proper implementation
through QtWebPageProxy itself.
With this we have a clear separation between PageClient and PageProxy, having
two well defined and separated entities for hooking our clients with our API layer (QtWebPageProxy)
and for hooking the WebPageProxy with our client implementations (QtPageClient).
As a positive side-effect we have a cleaner QtWebPageProxy.

* Target.pri:
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::QQuickWebViewPrivate):
* UIProcess/API/qt/qquickwebview_p_p.h:
* UIProcess/qt/QtPageClient.cpp: Added.
(QtPageClient::QtPageClient):
(QtPageClient::~QtPageClient):
(QtPageClient::createDrawingAreaProxy):
(QtPageClient::setViewNeedsDisplay):
(QtPageClient::pageDidRequestScroll):
(QtPageClient::processDidCrash):
(QtPageClient::didRelaunchProcess):
(QtPageClient::didChangeContentsSize):
(QtPageClient::didChangeViewportProperties):
(QtPageClient::startDrag):
(QtPageClient::handleDownloadRequest):
(QtPageClient::setCursor):
(QtPageClient::setCursorHiddenUntilMouseMoves):
(QtPageClient::toolTipChanged):
(QtPageClient::registerEditCommand):
(QtPageClient::clearAllEditCommands):
(QtPageClient::canUndoRedo):
(QtPageClient::executeUndoRedo):
(QtPageClient::convertToDeviceSpace):
(QtPageClient::convertToUserSpace):
(QtPageClient::screenToWindow):
(QtPageClient::windowToScreen):
(QtPageClient::createPopupMenuProxy):
(QtPageClient::createContextMenuProxy):
(QtPageClient::flashBackingStoreUpdates):
(QtPageClient::didFindZoomableArea):
(QtPageClient::didReceiveMessageFromNavigatorQtObject):
(QtPageClient::doneWithTouchEvent):
(QtPageClient::displayView):
(QtPageClient::scrollView):
(QtPageClient::viewSize):
(QtPageClient::isViewWindowActive):
(QtPageClient::isViewFocused):
(QtPageClient::isViewVisible):
(QtPageClient::isViewInWindow):
(QtPageClient::enterAcceleratedCompositingMode):
(QtPageClient::exitAcceleratedCompositingMode):
* UIProcess/qt/QtPageClient.h: Added.
(QtPageClient::pageClosed):
(QtPageClient::doneWithKeyEvent):
(QtPageClient::setFindIndicator):
(QtPageClient::didCommitLoadForMainFrame):
(QtPageClient::didFinishLoadingDataForCustomRepresentation):
(QtPageClient::customRepresentationZoomFactor):
(QtPageClient::setCustomRepresentationZoomFactor):
(QtPageClient::didChangeScrollbarsForMainFrame):
(QtPageClient::findStringInCustomRepresentation):
(QtPageClient::countStringMatchesInCustomRepresentation):
(QtPageClient::setEventHandler):
(QtPageClient::setPageProxy):
* UIProcess/qt/QtWebPageProxy.cpp:
(QtWebPageProxy::QtWebPageProxy):
* UIProcess/qt/QtWebPageProxy.h:

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

Source/WebKit2/ChangeLog
Source/WebKit2/Target.pri
Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
Source/WebKit2/UIProcess/qt/QtPageClient.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/qt/QtPageClient.h [new file with mode: 0644]
Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp
Source/WebKit2/UIProcess/qt/QtWebPageProxy.h

index 494a79f..f0f5229 100644 (file)
@@ -1,3 +1,79 @@
+2011-12-02  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
+
+        [Qt][WK2] Split the QtWebPageProxy into PageClient and QtPageProxy
+        https://bugs.webkit.org/show_bug.cgi?id=66668
+
+        Reviewed by Simon Hausmann.
+
+        Split QtPageClient out of QtWebPageProxy.
+        This client will live in QQuickWebViewPrivate and communicate directly
+        with QtWebPageProxy and QtWebPageEventHandler. The functions that need
+        anything else than these entities will need to call the proper implementation
+        through QtWebPageProxy itself.
+        With this we have a clear separation between PageClient and PageProxy, having
+        two well defined and separated entities for hooking our clients with our API layer (QtWebPageProxy)
+        and for hooking the WebPageProxy with our client implementations (QtPageClient).
+        As a positive side-effect we have a cleaner QtWebPageProxy.
+
+        * Target.pri:
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewPrivate::QQuickWebViewPrivate):
+        * UIProcess/API/qt/qquickwebview_p_p.h:
+        * UIProcess/qt/QtPageClient.cpp: Added.
+        (QtPageClient::QtPageClient):
+        (QtPageClient::~QtPageClient):
+        (QtPageClient::createDrawingAreaProxy):
+        (QtPageClient::setViewNeedsDisplay):
+        (QtPageClient::pageDidRequestScroll):
+        (QtPageClient::processDidCrash):
+        (QtPageClient::didRelaunchProcess):
+        (QtPageClient::didChangeContentsSize):
+        (QtPageClient::didChangeViewportProperties):
+        (QtPageClient::startDrag):
+        (QtPageClient::handleDownloadRequest):
+        (QtPageClient::setCursor):
+        (QtPageClient::setCursorHiddenUntilMouseMoves):
+        (QtPageClient::toolTipChanged):
+        (QtPageClient::registerEditCommand):
+        (QtPageClient::clearAllEditCommands):
+        (QtPageClient::canUndoRedo):
+        (QtPageClient::executeUndoRedo):
+        (QtPageClient::convertToDeviceSpace):
+        (QtPageClient::convertToUserSpace):
+        (QtPageClient::screenToWindow):
+        (QtPageClient::windowToScreen):
+        (QtPageClient::createPopupMenuProxy):
+        (QtPageClient::createContextMenuProxy):
+        (QtPageClient::flashBackingStoreUpdates):
+        (QtPageClient::didFindZoomableArea):
+        (QtPageClient::didReceiveMessageFromNavigatorQtObject):
+        (QtPageClient::doneWithTouchEvent):
+        (QtPageClient::displayView):
+        (QtPageClient::scrollView):
+        (QtPageClient::viewSize):
+        (QtPageClient::isViewWindowActive):
+        (QtPageClient::isViewFocused):
+        (QtPageClient::isViewVisible):
+        (QtPageClient::isViewInWindow):
+        (QtPageClient::enterAcceleratedCompositingMode):
+        (QtPageClient::exitAcceleratedCompositingMode):
+        * UIProcess/qt/QtPageClient.h: Added.
+        (QtPageClient::pageClosed):
+        (QtPageClient::doneWithKeyEvent):
+        (QtPageClient::setFindIndicator):
+        (QtPageClient::didCommitLoadForMainFrame):
+        (QtPageClient::didFinishLoadingDataForCustomRepresentation):
+        (QtPageClient::customRepresentationZoomFactor):
+        (QtPageClient::setCustomRepresentationZoomFactor):
+        (QtPageClient::didChangeScrollbarsForMainFrame):
+        (QtPageClient::findStringInCustomRepresentation):
+        (QtPageClient::countStringMatchesInCustomRepresentation):
+        (QtPageClient::setEventHandler):
+        (QtPageClient::setPageProxy):
+        * UIProcess/qt/QtWebPageProxy.cpp:
+        (QtWebPageProxy::QtWebPageProxy):
+        * UIProcess/qt/QtWebPageProxy.h:
+
 2011-12-02  Kenneth Rohde Christiansen  <kenneth@webkit.org>
 
         [Qt] Do not apply the transition state before we are unsuspended
index 4b7fce9..1b63a27 100644 (file)
@@ -252,6 +252,7 @@ HEADERS += \
     UIProcess/qt/QtWebError.h \
     UIProcess/qt/QtDialogRunner.h \
     UIProcess/qt/QtDownloadManager.h \
+    UIProcess/qt/QtPageClient.h \
     UIProcess/qt/QtWebPageLoadClient.h \
     UIProcess/qt/QtWebPagePolicyClient.h \
     UIProcess/qt/QtWebPageProxy.h \
@@ -564,6 +565,7 @@ SOURCES += \
     UIProcess/qt/QtWebError.cpp \
     UIProcess/qt/QtDialogRunner.cpp \
     UIProcess/qt/QtDownloadManager.cpp \
+    UIProcess/qt/QtPageClient.cpp \
     UIProcess/qt/QtWebPageLoadClient.cpp \
     UIProcess/qt/QtWebPagePolicyClient.cpp \
     UIProcess/qt/QtWebPageProxy.cpp \
index 76ea29e..3a0f9de 100644 (file)
@@ -50,8 +50,10 @@ QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport, WKContextRef
     QObject::connect(viewport, SIGNAL(visibleChanged()), viewport, SLOT(_q_onVisibleChanged()));
     pageView.reset(new QQuickWebPage(viewport));
 
+    pageClient.reset(new QtPageClient());
+
     QQuickWebPagePrivate* const pageViewPrivate = pageView.data()->d;
-    setPageProxy(new QtWebPageProxy(pageView.data(), q_ptr, contextRef, pageGroupRef));
+    setPageProxy(new QtWebPageProxy(pageView.data(), q_ptr, pageClient.data(), contextRef, pageGroupRef));
     pageViewPrivate->setPageProxy(pageProxy.data());
 
     pageLoadClient.reset(new QtWebPageLoadClient(pageProxy->pageRef(), q_ptr));
@@ -63,6 +65,9 @@ QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport, WKContextRef
     setUseTraditionalDesktopBehaviour(false);
     QWebPreferencesPrivate::get(pageProxy->preferences())->setAttribute(QWebPreferencesPrivate::AcceleratedCompositingEnabled, true);
 
+    pageClient->setEventHandler(eventHandler.data());
+    pageClient->setPageProxy(pageProxy.data());
+
     // Creates a page with the page creation parameters.
     pageProxy->init(eventHandler.data());
 }
index 2554635..f54efb5 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef qquickwebview_p_p_h
 #define qquickwebview_p_p_h
 
+#include "QtPageClient.h"
 #include "QtWebPageEventHandler.h"
 #include "QtViewportInteractionEngine.h"
 #include "QtWebPageLoadClient.h"
@@ -110,6 +111,7 @@ private:
 
     void setViewInAttachedProperties(QObject*);
 
+    QScopedPointer<QtPageClient> pageClient;
     QScopedPointer<QtWebPageEventHandler> eventHandler;
 
     QScopedPointer<QtWebPageLoadClient> pageLoadClient;
diff --git a/Source/WebKit2/UIProcess/qt/QtPageClient.cpp b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp
new file mode 100644 (file)
index 0000000..adba8c1
--- /dev/null
@@ -0,0 +1,236 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "QtPageClient.h"
+
+#include "QtWebPageEventHandler.h"
+#include "QtWebPageProxy.h"
+#include "QtWebUndoCommand.h"
+#include "WebContextMenuProxyQt.h"
+#include "WebEditCommandProxy.h"
+#include "WebPopupMenuProxyQtDesktop.h"
+#include <QGuiApplication>
+#include <QUndoStack>
+#include <WebCore/Cursor.h>
+#include <WebCore/DragData.h>
+#include <WebCore/FloatRect.h>
+#include <WebCore/NotImplemented.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+QtPageClient::QtPageClient()
+    : m_qtWebPageProxy(0)
+{
+}
+
+QtPageClient::~QtPageClient()
+{
+}
+
+PassOwnPtr<DrawingAreaProxy> QtPageClient::createDrawingAreaProxy()
+{
+    return m_qtWebPageProxy->createDrawingAreaProxy();
+}
+
+void QtPageClient::setViewNeedsDisplay(const WebCore::IntRect& rect)
+{
+    m_qtWebPageProxy->setViewNeedsDisplay(rect);
+}
+
+void QtPageClient::pageDidRequestScroll(const IntPoint& pos)
+{
+    m_qtWebPageProxy->pageDidRequestScroll(pos);
+}
+
+void QtPageClient::processDidCrash()
+{
+    m_qtWebPageProxy->processDidCrash();
+}
+
+void QtPageClient::didRelaunchProcess()
+{
+    m_qtWebPageProxy->didRelaunchProcess();
+}
+
+void QtPageClient::didChangeContentsSize(const IntSize& newSize)
+{
+    m_qtWebPageProxy->didChangeContentsSize(newSize);
+}
+
+void QtPageClient::didChangeViewportProperties(const WebCore::ViewportArguments& args)
+{
+    m_qtWebPageProxy->didChangeViewportProperties(args);
+}
+
+void QtPageClient::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
+{
+    m_qtWebPageProxy->startDrag(dragData, dragImage);
+}
+
+void QtPageClient::handleDownloadRequest(DownloadProxy* download)
+{
+    m_qtWebPageProxy->handleDownloadRequest(download);
+}
+
+void QtPageClient::setCursor(const WebCore::Cursor& cursor)
+{
+    // FIXME: This is a temporary fix until we get cursor support in QML items.
+    QGuiApplication::setOverrideCursor(*cursor.platformCursor());
+}
+
+void QtPageClient::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
+{
+    notImplemented();
+}
+
+void QtPageClient::toolTipChanged(const String&, const String& newTooltip)
+{
+    // There is not yet any UI defined for the tooltips for mobile so we ignore the change.
+}
+
+void QtPageClient::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
+{
+    m_qtWebPageProxy->registerEditCommand(command, undoOrRedo);
+}
+
+void QtPageClient::clearAllEditCommands()
+{
+    m_qtWebPageProxy->clearAllEditCommands();
+}
+
+bool QtPageClient::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+    return m_qtWebPageProxy->canUndoRedo(undoOrRedo);
+}
+
+void QtPageClient::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+    m_qtWebPageProxy->executeUndoRedo(undoOrRedo);
+}
+
+FloatRect QtPageClient::convertToDeviceSpace(const FloatRect& rect)
+{
+    return rect;
+}
+
+FloatRect QtPageClient::convertToUserSpace(const FloatRect& rect)
+{
+    return rect;
+}
+
+IntPoint QtPageClient::screenToWindow(const IntPoint& point)
+{
+    return point;
+}
+
+IntRect QtPageClient::windowToScreen(const IntRect& rect)
+{
+    return rect;
+}
+
+PassRefPtr<WebPopupMenuProxy> QtPageClient::createPopupMenuProxy(WebPageProxy* webPageProxy)
+{
+    return m_qtWebPageProxy->createPopupMenuProxy(webPageProxy);
+}
+
+PassRefPtr<WebContextMenuProxy> QtPageClient::createContextMenuProxy(WebPageProxy*)
+{
+    return WebContextMenuProxyQt::create(m_qtWebPageProxy);
+}
+
+void QtPageClient::flashBackingStoreUpdates(const Vector<IntRect>&)
+{
+    notImplemented();
+}
+
+void QtPageClient::didFindZoomableArea(const IntPoint& target, const IntRect& area)
+{
+    ASSERT(m_eventHandler);
+    m_eventHandler->didFindZoomableArea(target, area);
+}
+
+void QtPageClient::didReceiveMessageFromNavigatorQtObject(const String& message)
+{
+    m_qtWebPageProxy->didReceiveMessageFromNavigatorQtObject(message);
+}
+
+#if ENABLE(TOUCH_EVENTS)
+void QtPageClient::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
+{
+    ASSERT(m_eventHandler);
+    m_eventHandler->doneWithTouchEvent(event, wasEventHandled);
+}
+#endif
+
+void QtPageClient::displayView()
+{
+    // FIXME: Implement.
+}
+
+void QtPageClient::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset)
+{
+    // FIXME: Implement.
+}
+
+WebCore::IntSize QtPageClient::viewSize()
+{
+    return m_qtWebPageProxy->viewSize();
+}
+
+bool QtPageClient::isViewWindowActive()
+{
+    // FIXME: The scene graph does not have the concept of being active or not when this was written.
+    return true;
+}
+
+bool QtPageClient::isViewFocused()
+{
+    if (!m_qtWebPageProxy)
+        return false;
+
+    return m_qtWebPageProxy->isViewFocused();
+}
+
+bool QtPageClient::isViewVisible()
+{
+    if (!m_qtWebPageProxy)
+        return false;
+
+    return m_qtWebPageProxy->isViewVisible();
+}
+
+bool QtPageClient::isViewInWindow()
+{
+    // FIXME: Implement.
+    return true;
+}
+
+void QtPageClient::enterAcceleratedCompositingMode(const LayerTreeContext&)
+{
+    // FIXME: Implement.
+}
+
+void QtPageClient::exitAcceleratedCompositingMode()
+{
+    // FIXME: Implement.
+}
+
diff --git a/Source/WebKit2/UIProcess/qt/QtPageClient.h b/Source/WebKit2/UIProcess/qt/QtPageClient.h
new file mode 100644 (file)
index 0000000..a9e8478
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef QtPageClient_h
+#define QtPageClient_h
+
+#include "DrawingAreaProxy.h"
+#include "LayerTreeContext.h"
+#include "PageClient.h"
+#include "ShareableBitmap.h"
+#include "ViewportArguments.h"
+
+class QtWebPageEventHandler;
+
+using namespace WebKit;
+
+class QtPageClient : public WebKit::PageClient {
+public:
+    QtPageClient();
+    ~QtPageClient();
+
+    virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
+    virtual void setViewNeedsDisplay(const WebCore::IntRect&);
+    virtual void displayView();
+    virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
+    virtual WebCore::IntSize viewSize();
+    virtual bool isViewWindowActive();
+    virtual bool isViewFocused();
+    virtual bool isViewVisible();
+    virtual bool isViewInWindow();
+#if USE(ACCELERATED_COMPOSITING)
+    virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
+    virtual void exitAcceleratedCompositingMode();
+#endif // USE(ACCELERATED_COMPOSITING)
+    virtual void pageDidRequestScroll(const WebCore::IntPoint&);
+    virtual void processDidCrash();
+    virtual void pageClosed() { }
+    virtual void didRelaunchProcess();
+    virtual void didChangeContentsSize(const WebCore::IntSize&);
+    virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
+    virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
+    virtual void setCursor(const WebCore::Cursor&);
+    virtual void setCursorHiddenUntilMouseMoves(bool);
+    virtual void toolTipChanged(const String&, const String&);
+    virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
+    virtual void clearAllEditCommands();
+    virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
+    virtual void executeUndoRedo(WebPageProxy::UndoOrRedo);
+    virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
+    virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
+    virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&);
+    virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&);
+    virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) { }
+    virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
+    virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
+    virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate) { }
+    virtual void didCommitLoadForMainFrame(bool useCustomRepresentation) { }
+    virtual void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&) { }
+    virtual double customRepresentationZoomFactor() { return 1; }
+    virtual void setCustomRepresentationZoomFactor(double) { }
+    virtual void didChangeScrollbarsForMainFrame() const { }
+    virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);
+    virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) { }
+    virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) { }
+    virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
+    virtual void didReceiveMessageFromNavigatorQtObject(const String&);
+    virtual void handleDownloadRequest(DownloadProxy*);
+
+#if ENABLE(TOUCH_EVENTS)
+    virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
+#endif
+
+    void setEventHandler(QtWebPageEventHandler* eventHandler) { m_eventHandler = eventHandler; }
+    void setPageProxy(QtWebPageProxy* pageProxy) { m_qtWebPageProxy = pageProxy; }
+
+private:
+    QtWebPageProxy* m_qtWebPageProxy;
+    QtWebPageEventHandler* m_eventHandler;
+};
+
+#endif /* QtPageClient_h */
index 4ac04f4..ab1db47 100644 (file)
@@ -26,7 +26,6 @@
 #include "qquickwebview_p.h"
 #include "qquickwebview_p_p.h"
 #include "qquickwebpage_p.h"
-#include "QtWebError.h"
 #include "qwebdownloaditem_p.h"
 #include "qwebdownloaditem_p_p.h"
 #include "qwebpreferences_p.h"
 #include "DrawingAreaProxyImpl.h"
 #include "qwkhistory.h"
 #include "qwkhistory_p.h"
-#include "FindIndicator.h"
-#include "LocalizedStrings.h"
-#include "NotImplemented.h"
 #include "QtDownloadManager.h"
+#include "QtPageClient.h"
 #include "QtWebPageEventHandler.h"
 #include "QtWebUndoCommand.h"
 #include "WebBackForwardList.h"
 #include "WKStringQt.h"
 #include "WKURLQt.h"
 #include <QDrag>
-#include <QGuiApplication>
-#include <QJSEngine>
 #include <QMimeData>
-#include <QStyleHints>
 #include <QUndoStack>
-#include <QtDebug>
-#include <WebCore/Cursor.h>
 #include <WebCore/DragData.h>
-#include <WebCore/FloatRect.h>
-#include <WebCore/Region.h>
 #include <WebKit2/WKFrame.h>
 #include <WebKit2/WKPageGroup.h>
 #include <WebKit2/WKRetainPtr.h>
 using namespace WebKit;
 using namespace WebCore;
 
-QtWebPageProxy::QtWebPageProxy(QQuickWebPage* qmlWebPage, QQuickWebView* qmlWebView, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+QtWebPageProxy::QtWebPageProxy(QQuickWebPage* qmlWebPage, QQuickWebView* qmlWebView, QtPageClient *pageClient, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
     : m_qmlWebPage(qmlWebPage)
     , m_qmlWebView(qmlWebView)
     , m_context(contextRef ? QtWebContext::create(toImpl(contextRef)) : QtWebContext::defaultContext())
     , m_undoStack(adoptPtr(new QUndoStack(this)))
     , m_navigatorQtObjectEnabled(false)
 {
-    m_webPageProxy = m_context->createWebPage(this, toImpl(pageGroupRef));
+    m_webPageProxy = m_context->createWebPage(pageClient, toImpl(pageGroupRef));
     m_history = QWKHistoryPrivate::createHistory(this, m_webPageProxy->backForwardList());
 }
 
@@ -122,43 +112,16 @@ void QtWebPageProxy::hideContextMenu()
         activeMenu->hide();
 }
 
-void QtWebPageProxy::setCursor(const WebCore::Cursor& cursor)
-{
-    // FIXME: This is a temporary fix until we get cursor support in QML items.
-    QGuiApplication::setOverrideCursor(*cursor.platformCursor());
-}
-
-void QtWebPageProxy::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
-{
-    notImplemented();
-}
-
 void QtWebPageProxy::setViewNeedsDisplay(const WebCore::IntRect&)
 {
     m_qmlWebPage->update();
 }
 
-void QtWebPageProxy::displayView()
-{
-    // FIXME: Implement.
-}
-
-void QtWebPageProxy::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset)
-{
-    // FIXME: Implement.
-}
-
 WebCore::IntSize QtWebPageProxy::viewSize()
 {
     return WebCore::IntSize(m_qmlWebPage->width(), m_qmlWebPage->height());
 }
 
-bool QtWebPageProxy::isViewWindowActive()
-{
-    // FIXME: The scene graph does not have the concept of being active or not when this was written.
-    return true;
-}
-
 bool QtWebPageProxy::isViewFocused()
 {
     return m_qmlWebView->hasFocus();
@@ -169,22 +132,6 @@ bool QtWebPageProxy::isViewVisible()
     return m_qmlWebView->isVisible() && m_qmlWebPage->isVisible();
 }
 
-bool QtWebPageProxy::isViewInWindow()
-{
-    // FIXME: Implement.
-    return true;
-}
-
-void QtWebPageProxy::enterAcceleratedCompositingMode(const LayerTreeContext&)
-{
-    // FIXME: Implement.
-}
-
-void QtWebPageProxy::exitAcceleratedCompositingMode()
-{
-    // FIXME: Implement.
-}
-
 void QtWebPageProxy::pageDidRequestScroll(const IntPoint& pos)
 {
     m_qmlWebView->d_func()->scrollPositionRequested(pos);
@@ -200,11 +147,6 @@ void QtWebPageProxy::didChangeViewportProperties(const WebCore::ViewportArgument
     m_qmlWebView->d_func()->didChangeViewportProperties(args);
 }
 
-void QtWebPageProxy::toolTipChanged(const String&, const String& newTooltip)
-{
-    // There is not yet any UI defined for the tooltips for mobile so we ignore the change.
-}
-
 void QtWebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
 {
     if (undoOrRedo == WebPageProxy::Undo) {
@@ -235,72 +177,20 @@ void QtWebPageProxy::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
         m_undoStack->redo();
 }
 
-FloatRect QtWebPageProxy::convertToDeviceSpace(const FloatRect& rect)
-{
-    return rect;
-}
-
-IntPoint QtWebPageProxy::screenToWindow(const IntPoint& point)
-{
-    return point;
-}
-
-IntRect QtWebPageProxy::windowToScreen(const IntRect& rect)
-{
-    return rect;
-}
-
-FloatRect QtWebPageProxy::convertToUserSpace(const FloatRect& rect)
-{
-    return rect;
-}
-
 void QtWebPageProxy::selectionChanged(bool, bool, bool, bool)
 {
 }
 
-void QtWebPageProxy::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
-{
-}
-
 PassRefPtr<WebPopupMenuProxy> QtWebPageProxy::createPopupMenuProxy(WebPageProxy*)
 {
     return WebPopupMenuProxyQtDesktop::create(m_webPageProxy.get(), m_qmlWebView);
 }
 
-PassRefPtr<WebContextMenuProxy> QtWebPageProxy::createContextMenuProxy(WebPageProxy*)
-{
-    return WebContextMenuProxyQt::create(this);
-}
-
-void QtWebPageProxy::setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate)
-{
-}
-
-void QtWebPageProxy::didCommitLoadForMainFrame(bool useCustomRepresentation)
-{
-}
-
-void QtWebPageProxy::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&)
-{
-}
-
-void QtWebPageProxy::flashBackingStoreUpdates(const Vector<IntRect>&)
-{
-    notImplemented();
-}
-
 WKPageRef QtWebPageProxy::pageRef() const
 {
     return toAPI(m_webPageProxy.get());;
 }
 
-void QtWebPageProxy::didFindZoomableArea(const IntPoint& target, const IntRect& area)
-{
-    ASSERT(m_eventHandler);
-    m_eventHandler->didFindZoomableArea(target, area);
-}
-
 void QtWebPageProxy::didReceiveMessageFromNavigatorQtObject(const String& message)
 {
     QVariantMap variantMap;
@@ -536,14 +426,6 @@ void QtWebPageProxy::renderToCurrentGLContext(const TransformationMatrix& transf
         drawingArea->paintToCurrentGLContext(transform, opacity);
 }
 
-#if ENABLE(TOUCH_EVENTS)
-void QtWebPageProxy::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
-{
-    ASSERT(m_eventHandler);
-    m_eventHandler->doneWithTouchEvent(event, wasEventHandled);
-}
-#endif
-
 void QtWebPageProxy::setVisibleContentRectAndScale(const QRectF& visibleContentRect, float scale)
 {
     if (!m_webPageProxy->drawingArea())
index 3317044..2e6be56 100644 (file)
 #define QtWebPageProxy_h
 
 #include "DrawingAreaProxy.h"
-#include "LayerTreeContext.h"
-#include "PageClient.h"
 #include "QtWebContext.h"
 #include "ShareableBitmap.h"
 #include "ViewportArguments.h"
 #include "WebPageProxy.h"
 #include <wtf/RefPtr.h>
-#include <QGraphicsView>
 #include <QMenu>
 #include <QSharedPointer>
 
@@ -37,6 +34,7 @@ QT_BEGIN_NAMESPACE
 class QUndoStack;
 QT_END_NAMESPACE
 
+class QtPageClient;
 class QQuickWebPage;
 class QQuickWebView;
 class QtWebError;
@@ -52,7 +50,7 @@ class QtWebContext;
 using namespace WebKit;
 
 // FIXME: needs focus in/out, window activation, support through viewStateDidChange().
-class QtWebPageProxy : public QObject, WebKit::PageClient {
+class QtWebPageProxy : public QObject {
     Q_OBJECT
 
 public:
@@ -70,66 +68,33 @@ public:
         WebActionCount
     };
 
-    QtWebPageProxy(QQuickWebPage*, QQuickWebView*, WKContextRef = 0, WKPageGroupRef = 0);
+    QtWebPageProxy(QQuickWebPage*, QQuickWebView*, QtPageClient*, WKContextRef = 0, WKPageGroupRef = 0);
     ~QtWebPageProxy();
 
-    virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
-
-    // PageClient
-    virtual void setViewNeedsDisplay(const WebCore::IntRect&);
-    virtual void displayView();
-    virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
-
-    virtual WebCore::IntSize viewSize();
-    virtual bool isViewWindowActive();
-    virtual bool isViewFocused();
-    virtual bool isViewVisible();
-    virtual bool isViewInWindow();
-
-#if USE(ACCELERATED_COMPOSITING)
-    virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
-    virtual void exitAcceleratedCompositingMode();
-#endif // USE(ACCELERATED_COMPOSITING)
-    virtual void pageDidRequestScroll(const WebCore::IntPoint&);
-    virtual void processDidCrash();
-    virtual void pageClosed() { }
-    virtual void didRelaunchProcess();
-
-    virtual void didChangeContentsSize(const WebCore::IntSize&);
-    virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
-
-    virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
-    virtual void setCursor(const WebCore::Cursor&);
-    virtual void setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves);
-    virtual void toolTipChanged(const WTF::String&, const WTF::String&);
-    virtual void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo);
-    virtual void clearAllEditCommands();
-    virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
-    virtual void executeUndoRedo(WebPageProxy::UndoOrRedo);
-    virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
-    virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
-    virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&);
-    virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&);
-
-    virtual void doneWithKeyEvent(const WebKit::NativeWebKeyboardEvent&, bool wasEventHandled);
-    virtual void selectionChanged(bool, bool, bool, bool);
-    virtual PassRefPtr<WebKit::WebPopupMenuProxy> createPopupMenuProxy(WebKit::WebPageProxy*);
-    virtual PassRefPtr<WebKit::WebContextMenuProxy> createContextMenuProxy(WebKit::WebPageProxy*);
-
-    virtual void setFindIndicator(PassRefPtr<WebKit::FindIndicator>, bool fadeOut, bool animate);
-
-    virtual void didCommitLoadForMainFrame(bool useCustomRepresentation);
-    virtual void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&);
-    virtual double customRepresentationZoomFactor() { return 1; }
-    virtual void setCustomRepresentationZoomFactor(double) { }
-    virtual void didChangeScrollbarsForMainFrame() const { }
-
-    virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);
-    virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) { }
-    virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) { }
-
-    virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
-    virtual void didReceiveMessageFromNavigatorQtObject(const String&);
+    PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
+
+    void setViewNeedsDisplay(const WebCore::IntRect&);
+    WebCore::IntSize viewSize();
+    bool isViewFocused();
+    bool isViewVisible();
+
+    void pageDidRequestScroll(const WebCore::IntPoint&);
+    void processDidCrash();
+    void didRelaunchProcess();
+
+    void didChangeContentsSize(const WebCore::IntSize&);
+    void didChangeViewportProperties(const WebCore::ViewportArguments&);
+
+    void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
+    void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo);
+    void clearAllEditCommands();
+    bool canUndoRedo(WebPageProxy::UndoOrRedo);
+    void executeUndoRedo(WebPageProxy::UndoOrRedo);
+
+    void selectionChanged(bool, bool, bool, bool);
+    PassRefPtr<WebKit::WebPopupMenuProxy> createPopupMenuProxy(WebKit::WebPageProxy*);
+
+    void didReceiveMessageFromNavigatorQtObject(const String&);
 
     bool canGoBack() const;
     void goBack();
@@ -202,7 +167,7 @@ protected:
 
 private:
 #if ENABLE(TOUCH_EVENTS)
-    virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
+    void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
 #endif
 
     RefPtr<QtWebContext> m_context;