[Qt][WK2] Fold QtWebPageFindClient into QQuickWebViewPrivate
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2013 08:34:11 +0000 (08:34 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2013 08:34:11 +0000 (08:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108920

Reviewed by Jocelyn Turcotte, signed off for WK2 by Benjamin.

Employ the pattern suggested by Jocelyn to simply implement the C
callbacks directly using static functions.

* Target.pri:
* UIProcess/API/qt/qquickwebview.cpp:
(toQQuickWebViewPrivate):
(QQuickWebViewPrivate::initialize):
(QQuickWebViewPrivate::didFindString):
(QQuickWebViewPrivate::didFailToFindString):
* UIProcess/API/qt/qquickwebview_p_p.h:
(QQuickWebViewPrivate):
* UIProcess/qt/QtWebPageFindClient.cpp: Removed.
* UIProcess/qt/QtWebPageFindClient.h: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142073 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/QtWebPageFindClient.cpp [deleted file]
Source/WebKit2/UIProcess/qt/QtWebPageFindClient.h [deleted file]

index 935e483..76c58b0 100644 (file)
@@ -1,3 +1,24 @@
+2013-02-07  Simon Hausmann  <simon.hausmann@digia.com>
+
+        [Qt][WK2] Fold QtWebPageFindClient into QQuickWebViewPrivate
+        https://bugs.webkit.org/show_bug.cgi?id=108920
+
+        Reviewed by Jocelyn Turcotte, signed off for WK2 by Benjamin.
+
+        Employ the pattern suggested by Jocelyn to simply implement the C
+        callbacks directly using static functions.
+
+        * Target.pri:
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (toQQuickWebViewPrivate):
+        (QQuickWebViewPrivate::initialize):
+        (QQuickWebViewPrivate::didFindString):
+        (QQuickWebViewPrivate::didFailToFindString):
+        * UIProcess/API/qt/qquickwebview_p_p.h:
+        (QQuickWebViewPrivate):
+        * UIProcess/qt/QtWebPageFindClient.cpp: Removed.
+        * UIProcess/qt/QtWebPageFindClient.h: Removed.
+
 2013-02-03  Sam Weinig  <sam@webkit.org>
 
         Make CustomProtocolManagerProxy a MessageReceiver
index c6e3162..6a55f4f 100644 (file)
@@ -785,7 +785,6 @@ have?(QTQUICK) {
         UIProcess/qt/QtDialogRunner.h \
         UIProcess/qt/QtDownloadManager.h \
         UIProcess/qt/QtPageClient.h \
-        UIProcess/qt/QtWebPageFindClient.h \
         UIProcess/qt/QtWebPageLoadClient.h \
         UIProcess/qt/QtWebPagePolicyClient.h \
         UIProcess/qt/QtWebPageSGNode.h \
@@ -813,7 +812,6 @@ have?(QTQUICK) {
         UIProcess/qt/QtDialogRunner.cpp \
         UIProcess/qt/QtDownloadManager.cpp \
         UIProcess/qt/QtPageClient.cpp \
-        UIProcess/qt/QtWebPageFindClient.cpp \
         UIProcess/qt/QtWebPageLoadClient.cpp \
         UIProcess/qt/QtWebPagePolicyClient.cpp \
         UIProcess/qt/QtWebPageSGNode.cpp \
index f1f13cb..77e5e23 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
  * Copyright (c) 2012 Hewlett-Packard Development Company, L.P.
+ * Copyright (C) 2013 Digia Plc 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
@@ -31,7 +32,6 @@
 #include "QtWebError.h"
 #include "QtWebIconDatabaseClient.h"
 #include "QtWebPageEventHandler.h"
-#include "QtWebPageFindClient.h"
 #include "QtWebPageLoadClient.h"
 #include "QtWebPagePolicyClient.h"
 #include "WebBackForwardList.h"
@@ -86,6 +86,12 @@ static const int kAxisLockSampleCount = 5;
 static const qreal kAxisLockVelocityThreshold = 300;
 static const qreal kAxisLockVelocityDirectionThreshold = 50;
 
+static inline QQuickWebViewPrivate* toQQuickWebViewPrivate(const void* clientInfo)
+{
+    ASSERT(clientInfo);
+    return reinterpret_cast<QQuickWebViewPrivate*>(const_cast<void*>(clientInfo));
+}
+
 struct JSCallbackClosure {
     QPointer<QObject> receiver;
     QByteArray method;
@@ -314,7 +320,16 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa
     QQuickWebPagePrivate* const pageViewPrivate = pageView.data()->d;
     pageViewPrivate->initialize(webPageProxy.get());
 
-    pageFindClient.reset(new QtWebPageFindClient(webPage.get(), q_ptr));
+    {
+        WKPageFindClient findClient;
+        memset(&findClient, 0, sizeof(WKPageFindClient));
+        findClient.version = kWKPageFindClientCurrentVersion;
+        findClient.clientInfo = this;
+        findClient.didFindString = didFindString;
+        findClient.didFailToFindString = didFailToFindString;
+        WKPageSetPageFindClient(webPage.get(), &findClient);
+    }
+
     pageLoadClient.reset(new QtWebPageLoadClient(webPage.get(), q_ptr));
     pagePolicyClient.reset(new QtWebPagePolicyClient(webPage.get(), q_ptr));
     pageUIClient.reset(new QtWebPageUIClient(webPage.get(), q_ptr));
@@ -2073,12 +2088,17 @@ void QQuickWebView::setAllowAnyHTTPSCertificateForLocalHost(bool allow)
     d->m_allowAnyHTTPSCertificateForLocalHost = allow;
 }
 
-void QQuickWebViewPrivate::didFindString(unsigned matchCount)
+void QQuickWebViewPrivate::didFindString(WKPageRef, WKStringRef, unsigned matchCount, const void* clientInfo)
 {
-    Q_Q(QQuickWebView);
+    QQuickWebView* q = toQQuickWebViewPrivate(clientInfo)->q_ptr;
     emit q->experimental()->textFound(matchCount);
 }
 
+void QQuickWebViewPrivate::didFailToFindString(WKPageRef page, WKStringRef string, const void* clientInfo)
+{
+    QQuickWebViewPrivate::didFindString(page, string, 0, clientInfo);
+}
+
 /*!
     \qmlsignal WebView::onLoadingChanged(loadRequest)
 
index 21efdae..a3c94fa 100644 (file)
@@ -85,7 +85,8 @@ public:
     virtual void loadDidFail(const WebKit::QtWebError& error);
     virtual void handleMouseEvent(QMouseEvent*);
 
-    void didFindString(unsigned matchCount);
+    static void didFindString(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo);
+    static void didFailToFindString(WKPageRef page, WKStringRef string, const void* clientInfo);
 
     virtual void didChangeViewportProperties(const WebCore::ViewportAttributes& attr) { }
 
@@ -171,7 +172,6 @@ protected:
     OwnPtr<QWebPreferences> preferences;
 
     QScopedPointer<WebKit::QtWebPageLoadClient> pageLoadClient;
-    QScopedPointer<WebKit::QtWebPageFindClient> pageFindClient;
     QScopedPointer<WebKit::QtWebPagePolicyClient> pagePolicyClient;
     QScopedPointer<WebKit::QtWebPageUIClient> pageUIClient;
 
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageFindClient.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageFindClient.cpp
deleted file mode 100644 (file)
index 85e1e68..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2012 Hewlett-Packard Development Company, L.P.
- *
- * 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 "QtWebPageFindClient.h"
-
-#include "qquickwebview_p_p.h"
-
-using namespace WebCore;
-
-namespace WebKit {
-
-QtWebPageFindClient::QtWebPageFindClient(WKPageRef pageRef, QQuickWebView* webView)
-    : m_webView(webView)
-{
-    WKPageFindClient findClient;
-    memset(&findClient, 0, sizeof(WKPageFindClient));
-    findClient.version = kWKPageFindClientCurrentVersion;
-    findClient.clientInfo = this;
-    findClient.didFindString = didFindString;
-    findClient.didFailToFindString = didFailToFindString;
-    WKPageSetPageFindClient(pageRef, &findClient);
-}
-
-void QtWebPageFindClient::didFindString(unsigned matchCount)
-{
-    m_webView->d_func()->didFindString(matchCount);
-}
-
-static QtWebPageFindClient* toQtWebPageFindClient(const void* clientInfo)
-{
-    ASSERT(clientInfo);
-    return reinterpret_cast<QtWebPageFindClient*>(const_cast<void*>(clientInfo));
-}
-
-void QtWebPageFindClient::didFindString(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo)
-{
-    toQtWebPageFindClient(clientInfo)->didFindString(matchCount);
-}
-
-void QtWebPageFindClient::didFailToFindString(WKPageRef page, WKStringRef string, const void* clientInfo)
-{
-    toQtWebPageFindClient(clientInfo)->didFindString(0);
-}
-
-} // namespace Webkit
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageFindClient.h b/Source/WebKit2/UIProcess/qt/QtWebPageFindClient.h
deleted file mode 100644 (file)
index 55c0272..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2012 Hewlett-Packard Development Company, L.P.
- *
- * 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 QtWebPageFindClient_h
-#define QtWebPageFindClient_h
-
-#include <WKPage.h>
-#include <wtf/text/WTFString.h>
-
-class QQuickWebView;
-
-namespace WebKit {
-
-class QtWebPageFindClient {
-public:
-    QtWebPageFindClient(WKPageRef, QQuickWebView*);
-
-private:
-
-    void didFindString(unsigned matchCount);
-
-    // WKPageFindClient callbacks.
-    static void didFindString(WKPageRef, WKStringRef, unsigned matchCount, const void* clientInfo);
-    static void didFailToFindString(WKPageRef, WKStringRef, const void* clientInfo);
-
-    QQuickWebView* m_webView;
-};
-
-} // namespace Webkit
-
-#endif // QtWebPageFindClient_h