diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-05-29 18:57:14 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-05-29 19:47:44 +0800 |
commit | efd202df779a37001f7da04637f415a6ce575868 (patch) | |
tree | b303ae991f6fd499a0ed8e7cd9cd837f1f7eeb90 /mail/e-mail-display.c | |
parent | 767fc1d01b6e7526146e1fd134140994fd9d43b5 (diff) | |
download | gsoc2013-evolution-efd202df779a37001f7da04637f415a6ce575868.tar gsoc2013-evolution-efd202df779a37001f7da04637f415a6ce575868.tar.gz gsoc2013-evolution-efd202df779a37001f7da04637f415a6ce575868.tar.bz2 gsoc2013-evolution-efd202df779a37001f7da04637f415a6ce575868.tar.lz gsoc2013-evolution-efd202df779a37001f7da04637f415a6ce575868.tar.xz gsoc2013-evolution-efd202df779a37001f7da04637f415a6ce575868.tar.zst gsoc2013-evolution-efd202df779a37001f7da04637f415a6ce575868.zip |
Distinguish "attachment-wrapper" elements from attachments.
The HTML for attachments always has the following form:
<div class="attachment-wrapper" id="something" style="display: block;">
<actual attachment element>
</div>
The <div> element controls attachment visibility through its "display"
style attribute, which is either "block" or "none".
Problem is the <actual attachment element> was getting the same ID as
its parent <div> element. So when either element was requested by ID,
in certain cases the wrong element was returned and caused misbehavior
and console warnings.
Solve this by adding a "wrapper" suffix to the <div> element ID. So in
the example above, id="something" gets the <actual attachment element>,
whereas id="something.wrapper" gets the <div> element.
(cherry picked from commit 2d251a9597311d4eaaa73556c2c72af5fe62a86e)
Diffstat (limited to 'mail/e-mail-display.c')
-rw-r--r-- | mail/e-mail-display.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c index 28a576d941..3e52074def 100644 --- a/mail/e-mail-display.c +++ b/mail/e-mail-display.c @@ -694,8 +694,9 @@ attachment_button_expanded (GObject *object, WebKitDOMDocument *document; WebKitDOMElement *element; WebKitDOMCSSStyleDeclaration *css; + const gchar *attachment_part_id; + gchar *element_id; gboolean expanded; - gchar *id; d ( printf ("Attachment button %s has been %s!\n", @@ -707,8 +708,11 @@ attachment_button_expanded (GObject *object, gtk_widget_get_visible (GTK_WIDGET (button)); document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (display)); - element = find_element_by_id ( - document, g_object_get_data (object, "attachment_id")); + attachment_part_id = g_object_get_data (object, "attachment_id"); + + element_id = g_strconcat (attachment_part_id, ".wrapper", NULL); + element = find_element_by_id (document, element_id); + g_free (element_id); if (!WEBKIT_DOM_IS_ELEMENT (element)) { d ( @@ -723,16 +727,12 @@ attachment_button_expanded (GObject *object, webkit_dom_css_style_declaration_set_property ( css, "display", expanded ? "block" : "none", "", NULL); - id = g_strconcat ( - g_object_get_data (object, "attachment_id"), - ".iframe", NULL); - element = find_element_by_id (document, id); - g_free (id); + element_id = g_strconcat (attachment_part_id, ".iframe", NULL); + element = find_element_by_id (document, element_id); + g_free (element_id); if (!WEBKIT_DOM_IS_HTML_IFRAME_ELEMENT (element)) { - d ( - printf ("%s: No <iframe> found\n", - (gchar *) g_object_get_data (object, "attachment_id"))); + d (printf ("%s: No <iframe> found\n", attachment_part_id)); return; } bind_iframe_content_visibility (element, display, button); @@ -915,6 +915,7 @@ mail_display_plugin_widget_requested (WebKitWebView *web_view, WebKitDOMDocument *document; EMailPartAttachment *empa = (EMailPartAttachment *) part; gchar *attachment_part_id; + gchar *wrapper_element_id; if (empa->attachment_view_part_id) attachment_part_id = empa->attachment_view_part_id; @@ -925,7 +926,10 @@ mail_display_plugin_widget_requested (WebKitWebView *web_view, * the content of the attachment (iframe). */ document = webkit_web_view_get_dom_document ( WEBKIT_WEB_VIEW (display)); - attachment = find_element_by_id (document, attachment_part_id); + wrapper_element_id = g_strconcat ( + attachment_part_id, ".wrapper", NULL); + attachment = find_element_by_id (document, wrapper_element_id); + g_free (wrapper_element_id); /* None found? Attachment cannot be expanded */ if (attachment == NULL) { |