Move GTK WebKit1 code to std::unique_ptr
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Mar 2014 10:00:48 +0000 (10:00 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Mar 2014 10:00:48 +0000 (10:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=129675

Reviewed by Anders Carlsson.

Replace uses of OwnPtr and PassOwnPtr in GTK-specific WebKit1 code with std::unique_ptr.

* WebCoreSupport/AcceleratedCompositingContext.h:
* WebCoreSupport/NavigatorContentUtilsClientGtk.cpp:
* WebCoreSupport/NavigatorContentUtilsClientGtk.h:
* webkit/webkitfavicondatabase.cpp:
(getIconPixbufCancelled):
(webkit_favicon_database_get_favicon_pixbuf):
* webkit/webkitwebview.cpp:
(webkit_web_view_init):
* webkit/webkitwebviewprivate.h:

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

Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h
Source/WebKit/gtk/WebCoreSupport/NavigatorContentUtilsClientGtk.cpp
Source/WebKit/gtk/WebCoreSupport/NavigatorContentUtilsClientGtk.h
Source/WebKit/gtk/webkit/webkitfavicondatabase.cpp
Source/WebKit/gtk/webkit/webkitwebview.cpp
Source/WebKit/gtk/webkit/webkitwebviewprivate.h

index 6bc7bca..271b496 100644 (file)
@@ -1,3 +1,22 @@
+2014-03-07  Zan Dobersek  <zdobersek@igalia.com>
+
+        Move GTK WebKit1 code to std::unique_ptr
+        https://bugs.webkit.org/show_bug.cgi?id=129675
+
+        Reviewed by Anders Carlsson.
+
+        Replace uses of OwnPtr and PassOwnPtr in GTK-specific WebKit1 code with std::unique_ptr.
+
+        * WebCoreSupport/AcceleratedCompositingContext.h:
+        * WebCoreSupport/NavigatorContentUtilsClientGtk.cpp:
+        * WebCoreSupport/NavigatorContentUtilsClientGtk.h:
+        * webkit/webkitfavicondatabase.cpp:
+        (getIconPixbufCancelled):
+        (webkit_favicon_database_get_favicon_pixbuf):
+        * webkit/webkitwebview.cpp:
+        (webkit_web_view_init):
+        * webkit/webkitwebviewprivate.h:
+
 2014-03-06  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Expose the console object in JSContexts to interact with Web Inspector
index f852151..058fcba 100644 (file)
@@ -43,12 +43,9 @@ namespace WebKit {
 class AcceleratedCompositingContext : public WebCore::GraphicsLayerClient {
     WTF_MAKE_NONCOPYABLE(AcceleratedCompositingContext);
 public:
-    static PassOwnPtr<AcceleratedCompositingContext> create(WebKitWebView* webView)
-    {
-        return adoptPtr(new AcceleratedCompositingContext(webView));
-    }
-
+    explicit AcceleratedCompositingContext(WebKitWebView*);
     virtual ~AcceleratedCompositingContext();
+
     void setRootCompositingLayer(WebCore::GraphicsLayer*);
     void setNonCompositedContentsNeedDisplay(const WebCore::IntRect&);
     void scheduleLayerFlush();
@@ -94,8 +91,6 @@ private:
     std::unique_ptr<WebCore::GraphicsLayer> m_rootGraphicsLayer;
     OwnPtr<WebCore::TextureMapper> m_textureMapper;
 #endif
-
-    AcceleratedCompositingContext(WebKitWebView*);
 };
 
 } // namespace WebKit
index e9ab050..8be29ab 100644 (file)
 
 namespace WebKit {
 
-PassOwnPtr<NavigatorContentUtilsClient> NavigatorContentUtilsClient::create()
-{
-    return adoptPtr(new NavigatorContentUtilsClient);
-}
-
-NavigatorContentUtilsClient::NavigatorContentUtilsClient()
-{
-}
-
 void NavigatorContentUtilsClient::registerProtocolHandler(const String& scheme, const URL& baseURL, const URL& url, const String& title)
 {
     notImplemented();
index 7d5b79f..480b025 100644 (file)
@@ -28,14 +28,7 @@ namespace WebKit {
 
 class NavigatorContentUtilsClient : public WebCore::NavigatorContentUtilsClient {
 public:
-    static PassOwnPtr<NavigatorContentUtilsClient> create();
-
-    ~NavigatorContentUtilsClient() { }
-
     virtual void registerProtocolHandler(const String& scheme, const URL& baseURL, const URL&, const String& title);
-
-private:
-    NavigatorContentUtilsClient();
 };
 
 }
index 1d9609e..e04a573 100644 (file)
@@ -184,7 +184,7 @@ static guint webkit_favicon_database_signals[LAST_SIGNAL] = { 0, };
 
 G_DEFINE_TYPE(WebKitFaviconDatabase, webkit_favicon_database, G_TYPE_OBJECT)
 
-typedef Vector<OwnPtr<PendingIconRequest> > PendingIconRequestVector;
+typedef Vector<std::unique_ptr<PendingIconRequest>> PendingIconRequestVector;
 typedef HashMap<String, PendingIconRequestVector*> PendingIconRequestMap;
 
 struct _WebKitFaviconDatabasePrivate {
@@ -470,9 +470,16 @@ static void getIconPixbufCancelled(void* userData)
     if (!icons)
         return;
 
-    size_t itemIndex = icons->find(request);
-    if (itemIndex != notFound)
-        icons->remove(itemIndex);
+    size_t itemIndex = 0;
+    for (auto& item : *icons) {
+        if (item.get() == request) {
+            icons->remove(itemIndex);
+            break;
+        }
+
+        itemIndex++;
+    }
+
     if (icons->isEmpty())
         webkitfavicondatabaseDeleteRequests(database, icons, pageURL);
 }
@@ -536,7 +543,7 @@ void webkit_favicon_database_get_favicon_pixbuf(WebKitFaviconDatabase* database,
     // Register icon request before asking for the icon to avoid race conditions.
     PendingIconRequestVector* icons = webkitFaviconDatabaseGetOrCreateRequests(database, pageURL);
     ASSERT(icons);
-    icons->append(adoptPtr(request));
+    icons->append(std::unique_ptr<PendingIconRequest>(request));
 
     // We ask for the icon directly. If we don't get the icon data now,
     // we'll be notified later (even if the database is still importing icons).
index 8035a3b..6301813 100644 (file)
@@ -3853,7 +3853,7 @@ static void webkit_web_view_init(WebKitWebView* webView)
 
 #if ENABLE(GEOLOCATION)
     if (DumpRenderTreeSupportGtk::dumpRenderTreeModeEnabled()) {
-        priv->geolocationClientMock = adoptPtr(new GeolocationClientMock);
+        priv->geolocationClientMock = std::make_unique<GeolocationClientMock>();
         WebCore::provideGeolocationTo(priv->corePage, priv->geolocationClientMock.get());
         priv->geolocationClientMock.get()->setController(GeolocationController::from(priv->corePage));
     } else
@@ -3865,12 +3865,12 @@ static void webkit_web_view_init(WebKitWebView* webView)
 #endif
 
 #if ENABLE(MEDIA_STREAM)
-    priv->userMediaClient = adoptPtr(new UserMediaClientGtk);
+    priv->userMediaClient = std::make_unique<UserMediaClientGtk>();
     WebCore::provideUserMediaTo(priv->corePage, priv->userMediaClient.get());
 #endif
 
 #if ENABLE(NAVIGATOR_CONTENT_UTILS)
-    priv->navigatorContentUtilsClient = WebKit::NavigatorContentUtilsClient::create();
+    priv->navigatorContentUtilsClient = std::make_unique<WebKit::NavigatorContentUtilsClient>();
     WebCore::provideNavigatorContentUtilsTo(priv->corePage, priv->navigatorContentUtilsClient.get());
 #endif
 
@@ -3925,7 +3925,7 @@ static void webkit_web_view_init(WebKitWebView* webView)
 #endif
 
     priv->selfScrolling = false;
-    priv->acceleratedCompositingContext = AcceleratedCompositingContext::create(webView);
+    priv->acceleratedCompositingContext = std::make_unique<AcceleratedCompositingContext>(webView);
 
     g_signal_connect(webView, "direction-changed", G_CALLBACK(webkitWebViewDirectionChanged), 0);
 }
index 6b9036c..ef9b64e 100644 (file)
@@ -32,6 +32,7 @@
 #include "ResourceResponse.h"
 #include "WebViewInputMethodFilter.h"
 #include "WidgetBackingStore.h"
+#include <memory>
 #include <webkit/webkitwebview.h>
 
 #if ENABLE(MEDIA_STREAM)
@@ -102,22 +103,22 @@ struct _WebKitWebViewPrivate {
     bool selfScrolling;
     GRefPtr<GtkTargetList> targetList;
 
-    OwnPtr<WebKit::AcceleratedCompositingContext> acceleratedCompositingContext;
+    std::unique_ptr<WebKit::AcceleratedCompositingContext> acceleratedCompositingContext;
 
 #if ENABLE(ICONDATABASE)
     gulong iconLoadedHandler;
 #endif
 
 #if ENABLE(MEDIA_STREAM)
-    OwnPtr<WebKit::UserMediaClientGtk> userMediaClient;
+    std::unique_ptr<WebKit::UserMediaClientGtk> userMediaClient;
 #endif
 
 #if ENABLE(GEOLOCATION)
-    OwnPtr<WebCore::GeolocationClientMock> geolocationClientMock;
+    std::unique_ptr<WebCore::GeolocationClientMock> geolocationClientMock;
 #endif
 
 #if ENABLE(NAVIGATOR_CONTENT_UTILS)
-    OwnPtr<WebKit::NavigatorContentUtilsClient> navigatorContentUtilsClient;
+    std::unique_ptr<WebKit::NavigatorContentUtilsClient> navigatorContentUtilsClient;
 #endif
 };