From 57484fd63ddf3732ce868a22c21d82d9e0248c76 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Tue, 7 Feb 2023 12:32:35 +0100 Subject: [PATCH] Fixed ZIM viewer iframe height under SeaMonkey SeaMonkey doesn't yet support [Window.visualViewport][1]. As a result the height of the content iframe element was initialized to the default 150 pixels and never changed. Fortunately there is [Window.innerHeight][2] which is supported from the very first days of the Gecko layout engine. The difference between `Window.visualViewport.height` and `Window.innerHeight` is that the latter also includes - the height of the horizontal scroll bar, if present (but in a correctly implemented ZIM viewer there shouldn't be a horizontal scroll bar for the full web-page, so it's OK) - the height of the on-screen keyboard (which is mostly used on mobile devices where SeaMonkey doesn't run). And it is also arguable if the appearing on-screen keyboard should squeeze the iframe or slide over it (in which latter case it may make more sense to always use `innerHeight` instead of `visualViewport.height`). [1]: https://developer.mozilla.org/en-US/docs/Web/API/Window/visualViewport [2]: https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight --- static/skin/viewer.js | 5 ++++- test/server.cpp | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/static/skin/viewer.js b/static/skin/viewer.js index 0426aea0e..db7bc2ba8 100644 --- a/static/skin/viewer.js +++ b/static/skin/viewer.js @@ -198,7 +198,10 @@ function updateToolbarVisibilityState() { } function handle_visual_viewport_change() { - contentIframe.height = window.visualViewport.height - contentIframe.offsetTop - 4; + const wh = window.visualViewport + ? window.visualViewport.height + : window.innerHeight; + contentIframe.height = wh - contentIframe.offsetTop - 4; } function handle_location_hash_change() { diff --git a/test/server.cpp b/test/server.cpp index 0ec08c821..db34315fc 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -73,7 +73,7 @@ const ResourceCollection resources200Compressible{ { DYNAMIC_CONTENT, "/ROOT/skin/taskbar.css" }, { STATIC_CONTENT, "/ROOT/skin/taskbar.css?cacheid=2cbac34b" }, { DYNAMIC_CONTENT, "/ROOT/skin/viewer.js" }, - { STATIC_CONTENT, "/ROOT/skin/viewer.js?cacheid=430d45b0" }, + { STATIC_CONTENT, "/ROOT/skin/viewer.js?cacheid=03fd97ee" }, { DYNAMIC_CONTENT, "/ROOT/skin/fonts/Poppins.ttf" }, { STATIC_CONTENT, "/ROOT/skin/fonts/Poppins.ttf?cacheid=af705837" }, { DYNAMIC_CONTENT, "/ROOT/skin/fonts/Roboto.ttf" }, @@ -302,7 +302,7 @@ R"EXPECTEDRESULT( - + const blankPageUrl = root + "/skin/blank.html?cacheid=6b1fa032";