Name anonymous functions in core.js.

This commit is contained in:
Kalervo Kujala 2011-10-30 12:41:55 +02:00
parent eed0773259
commit ce3f9ae3e8

View File

@ -153,7 +153,7 @@ var Page = (function pagePage() {
return shadow(this, 'rotate', rotate); return shadow(this, 'rotate', rotate);
}, },
startRenderingFromIRQueue: function startRenderingFromIRQueue( startRenderingFromIRQueue: function pageStartRenderingFromIRQueue(
IRQueue, fonts) { IRQueue, fonts) {
var self = this; var self = this;
this.IRQueue = IRQueue; this.IRQueue = IRQueue;
@ -173,12 +173,13 @@ var Page = (function pagePage() {
}); });
}; };
this.ensureFonts(fonts, function() { this.ensureFonts(fonts,
function pageStartRenderingFromIRQueueEnsureFonts() {
displayContinuation(); displayContinuation();
}); });
}, },
getIRQueue: function(handler, dependency) { getIRQueue: function pageGetIRQueue(handler, dependency) {
if (this.IRQueue) { if (this.IRQueue) {
// content was compiled // content was compiled
return this.IRQueue; return this.IRQueue;
@ -202,7 +203,7 @@ var Page = (function pagePage() {
content, resources, IRQueue, dependency); content, resources, IRQueue, dependency);
}, },
ensureFonts: function(fonts, callback) { ensureFonts: function pageEnsureFonts(fonts, callback) {
// Convert the font names to the corresponding font obj. // Convert the font names to the corresponding font obj.
for (var i = 0; i < fonts.length; i++) { for (var i = 0; i < fonts.length; i++) {
fonts[i] = this.objs.objs[fonts[i]].data; fonts[i] = this.objs.objs[fonts[i]].data;
@ -211,7 +212,7 @@ var Page = (function pagePage() {
// Load all the fonts // Load all the fonts
var fontObjs = FontLoader.bind( var fontObjs = FontLoader.bind(
fonts, fonts,
function(fontObjs) { function pageEnsureFontsFontObjs(fontObjs) {
this.stats.fonts = Date.now(); this.stats.fonts = Date.now();
callback.call(this); callback.call(this);
@ -220,7 +221,7 @@ var Page = (function pagePage() {
); );
}, },
display: function(gfx, callback) { display: function pageDisplay(gfx, callback) {
var xref = this.xref; var xref = this.xref;
var resources = xref.fetchIfRef(this.resources); var resources = xref.fetchIfRef(this.resources);
var mediaBox = xref.fetchIfRef(this.mediaBox); var mediaBox = xref.fetchIfRef(this.mediaBox);
@ -305,7 +306,7 @@ var Page = (function pagePage() {
} }
return links; return links;
}, },
startRendering: function(ctx, callback) { startRendering: function pageStartRendering(ctx, callback) {
this.ctx = ctx; this.ctx = ctx;
this.callback = callback; this.callback = callback;
@ -446,7 +447,7 @@ var PDFDocModel = (function pdfDoc() {
return constructor; return constructor;
})(); })();
var PDFDoc = (function() { var PDFDoc = (function pdfDoc() {
function constructor(arg, callback) { function constructor(arg, callback) {
var stream = null; var stream = null;
var data = null; var data = null;
@ -475,10 +476,10 @@ var PDFDoc = (function() {
} else { } else {
// If we don't use a worker, just post/sendMessage to the main thread. // If we don't use a worker, just post/sendMessage to the main thread.
var worker = { var worker = {
postMessage: function(obj) { postMessage: function pdfDocPostMessage(obj) {
worker.onmessage({data: obj}); worker.onmessage({data: obj});
}, },
terminate: function() {} terminate: function pdfDocTerminate() {}
}; };
} }
this.worker = worker; this.worker = worker;
@ -488,7 +489,7 @@ var PDFDoc = (function() {
var processorHandler = this.processorHandler = var processorHandler = this.processorHandler =
new MessageHandler('main', worker); new MessageHandler('main', worker);
processorHandler.on('page', function(data) { processorHandler.on('page', function pdfDocPage(data) {
var pageNum = data.pageNum; var pageNum = data.pageNum;
var page = this.pageCache[pageNum]; var page = this.pageCache[pageNum];
var depFonts = data.depFonts; var depFonts = data.depFonts;
@ -496,7 +497,7 @@ var PDFDoc = (function() {
page.startRenderingFromIRQueue(data.IRQueue, depFonts); page.startRenderingFromIRQueue(data.IRQueue, depFonts);
}, this); }, this);
processorHandler.on('obj', function(data) { processorHandler.on('obj', function pdfDocObj(data) {
var id = data[0]; var id = data[0];
var type = data[1]; var type = data[1];
@ -540,7 +541,7 @@ var PDFDoc = (function() {
} }
}, this); }, this);
processorHandler.on('font_ready', function(data) { processorHandler.on('font_ready', function pdfDocFontReady(data) {
var id = data[0]; var id = data[0];
var font = new FontShape(data[1]); var font = new FontShape(data[1]);
@ -559,7 +560,7 @@ var PDFDoc = (function() {
} }
this.workerReadyPromise = new Promise('workerReady'); this.workerReadyPromise = new Promise('workerReady');
setTimeout(function() { setTimeout(function pdfDocFontReadySetTimeout() {
processorHandler.send('doc', this.data); processorHandler.send('doc', this.data);
this.workerReadyPromise.resolve(true); this.workerReadyPromise.resolve(true);
}.bind(this)); }.bind(this));
@ -570,14 +571,14 @@ var PDFDoc = (function() {
return this.pdf.numPages; return this.pdf.numPages;
}, },
startRendering: function(page) { startRendering: function pdfDocStartRendering(page) {
// The worker might not be ready to receive the page request yet. // The worker might not be ready to receive the page request yet.
this.workerReadyPromise.then(function() { this.workerReadyPromise.then(function pdfDocStartRenderingThen() {
this.processorHandler.send('page_request', page.pageNumber + 1); this.processorHandler.send('page_request', page.pageNumber + 1);
}.bind(this)); }.bind(this));
}, },
getPage: function(n) { getPage: function pdfDocGetPage(n) {
if (this.pageCache[n]) if (this.pageCache[n])
return this.pageCache[n]; return this.pageCache[n];
@ -589,7 +590,7 @@ var PDFDoc = (function() {
return this.pageCache[n] = page; return this.pageCache[n] = page;
}, },
destroy: function() { destroy: function pdfDocDestroy() {
if (this.worker) if (this.worker)
this.worker.terminate(); this.worker.terminate();