Unblock the "load" event in inactive windows/tabs (bug 1746213, PR 11646 follow-up)
Given that `requestAnimationFrame` is being used, see the `src/diplay/api.js` file, an inactive window/tab means that rendering will not run and we'll thus not fetch all pages. The latter is a requirement for the "load" event to be unblocked, in the MOZCENTRAL-version of, the default viewer. This patch is a *partial* solution, since it only addresses the following situations: - A *background* tab (containing the viewer) is reloaded, e.g. via the tab-bar context menu. - The viewer is loaded in a active tab, but the user switches away from it (or switches to another program window) *before* rendering has started.
This commit is contained in:
parent
a2ae56f394
commit
472bbf4592
@ -533,11 +533,14 @@ class BaseViewer {
|
||||
// `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 current window/tab is inactive, which will prevent rendering since
|
||||
// `requestAnimationFrame` is being used; fixes bug 1746213.
|
||||
// - The viewer is hidden in the DOM, e.g. in a `display: none` <iframe>
|
||||
// element; fixes bug 1618621.
|
||||
// - The viewer is visible, but none of the pages are (e.g. if the
|
||||
// viewer is very small); fixes bug 1618955.
|
||||
if (
|
||||
document.visibilityState === "hidden" ||
|
||||
!this.container.offsetParent ||
|
||||
this._getVisiblePages().views.length === 0
|
||||
) {
|
||||
|
Loading…
Reference in New Issue
Block a user