Blame SOURCES/evolution-3.28.5-frame-flattenning.patch

65ef60
diff -up evolution-3.28.5/data/webview.css.frame-flattenning evolution-3.28.5/data/webview.css
65ef60
--- evolution-3.28.5/data/webview.css.frame-flattenning	2018-07-30 15:37:05.000000000 +0200
65ef60
+++ evolution-3.28.5/data/webview.css	2023-01-04 09:25:06.252929132 +0100
65ef60
@@ -8,8 +8,8 @@ img {
65ef60
 }
65ef60
 
65ef60
 body {
65ef60
-  /* Use margin so that children can safely use width=100% */
65ef60
-  margin: 5px 10px 5px 10px;
65ef60
+  /* Use padding so that children can safely use width=100% */
65ef60
+  padding: 8px;
65ef60
 }
65ef60
 
65ef60
 th {
65ef60
@@ -30,21 +30,21 @@ img#__evo-contact-photo {
65ef60
 
65ef60
 img.navigable {
65ef60
   cursor: pointer;
65ef60
-  margin-right: 4px;
65ef60
+  padding-right: 4px;
65ef60
 }
65ef60
 
65ef60
 .attachments {
65ef60
   background: #FFF;
65ef60
   border: 1px solid silver;
65ef60
-  margin: 10px 10px 10px 10px;
65ef60
+  padding: 10px 10px 10px 10px;
65ef60
   border-left: 0;
65ef60
   border-right: 0;
65ef60
   border-bottom: 0;
65ef60
 }
65ef60
 
65ef60
 .attachment {
65ef60
-  margin-left: 8px;
65ef60
-  margin-right: 0px;
65ef60
+  padding-left: 8px;
65ef60
+  padding-right: 0px;
65ef60
 }
65ef60
 
65ef60
 .attachment td {
65ef60
@@ -58,21 +58,21 @@ iframe:not([id$=".itip"]) {
65ef60
 
65ef60
 .part-container {
65ef60
   height: 100%;
65ef60
-  margin-top: 2px;
65ef60
-  margin-bottom: 2px;
65ef60
+  padding: 0px;
65ef60
 }
65ef60
 
65ef60
 .part-container-nostyle iframe {
65ef60
-  margin-right: 10px;
65ef60
+  margin: 0px;
65ef60
+  padding: 0px;
65ef60
 }
65ef60
 
65ef60
 .part-container-inner-margin {
65ef60
-  margin: 8px;
65ef60
+  padding: 0px;
65ef60
 }
65ef60
 
65ef60
 object { /* GtkWidgets */
65ef60
-  margin-top: 2px;
65ef60
-  margin-bottom: 2px;
65ef60
+  padding-top: 2px;
65ef60
+  padding-bottom: 2px;
65ef60
 }
65ef60
 
65ef60
 .__evo-highlight {
65ef60
@@ -139,7 +139,7 @@ th.rtl {
65ef60
 /***** PRINTING *******/
65ef60
 
65ef60
 .printing-header {
65ef60
-  margin-bottom: 20px;
65ef60
+  padding-bottom: 20px;
65ef60
 }
65ef60
 
65ef60
 .printing-header h1,
65ef60
@@ -159,7 +159,7 @@ th.rtl {
65ef60
 /******* ITIP *********/
65ef60
 .itip.icon {
65ef60
   float: left;
65ef60
-  margin-right: 5px;
65ef60
+  padding-right: 5px;
65ef60
 }
65ef60
 
65ef60
 .itip.content {
65ef60
@@ -168,7 +168,7 @@ th.rtl {
65ef60
 }
65ef60
 
65ef60
 .itip.description {
65ef60
-  margin: 5px;
65ef60
+  padding: 5px;
65ef60
 }
65ef60
 
65ef60
 .itip tr {
65ef60
@@ -192,7 +192,7 @@ th.rtl {
65ef60
 }
65ef60
 
65ef60
 #table_row_buttons img {
65ef60
-  margin-right: 5px;
65ef60
+  padding-right: 5px;
65ef60
   vertical-align: middle;
65ef60
 }
65ef60
 
65ef60
diff -up evolution-3.28.5/src/em-format/e-mail-formatter-text-plain.c.frame-flattenning evolution-3.28.5/src/em-format/e-mail-formatter-text-plain.c
65ef60
--- evolution-3.28.5/src/em-format/e-mail-formatter-text-plain.c.frame-flattenning	2018-07-30 15:37:05.000000000 +0200
65ef60
+++ evolution-3.28.5/src/em-format/e-mail-formatter-text-plain.c	2023-01-04 09:25:06.252929132 +0100
65ef60
@@ -111,7 +111,7 @@ emfe_text_plain_format (EMailFormatterEx
65ef60
 		string =
65ef60
 			"
65ef60
 			"-e-web-view-background-color -e-web-view-text-color\" "
65ef60
-			"style=\"border: none; padding: 8px; margin: 0;\">";
65ef60
+			"style=\"border: none; padding: 0px; margin: 0;\">";
65ef60
 
65ef60
 		g_output_stream_write_all (
65ef60
 			stream, string, strlen (string),
65ef60
diff -up evolution-3.28.5/src/mail/e-mail-display.c.frame-flattenning evolution-3.28.5/src/mail/e-mail-display.c
65ef60
--- evolution-3.28.5/src/mail/e-mail-display.c.frame-flattenning	2018-07-30 15:37:05.000000000 +0200
65ef60
+++ evolution-3.28.5/src/mail/e-mail-display.c	2023-01-04 09:25:06.252929132 +0100
65ef60
@@ -1529,6 +1529,19 @@ mail_display_set_fonts (EWebView *web_vi
65ef60
 	mail_display_get_font_settings (display->priv->settings, monospace, variable);
65ef60
 }
65ef60
 
65ef60
+static gboolean
65ef60
+mail_display_can_use_frame_flattening (void)
65ef60
+{
65ef60
+	guint wk_major, wk_minor;
65ef60
+
65ef60
+	wk_major = webkit_get_major_version ();
65ef60
+	wk_minor = webkit_get_minor_version ();
65ef60
+
65ef60
+	/* The 2.38 is the last version, which supports frame-flattening;
65ef60
+	   prefer it over the manual and expensive calculations. */
65ef60
+	return (wk_major < 2) || (wk_major == 2 && wk_minor <= 38);
65ef60
+}
65ef60
+
65ef60
 static void
65ef60
 mail_display_web_view_initialize (WebKitWebView *web_view)
65ef60
 {
65ef60
@@ -1536,9 +1549,11 @@ mail_display_web_view_initialize (WebKit
65ef60
 
65ef60
 	webkit_settings = webkit_web_view_get_settings (web_view);
65ef60
 
65ef60
-	g_object_set (webkit_settings,
65ef60
-		"enable-frame-flattening", TRUE,
65ef60
-		NULL);
65ef60
+	if (mail_display_can_use_frame_flattening ()) {
65ef60
+		g_object_set (webkit_settings,
65ef60
+			"enable-frame-flattening", TRUE,
65ef60
+			NULL);
65ef60
+	}
65ef60
 }
65ef60
 
65ef60
 static void
65ef60
diff -up evolution-3.28.5/src/modules/itip-formatter/web-extension/module-itip-formatter-web-extension.c.frame-flattenning evolution-3.28.5/src/modules/itip-formatter/web-extension/module-itip-formatter-web-extension.c
65ef60
--- evolution-3.28.5/src/modules/itip-formatter/web-extension/module-itip-formatter-web-extension.c.frame-flattenning	2018-07-30 15:37:05.000000000 +0200
65ef60
+++ evolution-3.28.5/src/modules/itip-formatter/web-extension/module-itip-formatter-web-extension.c	2023-01-04 09:25:06.253929132 +0100
65ef60
@@ -259,7 +259,7 @@ handle_method_call (GDBusConnection *con
65ef60
                     gpointer user_data)
65ef60
 {
65ef60
 	WebKitWebExtension *web_extension = WEBKIT_WEB_EXTENSION (user_data);
65ef60
-	WebKitDOMDocument *document;
65ef60
+	WebKitDOMDocument *document = NULL, *top_document = NULL;
65ef60
 	const gchar *part_id = NULL;
65ef60
 	guint64 page_id;
65ef60
 
65ef60
@@ -281,11 +281,12 @@ handle_method_call (GDBusConnection *con
65ef60
 
65ef60
 		g_variant_get (parameters, "(t&s&s)", &page_id, &part_id, &button_id);
65ef60
 
65ef60
-		document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
-		if (document)
65ef60
-			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, document, part_id);
65ef60
+		top_document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
+		if (top_document)
65ef60
+			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, top_document, part_id);
65ef60
 		if (document) {
65ef60
 			module_itip_formatter_dom_utils_show_button (document, button_id);
65ef60
+			e_dom_update_iframe_height (top_document);
65ef60
 			g_dbus_method_invocation_return_value (invocation, NULL);
65ef60
 		}
65ef60
 	} else if (g_strcmp0 (method_name, "EnableButton") == 0) {
65ef60
@@ -306,11 +307,12 @@ handle_method_call (GDBusConnection *con
65ef60
 
65ef60
 		g_variant_get (parameters, "(t&s&s&s)", &page_id, &part_id, &element_id, &inner_html);
65ef60
 
65ef60
-		document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
-		if (document)
65ef60
-			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, document, part_id);
65ef60
+		top_document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
+		if (top_document)
65ef60
+			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, top_document, part_id);
65ef60
 		if (document) {
65ef60
 			e_dom_utils_element_set_inner_html (document, element_id, inner_html);
65ef60
+			e_dom_update_iframe_height (top_document);
65ef60
 			g_dbus_method_invocation_return_value (invocation, NULL);
65ef60
 		}
65ef60
 	} else if (g_strcmp0 (method_name, "RemoveElement") == 0) {
65ef60
@@ -318,11 +320,12 @@ handle_method_call (GDBusConnection *con
65ef60
 
65ef60
 		g_variant_get (parameters, "(t&s&s)", &page_id, &part_id, &element_id);
65ef60
 
65ef60
-		document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
-		if (document)
65ef60
-			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, document, part_id);
65ef60
+		top_document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
+		if (top_document)
65ef60
+			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, top_document, part_id);
65ef60
 		if (document) {
65ef60
 			e_dom_utils_remove_element (document, element_id);
65ef60
+			e_dom_update_iframe_height (top_document);
65ef60
 			g_dbus_method_invocation_return_value (invocation, NULL);
65ef60
 		}
65ef60
 	} else if (g_strcmp0 (method_name, "ElementRemoveChildNodes") == 0) {
65ef60
@@ -330,11 +333,12 @@ handle_method_call (GDBusConnection *con
65ef60
 
65ef60
 		g_variant_get (parameters, "(t&s&s)", &page_id, &part_id, &element_id);
65ef60
 
65ef60
-		document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
-		if (document)
65ef60
-			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, document, part_id);
65ef60
+		top_document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
+		if (top_document)
65ef60
+			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, top_document, part_id);
65ef60
 		if (document) {
65ef60
 			e_dom_utils_element_remove_child_nodes (document, element_id);
65ef60
+			e_dom_update_iframe_height (top_document);
65ef60
 			g_dbus_method_invocation_return_value (invocation, NULL);
65ef60
 		}
65ef60
 	} else if (g_strcmp0 (method_name, "HideElement") == 0) {
65ef60
@@ -343,11 +347,12 @@ handle_method_call (GDBusConnection *con
65ef60
 
65ef60
 		g_variant_get (parameters, "(t&s&sb)", &page_id, &part_id, &element_id, &hide);
65ef60
 
65ef60
-		document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
-		if (document)
65ef60
-			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, document, part_id);
65ef60
+		top_document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
+		if (top_document)
65ef60
+			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, top_document, part_id);
65ef60
 		if (document) {
65ef60
 			e_dom_utils_hide_element (document, element_id, hide);
65ef60
+			e_dom_update_iframe_height (top_document);
65ef60
 			g_dbus_method_invocation_return_value (invocation, NULL);
65ef60
 		}
65ef60
 	} else if (g_strcmp0 (method_name, "ElementIsHidden") == 0) {
65ef60
@@ -395,11 +400,12 @@ handle_method_call (GDBusConnection *con
65ef60
 
65ef60
 		g_variant_get (parameters, "(t&s&sbb)", &page_id, &part_id, &id, &show, &update_second);
65ef60
 
65ef60
-		document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
-		if (document)
65ef60
-			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, document, part_id);
65ef60
+		top_document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
+		if (top_document)
65ef60
+			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, top_document, part_id);
65ef60
 		if (document) {
65ef60
 			module_itip_formatter_dom_utils_show_checkbox (document, id, show, update_second);
65ef60
+			e_dom_update_iframe_height (top_document);
65ef60
 			g_dbus_method_invocation_return_value (invocation, NULL);
65ef60
 		}
65ef60
 	} else if (g_strcmp0 (method_name, "SetButtonsSensitive") == 0) {
65ef60
@@ -419,11 +425,12 @@ handle_method_call (GDBusConnection *con
65ef60
 
65ef60
 		g_variant_get (parameters, "(t&s&s&s)", &page_id, &part_id, &id, &text);
65ef60
 
65ef60
-		document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
-		if (document)
65ef60
-			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, document, part_id);
65ef60
+		top_document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
+		if (top_document)
65ef60
+			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, top_document, part_id);
65ef60
 		if (document) {
65ef60
 			module_itip_formatter_dom_utils_set_area_text (document, id, text);
65ef60
+			e_dom_update_iframe_height (top_document);
65ef60
 			g_dbus_method_invocation_return_value (invocation, NULL);
65ef60
 		}
65ef60
 	} else if (g_strcmp0 (method_name, "ElementSetAccessKey") == 0) {
65ef60
@@ -443,11 +450,12 @@ handle_method_call (GDBusConnection *con
65ef60
 
65ef60
 		g_variant_get (parameters, "(t&s&s)", &page_id, &part_id, &element_id);
65ef60
 
65ef60
-		document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
-		if (document)
65ef60
-			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, document, part_id);
65ef60
+		top_document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
+		if (top_document)
65ef60
+			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, top_document, part_id);
65ef60
 		if (document) {
65ef60
 			module_itip_formatter_dom_utils_element_hide_child_nodes (document, element_id);
65ef60
+			e_dom_update_iframe_height (top_document);
65ef60
 			g_dbus_method_invocation_return_value (invocation, NULL);
65ef60
 		}
65ef60
 	} else if (g_strcmp0 (method_name, "EnableSelect") == 0) {
65ef60
@@ -509,11 +517,12 @@ handle_method_call (GDBusConnection *con
65ef60
 
65ef60
 		g_variant_get (parameters, "(t&s&s&s&s)", &page_id, &part_id, &element_id, &header, &label);
65ef60
 
65ef60
-		document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
-		if (document)
65ef60
-			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, document, part_id);
65ef60
+		top_document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
+		if (top_document)
65ef60
+			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, top_document, part_id);
65ef60
 		if (document) {
65ef60
 			module_itip_formatter_dom_utils_update_times (document, element_id, header, label);
65ef60
+			e_dom_update_iframe_height (top_document);
65ef60
 			g_dbus_method_invocation_return_value (invocation, NULL);
65ef60
 		}
65ef60
 	} else if (g_strcmp0 (method_name, "AppendInfoItemRow") == 0) {
65ef60
@@ -521,11 +530,12 @@ handle_method_call (GDBusConnection *con
65ef60
 
65ef60
 		g_variant_get (parameters, "(t&s&s&s&s&s)", &page_id, &part_id, &table_id, &row_id, &icon_name, &message);
65ef60
 
65ef60
-		document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
-		if (document)
65ef60
-			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, document, part_id);
65ef60
+		top_document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
+		if (top_document)
65ef60
+			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, top_document, part_id);
65ef60
 		if (document) {
65ef60
 			module_itip_formatter_dom_utils_append_info_item_row (document, table_id, row_id, icon_name, message);
65ef60
+			e_dom_update_iframe_height (top_document);
65ef60
 			g_dbus_method_invocation_return_value (invocation, NULL);
65ef60
 		}
65ef60
 	} else if (g_strcmp0 (method_name, "EnableTextArea") == 0) {
65ef60
@@ -546,11 +556,12 @@ handle_method_call (GDBusConnection *con
65ef60
 
65ef60
 		g_variant_get (parameters, "(t&s&s&s)", &page_id, &part_id, &area_id, &value);
65ef60
 
65ef60
-		document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
-		if (document)
65ef60
-			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, document, part_id);
65ef60
+		top_document = get_webkit_document_or_return_dbus_error (invocation, web_extension, page_id);
65ef60
+		if (top_document)
65ef60
+			document = find_webkit_document_for_partid_or_return_dbus_error (invocation, top_document, part_id);
65ef60
 		if (document) {
65ef60
 			module_itip_formatter_dom_utils_text_area_set_value (document, area_id, value);
65ef60
+			e_dom_update_iframe_height (top_document);
65ef60
 			g_dbus_method_invocation_return_value (invocation, NULL);
65ef60
 		}
65ef60
 	} else if (g_strcmp0 (method_name, "TextAreaGetValue") == 0) {
65ef60
diff -up evolution-3.28.5/src/modules/text-highlight/e-mail-formatter-text-highlight.c.frame-flattenning evolution-3.28.5/src/modules/text-highlight/e-mail-formatter-text-highlight.c
65ef60
--- evolution-3.28.5/src/modules/text-highlight/e-mail-formatter-text-highlight.c.frame-flattenning	2018-07-30 15:37:05.000000000 +0200
65ef60
+++ evolution-3.28.5/src/modules/text-highlight/e-mail-formatter-text-highlight.c	2023-01-04 09:25:06.252929132 +0100
65ef60
@@ -122,16 +122,26 @@ text_hightlight_read_data_thread (gpoint
65ef60
 {
65ef60
 	TextHighlightClosure *closure = user_data;
65ef60
 	gint nbuffer = 10240;
65ef60
+	gssize read;
65ef60
+	gsize wrote = 0;
65ef60
 	gchar *buffer;
65ef60
 
65ef60
 	g_return_val_if_fail (closure != NULL, NULL);
65ef60
 
65ef60
 	buffer = g_new (gchar, nbuffer);
65ef60
 
65ef60
+	strcpy (buffer, "<style>body{margin:0; padding:8px;}</style>");
65ef60
+	read = strlen (buffer);
65ef60
+
65ef60
+	if (!g_output_stream_write_all (closure->output_stream, buffer, read, &wrote, closure->cancellable, &closure->error) ||
65ef60
+	    (gssize) wrote != read || closure->error) {
65ef60
+		g_free (buffer);
65ef60
+		return NULL;
65ef60
+	}
65ef60
+
65ef60
 	while (!camel_stream_eos (closure->read_stream) &&
65ef60
 	       !g_cancellable_set_error_if_cancelled (closure->cancellable, &closure->error)) {
65ef60
-		gssize read;
65ef60
-		gsize wrote = 0;
65ef60
+		wrote = 0;
65ef60
 
65ef60
 		read = camel_stream_read (closure->read_stream, buffer, nbuffer, closure->cancellable, &closure->error);
65ef60
 		if (read < 0 || closure->error)
65ef60
diff -up evolution-3.28.5/src/web-extensions/e-dom-utils.c.frame-flattenning evolution-3.28.5/src/web-extensions/e-dom-utils.c
65ef60
--- evolution-3.28.5/src/web-extensions/e-dom-utils.c.frame-flattenning	2018-07-30 15:37:05.000000000 +0200
65ef60
+++ evolution-3.28.5/src/web-extensions/e-dom-utils.c	2023-01-04 09:25:06.253929132 +0100
65ef60
@@ -837,9 +837,8 @@ set_iframe_and_body_width (WebKitDOMDocu
65ef60
 		gchar *style;
65ef60
 
65ef60
 		/* Message main body */
65ef60
-		local_width -= 8; /* 8 + 8 margins of body without iframes */
65ef60
-		if (level > 1)
65ef60
-			local_width -= 8;
65ef60
+		local_width -= level * 20; /* 10 + 10 margins of body without iframes */
65ef60
+		local_width -= 4;
65ef60
 
65ef60
 		style = g_strdup_printf ("width: %" G_GINT64_FORMAT "px;", local_width);
65ef60
 		e_dom_utils_add_css_rule_into_style_sheet_in_document (
65ef60
@@ -867,7 +866,7 @@ set_iframe_and_body_width (WebKitDOMDocu
65ef60
 			style);
65ef60
 		g_free (style);
65ef60
 
65ef60
-		local_width -= 2; /* 1 + 1 frame borders */
65ef60
+		local_width -= 4; /* 2 + 2 frame borders */
65ef60
 
65ef60
 		style = g_strdup_printf ("width: %" G_GINT64_FORMAT "px;", local_width);
65ef60
 		e_dom_utils_add_css_rule_into_style_sheet_in_document (
65ef60
@@ -891,15 +890,11 @@ set_iframe_and_body_width (WebKitDOMDocu
65ef60
 	} else {
65ef60
 		gchar *style;
65ef60
 
65ef60
-		local_width -= 20; /* 10 + 10 margins of body with iframes */
65ef60
-		local_width -= 8; /* attachment margin */
65ef60
-		local_width -= 2; /* 1 + 1 frame borders */
65ef60
+		local_width -= (level - 1) * 20; /* 10 + 10 margins of body with iframes */
65ef60
+		local_width -= 4; /* 2 + 2 frame borders */
65ef60
+		local_width -= 10; /* attachment margin */
65ef60
 
65ef60
-		/* We need to subtract another 10 pixels from the iframe width to
65ef60
-		 * have the iframe's borders on the correct place. We can't subtract
65ef60
-		 * it from local_width as we don't want to propagate this change
65ef60
-		 * further. */
65ef60
-		style = g_strdup_printf ("width: %" G_GINT64_FORMAT "px;", local_width - 10);
65ef60
+		style = g_strdup_printf ("width: %" G_GINT64_FORMAT "px;", local_width);
65ef60
 		e_dom_utils_add_css_rule_into_style_sheet_in_document (
65ef60
 			document,
65ef60
 			"-e-mail-formatter-style-sheet",
65ef60
@@ -933,7 +928,7 @@ set_iframe_and_body_width (WebKitDOMDocu
65ef60
 		if (level == 0) {
65ef60
 			gchar *style = NULL;
65ef60
 
65ef60
-			tmp_local_width -= 8; /* attachment's margin */
65ef60
+			tmp_local_width -= 10; /* attachment's margin */
65ef60
 
65ef60
 			style = g_strdup_printf ("width: %" G_GINT64_FORMAT "px;", tmp_local_width);
65ef60
 			e_dom_utils_add_css_rule_into_style_sheet_in_document (
65ef60
@@ -947,9 +942,7 @@ set_iframe_and_body_width (WebKitDOMDocu
65ef60
 				"-e-mail-formatter-style-sheet",
65ef60
 				".attachment-wrapper iframe[src*=\"__formatas=txt\"]",
65ef60
 				style);
65ef60
-			g_free (style);
65ef60
 
65ef60
-			style = g_strdup_printf ("width: %" G_GINT64_FORMAT "px;", local_width);
65ef60
 			e_dom_utils_add_css_rule_into_style_sheet_in_document (
65ef60
 				document,
65ef60
 				"-e-mail-formatter-style-sheet",
65ef60
@@ -992,8 +985,10 @@ dom_window_resize_cb (WebKitDOMDOMWindow
65ef60
 
65ef60
 	document = webkit_dom_dom_window_get_document (dom_window);
65ef60
 
65ef60
-	if (document)
65ef60
+	if (document) {
65ef60
 		e_dom_resize_document_content_to_preview_width (document);
65ef60
+		e_dom_update_iframe_height (document);
65ef60
+	}
65ef60
 }
65ef60
 
65ef60
 static gboolean
65ef60
@@ -1106,6 +1101,7 @@ e_dom_utils_e_mail_display_bind_dom (Web
65ef60
 	e_dom_wrap_long_anchors (document);
65ef60
 
65ef60
 	e_dom_resize_document_content_to_preview_width (document);
65ef60
+	e_dom_update_iframe_height (document);
65ef60
 }
65ef60
 
65ef60
 void
65ef60
@@ -1160,6 +1156,99 @@ e_dom_utils_e_mail_display_unstyle_block
65ef60
 	g_clear_object (&collection);
65ef60
 }
65ef60
 
65ef60
+static void
65ef60
+e_dom_update_iframe_height_recursive (WebKitDOMDocument *document)
65ef60
+{
65ef60
+	WebKitDOMHTMLCollection *frames = NULL;
65ef60
+	WebKitDOMElement *scrolling_elem;
65ef60
+	gulong ii, length;
65ef60
+
65ef60
+	frames = webkit_dom_document_get_elements_by_tag_name_as_html_collection (document, "iframe");
65ef60
+	length = webkit_dom_html_collection_get_length (frames);
65ef60
+	for (ii = 0; ii < length; ii++) {
65ef60
+		WebKitDOMHTMLIFrameElement *iframe;
65ef60
+		WebKitDOMDocument *content_document;
65ef60
+
65ef60
+		iframe = WEBKIT_DOM_HTML_IFRAME_ELEMENT (webkit_dom_html_collection_item (frames, ii));
65ef60
+
65ef60
+		content_document = webkit_dom_html_iframe_element_get_content_document (iframe);
65ef60
+		if (!content_document)
65ef60
+			continue;
65ef60
+
65ef60
+		e_dom_update_iframe_height_recursive (content_document);
65ef60
+	}
65ef60
+
65ef60
+	scrolling_elem = webkit_dom_document_get_scrolling_element (document);
65ef60
+	if (scrolling_elem) {
65ef60
+		WebKitDOMDOMWindow *default_view;
65ef60
+
65ef60
+		default_view = webkit_dom_document_get_default_view (document);
65ef60
+		if (default_view) {
65ef60
+			WebKitDOMElement *frame_elem;
65ef60
+
65ef60
+			frame_elem = webkit_dom_dom_window_get_frame_element (default_view);
65ef60
+			if (frame_elem) {
65ef60
+				WebKitDOMHTMLIFrameElement *iframe = WEBKIT_DOM_HTML_IFRAME_ELEMENT (frame_elem);
65ef60
+				glong scroll_height;
65ef60
+				gchar *height;
65ef60
+
65ef60
+				scroll_height = webkit_dom_element_get_scroll_height (scrolling_elem);
65ef60
+				height = webkit_dom_html_iframe_element_get_height (iframe);
65ef60
+				if (!height || scroll_height == (glong) g_ascii_strtoll (height, NULL, 10))
65ef60
+					webkit_dom_html_iframe_element_set_height (iframe, "10");
65ef60
+				g_free (height);
65ef60
+
65ef60
+				scroll_height = webkit_dom_element_get_scroll_height (scrolling_elem);
65ef60
+				height = g_strdup_printf ("%" G_GINT64_FORMAT, (gint64) (scroll_height + 2 +
65ef60
+					(webkit_dom_element_get_scroll_width (scrolling_elem) > webkit_dom_element_get_client_width (scrolling_elem) ? 20 : 0)));
65ef60
+				webkit_dom_html_iframe_element_set_height (iframe, height);
65ef60
+				g_free (height);
65ef60
+			}
65ef60
+		}
65ef60
+
65ef60
+		g_clear_object (&default_view);
65ef60
+	}
65ef60
+
65ef60
+	g_clear_object (&frames);
65ef60
+}
65ef60
+
65ef60
+static gboolean
65ef60
+mail_display_can_use_frame_flattening (void)
65ef60
+{
65ef60
+	guint wk_major, wk_minor;
65ef60
+
65ef60
+	wk_major = webkit_get_major_version ();
65ef60
+	wk_minor = webkit_get_minor_version ();
65ef60
+
65ef60
+	/* The 2.38 is the last version, which supports frame-flattening;
65ef60
+	   prefer it over the manual and expensive calculations. */
65ef60
+	return (wk_major < 2) || (wk_major == 2 && wk_minor <= 38);
65ef60
+}
65ef60
+
65ef60
+void
65ef60
+e_dom_update_iframe_height (WebKitDOMDocument *document)
65ef60
+{
65ef60
+	WebKitDOMDOMWindow *default_view;
65ef60
+
65ef60
+	if (mail_display_can_use_frame_flattening ())
65ef60
+		return;
65ef60
+
65ef60
+	default_view = webkit_dom_document_get_default_view (document);
65ef60
+	if (default_view) {
65ef60
+		glong scroll_x, scroll_y;
65ef60
+
65ef60
+		scroll_x = webkit_dom_dom_window_get_scroll_x (default_view);
65ef60
+		scroll_y = webkit_dom_dom_window_get_scroll_y (default_view);
65ef60
+
65ef60
+		e_dom_update_iframe_height_recursive (document);
65ef60
+
65ef60
+		if (scroll_y != webkit_dom_dom_window_get_scroll_y (default_view))
65ef60
+			webkit_dom_dom_window_scroll_to (default_view, scroll_x, scroll_y);
65ef60
+	}
65ef60
+
65ef60
+	g_clear_object (&default_view);
65ef60
+}
65ef60
+
65ef60
 void
65ef60
 e_dom_utils_eab_contact_formatter_bind_dom (WebKitDOMDocument *document)
65ef60
 {
65ef60
diff -up evolution-3.28.5/src/web-extensions/e-dom-utils.h.frame-flattenning evolution-3.28.5/src/web-extensions/e-dom-utils.h
65ef60
--- evolution-3.28.5/src/web-extensions/e-dom-utils.h.frame-flattenning	2018-07-30 15:37:05.000000000 +0200
65ef60
+++ evolution-3.28.5/src/web-extensions/e-dom-utils.h	2023-01-04 09:25:06.253929132 +0100
65ef60
@@ -69,6 +69,7 @@ void		e_dom_utils_e_mail_display_bind_do
65ef60
 						 GDBusConnection *connection);
65ef60
 void		e_dom_utils_e_mail_display_unstyle_blockquotes
65ef60
 						(WebKitDOMDocument *document);
65ef60
+void		e_dom_update_iframe_height	(WebKitDOMDocument *document);
65ef60
 WebKitDOMElement *
65ef60
 		e_dom_utils_find_element_by_selector
65ef60
 						(WebKitDOMDocument *document,
65ef60
diff -up evolution-3.28.5/src/web-extensions/e-web-extension.c.frame-flattenning evolution-3.28.5/src/web-extensions/e-web-extension.c
65ef60
--- evolution-3.28.5/src/web-extensions/e-web-extension.c.frame-flattenning	2018-07-30 15:37:05.000000000 +0200
65ef60
+++ evolution-3.28.5/src/web-extensions/e-web-extension.c	2023-01-04 09:25:06.253929132 +0100
65ef60
@@ -613,8 +613,10 @@ handle_method_call (GDBusConnection *con
65ef60
 
65ef60
 			e_dom_utils_hide_element (document, element_id, hidden);
65ef60
 
65ef60
-			if (expand_inner_data)
65ef60
+			if (expand_inner_data) {
65ef60
 				e_dom_resize_document_content_to_preview_width (document);
65ef60
+				e_dom_update_iframe_height (document);
65ef60
+			}
65ef60
 		}
65ef60
 
65ef60
 		g_dbus_method_invocation_return_value (invocation, NULL);