Add patch to workaround recursion in iframe height computation in mail preview

This commit is contained in:
Milan Crha 2023-05-30 08:26:40 +02:00
parent 833a21f7e0
commit 6118b98b2f
2 changed files with 106 additions and 1 deletions

View File

@ -0,0 +1,99 @@
diff --git a/data/webkit/e-web-view.js b/data/webkit/e-web-view.js
index c811c479db..032287fd73 100644
--- a/data/webkit/e-web-view.js
+++ b/data/webkit/e-web-view.js
@@ -760,6 +760,24 @@ Evo.EnsureMainDocumentInitialized = function()
Evo.initializeAndPostContentLoaded(null);
}
+Evo.mailDisplaySetIFrameHeight = function(iframe, height, forWidth, force)
+{
+ if (!force && iframe.hasAttribute("x-evo-height-for-width") && iframe.hasAttribute("x-evo-cached-height")) {
+ var heightForWidth = parseInt(iframe.getAttribute("x-evo-height-for-width"));
+ if (heightForWidth == forWidth) {
+ var cachedHeight = parseInt(iframe.getAttribute("x-evo-cached-height"));
+ if (cachedHeight > 0) {
+ iframe.height = cachedHeight;
+ return;
+ }
+ }
+ }
+
+ iframe.setAttribute("x-evo-height-for-width", forWidth);
+ iframe.setAttribute("x-evo-cached-height", height);
+ iframe.height = height;
+}
+
Evo.mailDisplayGetScrollbarHeight = function()
{
if (Evo.mailDisplayCachedScrollbarHeight != undefined)
@@ -779,7 +797,7 @@ Evo.mailDisplayUpdateIFramesHeightRecursive = function(doc)
if (!doc)
return;
- var ii, iframes;
+ var ii, iframes, force = false;
iframes = doc.getElementsByTagName("iframe");
@@ -791,20 +809,27 @@ Evo.mailDisplayUpdateIFramesHeightRecursive = function(doc)
if (!doc.scrollingElement || !doc.defaultView || !doc.defaultView.frameElement)
return;
- if (doc.defaultView.frameElement.height == doc.scrollingElement.scrollHeight)
+ if (doc.defaultView.frameElement.height == doc.scrollingElement.scrollHeight) {
doc.defaultView.frameElement.height = 10;
- doc.defaultView.frameElement.height = doc.scrollingElement.scrollHeight + 2 +
- (doc.scrollingElement.scrollWidth > doc.scrollingElement.clientWidth ? Evo.mailDisplayGetScrollbarHeight() : 0);
+ force = true;
+ }
+
+ Evo.mailDisplaySetIFrameHeight(doc.defaultView.frameElement, doc.scrollingElement.scrollHeight + 2 +
+ (doc.scrollingElement.scrollWidth > doc.scrollingElement.clientWidth ? Evo.mailDisplayGetScrollbarHeight() : 0),
+ doc.scrollingElement.clientWidth, force);
}
Evo.MailDisplayUpdateIFramesHeight = function()
{
+ var scrollx = document.defaultView ? document.defaultView.scrollX : -1;
var scrolly = document.defaultView ? document.defaultView.scrollY : -1;
Evo.mailDisplayUpdateIFramesHeightRecursive(document);
- if (scrolly != -1 && document.defaultView.scrollY != scrolly)
- document.defaultView.scrollTo(0, scrolly);
+ if (scrollx != -1 && scrolly != -1 && (
+ document.defaultView.scrollX != scrollx ||
+ document.defaultView.scrollY != scrolly))
+ document.defaultView.scrollTo(scrollx, scrolly);
Evo.mailDisplayResizeContentToPreviewWidth();
Evo.mailDisplayUpdateMagicSpacebarState();
@@ -1194,6 +1219,9 @@ Evo.unsetHTMLColors = function(doc)
Evo.mailDisplaySizeChanged = function(entries, observer)
{
+ var scrollx = document.defaultView ? document.defaultView.scrollX : -1;
+ var scrolly = document.defaultView ? document.defaultView.scrollY : -1;
+
for (const entry of entries) {
if (entry.target.ownerDocument.defaultView.frameElement && entry.borderBoxSize?.length > 0) {
var value = entry.borderBoxSize[0].blockSize;
@@ -1202,9 +1230,15 @@ Evo.mailDisplaySizeChanged = function(entries, observer)
value = entry.target.ownerDocument.scrollingElement.scrollHeight;
if (entry.target.ownerDocument.scrollingElement.scrollWidth > entry.target.ownerDocument.scrollingElement.clientWidth)
value += Evo.mailDisplayGetScrollbarHeight();
- entry.target.ownerDocument.defaultView.frameElement.height = value;
+ Evo.mailDisplaySetIFrameHeight(entry.target.ownerDocument.defaultView.frameElement, value,
+ entry.target.ownerDocument.scrollingElement.clientWidth, false);
}
}
+
+ if (scrollx != -1 && scrolly != -1 && (
+ document.defaultView.scrollX != scrollx ||
+ document.defaultView.scrollY != scrolly))
+ document.defaultView.scrollTo(scrollx, scrolly);
}
Evo.MailDisplayBindDOM = function(iframe_id, markCitationColor)

View File

@ -44,7 +44,7 @@
Name: evolution Name: evolution
Version: 3.48.2 Version: 3.48.2
Release: 2%{?dist} Release: 3%{?dist}
Summary: Mail and calendar client for GNOME Summary: Mail and calendar client for GNOME
License: GPL-2.0-or-later AND GFDL-1.3-or-later License: GPL-2.0-or-later AND GFDL-1.3-or-later
URL: https://wiki.gnome.org/Apps/Evolution URL: https://wiki.gnome.org/Apps/Evolution
@ -55,6 +55,9 @@ Source2: flatpak-evolution-wrapper.sh.in
# https://gitlab.gnome.org/GNOME/evolution/-/issues/2380 # https://gitlab.gnome.org/GNOME/evolution/-/issues/2380
Patch01: 0001-Mail-Preview-content-sometimes-grows-indefinitely.patch Patch01: 0001-Mail-Preview-content-sometimes-grows-indefinitely.patch
# https://gitlab.gnome.org/GNOME/evolution/-/issues/2382
Patch02: 0002-I-2382-Mail-Workaround-recursion-in-iframe-height-co.patch
# Approximate version number # Approximate version number
Provides: bundled(libgnomecanvas) = 2.30.0 Provides: bundled(libgnomecanvas) = 2.30.0
@ -581,6 +584,9 @@ grep -v "%{_datadir}/locale" evolution.lang > help.lang
%endif %endif
%changelog %changelog
* Tue May 30 2023 Milan Crha <mcrha@redhat.com> - 3.48.2-3
- Add patch to workaround recursion in iframe height computation in mail preview
* Mon May 29 2023 Milan Crha <mcrha@redhat.com> - 3.48.2-2 * Mon May 29 2023 Milan Crha <mcrha@redhat.com> - 3.48.2-2
- Add upstream fix for a regression on mail preview panel sometimes growing indefinitely - Add upstream fix for a regression on mail preview panel sometimes growing indefinitely