Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor src/core/pdf_manager.js: rename pdfModel to pdfDocument #4440

Merged
merged 1 commit into from
Mar 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/core/pdf_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@ var BasePdfManager = (function BasePdfManagerClosure() {
throw new NotImplementedException();
},

ensureModel: function BasePdfManager_ensureModel(prop, args) {
return this.ensure(this.pdfModel, prop, args);
ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other changes are fine, but this one seems confusing since it doesn't ensure the doc is ready. I'd say leave as is or something like ensureDocumentProperty

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second glance I guess this look like the other ensure* functions.

return this.ensure(this.pdfDocument, prop, args);
},

ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
return this.ensure(this.pdfModel.xref, prop, args);
return this.ensure(this.pdfDocument.xref, prop, args);
},

ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
return this.ensure(this.pdfModel.catalog, prop, args);
return this.ensure(this.pdfDocument.catalog, prop, args);
},

getPage: function BasePdfManager_pagePage(pageIndex) {
return this.pdfModel.getPage(pageIndex);
return this.pdfDocument.getPage(pageIndex);
},

cleanup: function BasePdfManager_cleanup() {
return this.pdfModel.cleanup();
return this.pdfDocument.cleanup();
},

ensure: function BasePdfManager_ensure(obj, prop, args) {
Expand All @@ -66,7 +66,7 @@ var BasePdfManager = (function BasePdfManagerClosure() {
},

updatePassword: function BasePdfManager_updatePassword(password) {
this.pdfModel.xref.password = this.password = password;
this.pdfDocument.xref.password = this.password = password;
if (this.passwordChangedPromise) {
this.passwordChangedPromise.resolve();
}
Expand All @@ -83,7 +83,7 @@ var BasePdfManager = (function BasePdfManagerClosure() {
var LocalPdfManager = (function LocalPdfManagerClosure() {
function LocalPdfManager(data, password) {
var stream = new Stream(data);
this.pdfModel = new PDFDocument(this, stream, password);
this.pdfDocument = new PDFDocument(this, stream, password);
this.loadedStream = new LegacyPromise();
this.loadedStream.resolve(stream);
}
Expand Down Expand Up @@ -150,7 +150,7 @@ var NetworkPdfManager = (function NetworkPdfManagerClosure() {
this.streamManager = new ChunkedStreamManager(args.length, RANGE_CHUNK_SIZE,
args.url, params);

this.pdfModel = new PDFDocument(this, this.streamManager.getStream(),
this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(),
args.password);
}

Expand Down
12 changes: 6 additions & 6 deletions src/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
var loadDocumentPromise = new LegacyPromise();

var parseSuccess = function parseSuccess() {
var numPagesPromise = pdfManager.ensureModel('numPages');
var fingerprintPromise = pdfManager.ensureModel('fingerprint');
var numPagesPromise = pdfManager.ensureDoc('numPages');
var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
var outlinePromise = pdfManager.ensureCatalog('documentOutline');
var infoPromise = pdfManager.ensureModel('documentInfo');
var infoPromise = pdfManager.ensureDoc('documentInfo');
var metadataPromise = pdfManager.ensureCatalog('metadata');
var encryptedPromise = pdfManager.ensureXRef('encrypt');
var javaScriptPromise = pdfManager.ensureCatalog('javaScript');
Expand All @@ -60,9 +60,9 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
loadDocumentPromise.reject(e);
};

pdfManager.ensureModel('checkHeader', []).then(function() {
pdfManager.ensureModel('parseStartXRef', []).then(function() {
pdfManager.ensureModel('parse', [recoveryMode]).then(
pdfManager.ensureDoc('checkHeader', []).then(function() {
pdfManager.ensureDoc('parseStartXRef', []).then(function() {
pdfManager.ensureDoc('parse', [recoveryMode]).then(
parseSuccess, parseFailure);
}, parseFailure);
}, parseFailure);
Expand Down