From 0f3e87911f59ed399df3b6fe570e30371b1794b6 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 23 Jan 2020 12:05:43 +0100 Subject: [PATCH 1/2] Return early in `PDFViewerApplication._parseHashParameters` when the hash is empty For people running e.g. Firefox with the `pdfBugEnabled` preference set, to allow quick access to debugging tools, this method will obviously run for every opened PDF file. However, in most cases the URL hash is empty and we can thus skip most of the parsing and simply return early instead. --- web/app.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/app.js b/web/app.js index 58984c9e3..8c1e20a52 100644 --- a/web/app.js +++ b/web/app.js @@ -239,6 +239,7 @@ const PDFViewerApplication = { }, /** + * Potentially parse special debugging flags in the hash section of the URL. * @private */ async _parseHashParameters() { @@ -249,11 +250,12 @@ const PDFViewerApplication = { ) { return undefined; } - const waitOn = []; - - // Special debugging flags in the hash section of the URL. const hash = document.location.hash.substring(1); - const hashParams = parseQueryString(hash); + if (!hash) { + return undefined; + } + const hashParams = parseQueryString(hash), + waitOn = []; if ( "disableworker" in hashParams && From 9a6ee1b7f28c6b469cd426996b3194e121b85790 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 23 Jan 2020 12:11:58 +0100 Subject: [PATCH 2/2] Remove the "useOnlyCssZoom" (debugging) hash parameter The debugging hash parameters[1] are intended to facilitate access to various tools/settings in PRODUCTION builds, protected by the `pdfBugEnabled` preference. At this point, the remaining debugging hash parameters are mainly intended to allow access to the `PDFBug` tools and/or to quickly toggle certain larger features. The "useOnlyCssZoom" functionality doesn't really seem to fit in with the rest of these hash parameters, since: - This is, comparatively speaking, a minor viewer-specific feature. - The zooming implementation will (almost) always fallback to CSS-only zooming, for any document, once the canvases becomes large enough. Hence, the majority of the CSS zooming feature can still be tested *directly* in any build of the viewer. - After the initial implementation, years ago, the CSS-only zooming code in question hasn't changed much (or even at all), i.e. it doesn't seem like an active development target.[2] - If the "useOnlyCssZoom" functionality was added today, it's unlikely that a hash parameter would've been added. - Last, but not least, there's also a `useOnlyCssZoom` preference hence toggling this functionality shouldn't be too difficult (e.g. if someone needs to hack on it). All in all, I'm thus suggesting that we remove the "useOnlyCssZoom" hash parameter. --- [1] Originally these hash parameters could be used directly in any build, which was bad since it would allow any link to potentially disable functionality and/or reduce performance. [2] If it had seen active development over the years, I'd be *much* more inclined to keep the hash parameter. --- web/app.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/web/app.js b/web/app.js index 8c1e20a52..57c647e9d 100644 --- a/web/app.js +++ b/web/app.js @@ -287,9 +287,6 @@ const PDFViewerApplication = { if ("webgl" in hashParams) { AppOptions.set("enableWebGL", hashParams["webgl"] === "true"); } - if ("useonlycsszoom" in hashParams) { - AppOptions.set("useOnlyCssZoom", hashParams["useonlycsszoom"] === "true"); - } if ("verbosity" in hashParams) { AppOptions.set("verbosity", hashParams["verbosity"] | 0); }