mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Refactor class method names.
Also move functionality to more logical place in canvas.js and jpx.js.
This commit is contained in:
parent
921c1e82a3
commit
99440ab691
15 changed files with 1554 additions and 1543 deletions
46
src/core.js
46
src/core.js
|
@ -72,10 +72,10 @@ var Page = (function PageClosure() {
|
|||
}
|
||||
|
||||
Page.prototype = {
|
||||
getPageProp: function pageGetPageProp(key) {
|
||||
getPageProp: function Page_getPageProp(key) {
|
||||
return this.xref.fetchIfRef(this.pageDict.get(key));
|
||||
},
|
||||
inheritPageProp: function pageInheritPageProp(key) {
|
||||
inheritPageProp: function Page_inheritPageProp(key) {
|
||||
var dict = this.pageDict;
|
||||
var obj = dict.get(key);
|
||||
while (obj === undefined) {
|
||||
|
@ -170,8 +170,8 @@ var Page = (function PageClosure() {
|
|||
return shadow(this, 'rotate', rotate);
|
||||
},
|
||||
|
||||
startRenderingFromOperatorList: function pageStartRenderingFromOperatorList(
|
||||
operatorList, fonts) {
|
||||
startRenderingFromOperatorList:
|
||||
function Page_startRenderingFromOperatorList(operatorList, fonts) {
|
||||
var self = this;
|
||||
this.operatorList = operatorList;
|
||||
|
||||
|
@ -190,7 +190,7 @@ var Page = (function PageClosure() {
|
|||
);
|
||||
},
|
||||
|
||||
getOperatorList: function pageGetOperatorList(handler, dependency) {
|
||||
getOperatorList: function Page_getOperatorList(handler, dependency) {
|
||||
if (this.operatorList) {
|
||||
// content was compiled
|
||||
return this.operatorList;
|
||||
|
@ -220,7 +220,7 @@ var Page = (function PageClosure() {
|
|||
return this.operatorList;
|
||||
},
|
||||
|
||||
ensureFonts: function pageEnsureFonts(fonts, callback) {
|
||||
ensureFonts: function Page_ensureFonts(fonts, callback) {
|
||||
this.stats.time('Font Loading');
|
||||
// Convert the font names to the corresponding font obj.
|
||||
for (var i = 0, ii = fonts.length; i < ii; i++) {
|
||||
|
@ -238,7 +238,7 @@ var Page = (function PageClosure() {
|
|||
);
|
||||
},
|
||||
|
||||
display: function pageDisplay(gfx, callback) {
|
||||
display: function Page_display(gfx, callback) {
|
||||
var stats = this.stats;
|
||||
stats.time('Rendering');
|
||||
var xref = this.xref;
|
||||
|
@ -276,7 +276,7 @@ var Page = (function PageClosure() {
|
|||
}
|
||||
next();
|
||||
},
|
||||
rotatePoint: function pageRotatePoint(x, y, reverse) {
|
||||
rotatePoint: function Page_rotatePoint(x, y, reverse) {
|
||||
var rotate = reverse ? (360 - this.rotate) : this.rotate;
|
||||
switch (rotate) {
|
||||
case 180:
|
||||
|
@ -291,7 +291,7 @@ var Page = (function PageClosure() {
|
|||
return {x: x, y: this.height - y};
|
||||
}
|
||||
},
|
||||
getLinks: function pageGetLinks() {
|
||||
getLinks: function Page_getLinks() {
|
||||
var links = [];
|
||||
var annotations = pageGetAnnotations();
|
||||
var i, n = annotations.length;
|
||||
|
@ -302,7 +302,7 @@ var Page = (function PageClosure() {
|
|||
}
|
||||
return links;
|
||||
},
|
||||
getAnnotations: function pageGetAnnotations() {
|
||||
getAnnotations: function Page_getAnnotations() {
|
||||
var xref = this.xref;
|
||||
function getInheritableProperty(annotation, name) {
|
||||
var item = annotation;
|
||||
|
@ -433,7 +433,7 @@ var Page = (function PageClosure() {
|
|||
}
|
||||
return items;
|
||||
},
|
||||
startRendering: function pageStartRendering(ctx, callback, textLayer) {
|
||||
startRendering: function Page_startRendering(ctx, callback, textLayer) {
|
||||
var stats = this.stats;
|
||||
stats.time('Overall');
|
||||
// If there is no displayReadyPromise yet, then the operatorList was never
|
||||
|
@ -570,7 +570,7 @@ var PDFDocModel = (function PDFDocModelClosure() {
|
|||
},
|
||||
// Find the header, remove leading garbage and setup the stream
|
||||
// starting from the header.
|
||||
checkHeader: function pdfDocCheckHeader() {
|
||||
checkHeader: function PDFDocModel_checkHeader() {
|
||||
var stream = this.stream;
|
||||
stream.reset();
|
||||
if (find(stream, '%PDF-', 1024)) {
|
||||
|
@ -580,7 +580,7 @@ var PDFDocModel = (function PDFDocModelClosure() {
|
|||
}
|
||||
// May not be a PDF file, continue anyway.
|
||||
},
|
||||
setup: function pdfDocSetup(ownerPassword, userPassword) {
|
||||
setup: function PDFDocModel_setup(ownerPassword, userPassword) {
|
||||
this.checkHeader();
|
||||
var xref = new XRef(this.stream,
|
||||
this.startXRef,
|
||||
|
@ -594,14 +594,14 @@ var PDFDocModel = (function PDFDocModelClosure() {
|
|||
// shadow the prototype getter
|
||||
return shadow(this, 'numPages', num);
|
||||
},
|
||||
getDocumentInfo: function pdfDocGetDocumentInfo() {
|
||||
getDocumentInfo: function PDFDocModel_getDocumentInfo() {
|
||||
var info;
|
||||
if (this.xref.trailer.has('Info'))
|
||||
info = this.xref.fetch(this.xref.trailer.get('Info'));
|
||||
|
||||
return shadow(this, 'getDocumentInfo', info);
|
||||
},
|
||||
getFingerprint: function pdfDocGetFingerprint() {
|
||||
getFingerprint: function PDFDocModel_getFingerprint() {
|
||||
var xref = this.xref, fileID;
|
||||
if (xref.trailer.has('ID')) {
|
||||
fileID = '';
|
||||
|
@ -622,7 +622,7 @@ var PDFDocModel = (function PDFDocModelClosure() {
|
|||
|
||||
return shadow(this, 'getFingerprint', fileID);
|
||||
},
|
||||
getPage: function pdfDocGetPage(n) {
|
||||
getPage: function PDFDocModel_getPage(n) {
|
||||
return this.catalog.getPage(n);
|
||||
}
|
||||
};
|
||||
|
@ -711,13 +711,13 @@ var PDFDoc = (function PDFDocClosure() {
|
|||
}
|
||||
|
||||
PDFDoc.prototype = {
|
||||
setupFakeWorker: function() {
|
||||
setupFakeWorker: function PDFDoc_setupFakeWorker() {
|
||||
// If we don't use a worker, just post/sendMessage to the main thread.
|
||||
var fakeWorker = {
|
||||
postMessage: function pdfDocPostMessage(obj) {
|
||||
postMessage: function PDFDoc_postMessage(obj) {
|
||||
fakeWorker.onmessage({data: obj});
|
||||
},
|
||||
terminate: function pdfDocTerminate() {}
|
||||
terminate: function PDFDoc_terminate() {}
|
||||
};
|
||||
|
||||
var messageHandler = new MessageHandler('main', fakeWorker);
|
||||
|
@ -729,7 +729,7 @@ var PDFDoc = (function PDFDocClosure() {
|
|||
},
|
||||
|
||||
|
||||
setupMessageHandler: function(messageHandler) {
|
||||
setupMessageHandler: function PDFDoc_setupMessageHandler(messageHandler) {
|
||||
this.messageHandler = messageHandler;
|
||||
|
||||
messageHandler.on('page', function pdfDocPage(data) {
|
||||
|
@ -828,7 +828,7 @@ var PDFDoc = (function PDFDocClosure() {
|
|||
return this.pdfModel.numPages;
|
||||
},
|
||||
|
||||
startRendering: function pdfDocStartRendering(page) {
|
||||
startRendering: function PDFDoc_startRendering(page) {
|
||||
// The worker might not be ready to receive the page request yet.
|
||||
this.workerReadyPromise.then(function pdfDocStartRenderingThen() {
|
||||
page.stats.time('Page Request');
|
||||
|
@ -836,7 +836,7 @@ var PDFDoc = (function PDFDocClosure() {
|
|||
}.bind(this));
|
||||
},
|
||||
|
||||
getPage: function pdfDocGetPage(n) {
|
||||
getPage: function PDFDoc_getPage(n) {
|
||||
if (this.pageCache[n])
|
||||
return this.pageCache[n];
|
||||
|
||||
|
@ -848,7 +848,7 @@ var PDFDoc = (function PDFDocClosure() {
|
|||
return (this.pageCache[n] = page);
|
||||
},
|
||||
|
||||
destroy: function pdfDocDestroy() {
|
||||
destroy: function PDFDoc_destroy() {
|
||||
if (this.worker)
|
||||
this.worker.terminate();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue