From bb1647507097c248cdce2b7f83ae03684b02d31e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 31 Jan 2015 22:43:30 +0100 Subject: [PATCH 1/2] Use the |shadow| function from src/shared/util.js in viewer.js --- src/shared/util.js | 1 + web/viewer.js | 42 +++++++++++------------------------------- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/src/shared/util.js b/src/shared/util.js index 58671f09a..d11ebe0be 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -325,6 +325,7 @@ function shadow(obj, prop, value) { writable: false }); return value; } +PDFJS.shadow = shadow; var PasswordResponses = PDFJS.PasswordResponses = { NEED_PASSWORD: 1, diff --git a/web/viewer.js b/web/viewer.js index 4c8492162..6438d3f75 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -299,12 +299,8 @@ var PDFViewerApplication = { get supportsPrinting() { var canvas = document.createElement('canvas'); var value = 'mozPrintCallback' in canvas; - // shadow - Object.defineProperty(this, 'supportsPrinting', { value: value, - enumerable: true, - configurable: true, - writable: false }); - return value; + + return PDFJS.shadow(this, 'supportsPrinting', value); }, get supportsFullscreen() { @@ -319,11 +315,7 @@ var PDFViewerApplication = { support = false; } - Object.defineProperty(this, 'supportsFullscreen', { value: support, - enumerable: true, - configurable: true, - writable: false }); - return support; + return PDFJS.shadow(this, 'supportsFullscreen', support); }, get supportsIntegratedFind() { @@ -332,11 +324,8 @@ var PDFViewerApplication = { //#else // support = FirefoxCom.requestSync('supportsIntegratedFind'); //#endif - Object.defineProperty(this, 'supportsIntegratedFind', { value: support, - enumerable: true, - configurable: true, - writable: false }); - return support; + + return PDFJS.shadow(this, 'supportsIntegratedFind', support); }, get supportsDocumentFonts() { @@ -345,11 +334,8 @@ var PDFViewerApplication = { //#else // support = FirefoxCom.requestSync('supportsDocumentFonts'); //#endif - Object.defineProperty(this, 'supportsDocumentFonts', { value: support, - enumerable: true, - configurable: true, - writable: false }); - return support; + + return PDFJS.shadow(this, 'supportsDocumentFonts', support); }, get supportsDocumentColors() { @@ -358,20 +344,14 @@ var PDFViewerApplication = { //#else // support = FirefoxCom.requestSync('supportsDocumentColors'); //#endif - Object.defineProperty(this, 'supportsDocumentColors', { value: support, - enumerable: true, - configurable: true, - writable: false }); - return support; + + return PDFJS.shadow(this, 'supportsDocumentColors', support); }, get loadingBar() { var bar = new ProgressBar('#loadingBar', {}); - Object.defineProperty(this, 'loadingBar', { value: bar, - enumerable: true, - configurable: true, - writable: false }); - return bar; + + return PDFJS.shadow(this, 'loadingBar', bar); }, //#if (FIREFOX || MOZCENTRAL) From d53fa1884b473c38f16b8bfed20893f5ffbb65af Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 31 Jan 2015 22:45:20 +0100 Subject: [PATCH 2/2] Simplify a couple of preprocessor tags in viewer.js --- web/viewer.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/web/viewer.js b/web/viewer.js index 6438d3f75..d8b62d1ba 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -320,8 +320,7 @@ var PDFViewerApplication = { get supportsIntegratedFind() { var support = false; -//#if !(FIREFOX || MOZCENTRAL) -//#else +//#if (FIREFOX || MOZCENTRAL) // support = FirefoxCom.requestSync('supportsIntegratedFind'); //#endif @@ -330,8 +329,7 @@ var PDFViewerApplication = { get supportsDocumentFonts() { var support = true; -//#if !(FIREFOX || MOZCENTRAL) -//#else +//#if (FIREFOX || MOZCENTRAL) // support = FirefoxCom.requestSync('supportsDocumentFonts'); //#endif @@ -340,8 +338,7 @@ var PDFViewerApplication = { get supportsDocumentColors() { var support = true; -//#if !(FIREFOX || MOZCENTRAL) -//#else +//#if (FIREFOX || MOZCENTRAL) // support = FirefoxCom.requestSync('supportsDocumentColors'); //#endif