From c5b0b5c754b1b925b1e3b6cff52823e1364c1f5d Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 24 Mar 2020 12:58:34 +0100 Subject: [PATCH 1/2] Ensure that automatic printing still works when the viewer and/or its pages are hidden (bug 1618621, bug 1618955) Please note that this patch, on its own, won't magically fix all of these printing bugs without [bug 1618553](https://bugzilla.mozilla.org/show_bug.cgi?id=1618553) also being fixed. (However I don't foresee that being too difficult, famous last words :-), but it will as suggested require a platform API that we can notify when the viewer is ready.) Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1618621 Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1618955 Fixes 8208 --- web/base_viewer.js | 23 ++++++++++++++++++++++- web/ui_utils.js | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/web/base_viewer.js b/web/base_viewer.js index 4b2fbe734..3b07953b2 100644 --- a/web/base_viewer.js +++ b/web/base_viewer.js @@ -396,6 +396,27 @@ class BaseViewer { throw new Error("Not implemented: _setDocumentViewerElement"); } + /** + * @private + */ + _onePageRenderedOrForceFetch() { + // Unless the viewer *and* its pages are visible, rendering won't start and + // `this._onePageRenderedCapability` thus won't be resolved. + // To ensure that automatic printing, on document load, still works even in + // those cases we force-allow fetching of all pages when: + // - The viewer is hidden in the DOM, e.g. in a `display: none`