1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Merge with master

This commit is contained in:
Julian Viereck 2011-11-01 19:56:34 +01:00
commit 94b8c4656b
23 changed files with 257 additions and 144 deletions

View file

@ -8,14 +8,14 @@ function MessageHandler(name, comObj) {
this.comObj = comObj;
var ah = this.actionHandler = {};
ah['console_log'] = [function(data) {
ah['console_log'] = [function ahConsoleLog(data) {
console.log.apply(console, data);
}];
ah['console_error'] = [function(data) {
ah['console_error'] = [function ahConsoleError(data) {
console.error.apply(console, data);
}];
comObj.onmessage = function(event) {
comObj.onmessage = function messageHandlerComObjOnMessage(event) {
var data = event.data;
if (data.action in ah) {
var action = ah[data.action];
@ -27,15 +27,15 @@ function MessageHandler(name, comObj) {
}
MessageHandler.prototype = {
on: function(actionName, handler, scope) {
on: function messageHandlerOn(actionName, handler, scope) {
var ah = this.actionHandler;
if (ah[actionName]) {
throw "There is already an actionName called '" + actionName + "'";
throw 'There is already an actionName called "' + actionName + '"';
}
ah[actionName] = [handler, scope];
},
send: function(actionName, data) {
send: function messageHandlerSend(actionName, data) {
this.comObj.postMessage({
action: actionName,
data: data
@ -44,23 +44,23 @@ MessageHandler.prototype = {
};
var WorkerProcessorHandler = {
setup: function(handler) {
setup: function wphSetup(handler) {
var pdfDoc = null;
handler.on('workerSrc', function(data) {
handler.on('workerSrc', function wphSetupWorkerSrc(data) {
// In development, the `workerSrc` message is handled in the
// `worker_loader.js` file. In production the workerProcessHandler is
// called for this. This servers as a dummy to prevent calling an
// undefined action `workerSrc`.
});
handler.on('doc', function(data) {
handler.on('doc', function wphSetupDoc(data) {
// Create only the model of the PDFDoc, which is enough for
// processing the content of the pdf.
pdfDoc = new PDFDocModel(new Stream(data));
});
handler.on('page_request', function(pageNum) {
handler.on('page_request', function wphSetupPageRequest(pageNum) {
pageNum = parseInt(pageNum);
var page = pdfDoc.getPage(pageNum);
@ -96,7 +96,7 @@ var WorkerProcessorHandler = {
});
}, this);
handler.on('font', function(data) {
handler.on('font', function wphSetupFont(data) {
var objId = data[0];
var name = data[1];
var file = data[2];
@ -166,11 +166,11 @@ var workerConsole = {
});
},
time: function(name) {
time: function time(name) {
consoleTimer[name] = Date.now();
},
timeEnd: function(name) {
timeEnd: function timeEnd(name) {
var time = consoleTimer[name];
if (time == null) {
throw 'Unkown timer name ' + name;