aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Popela <tpopela@redhat.com>2014-08-07 17:20:03 +0800
committerTomas Popela <tpopela@redhat.com>2014-08-07 17:20:03 +0800
commita0b11ce4ac8602a77e51c64d904ee9314bc9d10b (patch)
tree2f8b49325eed859aa8a14c2f5bdb1970a326a0b4
parentba8b45931956123e1621a669aee661e21c3287c0 (diff)
downloadgsoc2013-evolution-a0b11ce4ac8602a77e51c64d904ee9314bc9d10b.tar
gsoc2013-evolution-a0b11ce4ac8602a77e51c64d904ee9314bc9d10b.tar.gz
gsoc2013-evolution-a0b11ce4ac8602a77e51c64d904ee9314bc9d10b.tar.bz2
gsoc2013-evolution-a0b11ce4ac8602a77e51c64d904ee9314bc9d10b.tar.lz
gsoc2013-evolution-a0b11ce4ac8602a77e51c64d904ee9314bc9d10b.tar.xz
gsoc2013-evolution-a0b11ce4ac8602a77e51c64d904ee9314bc9d10b.tar.zst
gsoc2013-evolution-a0b11ce4ac8602a77e51c64d904ee9314bc9d10b.zip
Reduce the memory used by DOM variables
Free some of the DOM variables when they are not needed, before they are automatically freed when the frame is destroyed
-rw-r--r--addressbook/gui/widgets/eab-contact-formatter.c2
-rw-r--r--composer/e-composer-private.c3
-rw-r--r--composer/e-msg-composer.c4
-rw-r--r--e-util/e-html-editor-cell-dialog.c2
-rw-r--r--e-util/e-html-editor-selection.c34
-rw-r--r--e-util/e-html-editor-view.c43
-rw-r--r--e-util/e-mail-signature-preview.c2
-rw-r--r--e-util/e-web-view.c3
-rw-r--r--mail/e-mail-display.c21
-rw-r--r--modules/itip-formatter/e-mail-part-itip.c2
-rw-r--r--modules/vcard-inline/e-mail-part-vcard.c3
-rw-r--r--plugins/external-editor/external-editor.c1
12 files changed, 106 insertions, 14 deletions
diff --git a/addressbook/gui/widgets/eab-contact-formatter.c b/addressbook/gui/widgets/eab-contact-formatter.c
index 6aa45c966c..14e0d0ba87 100644
--- a/addressbook/gui/widgets/eab-contact-formatter.c
+++ b/addressbook/gui/widgets/eab-contact-formatter.c
@@ -1442,4 +1442,6 @@ eab_contact_formatter_bind_dom (WebKitDOMDocument *document)
WEBKIT_DOM_EVENT_TARGET (node), "click",
G_CALLBACK (collapse_contacts_list), FALSE, document);
}
+
+ g_object_unref (nodes);
}
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 6b5ac2cce6..569cc4d6ae 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -1004,6 +1004,9 @@ composer_move_caret (EMsgComposer *composer)
webkit_dom_dom_selection_remove_all_ranges (dom_selection);
webkit_dom_dom_selection_add_range (dom_selection, new_range);
+ g_object_unref (list);
+ g_object_unref (blockquotes);
+
e_html_editor_selection_unblock_selection_changed (editor_selection);
}
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index d60fa9e35d..8c1748c4c3 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -3180,6 +3180,8 @@ set_signature_gui (EMsgComposer *composer)
g_free (id);
}
+ g_object_unref (nodes);
+
/* The combo box active ID is the signature's ESource UID. */
if (uid != NULL) {
gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo_box), uid);
@@ -4973,6 +4975,8 @@ e_msg_composer_get_raw_message_text_without_signature (EMsgComposer *composer)
g_free (text);
}
+ g_object_unref (list);
+
return array;
}
diff --git a/e-util/e-html-editor-cell-dialog.c b/e-util/e-html-editor-cell-dialog.c
index 2b487288ae..0a936454c7 100644
--- a/e-util/e-html-editor-cell-dialog.c
+++ b/e-util/e-html-editor-cell-dialog.c
@@ -332,6 +332,8 @@ cell_set_header_style (WebKitDOMHTMLTableCellElement *cell,
dialog->priv->cell = new_cell;
+ g_object_unref (nodes);
+
g_free (tagname);
}
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index a47fcf94ee..2c50d13caf 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -917,6 +917,8 @@ e_html_editor_selection_has_text (EHTMLEditorSelection *selection)
}
}
+ g_object_unref (node);
+
return FALSE;
}
@@ -1272,6 +1274,7 @@ format_change_list_from_list (EHTMLEditorSelection *selection,
}
if (webkit_dom_node_contains (item, WEBKIT_DOM_NODE (selection_end_marker))) {
+ g_object_unref (source_list_clone);
source_list_clone = webkit_dom_node_clone_node (current_list, FALSE);
after_selection_end = TRUE;
}
@@ -1659,6 +1662,8 @@ remove_wrapping_from_element (WebKitDOMElement *element)
remove_node (webkit_dom_node_list_item (list, ii));
webkit_dom_node_normalize (WEBKIT_DOM_NODE (element));
+
+ g_object_unref (list);
}
void
@@ -1672,6 +1677,7 @@ remove_quoting_from_element (WebKitDOMElement *element)
length = webkit_dom_node_list_get_length (list);
for (ii = 0; ii < length; ii++)
remove_node (webkit_dom_node_list_item (list, ii));
+ g_object_unref (list);
list = webkit_dom_element_query_selector_all (
element, "span.-x-evo-temp-text-wrapper", NULL);
@@ -1689,12 +1695,14 @@ remove_quoting_from_element (WebKitDOMElement *element)
remove_node (node);
}
+ g_object_unref (list);
list = webkit_dom_element_query_selector_all (
element, "br.-x-evo-temp-br", NULL);
length = webkit_dom_node_list_get_length (list);
for (ii = 0; ii < length; ii++)
remove_node (webkit_dom_node_list_item (list, ii));
+ g_object_unref (list);
webkit_dom_node_normalize (WEBKIT_DOM_NODE (element));
}
@@ -2592,14 +2600,18 @@ e_html_editor_selection_is_indented (EHTMLEditorSelection *selection)
fragment = webkit_dom_range_clone_contents (range, NULL);
if (fragment) {
+ gboolean ret_val = TRUE;
+
element = webkit_dom_document_fragment_query_selector (
fragment, ".-x-evo-indented", NULL);
- if (element)
- return TRUE;
+ if (!element) {
+ element = get_element_for_inspection (range);
+ ret_val = element_has_class (element, "-x-evo-indented");
+ }
- element = get_element_for_inspection (range);
- return element_has_class (element, "-x-evo-indented");
+ g_object_unref (fragment);
+ return ret_val;
}
}
@@ -2862,6 +2874,8 @@ e_html_editor_selection_indent (EHTMLEditorSelection *selection)
goto out;
}
+ g_object_unref (list);
+
block = next_block;
}
out:
@@ -3182,6 +3196,7 @@ e_html_editor_selection_unindent (EHTMLEditorSelection *selection)
if (after_selection_end)
goto out;
}
+ g_object_unref (list);
block = next_block;
}
out:
@@ -3563,12 +3578,13 @@ e_html_editor_selection_set_monospaced (EHTMLEditorSelection *selection,
if (!e_html_editor_selection_is_collapsed (selection)) {
gchar *html, *outer_html;
+ WebKitDOMNode *range_clone;
+
+ range_clone = WEBKIT_DOM_NODE (
+ webkit_dom_range_clone_contents (range, NULL));
webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (monospace),
- WEBKIT_DOM_NODE (
- webkit_dom_range_clone_contents (range, NULL)),
- NULL);
+ WEBKIT_DOM_NODE (monospace), range_clone, NULL);
outer_html = webkit_dom_html_element_get_outer_html (
WEBKIT_DOM_HTML_ELEMENT (monospace));
@@ -5032,6 +5048,7 @@ wrap_lines (EHTMLEditorSelection *selection,
/* And remove them */
for (ii = 0; ii < br_count; ii++)
remove_node (webkit_dom_node_list_item (wrap_br, ii));
+ g_object_unref (wrap_br);
} else {
if (!webkit_dom_node_has_child_nodes (paragraph))
return WEBKIT_DOM_ELEMENT (paragraph);
@@ -5687,6 +5704,7 @@ e_html_editor_selection_wrap_paragraphs_in_document (EHTMLEditorSelection *selec
selection->priv->word_wrap_length - quote);
}
}
+ g_object_unref (list);
}
WebKitDOMElement *
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 580c8a3e69..414ab10976 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -517,6 +517,7 @@ quote_plain_text_element_after_wrapping (WebKitDOMDocument *document,
NULL);
}
+ g_object_unref (list);
g_free (quotation);
}
@@ -1019,6 +1020,7 @@ change_cid_images_src_to_base64 (EHTMLEditorView *view)
set_base64_to_element_attribute (view, WEBKIT_DOM_ELEMENT (node), "src");
}
+ g_object_unref (list);
/* Namespaces */
attributes = webkit_dom_element_get_attributes (document_element);
@@ -1045,11 +1047,13 @@ change_cid_images_src_to_base64 (EHTMLEditorView *view)
view, WEBKIT_DOM_ELEMENT (node), attribute_ns);
}
+ g_object_unref (list);
g_free (attribute_ns);
g_free (selector);
}
g_free (name);
}
+ g_object_unref (attributes);
list = webkit_dom_document_query_selector_all (
document, "[background^=\"cid:\"]", NULL);
@@ -1060,6 +1064,7 @@ change_cid_images_src_to_base64 (EHTMLEditorView *view)
set_base64_to_element_attribute (
view, WEBKIT_DOM_ELEMENT (node), "background");
}
+ g_object_unref (list);
g_hash_table_remove_all (view->priv->inline_images);
}
@@ -1110,6 +1115,7 @@ move_elements_to_body (WebKitDOMDocument *document)
remove_node (node);
}
+ g_object_unref (list);
}
static void
@@ -1128,6 +1134,7 @@ repair_gmail_blockquotes (WebKitDOMDocument *document)
webkit_dom_element_remove_attribute (WEBKIT_DOM_ELEMENT (node), "style");
webkit_dom_element_set_attribute (WEBKIT_DOM_ELEMENT (node), "type", "cite", NULL);
}
+ g_object_unref (list);
}
static void
@@ -2261,6 +2268,7 @@ prevent_from_deleting_last_element_in_body (EHTMLEditorView *view)
if (webkit_dom_element_query_selector (WEBKIT_DOM_ELEMENT (body), "img", NULL))
ret_val = FALSE;
}
+ g_object_unref (list);
return ret_val;
}
@@ -2570,6 +2578,7 @@ mark_node_as_paragraph_after_ending_list (EHTMLEditorSelection *selection,
e_html_editor_selection_set_paragraph_style (
selection, WEBKIT_DOM_ELEMENT (node), -1, 0, "");
}
+ g_object_unref (list);
}
static gboolean
@@ -3522,6 +3531,7 @@ e_html_editor_view_quote_plain_text_element (EHTMLEditorView *view,
WEBKIT_DOM_NODE (element),
NULL);
+ g_object_unref (list);
return WEBKIT_DOM_ELEMENT (element_clone);
}
@@ -3578,6 +3588,7 @@ e_html_editor_view_quote_plain_text (EHTMLEditorView *view)
remove_node (child);
}
}
+ g_object_unref (list);
webkit_dom_node_normalize (body_clone);
quote_plain_text_recursive (document, body_clone, body_clone, 0);
@@ -3598,6 +3609,7 @@ e_html_editor_view_quote_plain_text (EHTMLEditorView *view)
g_free (name);
g_free (value);
}
+ g_object_unref (attributes);
/* Replace old BODY with one, that is quoted */
webkit_dom_node_replace_child (
@@ -3639,6 +3651,7 @@ e_html_editor_view_dequote_plain_text (EHTMLEditorView *view)
remove_quoting_from_element (element);
}
}
+ g_object_unref (paragraphs);
}
static gboolean
@@ -4107,6 +4120,7 @@ html_editor_view_process_document_from_convertor (EHTMLEditorView *view,
remove_node (node);
}
+ g_object_unref (list);
repair_gmail_blockquotes (document_convertor);
@@ -5074,6 +5088,7 @@ process_blockquote (WebKitDOMElement *blockquote)
g_free (text_content);
}
+ g_object_unref (list);
/* Afterwards replace quote nodes with symbols */
list = webkit_dom_element_query_selector_all (
@@ -5090,6 +5105,7 @@ process_blockquote (WebKitDOMElement *blockquote)
g_free (text_content);
}
+ g_object_unref (list);
if (element_has_class (blockquote, "-x-evo-indented")) {
WebKitDOMNode *child;
@@ -5529,6 +5545,7 @@ process_elements (EHTMLEditorView *view,
g_free (value);
}
g_string_append (buffer, ">");
+ g_object_unref (attributes);
}
if (to_html)
remove_evolution_attributes (WEBKIT_DOM_ELEMENT (node));
@@ -5960,6 +5977,7 @@ process_elements (EHTMLEditorView *view,
g_free (content);
}
+ g_object_unref (nodes);
}
static void
@@ -5976,6 +5994,8 @@ remove_wrapping_from_view (EHTMLEditorView *view)
length = webkit_dom_node_list_get_length (list);
for (ii = 0; ii < length; ii++)
remove_node (webkit_dom_node_list_item (list, ii));
+
+ g_object_unref (list);
}
static void
@@ -5992,6 +6012,8 @@ remove_images_in_element (EHTMLEditorView *view,
length = webkit_dom_node_list_get_length (images);
for (ii = 0; ii < length; ii++)
remove_node (webkit_dom_node_list_item (images, ii));
+
+ g_object_unref (images);
}
static void
@@ -6042,6 +6064,8 @@ toggle_smileys (EHTMLEditorView *view)
else
element_remove_class (parent, "-x-evo-resizable-wrapper");
}
+
+ g_object_unref (smileys);
}
static void
@@ -6110,6 +6134,7 @@ toggle_paragraphs_style_in_element (EHTMLEditorView *view,
}
}
}
+ g_object_unref (paragraphs);
}
static void
@@ -6372,10 +6397,13 @@ process_content_for_plain_text (EHTMLEditorView *view)
webkit_dom_element_set_id (
WEBKIT_DOM_ELEMENT (paragraph), "");
}
+ g_object_unref (paragraphs);
convert_element_from_html_to_plain_text (
view, div, &wrap, &quote);
+ g_object_unref (source);
+
source = WEBKIT_DOM_NODE (div);
clean = TRUE;
@@ -6410,6 +6438,7 @@ process_content_for_plain_text (EHTMLEditorView *view)
selection, WEBKIT_DOM_ELEMENT (paragraph));
}
}
+ g_object_unref (paragraphs);
paragraphs = webkit_dom_element_query_selector_all (
WEBKIT_DOM_ELEMENT (source),
@@ -6424,6 +6453,7 @@ process_content_for_plain_text (EHTMLEditorView *view)
remove_node (node);
webkit_dom_node_normalize (parent);
}
+ g_object_unref (paragraphs);
if (view->priv->html_mode || quote)
quote_plain_text_recursive (document, source, source, 0);
@@ -6432,6 +6462,8 @@ process_content_for_plain_text (EHTMLEditorView *view)
if (clean)
remove_node (source);
+ else
+ g_object_unref (source);
/* Return text content between <body> and </body> */
return g_string_free (plain_text, FALSE);
@@ -6442,6 +6474,7 @@ process_content_for_html (EHTMLEditorView *view)
{
WebKitDOMDocument *document;
WebKitDOMNode *body, *document_clone;
+ gchar *html_content;
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
document_clone = webkit_dom_node_clone_node (
@@ -6450,8 +6483,12 @@ process_content_for_html (EHTMLEditorView *view)
WEBKIT_DOM_ELEMENT (document_clone), "body", NULL));
process_elements (view, body, TRUE, FALSE, FALSE, NULL);
- return webkit_dom_html_element_get_outer_html (
+ html_content = webkit_dom_html_element_get_outer_html (
WEBKIT_DOM_HTML_ELEMENT (document_clone));
+
+ g_object_unref (document_clone);
+
+ return html_content;
}
static gboolean
@@ -6512,6 +6549,7 @@ clear_attributes (WebKitDOMDocument *document)
webkit_dom_element_remove_attribute_node (
document_element, WEBKIT_DOM_ATTR (node), NULL);
}
+ g_object_unref (attributes);
/* Remove everything from HEAD element */
while (webkit_dom_node_has_child_nodes (WEBKIT_DOM_NODE (head)))
@@ -6537,6 +6575,7 @@ clear_attributes (WebKitDOMDocument *document)
g_free (name);
}
+ g_object_unref (attributes);
}
static void
@@ -7592,6 +7631,7 @@ e_html_editor_view_get_parts_for_inline_images (EHTMLEditorView *view,
g_free (src);
g_free (cid);
}
+ g_object_unref (list);
list = webkit_dom_document_query_selector_all (
document, "[data-inline][background]", NULL);
@@ -7624,6 +7664,7 @@ e_html_editor_view_get_parts_for_inline_images (EHTMLEditorView *view,
g_free (cid);
}
+ g_object_unref (list);
g_hash_table_destroy (added);
return parts;
diff --git a/e-util/e-mail-signature-preview.c b/e-util/e-mail-signature-preview.c
index ecf64191b6..f125c8b33d 100644
--- a/e-util/e-mail-signature-preview.c
+++ b/e-util/e-mail-signature-preview.c
@@ -80,6 +80,7 @@ replace_local_image_links (WebKitDOMDocument *document)
g_free (new_src);
g_free (src);
}
+ g_object_unref (list);
list = webkit_dom_document_get_elements_by_tag_name ( document, "iframe");
length = webkit_dom_node_list_get_length (list);
@@ -96,6 +97,7 @@ replace_local_image_links (WebKitDOMDocument *document)
if (content_document && WEBKIT_DOM_IS_DOCUMENT (content_document))
replace_local_image_links (content_document);
}
+ g_object_unref (list);
}
static void
diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c
index ed8324c1b1..8a3b9c794b 100644
--- a/e-util/e-web-view.c
+++ b/e-util/e-web-view.c
@@ -2536,6 +2536,7 @@ web_view_get_frame_selection_html (WebKitDOMElement *iframe)
if (text != NULL)
return text;
}
+ g_object_unref (frames);
return NULL;
}
@@ -2568,6 +2569,7 @@ e_web_view_get_selection_html (EWebView *web_view)
if (text != NULL)
return text;
}
+ g_object_unref (frames);
return NULL;
}
@@ -3368,6 +3370,7 @@ add_css_rule_into_style_sheet_recursive (WebKitDOMDocument *document,
selector,
style);
}
+ g_object_unref (frames);
}
/**
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index c610636ee9..74010e1ff9 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -314,7 +314,7 @@ find_element_by_id (WebKitDOMDocument *document,
const gchar *id)
{
WebKitDOMNodeList *frames;
- WebKitDOMElement *element;
+ WebKitDOMElement *element = NULL;
gulong ii, length;
if (!WEBKIT_DOM_IS_DOCUMENT (document))
@@ -342,10 +342,12 @@ find_element_by_id (WebKitDOMDocument *document,
element = find_element_by_id (frame_doc, id);
if (element != NULL)
- return element;
+ goto out;
}
+ out:
+ g_object_unref (frames);
- return NULL;
+ return element;
}
static void
@@ -924,6 +926,7 @@ setup_image_click_event_listeners_on_document (WebKitDOMDocument *document,
G_CALLBACK (toggle_address_visibility), FALSE,
NULL);
}
+ g_object_unref (list);
}
static void
@@ -2110,10 +2113,14 @@ mail_display_get_frame_selection_text (WebKitDOMElement *iframe)
text = mail_display_get_frame_selection_text (
WEBKIT_DOM_ELEMENT (node));
- if (text != NULL)
+ if (text != NULL) {
+ g_object_unref (frames);
return text;
+ }
}
+ g_object_unref (frames);
+
return NULL;
}
@@ -2142,10 +2149,14 @@ e_mail_display_get_selection_plain_text (EMailDisplay *display)
text = mail_display_get_frame_selection_text (
WEBKIT_DOM_ELEMENT (node));
- if (text != NULL)
+ if (text != NULL) {
+ g_object_unref (frames);
return text;
+ }
}
+ g_object_unref (frames);
+
return NULL;
}
diff --git a/modules/itip-formatter/e-mail-part-itip.c b/modules/itip-formatter/e-mail-part-itip.c
index 8dab55d6a2..bcc48dbfd3 100644
--- a/modules/itip-formatter/e-mail-part-itip.c
+++ b/modules/itip-formatter/e-mail-part-itip.c
@@ -95,6 +95,8 @@ mail_part_itip_bind_dom_element (EMailPart *part,
if (length > 0)
element = WEBKIT_DOM_ELEMENT (
webkit_dom_node_list_item (nodes, 0));
+
+ g_object_unref (nodes);
}
g_return_if_fail (WEBKIT_DOM_IS_HTML_IFRAME_ELEMENT (element));
diff --git a/modules/vcard-inline/e-mail-part-vcard.c b/modules/vcard-inline/e-mail-part-vcard.c
index 4cf5bed66b..4335f30324 100644
--- a/modules/vcard-inline/e-mail-part-vcard.c
+++ b/modules/vcard-inline/e-mail-part-vcard.c
@@ -267,6 +267,7 @@ mail_part_vcard_bind_dom_element (EMailPart *part,
iframe = WEBKIT_DOM_ELEMENT (webkit_dom_node_list_item (list, 0));
g_clear_object (&vcard_part->iframe);
vcard_part->iframe = g_object_ref (iframe);
+ g_object_unref (list);
/* TOGGLE DISPLAY MODE BUTTON */
list = webkit_dom_element_get_elements_by_class_name (
@@ -276,6 +277,7 @@ mail_part_vcard_bind_dom_element (EMailPart *part,
toggle_button = WEBKIT_DOM_ELEMENT (webkit_dom_node_list_item (list, 0));
g_clear_object (&vcard_part->toggle_button);
vcard_part->toggle_button = g_object_ref (toggle_button);
+ g_object_unref (list);
/* SAVE TO ADDRESSBOOK BUTTON */
list = webkit_dom_element_get_elements_by_class_name (
@@ -285,6 +287,7 @@ mail_part_vcard_bind_dom_element (EMailPart *part,
save_button = WEBKIT_DOM_ELEMENT (webkit_dom_node_list_item (list, 0));
g_clear_object (&vcard_part->save_button);
vcard_part->save_button = g_object_ref (save_button);
+ g_object_unref (list);
webkit_dom_event_target_add_event_listener (
WEBKIT_DOM_EVENT_TARGET (toggle_button),
diff --git a/plugins/external-editor/external-editor.c b/plugins/external-editor/external-editor.c
index 2eb00b6e87..9ada39f0be 100644
--- a/plugins/external-editor/external-editor.c
+++ b/plugins/external-editor/external-editor.c
@@ -294,6 +294,7 @@ get_caret_position (EHTMLEditorView *view)
}
}
+ g_object_unref (nodes);
return webkit_dom_range_get_start_offset (range, NULL) + range_count;
}