From b263b702e8f9230484e835d88c206feda2ecb743 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 5 Jun 2018 20:30:06 +0200 Subject: [PATCH] Rename `PDFPageProxy.pageInfo` to `PDFPageProxy._pageInfo` to indicate that the property should be considered "private" Since `PDFPageProxy` already provide getters for all the data returned by `GetPage` (in the Worker), there isn't any compelling reason for accessing the `pageInfo` directly on `PDFPageProxy`. The patch also changes the `GetPage` handler, in `src/core/worker.js`, to use modern JavaScript features. --- src/core/worker.js | 20 +++++++++----------- src/display/api.js | 10 +++++----- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/core/worker.js b/src/core/worker.js index 106d31bcb..5b5020dfd 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -639,19 +639,17 @@ var WorkerMessageHandler = { handler.on('GetPage', function wphSetupGetPage(data) { return pdfManager.getPage(data.pageIndex).then(function(page) { - var rotatePromise = pdfManager.ensure(page, 'rotate'); - var refPromise = pdfManager.ensure(page, 'ref'); - var userUnitPromise = pdfManager.ensure(page, 'userUnit'); - var viewPromise = pdfManager.ensure(page, 'view'); - return Promise.all([ - rotatePromise, refPromise, userUnitPromise, viewPromise - ]).then(function(results) { + pdfManager.ensure(page, 'rotate'), + pdfManager.ensure(page, 'ref'), + pdfManager.ensure(page, 'userUnit'), + pdfManager.ensure(page, 'view'), + ]).then(function([rotate, ref, userUnit, view]) { return { - rotate: results[0], - ref: results[1], - userUnit: results[2], - view: results[3], + rotate, + ref, + userUnit, + view, }; }); }); diff --git a/src/display/api.js b/src/display/api.js index cfda93dd8..b5fa9e8d2 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -831,7 +831,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() { var PDFPageProxy = (function PDFPageProxyClosure() { function PDFPageProxy(pageIndex, pageInfo, transport, pdfBug = false) { this.pageIndex = pageIndex; - this.pageInfo = pageInfo; + this._pageInfo = pageInfo; this.transport = transport; this._stats = (pdfBug ? new StatTimer() : DummyStatTimer); this._pdfBug = pdfBug; @@ -853,27 +853,27 @@ var PDFPageProxy = (function PDFPageProxyClosure() { * @return {number} The number of degrees the page is rotated clockwise. */ get rotate() { - return this.pageInfo.rotate; + return this._pageInfo.rotate; }, /** * @return {Object} The reference that points to this page. It has 'num' and * 'gen' properties. */ get ref() { - return this.pageInfo.ref; + return this._pageInfo.ref; }, /** * @return {number} The default size of units in 1/72nds of an inch. */ get userUnit() { - return this.pageInfo.userUnit; + return this._pageInfo.userUnit; }, /** * @return {Array} An array of the visible portion of the PDF page in the * user space units - [x1, y1, x2, y2]. */ get view() { - return this.pageInfo.view; + return this._pageInfo.view; }, /**