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.
This commit is contained in:
Jonas Jenwald 2018-06-05 20:30:06 +02:00
parent 4f4b50e01e
commit b263b702e8
2 changed files with 14 additions and 16 deletions

View File

@ -639,19 +639,17 @@ var WorkerMessageHandler = {
handler.on('GetPage', function wphSetupGetPage(data) { handler.on('GetPage', function wphSetupGetPage(data) {
return pdfManager.getPage(data.pageIndex).then(function(page) { 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([ return Promise.all([
rotatePromise, refPromise, userUnitPromise, viewPromise pdfManager.ensure(page, 'rotate'),
]).then(function(results) { pdfManager.ensure(page, 'ref'),
pdfManager.ensure(page, 'userUnit'),
pdfManager.ensure(page, 'view'),
]).then(function([rotate, ref, userUnit, view]) {
return { return {
rotate: results[0], rotate,
ref: results[1], ref,
userUnit: results[2], userUnit,
view: results[3], view,
}; };
}); });
}); });

View File

@ -831,7 +831,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
var PDFPageProxy = (function PDFPageProxyClosure() { var PDFPageProxy = (function PDFPageProxyClosure() {
function PDFPageProxy(pageIndex, pageInfo, transport, pdfBug = false) { function PDFPageProxy(pageIndex, pageInfo, transport, pdfBug = false) {
this.pageIndex = pageIndex; this.pageIndex = pageIndex;
this.pageInfo = pageInfo; this._pageInfo = pageInfo;
this.transport = transport; this.transport = transport;
this._stats = (pdfBug ? new StatTimer() : DummyStatTimer); this._stats = (pdfBug ? new StatTimer() : DummyStatTimer);
this._pdfBug = pdfBug; this._pdfBug = pdfBug;
@ -853,27 +853,27 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
* @return {number} The number of degrees the page is rotated clockwise. * @return {number} The number of degrees the page is rotated clockwise.
*/ */
get rotate() { get rotate() {
return this.pageInfo.rotate; return this._pageInfo.rotate;
}, },
/** /**
* @return {Object} The reference that points to this page. It has 'num' and * @return {Object} The reference that points to this page. It has 'num' and
* 'gen' properties. * 'gen' properties.
*/ */
get ref() { get ref() {
return this.pageInfo.ref; return this._pageInfo.ref;
}, },
/** /**
* @return {number} The default size of units in 1/72nds of an inch. * @return {number} The default size of units in 1/72nds of an inch.
*/ */
get userUnit() { get userUnit() {
return this.pageInfo.userUnit; return this._pageInfo.userUnit;
}, },
/** /**
* @return {Array} An array of the visible portion of the PDF page in the * @return {Array} An array of the visible portion of the PDF page in the
* user space units - [x1, y1, x2, y2]. * user space units - [x1, y1, x2, y2].
*/ */
get view() { get view() {
return this.pageInfo.view; return this._pageInfo.view;
}, },
/** /**