Title: [100990] trunk/Source/WebKit2
Revision
100990
Author
caio.olive...@openbossa.org
Date
2011-11-22 05:21:18 -0800 (Tue, 22 Nov 2011)

Log Message

[Qt] [WK2] Move PageUIClient related code to QtWebPageUIClient
https://bugs.webkit.org/show_bug.cgi?id=72910

Reviewed by Andreas Kling.

Split PageUIClient related code from QtWebPageProxy/ClientImpl. The new
QtWebPageUIClient registers itself with WKPageRef and it's owned by the
QQuickWebViewPrivate. This is a move to clean up QtWebPageProxy object.

* Target.pri:
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::QQuickWebViewPrivate):
(QQuickWebViewPrivate::chooseFiles):
* UIProcess/API/qt/qquickwebview_p.h:
* UIProcess/API/qt/qquickwebview_p_p.h:
* UIProcess/qt/ClientImpl.cpp:
* UIProcess/qt/ClientImpl.h:
* UIProcess/qt/QtWebPageProxy.cpp:
(QtWebPageProxy::init):
* UIProcess/qt/QtWebPageProxy.h:
* UIProcess/qt/QtWebPageUIClient.cpp: Added.
(QtWebPageUIClient::QtWebPageUIClient):
(QtWebPageUIClient::runJavaScriptAlert):
(QtWebPageUIClient::runJavaScriptConfirm):
(QtWebPageUIClient::runJavaScriptPrompt):
(QtWebPageUIClient::runOpenPanel):
(QtWebPageUIClient::setStatusText):
(QtWebPageUIClient::mouseDidMoveOverElement):
(toQtWebPageUIClient):
(createNullWKString):
* UIProcess/qt/QtWebPageUIClient.h: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (100989 => 100990)


--- trunk/Source/WebKit2/ChangeLog	2011-11-22 12:58:20 UTC (rev 100989)
+++ trunk/Source/WebKit2/ChangeLog	2011-11-22 13:21:18 UTC (rev 100990)
@@ -1,3 +1,37 @@
+2011-11-22  Caio Marcelo de Oliveira Filho  <caio.olive...@openbossa.org>
+
+        [Qt] [WK2] Move PageUIClient related code to QtWebPageUIClient
+        https://bugs.webkit.org/show_bug.cgi?id=72910
+
+        Reviewed by Andreas Kling.
+
+        Split PageUIClient related code from QtWebPageProxy/ClientImpl. The new
+        QtWebPageUIClient registers itself with WKPageRef and it's owned by the
+        QQuickWebViewPrivate. This is a move to clean up QtWebPageProxy object.
+
+        * Target.pri:
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewPrivate::QQuickWebViewPrivate):
+        (QQuickWebViewPrivate::chooseFiles):
+        * UIProcess/API/qt/qquickwebview_p.h:
+        * UIProcess/API/qt/qquickwebview_p_p.h:
+        * UIProcess/qt/ClientImpl.cpp:
+        * UIProcess/qt/ClientImpl.h:
+        * UIProcess/qt/QtWebPageProxy.cpp:
+        (QtWebPageProxy::init):
+        * UIProcess/qt/QtWebPageProxy.h:
+        * UIProcess/qt/QtWebPageUIClient.cpp: Added.
+        (QtWebPageUIClient::QtWebPageUIClient):
+        (QtWebPageUIClient::runJavaScriptAlert):
+        (QtWebPageUIClient::runJavaScriptConfirm):
+        (QtWebPageUIClient::runJavaScriptPrompt):
+        (QtWebPageUIClient::runOpenPanel):
+        (QtWebPageUIClient::setStatusText):
+        (QtWebPageUIClient::mouseDidMoveOverElement):
+        (toQtWebPageUIClient):
+        (createNullWKString):
+        * UIProcess/qt/QtWebPageUIClient.h: Added.
+
 2011-11-22  Eunmi Lee  <eunmi15....@samsung.com>
 
         [WK2] Modify EFL port's WebEventFactory to use EflKeyboardUtilities's

Modified: trunk/Source/WebKit2/Target.pri (100989 => 100990)


--- trunk/Source/WebKit2/Target.pri	2011-11-22 12:58:20 UTC (rev 100989)
+++ trunk/Source/WebKit2/Target.pri	2011-11-22 13:21:18 UTC (rev 100990)
@@ -323,6 +323,7 @@
     UIProcess/qt/QtDialogRunner.h \
     UIProcess/qt/QtDownloadManager.h \
     UIProcess/qt/QtWebPageProxy.h \
+    UIProcess/qt/QtWebPageUIClient.h \
     UIProcess/qt/qwkhistory.h \
     UIProcess/qt/qwkhistory_p.h \
     UIProcess/qt/QtSGUpdateQueue.h \
@@ -628,6 +629,7 @@
     UIProcess/qt/QtDialogRunner.cpp \
     UIProcess/qt/QtDownloadManager.cpp \
     UIProcess/qt/QtWebPageProxy.cpp \
+    UIProcess/qt/QtWebPageUIClient.cpp \
     UIProcess/qt/qwkhistory.cpp \
     UIProcess/qt/QtSGUpdateQueue.cpp \
     UIProcess/qt/QtSGTileNode.cpp \

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp (100989 => 100990)


--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp	2011-11-22 12:58:20 UTC (rev 100989)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp	2011-11-22 13:21:18 UTC (rev 100990)
@@ -58,6 +58,8 @@
     pageProxy->init();
 
     QObject::connect(pageProxy.data(), SIGNAL(updateNavigationState()), q_ptr, SIGNAL(navigationStateChanged()));
+
+    pageUIClient.reset(new QtWebPageUIClient(pageProxy->pageRef(), q_ptr));
 }
 
 void QQuickWebViewPrivate::enableMouseEvents()
@@ -274,7 +276,7 @@
     return dialogRunner.result();
 }
 
-void QQuickWebViewPrivate::chooseFiles(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, QtWebPageProxy::FileChooserType type)
+void QQuickWebViewPrivate::chooseFiles(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, QtWebPageUIClient::FileChooserType type)
 {
 #ifndef QT_NO_FILEDIALOG
     Q_Q(QQuickWebView);

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h (100989 => 100990)


--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h	2011-11-22 12:58:20 UTC (rev 100989)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h	2011-11-22 13:21:18 UTC (rev 100990)
@@ -135,6 +135,7 @@
     QQuickWebViewExperimental* m_experimental;
 
     friend class QtWebPageProxy;
+    friend class QtWebPageUIClient;
     friend class WTR::PlatformWebView;
     friend class QQuickWebViewExperimental;
 };

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h (100989 => 100990)


--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h	2011-11-22 12:58:20 UTC (rev 100989)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h	2011-11-22 13:21:18 UTC (rev 100990)
@@ -24,6 +24,7 @@
 #include "QtPolicyInterface.h"
 #include "QtViewportInteractionEngine.h"
 #include "QtWebPageProxy.h"
+#include "QtWebPageUIClient.h"
 
 #include "qquickwebview_p.h"
 #include "qquickwebpage_p.h"
@@ -72,7 +73,7 @@
     // QtPolicyInterface.
     virtual QtPolicyInterface::PolicyAction navigationPolicyForURL(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers);
 
-    void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, QtWebPageProxy::FileChooserType);
+    void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, QtWebPageUIClient::FileChooserType);
     void runJavaScriptAlert(const QString&);
     bool runJavaScriptConfirm(const QString&);
     QString runJavaScriptPrompt(const QString&, const QString& defaultValue, bool& ok);
@@ -110,6 +111,8 @@
 
     void setViewInAttachedProperties(QObject*);
 
+    QScopedPointer<QtWebPageUIClient> pageUIClient;
+
     QScopedPointer<QQuickWebPage> pageView;
     QScopedPointer<QtViewportInteractionEngine> interactionEngine;
 

Modified: trunk/Source/WebKit2/UIProcess/qt/ClientImpl.cpp (100989 => 100990)


--- trunk/Source/WebKit2/UIProcess/qt/ClientImpl.cpp	2011-11-22 12:58:20 UTC (rev 100989)
+++ trunk/Source/WebKit2/UIProcess/qt/ClientImpl.cpp	2011-11-22 13:21:18 UTC (rev 100990)
@@ -31,8 +31,6 @@
 #include <WKFrame.h>
 #include <WKFramePolicyListener.h>
 #include <WKHitTestResult.h>
-#include <WKOpenPanelParameters.h>
-#include <WKOpenPanelResultListener.h>
 #include <WKPage.h>
 #include <WKString.h>
 #include <WKType.h>
@@ -152,61 +150,6 @@
     toQtWebPageProxy(clientInfo)->didFinishFirstNonEmptyLayout();
 }
 
-static void qt_wk_runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
-{
-    QString qAlertText = WKStringCopyQString(alertText);
-    toQtWebPageProxy(clientInfo)->runJavaScriptAlert(qAlertText);
-}
-
-static bool qt_wk_runJavaScriptConfirm(WKPageRef, WKStringRef message, WKFrameRef, const void* clientInfo)
-{
-    QString qMessage = WKStringCopyQString(message);
-    return toQtWebPageProxy(clientInfo)->runJavaScriptConfirm(qMessage);
-}
-
-static inline WKStringRef createNullWKString()
-{
-    RefPtr<WebString> webString = WebString::createNull();
-    return toAPI(webString.release().leakRef());
-}
-
-static WKStringRef qt_wk_runJavaScriptPrompt(WKPageRef, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void* clientInfo)
-{
-    QString qMessage = WKStringCopyQString(message);
-    QString qDefaultValue = WKStringCopyQString(defaultValue);
-    bool ok = false;
-    QString result = toQtWebPageProxy(clientInfo)->runJavaScriptPrompt(qMessage, qDefaultValue, ok);
-    if (!ok)
-        return createNullWKString();
-    return WKStringCreateWithQString(result);
-}
-
-static void qt_wk_setStatusText(WKPageRef, WKStringRef text, const void *clientInfo)
-{
-    QString qText = WKStringCopyQString(text);
-    toQtWebPageProxy(clientInfo)->didChangeStatusText(qText);
-}
-
-static void qt_wk_runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo)
-{
-    Vector<String> wkSelectedFileNames = toImpl(parameters)->selectedFileNames();
-
-    QStringList selectedFileNames;
-    if (!wkSelectedFileNames.isEmpty())
-        for (unsigned i = 0; wkSelectedFileNames.size(); ++i)
-            selectedFileNames += wkSelectedFileNames.at(i);
-
-    QtWebPageProxy::FileChooserType allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? QtWebPageProxy::MultipleFilesSelection : QtWebPageProxy::SingleFileSelection;
-    toQtWebPageProxy(clientInfo)->chooseFiles(listener, selectedFileNames, allowMultipleFiles);
-}
-
-static void qt_wk_mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void* clientInfo)
-{
-    const QUrl absoluteLinkUrl = WKURLCopyQUrl(WKHitTestResultCopyAbsoluteLinkURL(hitTestResult));
-    const QString linkTitle = WKStringCopyQString(WKHitTestResultCopyLinkTitle(hitTestResult));
-    toQtWebPageProxy(clientInfo)->didMouseMoveOverElement(absoluteLinkUrl, linkTitle);
-}
-
 static Qt::MouseButton toQtMouseButton(WKEventMouseButton button)
 {
     switch (button) {
@@ -321,21 +264,6 @@
     WKPageSetPageLoaderClient(qtWebPageProxy->pageRef(), &loadClient);
 }
 
-void setupPageUiClient(QtWebPageProxy* qtWebPageProxy, WebPageProxy* webPageProxy)
-{
-    WKPageUIClient uiClient;
-    memset(&uiClient, 0, sizeof(WKPageUIClient));
-    uiClient.version = kWKPageUIClientCurrentVersion;
-    uiClient.clientInfo = qtWebPageProxy;
-    uiClient.runJavaScriptAlert = qt_wk_runJavaScriptAlert;
-    uiClient.runJavaScriptConfirm = qt_wk_runJavaScriptConfirm;
-    uiClient.runJavaScriptPrompt = qt_wk_runJavaScriptPrompt;
-    uiClient.setStatusText = qt_wk_setStatusText;
-    uiClient.runOpenPanel = qt_wk_runOpenPanel;
-    uiClient.mouseDidMoveOverElement = qt_wk_mouseDidMoveOverElement;
-    WKPageSetPageUIClient(toAPI(webPageProxy), &uiClient);
-}
-
 void setupPagePolicyClient(QtPolicyInterface* policyInterface, WebPageProxy* webPageProxy)
 {
     WKPagePolicyClient policyClient;

Modified: trunk/Source/WebKit2/UIProcess/qt/ClientImpl.h (100989 => 100990)


--- trunk/Source/WebKit2/UIProcess/qt/ClientImpl.h	2011-11-22 12:58:20 UTC (rev 100989)
+++ trunk/Source/WebKit2/UIProcess/qt/ClientImpl.h	2011-11-22 13:21:18 UTC (rev 100990)
@@ -29,7 +29,6 @@
 }
 
 void setupPageLoaderClient(QtWebPageProxy*, WebKit::WebPageProxy*);
-void setupPageUiClient(QtWebPageProxy*, WebKit::WebPageProxy*);
 void setupPagePolicyClient(WebKit::QtPolicyInterface*, WebKit::WebPageProxy*);
 
 void setupContextInjectedBundleClient(WKContextRef);

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp (100989 => 100990)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp	2011-11-22 12:58:20 UTC (rev 100989)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp	2011-11-22 13:21:18 UTC (rev 100990)
@@ -157,7 +157,6 @@
     m_webPageProxy->initializeWebPage();
 
     setupPageLoaderClient(this, m_webPageProxy.get());
-    setupPageUiClient(this, m_webPageProxy.get());
 
     if (m_policyInterface)
         setupPagePolicyClient(m_policyInterface, m_webPageProxy.get());
@@ -355,20 +354,6 @@
     m_webPageProxy->findZoomableAreaForPoint(point.pos().toPoint());
 }
 
-void QtWebPageProxy::didChangeStatusText(const QString& newMessage)
-{
-    emit m_qmlWebView->statusBarMessageChanged(newMessage);
-}
-
-void QtWebPageProxy::didMouseMoveOverElement(const QUrl& linkURL, const QString& linkTitle)
-{
-    if (linkURL == lastHoveredURL && linkTitle == lastHoveredTitle)
-        return;
-    lastHoveredURL = linkURL;
-    lastHoveredTitle = linkTitle;
-    emit m_qmlWebView->linkHovered(lastHoveredURL, lastHoveredTitle);
-}
-
 void QtWebPageProxy::showContextMenu(QSharedPointer<QMenu> menu)
 {
     // Remove the active menu in case this function is called twice.
@@ -401,26 +386,6 @@
         activeMenu->hide();
 }
 
-void QtWebPageProxy::runJavaScriptAlert(const QString& alertText)
-{
-    m_qmlWebView->d_func()->runJavaScriptAlert(alertText);
-}
-
-bool QtWebPageProxy::runJavaScriptConfirm(const QString& message)
-{
-    return m_qmlWebView->d_func()->runJavaScriptConfirm(message);
-}
-
-QString QtWebPageProxy::runJavaScriptPrompt(const QString& message, const QString& defaultValue, bool& ok)
-{
-    return m_qmlWebView->d_func()->runJavaScriptPrompt(message, defaultValue, ok);
-}
-
-void QtWebPageProxy::chooseFiles(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, FileChooserType type)
-{
-    m_qmlWebView->d_func()->chooseFiles(listenerRef, selectedFileNames, type);
-}
-
 void QtWebPageProxy::timerEvent(QTimerEvent* ev)
 {
     int timerId = ev->timerId();

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h (100989 => 100990)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h	2011-11-22 12:58:20 UTC (rev 100989)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h	2011-11-22 13:21:18 UTC (rev 100990)
@@ -74,11 +74,6 @@
         WebActionCount
     };
 
-    enum FileChooserType {
-        SingleFileSelection,
-        MultipleFilesSelection
-    };
-
     QtWebPageProxy(QQuickWebPage*, QQuickWebView*, WebKit::QtViewportInteractionEngine* = 0, WebKit::QtPolicyInterface* = 0, WKContextRef = 0, WKPageGroupRef = 0);
     ~QtWebPageProxy();
 
@@ -210,19 +205,9 @@
     void handleSingleTapEvent(const QTouchEvent::TouchPoint&);
     void handleDoubleTapEvent(const QTouchEvent::TouchPoint&);
 
-    void didChangeStatusText(const QString&);
-
     void showContextMenu(QSharedPointer<QMenu>);
     void hideContextMenu();
 
-    void runJavaScriptAlert(const QString&);
-    bool runJavaScriptConfirm(const QString&);
-    QString runJavaScriptPrompt(const QString&, const QString& defaultValue, bool& ok);
-
-    void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, FileChooserType);
-
-    void didMouseMoveOverElement(const QUrl&, const QString&);
-
 public Q_SLOTS:
     void navigationStateChanged();
     void didReceiveDownloadResponse(QWebDownloadItem* downloadItem);
@@ -285,8 +270,6 @@
     QBasicTimer m_tripleClickTimer;
 
     QSharedPointer<QMenu> activeMenu;
-    QUrl lastHoveredURL;
-    QString lastHoveredTitle;
 };
 
 #endif /* QtWebPageProxy_h */

Added: trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp (0 => 100990)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp	2011-11-22 13:21:18 UTC (rev 100990)
@@ -0,0 +1,141 @@
+/*
+ * 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 "QtWebPageUIClient.h"
+
+#include "WKStringQt.h"
+#include "WKURLQt.h"
+#include "qquickwebview_p.h"
+#include "qquickwebview_p_p.h"
+#include <WKAPICast.h>
+#include <WKHitTestResult.h>
+#include <WKOpenPanelParameters.h>
+#include <WKOpenPanelResultListener.h>
+
+QtWebPageUIClient::QtWebPageUIClient(WKPageRef pageRef, QQuickWebView* webView)
+    : m_webView(webView)
+{
+    WKPageUIClient uiClient;
+    memset(&uiClient, 0, sizeof(WKPageUIClient));
+    uiClient.version = kWKPageUIClientCurrentVersion;
+    uiClient.clientInfo = this;
+    uiClient.runJavaScriptAlert = runJavaScriptAlert;
+    uiClient.runJavaScriptConfirm = runJavaScriptConfirm;
+    uiClient.runJavaScriptPrompt = runJavaScriptPrompt;
+    uiClient.setStatusText = setStatusText;
+    uiClient.runOpenPanel = runOpenPanel;
+    uiClient.mouseDidMoveOverElement = mouseDidMoveOverElement;
+    WKPageSetPageUIClient(pageRef, &uiClient);
+}
+
+void QtWebPageUIClient::runJavaScriptAlert(const QString& message)
+{
+    m_webView->d_func()->runJavaScriptAlert(message);
+}
+
+bool QtWebPageUIClient::runJavaScriptConfirm(const QString& message)
+{
+    return m_webView->d_func()->runJavaScriptConfirm(message);
+}
+
+QString QtWebPageUIClient::runJavaScriptPrompt(const QString& message, const QString& defaultValue, bool& ok)
+{
+    return m_webView->d_func()->runJavaScriptPrompt(message, defaultValue, ok);
+}
+
+void QtWebPageUIClient::runOpenPanel(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, FileChooserType type)
+{
+    m_webView->d_func()->chooseFiles(listenerRef, selectedFileNames, type);
+}
+
+void QtWebPageUIClient::setStatusText(const QString& newMessage)
+{
+    emit m_webView->statusBarMessageChanged(newMessage);
+}
+
+void QtWebPageUIClient::mouseDidMoveOverElement(const QUrl& linkURL, const QString& linkTitle)
+{
+    if (linkURL == m_lastHoveredURL && linkTitle == m_lastHoveredTitle)
+        return;
+    m_lastHoveredURL = linkURL;
+    m_lastHoveredTitle = linkTitle;
+    emit m_webView->linkHovered(m_lastHoveredURL, m_lastHoveredTitle);
+}
+
+static QtWebPageUIClient* toQtWebPageUIClient(const void* clientInfo)
+{
+    ASSERT(clientInfo);
+    return reinterpret_cast<QtWebPageUIClient*>(const_cast<void*>(clientInfo));
+}
+
+void QtWebPageUIClient::runJavaScriptAlert(WKPageRef, WKStringRef alertText, WKFrameRef, const void* clientInfo)
+{
+    QString qAlertText = WKStringCopyQString(alertText);
+    toQtWebPageUIClient(clientInfo)->runJavaScriptAlert(qAlertText);
+}
+
+bool QtWebPageUIClient::runJavaScriptConfirm(WKPageRef, WKStringRef message, WKFrameRef, const void* clientInfo)
+{
+    QString qMessage = WKStringCopyQString(message);
+    return toQtWebPageUIClient(clientInfo)->runJavaScriptConfirm(qMessage);
+}
+
+static inline WKStringRef createNullWKString()
+{
+    RefPtr<WebString> webString = WebString::createNull();
+    return toAPI(webString.release().leakRef());
+}
+
+WKStringRef QtWebPageUIClient::runJavaScriptPrompt(WKPageRef, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void* clientInfo)
+{
+    QString qMessage = WKStringCopyQString(message);
+    QString qDefaultValue = WKStringCopyQString(defaultValue);
+    bool ok = false;
+    QString result = toQtWebPageUIClient(clientInfo)->runJavaScriptPrompt(qMessage, qDefaultValue, ok);
+    if (!ok)
+        return createNullWKString();
+    return WKStringCreateWithQString(result);
+}
+
+void QtWebPageUIClient::setStatusText(WKPageRef, WKStringRef text, const void *clientInfo)
+{
+    QString qText = WKStringCopyQString(text);
+    toQtWebPageUIClient(clientInfo)->setStatusText(qText);
+}
+
+void QtWebPageUIClient::runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo)
+{
+    Vector<String> wkSelectedFileNames = toImpl(parameters)->selectedFileNames();
+
+    QStringList selectedFileNames;
+    for (size_t i = 0; i < wkSelectedFileNames.size(); ++i)
+        selectedFileNames += wkSelectedFileNames.at(i);
+
+    FileChooserType allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? MultipleFilesSelection : SingleFileSelection;
+    toQtWebPageUIClient(clientInfo)->runOpenPanel(listener, selectedFileNames, allowMultipleFiles);
+}
+
+void QtWebPageUIClient::mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void* clientInfo)
+{
+    const QUrl absoluteLinkUrl = WKURLCopyQUrl(WKHitTestResultCopyAbsoluteLinkURL(hitTestResult));
+    const QString linkTitle = WKStringCopyQString(WKHitTestResultCopyLinkTitle(hitTestResult));
+    toQtWebPageUIClient(clientInfo)->mouseDidMoveOverElement(absoluteLinkUrl, linkTitle);
+}

Added: trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.h (0 => 100990)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.h	2011-11-22 13:21:18 UTC (rev 100990)
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ *
+ */
+
+#ifndef QtWebPageUIClient_h
+#define QtWebPageUIClient_h
+
+#include <QtCore/QString>
+#include <QtCore/QUrl>
+#include <WKPage.h>
+
+class QQuickWebView;
+
+class QtWebPageUIClient {
+public:
+    enum FileChooserType {
+        SingleFileSelection,
+        MultipleFilesSelection
+    };
+
+    QtWebPageUIClient(WKPageRef, QQuickWebView*);
+
+private:
+    void runJavaScriptAlert(const QString& message);
+    bool runJavaScriptConfirm(const QString& message);
+    QString runJavaScriptPrompt(const QString& message, const QString& defaultValue, bool& ok);
+    void setStatusText(const QString&);
+    void runOpenPanel(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, FileChooserType);
+    void mouseDidMoveOverElement(const QUrl& linkURL, const QString& linkTitle);
+
+    // WKPageUIClient callbacks.
+    static void runJavaScriptAlert(WKPageRef, WKStringRef alertText, WKFrameRef, const void* clientInfo);
+    static bool runJavaScriptConfirm(WKPageRef, WKStringRef message, WKFrameRef, const void* clientInfo);
+    static WKStringRef runJavaScriptPrompt(WKPageRef, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void* clientInfo);
+    static void setStatusText(WKPageRef, WKStringRef, const void *clientInfo);
+    static void runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef, WKOpenPanelResultListenerRef, const void* clientInfo);
+    static void mouseDidMoveOverElement(WKPageRef, WKHitTestResultRef, WKEventModifiers, WKTypeRef userData, const void* clientInfo);
+
+    QQuickWebView* m_webView;
+    QUrl m_lastHoveredURL;
+    QString m_lastHoveredTitle;
+};
+
+#endif // QtWebPageUIClient_h
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to