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