2010-05-12 Martin Robinson <mrobinson@igalia.com>
authormrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 May 2010 17:11:57 +0000 (17:11 +0000)
committermrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 May 2010 17:11:57 +0000 (17:11 +0000)
        Reviewed by Xan Lopez.

        [Gtk] Use GOwnPtr for code that needs it
        https://bugs.webkit.org/show_bug.cgi?id=21594

        Convert many uses of raw pointers to GRefPtr and GOwnPtr in WebKitWebView.

        * WebCoreSupport/ContextMenuClientGtk.cpp:
        (WebKit::inputMethodsMenuItem):
        * WebCoreSupport/EditorClientGtk.cpp:
        (WebKit::EditorClient::setInputMethodState):
        (WebKit::EditorClient::respondToChangedSelection):
        (WebKit::EditorClient::handleInputMethodKeydown):
        (WebKit::EditorClient::EditorClient):
        (WebKit::EditorClient::~EditorClient):
        * WebCoreSupport/FrameLoaderClientGtk.cpp:
        (WebKit::postCommitFrameViewSetup):
        * webkit/webkitprivate.h:
        * webkit/webkitwebview.cpp:
        (destroy_menu_cb):
        (webkit_web_view_forward_context_menu_event):
        (webkit_web_view_key_release_event):
        (webkit_web_view_button_release_event):
        (webkit_web_view_focus_in_event):
        (webkit_web_view_focus_out_event):
        (webkit_web_view_realize):
        (webkit_web_view_set_scroll_adjustments):
        (webkit_web_view_dispose):
        (webkit_web_view_finalize):
        (webViewGetDPI):
        (webkit_web_view_screen_changed):
        (webkit_web_view_query_tooltip):
        (webkit_web_view_get_im_context):
        (webkit_web_view_update_settings):
        (webkit_web_view_init):
        (webkit_web_view_set_settings):
        (webkit_web_view_get_settings):
        (webkit_web_view_get_inspector):
        (webkit_web_view_set_window_features):
        (webkit_web_view_get_window_features):
        (webkit_web_view_get_back_forward_list):
        (webkit_web_view_zoom_in):
        (webkit_web_view_zoom_out):
        (webkit_web_view_get_encoding):
        (webkit_web_view_get_custom_encoding):
        (webkit_web_view_add_resource):
        (webkit_web_view_get_resource):
        (webkit_web_view_get_main_resource):
        (webkit_web_view_clear_resources):
        (webkit_web_view_get_subresources):
        (webkit_web_view_set_tooltip_text):
        (webkit_web_view_get_icon_uri):

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

WebKit/gtk/ChangeLog
WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp
WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
WebKit/gtk/webkit/webkitprivate.h
WebKit/gtk/webkit/webkitwebview.cpp

index 3bf241d..e166b52 100644 (file)
@@ -1,3 +1,58 @@
+2010-05-12  Martin Robinson  <mrobinson@igalia.com>
+
+        Reviewed by Xan Lopez.
+
+        [Gtk] Use GOwnPtr for code that needs it
+        https://bugs.webkit.org/show_bug.cgi?id=21594
+
+        Convert many uses of raw pointers to GRefPtr and GOwnPtr in WebKitWebView.
+
+        * WebCoreSupport/ContextMenuClientGtk.cpp:
+        (WebKit::inputMethodsMenuItem):
+        * WebCoreSupport/EditorClientGtk.cpp:
+        (WebKit::EditorClient::setInputMethodState):
+        (WebKit::EditorClient::respondToChangedSelection):
+        (WebKit::EditorClient::handleInputMethodKeydown):
+        (WebKit::EditorClient::EditorClient):
+        (WebKit::EditorClient::~EditorClient):
+        * WebCoreSupport/FrameLoaderClientGtk.cpp:
+        (WebKit::postCommitFrameViewSetup):
+        * webkit/webkitprivate.h:
+        * webkit/webkitwebview.cpp:
+        (destroy_menu_cb):
+        (webkit_web_view_forward_context_menu_event):
+        (webkit_web_view_key_release_event):
+        (webkit_web_view_button_release_event):
+        (webkit_web_view_focus_in_event):
+        (webkit_web_view_focus_out_event):
+        (webkit_web_view_realize):
+        (webkit_web_view_set_scroll_adjustments):
+        (webkit_web_view_dispose):
+        (webkit_web_view_finalize):
+        (webViewGetDPI):
+        (webkit_web_view_screen_changed):
+        (webkit_web_view_query_tooltip):
+        (webkit_web_view_get_im_context):
+        (webkit_web_view_update_settings):
+        (webkit_web_view_init):
+        (webkit_web_view_set_settings):
+        (webkit_web_view_get_settings):
+        (webkit_web_view_get_inspector):
+        (webkit_web_view_set_window_features):
+        (webkit_web_view_get_window_features):
+        (webkit_web_view_get_back_forward_list):
+        (webkit_web_view_zoom_in):
+        (webkit_web_view_zoom_out):
+        (webkit_web_view_get_encoding):
+        (webkit_web_view_get_custom_encoding):
+        (webkit_web_view_add_resource):
+        (webkit_web_view_get_resource):
+        (webkit_web_view_get_main_resource):
+        (webkit_web_view_clear_resources):
+        (webkit_web_view_get_subresources):
+        (webkit_web_view_set_tooltip_text):
+        (webkit_web_view_get_icon_uri):
+
 2010-05-11  Martin Robinson  <mrobinson@igalia.com>
 
         Reviewed by Xan Lopez.
index 5c1bc0b..069fb19 100644 (file)
@@ -62,7 +62,7 @@ static GtkWidget* inputMethodsMenuItem (WebKitWebView* webView)
 
     WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
     GtkWidget* imContextMenu = gtk_menu_new();
-    gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(priv->imContext), GTK_MENU_SHELL(imContextMenu));
+    gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(priv->imContext.get()), GTK_MENU_SHELL(imContextMenu));
 
     gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), imContextMenu);
 
index a5c36e8..d3f8fa1 100644 (file)
@@ -220,15 +220,15 @@ void EditorClient::setInputMethodState(bool active)
     WebKitWebViewPrivate* priv = m_webView->priv;
 
     if (active)
-        gtk_im_context_focus_in(priv->imContext);
+        gtk_im_context_focus_in(priv->imContext.get());
     else
-        gtk_im_context_focus_out(priv->imContext);
+        gtk_im_context_focus_out(priv->imContext.get());
 
 #ifdef MAEMO_CHANGES
     if (active)
-        hildon_gtk_im_context_show(priv->imContext);
+        hildon_gtk_im_context_show(priv->imContext.get());
     else
-        hildon_gtk_im_context_hide(priv->imContext);
+        hildon_gtk_im_context_hide(priv->imContext.get());
 #endif
 }
 
@@ -367,7 +367,7 @@ void EditorClient::respondToChangedSelection()
     unsigned end;
     if (!targetFrame->editor()->getCompositionSelection(start, end)) {
         // gtk_im_context_reset() clears the composition for us.
-        gtk_im_context_reset(priv->imContext);
+        gtk_im_context_reset(priv->imContext.get());
         targetFrame->editor()->confirmCompositionWithoutDisturbingSelection();
     }
 }
@@ -700,7 +700,7 @@ void EditorClient::handleInputMethodKeydown(KeyboardEvent* event)
     m_treatContextCommitAsKeyEvent = (!targetFrame->editor()->hasComposition())
          && event->keyEvent()->gdkEventKey()->keyval;
     clearPendingComposition();
-    if ((gtk_im_context_filter_keypress(priv->imContext, event->keyEvent()->gdkEventKey()) && !m_pendingComposition)
+    if ((gtk_im_context_filter_keypress(priv->imContext.get(), event->keyEvent()->gdkEventKey()) && !m_pendingComposition)
         || (!m_treatContextCommitAsKeyEvent && !targetFrame->editor()->hasComposition()))
         event->preventDefault();
 
@@ -714,8 +714,8 @@ EditorClient::EditorClient(WebKitWebView* webView)
     , m_nativeWidget(gtk_text_view_new())
 {
     WebKitWebViewPrivate* priv = m_webView->priv;
-    g_signal_connect(priv->imContext, "commit", G_CALLBACK(imContextCommitted), this);
-    g_signal_connect(priv->imContext, "preedit-changed", G_CALLBACK(imContextPreeditChanged), this);
+    g_signal_connect(priv->imContext.get(), "commit", G_CALLBACK(imContextCommitted), this);
+    g_signal_connect(priv->imContext.get(), "preedit-changed", G_CALLBACK(imContextPreeditChanged), this);
 
     g_signal_connect(m_nativeWidget.get(), "backspace", G_CALLBACK(backspaceCallback), this);
     g_signal_connect(m_nativeWidget.get(), "cut-clipboard", G_CALLBACK(cutClipboardCallback), this);
@@ -729,8 +729,8 @@ EditorClient::EditorClient(WebKitWebView* webView)
 EditorClient::~EditorClient()
 {
     WebKitWebViewPrivate* priv = m_webView->priv;
-    g_signal_handlers_disconnect_by_func(priv->imContext, (gpointer)imContextCommitted, this);
-    g_signal_handlers_disconnect_by_func(priv->imContext, (gpointer)imContextPreeditChanged, this);
+    g_signal_handlers_disconnect_by_func(priv->imContext.get(), (gpointer)imContextCommitted, this);
+    g_signal_handlers_disconnect_by_func(priv->imContext.get(), (gpointer)imContextPreeditChanged, this);
 }
 
 void EditorClient::textFieldDidBeginEditing(Element*)
index fd2d7ed..1fe6b0f 100644 (file)
@@ -1135,14 +1135,11 @@ static void postCommitFrameViewSetup(WebKitWebFrame *frame, FrameView *view, boo
 {
     WebKitWebView* containingWindow = getViewFromFrame(frame);
     WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(containingWindow);
-    view->setGtkAdjustments(priv->horizontalAdjustment, priv->verticalAdjustment, resetValues);
+    view->setGtkAdjustments(priv->horizontalAdjustment.get(), priv->verticalAdjustment.get(), resetValues);
 
     if (priv->currentMenu) {
-        GtkMenu* menu = priv->currentMenu;
-        priv->currentMenu = 0;
-
-        gtk_menu_popdown(menu);
-        g_object_unref(menu);
+        gtk_menu_popdown(priv->currentMenu.get());
+        priv->currentMenu.clear();
     }
 }
 
index 057b0e5..abca3c8 100644 (file)
@@ -115,42 +115,42 @@ extern "C" {
     typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate;
     struct _WebKitWebViewPrivate {
         WebCore::Page* corePage;
-        WebKitWebSettings* webSettings;
-        WebKitWebInspector* webInspector;
-        WebKitWebWindowFeatures* webWindowFeatures;
+        GRefPtr<WebKitWebSettings> webSettings;
+        GRefPtr<WebKitWebInspector> webInspector;
+        GRefPtr<WebKitWebWindowFeatures> webWindowFeatures;
 
         WebKitWebFrame* mainFrame;
-        WebKitWebBackForwardList* backForwardList;
+        GRefPtr<WebKitWebBackForwardList> backForwardList;
 
-        GtkMenu* currentMenu;
+        GRefPtr<GtkMenu> currentMenu;
         gint lastPopupXPosition;
         gint lastPopupYPosition;
 
         HashSet<GtkWidget*> children;
         bool editable;
-        GtkIMContext* imContext;
+        GRefPtr<GtkIMContext> imContext;
 
         gboolean transparent;
 
-        GtkAdjustment* horizontalAdjustment;
-        GtkAdjustment* verticalAdjustment;
+        GRefPtr<GtkAdjustment> horizontalAdjustment;
+        GRefPtr<GtkAdjustment> verticalAdjustment;
 
         gboolean zoomFullContent;
         WebKitLoadStatus loadStatus;
-        char* encoding;
-        char* customEncoding;
+        GOwnPtr<char> encoding;
+        GOwnPtr<char> customEncoding;
 
-        char* iconURI;
+        GOwnPtr<char> iconURI;
 
         gboolean disposing;
         gboolean usePrimaryForPaste;
 
         // These are hosted here because the DataSource object is
         // created too late in the frame loading process.
-        WebKitWebResource* mainResource;
-        char* mainResourceIdentifier;
-        GHashTable* subResources;
-        char* tooltipText;
+        GRefPtr<WebKitWebResource> mainResource;
+        GOwnPtr<char> mainResourceIdentifier;
+        GRefPtr<GHashTable> subResources;
+        GOwnPtr<char> tooltipText;
 
         HashMap<GdkDragContext*, RefPtr<WebCore::DataObjectGtk> > draggingDataObjects;
     };
index 10a082c..ca72665 100644 (file)
@@ -204,9 +204,7 @@ static void destroy_menu_cb(GtkObject* object, gpointer data)
 {
     WebKitWebView* webView = WEBKIT_WEB_VIEW(data);
     WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
-
-    g_object_unref(priv->currentMenu);
-    priv->currentMenu = NULL;
+    priv->currentMenu = 0;
 }
 
 static void PopupMenuPositionFunc(GtkMenu* menu, gint *x, gint *y, gboolean *pushIn, gpointer userData)
@@ -296,7 +294,7 @@ static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webVie
         return FALSE;
 
     WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
-    priv->currentMenu = GTK_MENU(g_object_ref(menu));
+    priv->currentMenu = menu;
     priv->lastPopupXPosition = event.globalX();
     priv->lastPopupYPosition = event.globalY();
 
@@ -570,7 +568,7 @@ static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey
     // the event if we don't have a pending composition, because that means we
     // are using a context like 'simple' which marks every keystroke as filtered.
     WebKit::EditorClient* client = static_cast<WebKit::EditorClient*>(core(webView)->editorClient());
-    if (gtk_im_context_filter_keypress(webView->priv->imContext, event) && !client->hasPendingComposition())
+    if (gtk_im_context_filter_keypress(webView->priv->imContext.get(), event) && !client->hasPendingComposition())
         return TRUE;
 
     Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
@@ -627,7 +625,7 @@ static gboolean webkit_web_view_button_release_event(GtkWidget* widget, GdkEvent
     if (focusedFrame && focusedFrame->editor()->canEdit()) {
 #ifdef MAEMO_CHANGES
         WebKitWebViewPrivate* priv = webView->priv;
-        hildon_gtk_im_context_filter_event(priv->imContext, (GdkEvent*)event);
+        hildon_gtk_im_context_filter_event(priv->imContext.get(), (GdkEvent*)event);
 #endif
     }
 
@@ -730,7 +728,7 @@ static gboolean webkit_web_view_focus_in_event(GtkWidget* widget, GdkEventFocus*
         else
             focusController->setFocusedFrame(core(webView)->mainFrame());
 
-        gtk_im_context_focus_in(webView->priv->imContext);
+        gtk_im_context_focus_in(webView->priv->imContext.get());
     }
     return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_in_event(widget, event);
 }
@@ -748,7 +746,7 @@ static gboolean webkit_web_view_focus_out_event(GtkWidget* widget, GdkEventFocus
     }
 
     if (webView->priv->imContext)
-        gtk_im_context_focus_out(webView->priv->imContext);
+        gtk_im_context_focus_out(webView->priv->imContext.get());
 
     return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_out_event(widget, event);
 }
@@ -787,7 +785,7 @@ static void webkit_web_view_realize(GtkWidget* widget)
 
     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
     WebKitWebViewPrivate* priv = webView->priv;
-    gtk_im_context_set_client_window(priv->imContext, widget->window);
+    gtk_im_context_set_client_window(priv->imContext.get(), widget->window);
 }
 
 static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* hadj, GtkAdjustment* vadj)
@@ -796,19 +794,7 @@ static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAd
         return;
 
     FrameView* view = core(webkit_web_view_get_main_frame(webView))->view();
-
-    if (hadj)
-        g_object_ref(hadj);
-    if (vadj)
-        g_object_ref(vadj);
-
     WebKitWebViewPrivate* priv = webView->priv;
-
-    if (priv->horizontalAdjustment)
-        g_object_unref(priv->horizontalAdjustment);
-    if (priv->verticalAdjustment)
-        g_object_unref(priv->verticalAdjustment);
-
     priv->horizontalAdjustment = hadj;
     priv->verticalAdjustment = vadj;
 
@@ -1076,21 +1062,6 @@ static void webkit_web_view_dispose(GObject* object)
 
     priv->disposing = TRUE;
 
-    if (priv->horizontalAdjustment) {
-        g_object_unref(priv->horizontalAdjustment);
-        priv->horizontalAdjustment = NULL;
-    }
-
-    if (priv->verticalAdjustment) {
-        g_object_unref(priv->verticalAdjustment);
-        priv->verticalAdjustment = NULL;
-    }
-
-    if (priv->backForwardList) {
-        g_object_unref(priv->backForwardList);
-        priv->backForwardList = NULL;
-    }
-
     if (priv->corePage) {
         webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object));
 
@@ -1100,30 +1071,18 @@ static void webkit_web_view_dispose(GObject* object)
     }
 
     if (priv->webSettings) {
-        g_signal_handlers_disconnect_by_func(priv->webSettings, (gpointer)webkit_web_view_settings_notify, webView);
-        g_object_unref(priv->webSettings);
-        priv->webSettings = NULL;
-
-        g_object_unref(priv->webInspector);
-        priv->webInspector = NULL;
-
-        g_object_unref(priv->webWindowFeatures);
-        priv->webWindowFeatures = NULL;
-
-        g_object_unref(priv->imContext);
-        priv->imContext = NULL;
-    }
-
-    if (priv->mainResource) {
-        g_object_unref(priv->mainResource);
-        priv->mainResource = NULL;
-    }
-
-    if (priv->subResources) {
-        g_hash_table_unref(priv->subResources);
-        priv->subResources = NULL;
+        g_signal_handlers_disconnect_by_func(priv->webSettings.get(), (gpointer)webkit_web_view_settings_notify, webView);
+        priv->webSettings.clear();
     }
 
+    priv->horizontalAdjustment.clear();
+    priv->verticalAdjustment.clear();
+    priv->backForwardList.clear();
+    priv->webInspector.clear();
+    priv->webWindowFeatures.clear();
+    priv->imContext.clear();
+    priv->mainResource.clear();
+    priv->subResources.clear();
     priv->draggingDataObjects.clear();
 
     G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object);
@@ -1134,11 +1093,11 @@ static void webkit_web_view_finalize(GObject* object)
     WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
     WebKitWebViewPrivate* priv = webView->priv;
 
-    g_free(priv->tooltipText);
-    g_free(priv->mainResourceIdentifier);
-    g_free(priv->encoding);
-    g_free(priv->customEncoding);
-    g_free(priv->iconURI);
+    priv->tooltipText.clear();
+    priv->mainResourceIdentifier.clear();
+    priv->encoding.clear();
+    priv->customEncoding.clear();
+    priv->iconURI.clear();
 
     G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object);
 }
@@ -1189,7 +1148,7 @@ static AtkObject* webkit_web_view_get_accessible(GtkWidget* widget)
 static gdouble webViewGetDPI(WebKitWebView* webView)
 {
     WebKitWebViewPrivate* priv = webView->priv;
-    WebKitWebSettings* webSettings = priv->webSettings;
+    WebKitWebSettings* webSettings = priv->webSettings.get();
     gboolean enforce96DPI;
     g_object_get(webSettings, "enforce-96-dpi", &enforce96DPI, NULL);
     if (enforce96DPI)
@@ -1215,7 +1174,7 @@ static void webkit_web_view_screen_changed(GtkWidget* widget, GdkScreen* previou
     if (priv->disposing)
         return;
 
-    WebKitWebSettings* webSettings = priv->webSettings;
+    WebKitWebSettings* webSettings = priv->webSettings.get();
     Settings* settings = core(webView)->settings();
     gdouble DPI = webViewGetDPI(webView);
 
@@ -1264,7 +1223,7 @@ static gboolean webkit_web_view_query_tooltip(GtkWidget *widget, gint x, gint y,
     WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(widget);
 
     if (priv->tooltipText) {
-        gtk_tooltip_set_text(tooltip, priv->tooltipText);
+        gtk_tooltip_set_text(tooltip, priv->tooltipText.get());
         return TRUE;
     }
 
@@ -1275,7 +1234,7 @@ static gboolean webkit_web_view_query_tooltip(GtkWidget *widget, gint x, gint y,
 static GtkIMContext* webkit_web_view_get_im_context(WebKitWebView* webView)
 {
     g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
-    return GTK_IM_CONTEXT(webView->priv->imContext);
+    return GTK_IM_CONTEXT(webView->priv->imContext.get());
 }
 
 static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
@@ -2591,7 +2550,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
 static void webkit_web_view_update_settings(WebKitWebView* webView)
 {
     WebKitWebViewPrivate* priv = webView->priv;
-    WebKitWebSettings* webSettings = priv->webSettings;
+    WebKitWebSettings* webSettings = priv->webSettings.get();
     Settings* settings = core(webView)->settings();
 
     gchar* defaultEncoding, *cursiveFontFamily, *defaultFontFamily, *fantasyFontFamily, *monospaceFontFamily, *sansSerifFontFamily, *serifFontFamily, *userStylesheetUri;
@@ -2795,40 +2754,36 @@ static void webkit_web_view_init(WebKitWebView* webView)
     WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
     webView->priv = priv;
 
-    priv->imContext = gtk_im_multicontext_new();
+    priv->imContext = adoptGRef(gtk_im_multicontext_new());
 
     WebKit::InspectorClient* inspectorClient = new WebKit::InspectorClient(webView);
     priv->corePage = new Page(new WebKit::ChromeClient(webView), new WebKit::ContextMenuClient(webView), new WebKit::EditorClient(webView), new WebKit::DragClient(webView), inspectorClient, 0, 0);
 
     // We also add a simple wrapper class to provide the public
     // interface for the Web Inspector.
-    priv->webInspector = WEBKIT_WEB_INSPECTOR(g_object_new(WEBKIT_TYPE_WEB_INSPECTOR, NULL));
-    webkit_web_inspector_set_inspector_client(priv->webInspector, priv->corePage);
+    priv->webInspector = adoptGRef(WEBKIT_WEB_INSPECTOR(g_object_new(WEBKIT_TYPE_WEB_INSPECTOR, NULL)));
+    webkit_web_inspector_set_inspector_client(priv->webInspector.get(), priv->corePage);
 
+    // These are create with floating references, so they should not be wrapped in adoptGref.
     priv->horizontalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
     priv->verticalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
 
-    g_object_ref_sink(priv->horizontalAdjustment);
-    g_object_ref_sink(priv->verticalAdjustment);
-
     GTK_WIDGET_SET_FLAGS(webView, GTK_CAN_FOCUS);
     priv->mainFrame = WEBKIT_WEB_FRAME(webkit_web_frame_new(webView));
     priv->lastPopupXPosition = priv->lastPopupYPosition = -1;
     priv->editable = false;
 
-    priv->backForwardList = webkit_web_back_forward_list_new_with_web_view(webView);
+    priv->backForwardList = adoptGRef(webkit_web_back_forward_list_new_with_web_view(webView));
 
     priv->zoomFullContent = FALSE;
 
-    priv->webSettings = webkit_web_settings_new();
+    priv->webSettings = adoptGRef(webkit_web_settings_new());
     webkit_web_view_update_settings(webView);
-    g_signal_connect(priv->webSettings, "notify", G_CALLBACK(webkit_web_view_settings_notify), webView);
-
-    priv->webWindowFeatures = webkit_web_window_features_new();
+    g_signal_connect(priv->webSettings.get(), "notify", G_CALLBACK(webkit_web_view_settings_notify), webView);
 
-    priv->subResources = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
+    priv->webWindowFeatures = adoptGRef(webkit_web_window_features_new());
 
-    priv->tooltipText = 0;
+    priv->subResources = adoptGRef(g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref));
 }
 
 GtkWidget* webkit_web_view_new(void)
@@ -2884,9 +2839,7 @@ void webkit_web_view_set_settings(WebKitWebView* webView, WebKitWebSettings* web
     g_return_if_fail(WEBKIT_IS_WEB_SETTINGS(webSettings));
 
     WebKitWebViewPrivate* priv = webView->priv;
-    g_signal_handlers_disconnect_by_func(priv->webSettings, (gpointer)webkit_web_view_settings_notify, webView);
-    g_object_unref(priv->webSettings);
-    g_object_ref(webSettings);
+    g_signal_handlers_disconnect_by_func(priv->webSettings.get(), (gpointer)webkit_web_view_settings_notify, webView);
     priv->webSettings = webSettings;
     webkit_web_view_update_settings(webView);
     g_signal_connect(webSettings, "notify", G_CALLBACK(webkit_web_view_settings_notify), webView);
@@ -2898,7 +2851,7 @@ WebKitWebSettings* webkit_web_view_get_settings(WebKitWebView* webView)
     g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL);
 
     WebKitWebViewPrivate* priv = webView->priv;
-    return priv->webSettings;
+    return priv->webSettings.get();
 }
 
 /**
@@ -2922,7 +2875,7 @@ WebKitWebInspector* webkit_web_view_get_inspector(WebKitWebView* webView)
     g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL);
 
     WebKitWebViewPrivate* priv = webView->priv;
-    return priv->webInspector;
+    return priv->webInspector.get();
 }
 
 // internal
@@ -2933,11 +2886,9 @@ static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWe
     if (!webWindowFeatures)
       return;
 
-    if (webkit_web_window_features_equal(priv->webWindowFeatures, webWindowFeatures))
+    if (webkit_web_window_features_equal(priv->webWindowFeatures.get(), webWindowFeatures))
       return;
 
-    g_object_unref(priv->webWindowFeatures);
-    g_object_ref(webWindowFeatures);
     priv->webWindowFeatures = webWindowFeatures;
 }
 
@@ -2957,7 +2908,7 @@ WebKitWebWindowFeatures* webkit_web_view_get_window_features(WebKitWebView* webV
     g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL);
 
     WebKitWebViewPrivate* priv = webView->priv;
-    return priv->webWindowFeatures;
+    return priv->webWindowFeatures.get();
 }
 
 /**
@@ -3027,7 +2978,7 @@ WebKitWebBackForwardList* webkit_web_view_get_back_forward_list(WebKitWebView* w
     if (!core(webView) || !core(webView)->backForwardList()->enabled())
         return NULL;
 
-    return priv->backForwardList;
+    return priv->backForwardList.get();
 }
 
 /**
@@ -3787,7 +3738,7 @@ void webkit_web_view_zoom_in(WebKitWebView* webView)
 
     WebKitWebViewPrivate* priv = webView->priv;
     gfloat zoomMultiplierRatio;
-    g_object_get(priv->webSettings, "zoom-step", &zoomMultiplierRatio, NULL);
+    g_object_get(priv->webSettings.get(), "zoom-step", &zoomMultiplierRatio, NULL);
 
     webkit_web_view_set_zoom_level(webView, webkit_web_view_get_zoom_level(webView) + zoomMultiplierRatio);
 }
@@ -3808,7 +3759,7 @@ void webkit_web_view_zoom_out(WebKitWebView* webView)
 
     WebKitWebViewPrivate* priv = webView->priv;
     gfloat zoomMultiplierRatio;
-    g_object_get(priv->webSettings, "zoom-step", &zoomMultiplierRatio, NULL);
+    g_object_get(priv->webSettings.get(), "zoom-step", &zoomMultiplierRatio, NULL);
 
     webkit_web_view_set_zoom_level(webView, webkit_web_view_get_zoom_level(webView) - zoomMultiplierRatio);
 }
@@ -3923,9 +3874,8 @@ const gchar* webkit_web_view_get_encoding(WebKitWebView* webView)
 
     if (!encoding.isEmpty()) {
         WebKitWebViewPrivate* priv = webView->priv;
-        g_free(priv->encoding);
-        priv->encoding = g_strdup(encoding.utf8().data());
-        return priv->encoding;
+        priv->encoding.set(g_strdup(encoding.utf8().data()));
+        return priv->encoding.get();
     } else
       return NULL;
 }
@@ -3966,9 +3916,8 @@ const char* webkit_web_view_get_custom_encoding(WebKitWebView* webView)
 
     if (!overrideEncoding.isEmpty()) {
         WebKitWebViewPrivate* priv = webView->priv;
-        g_free (priv->customEncoding);
-        priv->customEncoding = g_strdup(overrideEncoding.utf8().data());
-        return priv->customEncoding;
+        priv->customEncoding.set(g_strdup(overrideEncoding.utf8().data()));
+        return priv->customEncoding.get();
     } else
       return NULL;
 }
@@ -4123,11 +4072,11 @@ void webkit_web_view_add_resource(WebKitWebView* webView, char* identifier, WebK
 
     if (!priv->mainResource) {
         priv->mainResource = webResource;
-        priv->mainResourceIdentifier = g_strdup(identifier);
+        priv->mainResourceIdentifier.set(g_strdup(identifier));
         return;
     }
 
-    g_hash_table_insert(priv->subResources, identifier, webResource);
+    g_hash_table_insert(priv->subResources.get(), identifier, webResource);
 }
 
 WebKitWebResource* webkit_web_view_get_resource(WebKitWebView* webView, char* identifier)
@@ -4135,13 +4084,13 @@ WebKitWebResource* webkit_web_view_get_resource(WebKitWebView* webView, char* id
     WebKitWebViewPrivate* priv = webView->priv;
     gpointer webResource = NULL;
 
-    gboolean resourceFound = g_hash_table_lookup_extended(priv->subResources, identifier, NULL, &webResource);
+    gboolean resourceFound = g_hash_table_lookup_extended(priv->subResources.get(), identifier, NULL, &webResource);
 
     // The only resource we do not store in this hash table is the
     // main!  If we did not find a request, it probably means the load
     // has been interrupted while while a resource was still being
     // loaded.
-    if (!resourceFound && !g_str_equal(identifier, priv->mainResourceIdentifier))
+    if (!resourceFound && !g_str_equal(identifier, priv->mainResourceIdentifier.get()))
         return NULL;
 
     if (!webResource)
@@ -4152,30 +4101,24 @@ WebKitWebResource* webkit_web_view_get_resource(WebKitWebView* webView, char* id
 
 WebKitWebResource* webkit_web_view_get_main_resource(WebKitWebView* webView)
 {
-    return webView->priv->mainResource;
+    return webView->priv->mainResource.get();
 }
 
 void webkit_web_view_clear_resources(WebKitWebView* webView)
 {
     WebKitWebViewPrivate* priv = webView->priv;
-
-    g_free(priv->mainResourceIdentifier);
-    priv->mainResourceIdentifier = NULL;
-
-    if (priv->mainResource) {
-        g_object_unref(priv->mainResource);
-        priv->mainResource = NULL;
-    }
+    priv->mainResourceIdentifier.clear();
+    priv->mainResource.clear();
 
     if (priv->subResources)
-        g_hash_table_remove_all(priv->subResources);
+        g_hash_table_remove_all(priv->subResources.get());
 }
 
 GList* webkit_web_view_get_subresources(WebKitWebView* webView)
 {
     WebKitWebViewPrivate* priv = webView->priv;
-    GList* subResources = g_hash_table_get_values(priv->subResources);
-    return g_list_remove(subResources, priv->mainResource);
+    GList* subResources = g_hash_table_get_values(priv->subResources.get());
+    return g_list_remove(subResources, priv->mainResource.get());
 }
 
 /* From EventHandler.cpp */
@@ -4191,12 +4134,11 @@ void webkit_web_view_set_tooltip_text(WebKitWebView* webView, const char* toolti
 {
 #if GTK_CHECK_VERSION(2, 12, 0)
     WebKitWebViewPrivate* priv = webView->priv;
-    g_free(priv->tooltipText);
     if (tooltip && *tooltip != '\0') {
-        priv->tooltipText = g_strdup(tooltip);
+        priv->tooltipText.set(g_strdup(tooltip));
         gtk_widget_set_has_tooltip(GTK_WIDGET(webView), TRUE);
     } else {
-        priv->tooltipText = 0;
+        priv->tooltipText.clear();
         gtk_widget_set_has_tooltip(GTK_WIDGET(webView), FALSE);
     }
 
@@ -4254,9 +4196,8 @@ G_CONST_RETURN gchar* webkit_web_view_get_icon_uri(WebKitWebView* webView)
     String iconURL = iconDatabase()->iconURLForPageURL(corePage->mainFrame()->loader()->url().prettyURL());
 
     WebKitWebViewPrivate* priv = webView->priv;
-    g_free(priv->iconURI);
-    priv->iconURI = g_strdup(iconURL.utf8().data());
-    return priv->iconURI;
+    priv->iconURI.set(g_strdup(iconURL.utf8().data()));
+    return priv->iconURI.get();
 }
 
 /**