diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-03-25 17:47:59 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-03-25 17:47:59 +0100 |
commit | 917a2c450f08ab4c934c9938319f10a1114272b4 (patch) | |
tree | 79394bdbef8c5bc90734918a9f862efaf6ec2e1a /application/basilisk/extensions/pdfjs | |
parent | eb77e289bbe056b58051db0fa868e95da803aa0a (diff) | |
parent | a1ad1d835b66e9300cc011244a23aea5d660baf1 (diff) | |
download | UXP-917a2c450f08ab4c934c9938319f10a1114272b4.tar UXP-917a2c450f08ab4c934c9938319f10a1114272b4.tar.gz UXP-917a2c450f08ab4c934c9938319f10a1114272b4.tar.lz UXP-917a2c450f08ab4c934c9938319f10a1114272b4.tar.xz UXP-917a2c450f08ab4c934c9938319f10a1114272b4.zip |
Merge branch 'master' of https://github.com/MoonchildProductions/UXP
Diffstat (limited to 'application/basilisk/extensions/pdfjs')
-rw-r--r-- | application/basilisk/extensions/pdfjs/content/PdfJs.jsm | 23 | ||||
-rw-r--r-- | application/basilisk/extensions/pdfjs/content/PdfStreamConverter.jsm | 38 |
2 files changed, 14 insertions, 47 deletions
diff --git a/application/basilisk/extensions/pdfjs/content/PdfJs.jsm b/application/basilisk/extensions/pdfjs/content/PdfJs.jsm index b3d85436e..7dc01c398 100644 --- a/application/basilisk/extensions/pdfjs/content/PdfJs.jsm +++ b/application/basilisk/extensions/pdfjs/content/PdfJs.jsm @@ -52,23 +52,6 @@ XPCOMUtils.defineLazyModuleGetter(this, 'PdfjsChromeUtils', 'resource://pdf.js/PdfjsChromeUtils.jsm'); XPCOMUtils.defineLazyModuleGetter(this, 'PdfjsContentUtils', 'resource://pdf.js/PdfjsContentUtils.jsm'); - -function getBoolPref(aPref, aDefaultValue) { - try { - return Services.prefs.getBoolPref(aPref); - } catch (ex) { - return aDefaultValue; - } -} - -function getIntPref(aPref, aDefaultValue) { - try { - return Services.prefs.getIntPref(aPref); - } catch (ex) { - return aDefaultValue; - } -} - function isDefaultHandler() { if (Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_CONTENT) { return PdfjsContentUtils.isDefaultHandlerApp(); @@ -172,7 +155,7 @@ var PdfJs = { } this._initialized = true; - if (!getBoolPref(PREF_DISABLED, true)) { + if (!Services.prefs.getBoolPref(PREF_DISABLED, true)) { this._migrate(); } @@ -209,7 +192,7 @@ var PdfJs = { _migrate: function migrate() { const VERSION = 2; - var currentVersion = getIntPref(PREF_MIGRATION_VERSION, 0); + var currentVersion = Services.prefs.getIntPref(PREF_MIGRATION_VERSION, 0); if (currentVersion >= VERSION) { return; } @@ -284,7 +267,7 @@ var PdfJs = { * @return {boolean} Whether or not it's enabled. */ get enabled() { - var disabled = getBoolPref(PREF_DISABLED, true); + var disabled = Services.prefs.getBoolPref(PREF_DISABLED, true); if (disabled) { return false; } diff --git a/application/basilisk/extensions/pdfjs/content/PdfStreamConverter.jsm b/application/basilisk/extensions/pdfjs/content/PdfStreamConverter.jsm index 5e337bbc5..b5b21f214 100644 --- a/application/basilisk/extensions/pdfjs/content/PdfStreamConverter.jsm +++ b/application/basilisk/extensions/pdfjs/content/PdfStreamConverter.jsm @@ -78,22 +78,6 @@ function getFindBar(domWindow) { } } -function getBoolPref(pref, def) { - try { - return Services.prefs.getBoolPref(pref); - } catch (ex) { - return def; - } -} - -function getIntPref(pref, def) { - try { - return Services.prefs.getIntPref(pref); - } catch (ex) { - return def; - } -} - function getStringPref(pref, def) { try { return Services.prefs.getComplexValue(pref, Ci.nsISupportsString).data; @@ -103,7 +87,7 @@ function getStringPref(pref, def) { } function log(aMsg) { - if (!getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false)) { + if (!Services.prefs.getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false)) { return; } var msg = 'PdfStreamConverter.js: ' + (aMsg.join ? aMsg.join('') : aMsg); @@ -359,17 +343,17 @@ ChromeActions.prototype = { return !!findBar && ('updateControlState' in findBar); }, supportsDocumentFonts: function() { - var prefBrowser = getIntPref('browser.display.use_document_fonts', 1); - var prefGfx = getBoolPref('gfx.downloadable_fonts.enabled', true); + var prefBrowser = Services.prefs.getIntPref('browser.display.use_document_fonts', 1); + var prefGfx = Services.prefs.getBoolPref('gfx.downloadable_fonts.enabled', true); return (!!prefBrowser && prefGfx); }, supportsDocumentColors: function() { - return getIntPref('browser.display.document_color_use', 0) !== 2; + return Services.prefs.getIntPref('browser.display.document_color_use', 0) !== 2; }, supportedMouseWheelZoomModifierKeys: function() { return { - ctrlKey: getIntPref('mousewheel.with_control.action', 3) === 3, - metaKey: getIntPref('mousewheel.with_meta.action', 1) === 3, + ctrlKey: Services.prefs.getIntPref('mousewheel.with_control.action', 3) === 3, + metaKey: Services.prefs.getIntPref('mousewheel.with_meta.action', 1) === 3, }; }, reportTelemetry: function (data) { @@ -531,10 +515,10 @@ ChromeActions.prototype = { prefName = (PREF_PREFIX + '.' + key); switch (typeof prefValue) { case 'boolean': - currentPrefs[key] = getBoolPref(prefName, prefValue); + currentPrefs[key] = Services.prefs.getBoolPref(prefName, prefValue); break; case 'number': - currentPrefs[key] = getIntPref(prefName, prefValue); + currentPrefs[key] = Services.prefs.getIntPref(prefName, prefValue); break; case 'string': currentPrefs[key] = getStringPref(prefName, prefValue); @@ -921,16 +905,16 @@ PdfStreamConverter.prototype = { } catch (e) {} var hash = aRequest.URI.ref; - var isPDFBugEnabled = getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false); + var isPDFBugEnabled = Services.prefs.getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false); rangeRequest = contentEncoding === 'identity' && acceptRanges === 'bytes' && aRequest.contentLength >= 0 && - !getBoolPref(PREF_PREFIX + '.disableRange', false) && + !Services.prefs.getBoolPref(PREF_PREFIX + '.disableRange', false) && (!isPDFBugEnabled || hash.toLowerCase().indexOf('disablerange=true') < 0); streamRequest = contentEncoding === 'identity' && aRequest.contentLength >= 0 && - !getBoolPref(PREF_PREFIX + '.disableStream', false) && + !Services.prefs.getBoolPref(PREF_PREFIX + '.disableStream', false) && (!isPDFBugEnabled || hash.toLowerCase().indexOf('disablestream=true') < 0); } |