[epiphany/gnome-3-20] Clear various WebKit DOM objects after using them
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-3-20] Clear various WebKit DOM objects after using them
- Date: Mon, 8 Aug 2016 02:35:44 +0000 (UTC)
commit d8b1e5e58619bfe0348e55362bbeebec57889841
Author: Tomas Popela <tpopela redhat com>
Date: Wed Jul 27 16:16:00 2016 +0200
Clear various WebKit DOM objects after using them
embed/web-extension/ephy-web-dom-utils.c | 32 +++++++++++++++++++++++------
embed/web-extension/ephy-web-extension.c | 1 +
embed/web-extension/ephy-web-overview.c | 10 +++++++-
3 files changed, 34 insertions(+), 9 deletions(-)
---
diff --git a/embed/web-extension/ephy-web-dom-utils.c b/embed/web-extension/ephy-web-dom-utils.c
index cf32786..9a2db76 100644
--- a/embed/web-extension/ephy-web-dom-utils.c
+++ b/embed/web-extension/ephy-web-dom-utils.c
@@ -40,6 +40,7 @@ ephy_web_dom_utils_has_modified_forms (WebKitDOMDocument *document)
WebKitDOMHTMLCollection *forms;
gulong forms_n;
guint i;
+ gboolean modified_forms = FALSE;
forms = webkit_dom_document_get_forms (document);
forms_n = webkit_dom_html_collection_get_length (forms);
@@ -68,8 +69,11 @@ ephy_web_dom_utils_has_modified_forms (WebKitDOMDocument *document)
has_data = text && *text;
g_free (text);
- if (has_data)
- return TRUE;
+ if (has_data) {
+ g_object_unref (elements);
+ modified_forms = TRUE;
+ goto out;
+ }
}
if (WEBKIT_DOM_IS_HTML_INPUT_ELEMENT (element))
@@ -81,8 +85,11 @@ ephy_web_dom_utils_has_modified_forms (WebKitDOMDocument *document)
* modified and it does not have a lot of text the user is
* likely not very interested in saving this work, so do
* nothing (eg, google search input). */
- if (modified_input_element)
- return TRUE;
+ if (modified_input_element) {
+ g_object_unref (elements);
+ modified_forms = TRUE;
+ goto out;
+ }
modified_input_element = TRUE;
@@ -90,13 +97,19 @@ ephy_web_dom_utils_has_modified_forms (WebKitDOMDocument *document)
length = g_utf8_strlen (text, -1);
g_free (text);
- if (length > 50)
- return TRUE;
+ if (length > 50) {
+ g_object_unref (elements);
+ modified_forms = TRUE;
+ goto out;
+ }
}
}
+ g_object_unref (elements);
}
- return FALSE;
+ out:
+ g_object_unref (forms);
+ return modified_forms;
}
/**
@@ -130,6 +143,7 @@ ephy_web_dom_utils_get_application_title (WebKitDOMDocument *document)
g_free (property);
g_free (name);
}
+ g_object_unref (metas);
return title;
}
@@ -187,6 +201,7 @@ get_icon_from_mstile (WebKitDOMDocument *document,
color = webkit_dom_html_meta_element_get_content (WEBKIT_DOM_HTML_META_ELEMENT (node));
}
}
+ g_object_unref (metas);
ret = (image != NULL && *image != '\0');
@@ -229,6 +244,7 @@ get_icon_from_ogp (WebKitDOMDocument *document,
g_free (property);
g_free (itemprop);
}
+ g_object_unref (metas);
ret = (image != NULL && *image != '\0');
@@ -266,6 +282,7 @@ get_icon_from_touch_icon (WebKitDOMDocument *document,
}
g_free (rel);
}
+ g_object_unref (links);
ret = (image != NULL && *image != '\0');
@@ -306,6 +323,7 @@ get_icon_from_favicon (WebKitDOMDocument *document,
}
g_free (rel);
}
+ g_object_unref (links);
ret = (image != NULL && *image != '\0');
diff --git a/embed/web-extension/ephy-web-extension.c b/embed/web-extension/ephy-web-extension.c
index a0ec04d..514d22e 100644
--- a/embed/web-extension/ephy-web-extension.c
+++ b/embed/web-extension/ephy-web-extension.c
@@ -267,6 +267,7 @@ request_decision_on_storing (EphyEmbedFormAuth *form_auth)
g_warning ("Error sending formAuthData message");
}
+ g_object_unref (dom_window);
g_free (message);
g_object_unref (form_auth);
}
diff --git a/embed/web-extension/ephy-web-overview.c b/embed/web-extension/ephy-web-overview.c
index 93503ad..eb0fe21 100644
--- a/embed/web-extension/ephy-web-overview.c
+++ b/embed/web-extension/ephy-web-overview.c
@@ -165,6 +165,7 @@ ephy_web_overview_model_urls_changed (EphyWebOverviewModel *model,
} else {
webkit_dom_element_remove_attribute (item->thumbnail, "style");
}
+ g_clear_object (&class_list);
} else {
WebKitDOMDocument *document;
WebKitDOMElement *item_list, *anchor;
@@ -312,12 +313,16 @@ ephy_web_overview_update_thumbnail_in_model_from_element (EphyWebOverview *over
char *thumbnail_path;
style = webkit_dom_element_get_style (thumbnail);
- if (webkit_dom_css_style_declaration_is_property_implicit (style, "background"))
+ if (webkit_dom_css_style_declaration_is_property_implicit (style, "background")) {
+ g_object_unref (style);
return;
+ }
background = webkit_dom_css_style_declaration_get_property_value (style, "background");
- if (!background)
+ if (!background) {
+ g_object_unref (style);
return;
+ }
thumbnail_path = g_strrstr (background, "file://");
if (thumbnail_path) {
@@ -341,6 +346,7 @@ ephy_web_overview_update_thumbnail_in_model_from_element (EphyWebOverview *over
update_thumbnail_element_style (thumbnail, path);
}
g_free (background);
+ g_object_unref (style);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]