Title: [145518] trunk/Source/WebKit2
Revision
145518
Author
[email protected]
Date
2013-03-12 04:17:19 -0700 (Tue, 12 Mar 2013)

Log Message

[Qt][WK2] Layer QtWebIconDatabaseClient on the C API
https://bugs.webkit.org/show_bug.cgi?id=109564

Reviewed by Simon Hausmann.
Signed off for WebKit2 by Benjamin Poulain.

* Target.pri:
* UIProcess/API/C/qt/WKIconDatabaseQt.cpp: Added.
(WKIconDatabaseTryGetQImageForURL):
  - New API added to get a QImage from the IconDatabase.
    Based on WKIconDatabaseCG.h/cpp
* UIProcess/API/C/qt/WKIconDatabaseQt.h: Added.
* UIProcess/API/cpp/qt/WKURLQt.cpp:
(WKURLCreateWithQString):
(WKURLCopyQString):
(WKURLCreateWithQUrl):
(WKURLCopyQUrl):
  - The WKUrlRef behind the scene is a WTF::String and encoding it back and forth to
    a QUrl can slightly change its string representation. Allow converting a WKUrlRef
    to and from a QString to ensure this.
* UIProcess/API/cpp/qt/WKURLQt.h:
* UIProcess/API/qt/qwebiconimageprovider.cpp:
(QWebIconImageProvider::iconURLForPageURLInContext):
  - The icon URL isn't accessible form the C API and shouldn't need to be.
    Use an ID incremented on each update to trigger an update of the QML Image component.
(QWebIconImageProvider::requestImage):
  - The IconDatabase was previously assumed to resize the image to the requested size,
    but this parameter is ignored, as stated in a comment in WebIconDatabase::imageForPageURL.
    Explicitely do the resize after fetching the original icon to also be able to report
    the original size properly to QtQuick.
* UIProcess/API/qt/qwebiconimageprovider_p.h:
* UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml:
  - Set the image to load asynchronously to further test the possibility of threading issues
    in QtWebIconDatabaseClient::iconImageForPageURL
  - Add a few barriers to fix some issues where the load succeeded signal would be wrongly
    catched by init() before the next test.
* UIProcess/qt/QtWebContext.cpp:
(WebKit::QtWebContext::QtWebContext):
* UIProcess/qt/QtWebIconDatabaseClient.cpp:
(WebKit):
(WebKit::QtWebIconDatabaseClient::QtWebIconDatabaseClient):
(WebKit::QtWebIconDatabaseClient::~QtWebIconDatabaseClient):
(WebKit::QtWebIconDatabaseClient::updateID):
(WebKit::QtWebIconDatabaseClient::didChangeIconForPageURL):
(WebKit::QtWebIconDatabaseClient::iconImageForPageURL):
  - Remove the Mutex. This mutex was useless given that it would only
    be locked from a single thread. Since the IconDatabase runs in its own thread,
    it already is thread-safe to access.
(WebKit::QtWebIconDatabaseClient::retainIconForPageURL):
(WebKit::QtWebIconDatabaseClient::releaseIconForPageURL):
* UIProcess/qt/QtWebIconDatabaseClient.h:
(QtWebIconDatabaseClient):
* WebKit2.pri:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (145517 => 145518)


--- trunk/Source/WebKit2/ChangeLog	2013-03-12 11:16:01 UTC (rev 145517)
+++ trunk/Source/WebKit2/ChangeLog	2013-03-12 11:17:19 UTC (rev 145518)
@@ -1,5 +1,61 @@
 2013-03-11  Jocelyn Turcotte  <[email protected]>
 
+        [Qt][WK2] Layer QtWebIconDatabaseClient on the C API
+        https://bugs.webkit.org/show_bug.cgi?id=109564
+
+        Reviewed by Simon Hausmann.
+        Signed off for WebKit2 by Benjamin Poulain.
+
+        * Target.pri:
+        * UIProcess/API/C/qt/WKIconDatabaseQt.cpp: Added.
+        (WKIconDatabaseTryGetQImageForURL):
+          - New API added to get a QImage from the IconDatabase.
+            Based on WKIconDatabaseCG.h/cpp
+        * UIProcess/API/C/qt/WKIconDatabaseQt.h: Added.
+        * UIProcess/API/cpp/qt/WKURLQt.cpp:
+        (WKURLCreateWithQString):
+        (WKURLCopyQString):
+        (WKURLCreateWithQUrl):
+        (WKURLCopyQUrl):
+          - The WKUrlRef behind the scene is a WTF::String and encoding it back and forth to
+            a QUrl can slightly change its string representation. Allow converting a WKUrlRef
+            to and from a QString to ensure this.
+        * UIProcess/API/cpp/qt/WKURLQt.h:
+        * UIProcess/API/qt/qwebiconimageprovider.cpp:
+        (QWebIconImageProvider::iconURLForPageURLInContext):
+          - The icon URL isn't accessible form the C API and shouldn't need to be.
+            Use an ID incremented on each update to trigger an update of the QML Image component.
+        (QWebIconImageProvider::requestImage):
+          - The IconDatabase was previously assumed to resize the image to the requested size,
+            but this parameter is ignored, as stated in a comment in WebIconDatabase::imageForPageURL.
+            Explicitely do the resize after fetching the original icon to also be able to report
+            the original size properly to QtQuick.
+        * UIProcess/API/qt/qwebiconimageprovider_p.h:
+        * UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml:
+          - Set the image to load asynchronously to further test the possibility of threading issues
+            in QtWebIconDatabaseClient::iconImageForPageURL
+          - Add a few barriers to fix some issues where the load succeeded signal would be wrongly
+            catched by init() before the next test.
+        * UIProcess/qt/QtWebContext.cpp:
+        (WebKit::QtWebContext::QtWebContext):
+        * UIProcess/qt/QtWebIconDatabaseClient.cpp:
+        (WebKit):
+        (WebKit::QtWebIconDatabaseClient::QtWebIconDatabaseClient):
+        (WebKit::QtWebIconDatabaseClient::~QtWebIconDatabaseClient):
+        (WebKit::QtWebIconDatabaseClient::updateID):
+        (WebKit::QtWebIconDatabaseClient::didChangeIconForPageURL):
+        (WebKit::QtWebIconDatabaseClient::iconImageForPageURL):
+          - Remove the Mutex. This mutex was useless given that it would only
+            be locked from a single thread. Since the IconDatabase runs in its own thread,
+            it already is thread-safe to access.
+        (WebKit::QtWebIconDatabaseClient::retainIconForPageURL):
+        (WebKit::QtWebIconDatabaseClient::releaseIconForPageURL):
+        * UIProcess/qt/QtWebIconDatabaseClient.h:
+        (QtWebIconDatabaseClient):
+        * WebKit2.pri:
+
+2013-03-11  Jocelyn Turcotte  <[email protected]>
+
         [Qt][WK2] Specify storage paths through the C API
         https://bugs.webkit.org/show_bug.cgi?id=111435
 

Modified: trunk/Source/WebKit2/Target.pri (145517 => 145518)


--- trunk/Source/WebKit2/Target.pri	2013-03-12 11:16:01 UTC (rev 145517)
+++ trunk/Source/WebKit2/Target.pri	2013-03-12 11:17:19 UTC (rev 145518)
@@ -194,6 +194,7 @@
     UIProcess/API/C/WKVibration.h \
     UIProcess/API/C/WebKit2_C.h \
     UIProcess/API/C/qt/WKNativeEvent.h \
+    UIProcess/API/C/qt/WKIconDatabaseQt.h \
     UIProcess/API/cpp/WKRetainPtr.h \
     UIProcess/API/cpp/qt/WKStringQt.h \
     UIProcess/API/cpp/qt/WKURLQt.h \
@@ -544,6 +545,7 @@
     UIProcess/API/C/WKResourceCacheManager.cpp \
     UIProcess/API/C/WKTextChecker.cpp \
     UIProcess/API/C/WKVibration.cpp \
+    UIProcess/API/C/qt/WKIconDatabaseQt.cpp \
     UIProcess/API/cpp/qt/WKStringQt.cpp \
     UIProcess/API/cpp/qt/WKURLQt.cpp \
     UIProcess/API/qt/raw/qrawwebview.cpp \

Added: trunk/Source/WebKit2/UIProcess/API/C/qt/WKIconDatabaseQt.cpp (0 => 145518)


--- trunk/Source/WebKit2/UIProcess/API/C/qt/WKIconDatabaseQt.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/C/qt/WKIconDatabaseQt.cpp	2013-03-12 11:17:19 UTC (rev 145518)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTAwBILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WKIconDatabaseQt.h"
+
+#include "WKAPICast.h"
+#include "WKSharedAPICast.h"
+#include "WebIconDatabase.h"
+#include <QPixmap>
+
+using namespace WebKit;
+using namespace WebCore;
+
+QImage WKIconDatabaseTryGetQImageForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef)
+{
+    QPixmap* pixmap = toImpl(iconDatabaseRef)->nativeImageForPageURL(toWTFString(urlRef));
+    return pixmap ? pixmap->toImage() : QImage();
+}

Added: trunk/Source/WebKit2/UIProcess/API/C/qt/WKIconDatabaseQt.h (0 => 145518)


--- trunk/Source/WebKit2/UIProcess/API/C/qt/WKIconDatabaseQt.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/C/qt/WKIconDatabaseQt.h	2013-03-12 11:17:19 UTC (rev 145518)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WKIconDatabaseQt_h
+#define WKIconDatabaseQt_h
+
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKGeometry.h>
+
+QT_BEGIN_NAMESPACE
+class QImage;
+QT_END_NAMESPACE
+
+WK_EXPORT QImage WKIconDatabaseTryGetQImageForURL(WKIconDatabaseRef iconDatabase, WKURLRef url);
+
+#endif /* WKIconDatabaseQt_h */

Modified: trunk/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.cpp (145517 => 145518)


--- trunk/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.cpp	2013-03-12 11:16:01 UTC (rev 145517)
+++ trunk/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.cpp	2013-03-12 11:17:19 UTC (rev 145518)
@@ -28,16 +28,26 @@
 
 using namespace WebKit;
 
-WKURLRef WKURLCreateWithQUrl(const QUrl& qURL)
+WKURLRef WKURLCreateWithQString(const QString& url)
 {
-    WTF::String urlString(qURL.toString());
-    return toCopiedURLAPI(urlString);
+    return toCopiedURLAPI(url);
 }
 
+QString WKURLCopyQString(WKURLRef urlRef)
+{
+    if (!urlRef)
+        return QString();
+    return toImpl(urlRef)->string();
+}
+
+WKURLRef WKURLCreateWithQUrl(const QUrl& url)
+{
+    return WKURLCreateWithQString(url.toString(QUrl::FullyEncoded));
+}
+
 QUrl WKURLCopyQUrl(WKURLRef urlRef)
 {
     if (!urlRef)
         return QUrl();
-    const WTF::String& string = toImpl(urlRef)->string();
-    return QUrl(QString(reinterpret_cast<const QChar*>(string.characters()), string.length()));
+    return QUrl(WKURLCopyQString(urlRef));
 }

Modified: trunk/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h (145517 => 145518)


--- trunk/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h	2013-03-12 11:16:01 UTC (rev 145517)
+++ trunk/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h	2013-03-12 11:17:19 UTC (rev 145518)
@@ -25,7 +25,10 @@
 #include <WebKit2/WKBase.h>
 #include <WebKit2/WKURL.h>
 
+WK_EXPORT WKURLRef WKURLCreateWithQString(const QString& url);
+WK_EXPORT QString WKURLCopyQString(WKURLRef url);
+
 WK_EXPORT WKURLRef WKURLCreateWithQUrl(const QUrl& url);
-QUrl WKURLCopyQUrl(WKURLRef url);
+WK_EXPORT QUrl WKURLCopyQUrl(WKURLRef url);
 
 #endif /* WKURLCF_h */

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp (145517 => 145518)


--- trunk/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp	2013-03-12 11:16:01 UTC (rev 145517)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp	2013-03-12 11:17:19 UTC (rev 145518)
@@ -24,8 +24,6 @@
 #include "QtWebIconDatabaseClient.h"
 #include <QtCore/QUrl>
 #include <QtGui/QImage>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
 
 using namespace WebKit;
 
@@ -41,16 +39,17 @@
 QUrl QWebIconImageProvider::iconURLForPageURLInContext(const QString &pageURL, QtWebContext* context)
 {
     QtWebIconDatabaseClient* iconDatabase = context->iconDatabase();
-    QUrl iconURL = iconDatabase->iconForPageURL(pageURL);
 
-    if (iconURL.isEmpty())
+    // Verify that the image data is actually available before reporting back
+    // a url, since clients assume that the url can be used directly.
+    if (iconDatabase->iconImageForPageURL(pageURL).isNull())
         return QUrl();
 
     QUrl url;
     url.setScheme(QStringLiteral("image"));
     url.setHost(QWebIconImageProvider::identifier());
-    // Make sure that QML doesn't show cached versions of the previous icon if the icon location changed.
-    url.setPath(QLatin1Char('/') + QString::number(WTF::StringHash::hash(iconURL.toString())));
+    // Make sure that QML doesn't show a cached previous version of the icon after it changed.
+    url.setPath(QStringLiteral("/%1").arg(QtWebIconDatabaseClient::updateID()));
 
     // FIXME: Use QUrl::DecodedMode when landed in Qt
     url.setFragment(QString::fromLatin1(pageURL.toUtf8().toBase64()));
@@ -68,14 +67,16 @@
     QString pageURL = QString::fromUtf8(QByteArray::fromBase64(id.midRef(id.indexOf('#') + 1).toLatin1()));
 
     QtWebIconDatabaseClient* iconDatabase = QtWebContext::defaultContext()->iconDatabase();
-    if (!iconDatabase)
-        return QImage();
+    Q_ASSERT(iconDatabase);
 
-    QImage icon = requestedSize.isValid() ? iconDatabase->iconImageForPageURL(pageURL, requestedSize) : iconDatabase->iconImageForPageURL(pageURL);
-    ASSERT(!icon.isNull());
+    QImage icon = iconDatabase->iconImageForPageURL(pageURL);
+    Q_ASSERT(!icon.isNull());
 
     if (size)
         *size = icon.size();
 
+    if (requestedSize.isValid())
+        return icon.scaled(requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+
     return icon;
 }

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider_p.h (145517 => 145518)


--- trunk/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider_p.h	2013-03-12 11:16:01 UTC (rev 145517)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider_p.h	2013-03-12 11:17:19 UTC (rev 145518)
@@ -23,7 +23,6 @@
 #include "qwebkitglobal.h"
 #include <QString>
 #include <QtQuick/QQuickImageProvider>
-#include <wtf/text/WTFString.h>
 
 namespace WebKit {
     class QtWebContext;

Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml (145517 => 145518)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml	2013-03-12 11:16:01 UTC (rev 145517)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml	2013-03-12 11:17:19 UTC (rev 145518)
@@ -14,6 +14,7 @@
 
     Image {
         id: favicon
+        asynchronous: true
         source: webView.icon
     }
 
@@ -26,8 +27,8 @@
             if (webView.icon != '') {
                 // If this is not the first test, then load a blank page without favicon, restoring the initial state.
                 webView.url = ''
+                verify(webView.waitForLoadSucceeded())
                 spy.wait()
-                verify(webView.waitForLoadSucceeded())
             }
             spy.clear()
         }
@@ -36,6 +37,7 @@
             compare(spy.count, 0)
             var url = ""
             webView.url = ""
+            verify(webView.waitForLoadSucceeded())
             spy.wait()
             compare(spy.count, 1)
             compare(favicon.width, 48)
@@ -46,6 +48,7 @@
             compare(spy.count, 0)
             var url = "" should work with#whitespace!")
             webView.url = ""
+            verify(webView.waitForLoadSucceeded())
             spy.wait()
             compare(spy.count, 1)
             compare(favicon.width, 16)

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebContext.cpp (145517 => 145518)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebContext.cpp	2013-03-12 11:16:01 UTC (rev 145517)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebContext.cpp	2013-03-12 11:17:19 UTC (rev 145518)
@@ -118,7 +118,7 @@
 QtWebContext::QtWebContext(WKContextRef context)
     : m_context(context)
     , m_downloadManager(new QtDownloadManager(toImpl(context)))
-    , m_iconDatabase(new QtWebIconDatabaseClient(toImpl(context)))
+    , m_iconDatabase(new QtWebIconDatabaseClient(context))
 {
 }
 

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp (145517 => 145518)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp	2013-03-12 11:16:01 UTC (rev 145517)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp	2013-03-12 11:17:19 UTC (rev 145518)
@@ -20,93 +20,73 @@
 #include "config.h"
 #include "QtWebIconDatabaseClient.h"
 
-#include "Image.h"
-#include "KURL.h"
 #include "QtWebContext.h"
-#include "SharedBuffer.h"
-#include "WKURLQt.h"
-#include "WebContext.h"
-#include "WebIconDatabase.h"
 #include <QtCore/QHash>
 #include <QtCore/QObject>
 #include <QtCore/QUrl>
 #include <QtGui/QImage>
+#include <WKContext.h>
 #include <WKContextPrivate.h>
+#include <WKIconDatabaseQt.h>
 #include <WKRetainPtr.h>
 #include <WKStringQt.h>
+#include <WKURLQt.h>
 
 namespace WebKit {
 
+static unsigned s_updateId = 0;
+
 static inline QtWebIconDatabaseClient* toQtWebIconDatabaseClient(const void* clientInfo)
 {
     ASSERT(clientInfo);
     return reinterpret_cast<QtWebIconDatabaseClient*>(const_cast<void*>(clientInfo));
 }
 
-QtWebIconDatabaseClient::QtWebIconDatabaseClient(WebContext *context)
+QtWebIconDatabaseClient::QtWebIconDatabaseClient(WKContextRef context)
 {
-    m_iconDatabase = context->iconDatabase();
+    m_iconDatabase = WKContextGetIconDatabase(context);
 
     WKIconDatabaseClient iconDatabaseClient;
     memset(&iconDatabaseClient, 0, sizeof(WKIconDatabaseClient));
     iconDatabaseClient.version = kWKIconDatabaseClientCurrentVersion;
     iconDatabaseClient.clientInfo = this;
     iconDatabaseClient.didChangeIconForPageURL = didChangeIconForPageURL;
-    WKIconDatabaseSetIconDatabaseClient(toAPI(m_iconDatabase.get()), &iconDatabaseClient);
+    WKIconDatabaseSetIconDatabaseClient(m_iconDatabase, &iconDatabaseClient);
     // Triggers the startup of the icon database.
     WKRetainPtr<WKStringRef> path = adoptWK(WKStringCreateWithQString(QtWebContext::preparedStoragePath(QtWebContext::IconDatabaseStorage)));
-    WKContextSetIconDatabasePath(toAPI(context), path.get());
+    WKContextSetIconDatabasePath(context, path.get());
 }
 
 QtWebIconDatabaseClient::~QtWebIconDatabaseClient()
 {
-    m_iconDatabase->close();
-    WKIconDatabaseSetIconDatabaseClient(toAPI(m_iconDatabase.get()), 0);
+    WKIconDatabaseClose(m_iconDatabase);
+    WKIconDatabaseSetIconDatabaseClient(m_iconDatabase, 0);
 }
 
-void QtWebIconDatabaseClient::didChangeIconForPageURL(WKIconDatabaseRef, WKURLRef pageURL, const void* clientInfo)
+unsigned QtWebIconDatabaseClient::updateID()
 {
-    emit toQtWebIconDatabaseClient(clientInfo)->iconChangedForPageURL(toImpl(pageURL)->string());
+    return s_updateId;
 }
 
-QUrl QtWebIconDatabaseClient::iconForPageURL(const QString& pageURL)
+void QtWebIconDatabaseClient::didChangeIconForPageURL(WKIconDatabaseRef, WKURLRef pageURL, const void* clientInfo)
 {
-    String iconURL;
-    m_iconDatabase->synchronousIconURLForPageURL(pageURL, iconURL);
-
-    if (iconURL.isEmpty())
-        return QUrl();
-
-    // Verify that the image data is actually available before reporting back
-    // a url, since clients assume that the url can be used directly.
-    WebCore::Image* iconImage = m_iconDatabase->imageForPageURL(pageURL);
-    if (!iconImage || iconImage->isNull())
-        return QUrl();
-
-    return QUrl(iconURL);
+    ++s_updateId;
+    emit toQtWebIconDatabaseClient(clientInfo)->iconChangedForPageURL(WKURLCopyQString(pageURL));
 }
 
-QImage QtWebIconDatabaseClient::iconImageForPageURL(const QString& pageURL, const QSize& iconSize)
+QImage QtWebIconDatabaseClient::iconImageForPageURL(const QString& pageURL)
 {
-    MutexLocker locker(m_imageLock);
-
-    WebCore::IntSize size(iconSize.width(), iconSize.height());
-
-    QPixmap* nativeImage = m_iconDatabase->nativeImageForPageURL(pageURL, size);
-    if (!nativeImage)
-        return QImage();
-
-    return nativeImage->toImage();
+    return WKIconDatabaseTryGetQImageForURL(m_iconDatabase, adoptWK(WKURLCreateWithQString(pageURL)).get());
 }
 
 void QtWebIconDatabaseClient::retainIconForPageURL(const QString& pageURL)
 {
-    m_iconDatabase->retainIconForPageURL(pageURL);
+    WKIconDatabaseRetainIconForURL(m_iconDatabase, adoptWK(WKURLCreateWithQString(pageURL)).get());
 }
 
 void QtWebIconDatabaseClient::releaseIconForPageURL(const QString& pageURL)
 {
-    m_iconDatabase->releaseIconForPageURL(pageURL);
+    WKIconDatabaseReleaseIconForURL(m_iconDatabase, adoptWK(WKURLCreateWithQString(pageURL)).get());
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.h (145517 => 145518)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.h	2013-03-12 11:16:01 UTC (rev 145517)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.h	2013-03-12 11:17:19 UTC (rev 145518)
@@ -21,12 +21,9 @@
 #ifndef QtWebIconDatabaseClient_h
 #define QtWebIconDatabaseClient_h
 
-#include "WKIconDatabase.h"
 #include "qwebkitglobal.h"
 #include <QtCore/QObject>
-#include <QtCore/QSize>
-#include <wtf/RefPtr.h>
-#include <wtf/Threading.h>
+#include <WKIconDatabase.h>
 
 QT_BEGIN_NAMESPACE
 class QImage;
@@ -35,29 +32,26 @@
 
 namespace WebKit {
 
-class WebContext;
-class WebIconDatabase;
-
 class QtWebIconDatabaseClient : public QObject {
     Q_OBJECT
 
 public:
-    QtWebIconDatabaseClient(WebContext*);
+    QtWebIconDatabaseClient(WKContextRef);
     ~QtWebIconDatabaseClient();
 
-    QUrl iconForPageURL(const QString& pageURL);
-    QImage iconImageForPageURL(const QString& pageURL, const QSize& iconSize = QSize(32, 32));
+    QImage iconImageForPageURL(const QString&);
 
     void retainIconForPageURL(const QString&);
     void releaseIconForPageURL(const QString&);
 
+    static unsigned updateID();
+
 public:
     Q_SIGNAL void iconChangedForPageURL(const QString& pageURL);
 
 private:
     static void didChangeIconForPageURL(WKIconDatabaseRef, WKURLRef pageURL, const void* clientInfo);
-    RefPtr<WebKit::WebIconDatabase> m_iconDatabase;
-    Mutex m_imageLock;
+    WKIconDatabaseRef m_iconDatabase;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebKit2.pri (145517 => 145518)


--- trunk/Source/WebKit2/WebKit2.pri	2013-03-12 11:16:01 UTC (rev 145517)
+++ trunk/Source/WebKit2/WebKit2.pri	2013-03-12 11:17:19 UTC (rev 145518)
@@ -28,6 +28,7 @@
     $$SOURCE_DIR/Shared/qt \
     $$SOURCE_DIR/UIProcess \
     $$SOURCE_DIR/UIProcess/API/C \
+    $$SOURCE_DIR/UIProcess/API/C/qt \
     $$SOURCE_DIR/UIProcess/API/cpp \
     $$SOURCE_DIR/UIProcess/API/cpp/qt \
     $$SOURCE_DIR/UIProcess/API/qt \
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to