Zero gjslint warnings mark
This commit is contained in:
parent
537eb8f47b
commit
7036bcd4c7
4
pdf.js
4
pdf.js
@ -3226,8 +3226,8 @@ var XRef = (function() {
|
|||||||
if (this.encrypt && !suppressEncryption) {
|
if (this.encrypt && !suppressEncryption) {
|
||||||
try {
|
try {
|
||||||
e = parser.getObj(this.encrypt.createCipherTransform(num, gen));
|
e = parser.getObj(this.encrypt.createCipherTransform(num, gen));
|
||||||
} catch(ex) {
|
} catch (ex) {
|
||||||
// almost all streams must to encrypted, but sometimes
|
// almost all streams must be encrypted, but sometimes
|
||||||
// they are not probably due to some broken generators
|
// they are not probably due to some broken generators
|
||||||
// re-trying without encryption
|
// re-trying without encryption
|
||||||
return this.fetch(ref, true);
|
return this.fetch(ref, true);
|
||||||
|
@ -49,7 +49,7 @@ function load() {
|
|||||||
};
|
};
|
||||||
r.send(null);
|
r.send(null);
|
||||||
}
|
}
|
||||||
window.onload = load;
|
documet.addEventListener('DOMContentLoaded', load);
|
||||||
|
|
||||||
function nextTask() {
|
function nextTask() {
|
||||||
if (currentTaskIdx == manifest.length) {
|
if (currentTaskIdx == manifest.length) {
|
||||||
|
101
worker/client.js
101
worker/client.js
@ -3,23 +3,26 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
if (typeof console.time == 'undefined') {
|
var consoleUtils = (function() {
|
||||||
var consoleTimer = {};
|
var consoleTimer = {};
|
||||||
console.time = function(name) {
|
|
||||||
|
var obj = {};
|
||||||
|
obj.time = function(name) {
|
||||||
consoleTimer[name] = Date.now();
|
consoleTimer[name] = Date.now();
|
||||||
};
|
};
|
||||||
|
obj.timeEnd = function(name) {
|
||||||
console.timeEnd = function(name) {
|
|
||||||
var time = consoleTimer[name];
|
var time = consoleTimer[name];
|
||||||
if (time == null) {
|
if (time == null) {
|
||||||
throw 'Unkown timer name ' + name;
|
throw 'Unkown timer name ' + name;
|
||||||
}
|
}
|
||||||
this.log('Timer:', name, Date.now() - time);
|
console.log('Timer:', name, Date.now() - time);
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
return obj;
|
||||||
|
})();
|
||||||
|
|
||||||
function FontWorker() {
|
function FontWorker() {
|
||||||
this.worker = new Worker('worker/font.js');
|
this.worker = new Worker('../worker/font.js');
|
||||||
this.fontsWaiting = 0;
|
this.fontsWaiting = 0;
|
||||||
this.fontsWaitingCallbacks = [];
|
this.fontsWaitingCallbacks = [];
|
||||||
|
|
||||||
@ -96,7 +99,7 @@ FontWorker.prototype = {
|
|||||||
this.fontsWaiting++;
|
this.fontsWaiting++;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.time('ensureFonts');
|
consoleUtils.time('ensureFonts');
|
||||||
// If there are fonts, that need to get loaded, tell the FontWorker to get
|
// If there are fonts, that need to get loaded, tell the FontWorker to get
|
||||||
// started and push the callback on the waiting-callback-stack.
|
// started and push the callback on the waiting-callback-stack.
|
||||||
if (notLoaded.length != 0) {
|
if (notLoaded.length != 0) {
|
||||||
@ -124,7 +127,7 @@ function WorkerPDFDoc(canvas) {
|
|||||||
|
|
||||||
this.ctx = canvas.getContext('2d');
|
this.ctx = canvas.getContext('2d');
|
||||||
this.canvas = canvas;
|
this.canvas = canvas;
|
||||||
this.worker = new Worker('worker/pdf.js');
|
this.worker = new Worker('../worker/pdf.js');
|
||||||
this.fontWorker = new FontWorker();
|
this.fontWorker = new FontWorker();
|
||||||
this.waitingForFonts = false;
|
this.waitingForFonts = false;
|
||||||
this.waitingForFontsCallback = [];
|
this.waitingForFontsCallback = [];
|
||||||
@ -167,7 +170,8 @@ function WorkerPDFDoc(canvas) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
'$putImageData': function(imageData, x, y) {
|
'$putImageData': function(imageData, x, y) {
|
||||||
var imgData = this.getImageData(0, 0, imageData.width, imageData.height);
|
var imgData = this.getImageData(0, 0,
|
||||||
|
imageData.width, imageData.height);
|
||||||
|
|
||||||
// Store the .data property to avaid property lookups.
|
// Store the .data property to avaid property lookups.
|
||||||
var imageRealData = imageData.data;
|
var imageRealData = imageData.data;
|
||||||
@ -339,7 +343,7 @@ function WorkerPDFDoc(canvas) {
|
|||||||
|
|
||||||
var renderData = function() {
|
var renderData = function() {
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
console.time('main canvas rendering');
|
consoleUtils.time('main canvas rendering');
|
||||||
var ctx = this.ctx;
|
var ctx = this.ctx;
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.fillStyle = 'rgb(255, 255, 255)';
|
ctx.fillStyle = 'rgb(255, 255, 255)';
|
||||||
@ -348,8 +352,8 @@ function WorkerPDFDoc(canvas) {
|
|||||||
}
|
}
|
||||||
renderProxyCanvas(canvasList[id], cmdQueue);
|
renderProxyCanvas(canvasList[id], cmdQueue);
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
console.timeEnd('main canvas rendering');
|
consoleUtils.timeEnd('main canvas rendering');
|
||||||
console.timeEnd('>>> total page display time:');
|
consoleUtils.timeEnd('>>> total page display time:');
|
||||||
}
|
}
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
@ -368,51 +372,52 @@ function WorkerPDFDoc(canvas) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Listen to the WebWorker for data and call actionHandler on it.
|
// Listen to the WebWorker for data and call actionHandler on it.
|
||||||
this.worker.onmessage = function(event) {
|
this.worker.addEventListener('message', function(event) {
|
||||||
var data = event.data;
|
var data = event.data;
|
||||||
if (data.action in actionHandler) {
|
if (data.action in actionHandler) {
|
||||||
actionHandler[data.action].call(this, data.data);
|
actionHandler[data.action].call(this, data.data);
|
||||||
} else {
|
} else {
|
||||||
throw 'Unkown action from worker: ' + data.action;
|
throw 'Unkown action from worker: ' + data.action;
|
||||||
}
|
}
|
||||||
}.bind(this);
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkerPDFDoc.prototype.open = function(url, callback) {
|
WorkerPDFDoc.prototype = {
|
||||||
var req = new XMLHttpRequest();
|
open: function(url, callback) {
|
||||||
req.open('GET', url);
|
var req = new XMLHttpRequest();
|
||||||
req.mozResponseType = req.responseType = 'arraybuffer';
|
req.open('GET', url);
|
||||||
req.expected = (document.URL.indexOf('file:') == 0) ? 0 : 200;
|
req.mozResponseType = req.responseType = 'arraybuffer';
|
||||||
req.onreadystatechange = function() {
|
req.expected = (document.URL.indexOf('file:') == 0) ? 0 : 200;
|
||||||
if (req.readyState == 4 && req.status == req.expected) {
|
req.onreadystatechange = function() {
|
||||||
var data = req.mozResponseArrayBuffer || req.mozResponse ||
|
if (req.readyState == 4 && req.status == req.expected) {
|
||||||
req.responseArrayBuffer || req.response;
|
var data = req.mozResponseArrayBuffer || req.mozResponse ||
|
||||||
|
req.responseArrayBuffer || req.response;
|
||||||
|
|
||||||
this.loadCallback = callback;
|
this.loadCallback = callback;
|
||||||
this.worker.postMessage(data);
|
this.worker.postMessage(data);
|
||||||
this.showPage(this.numPage);
|
this.showPage(this.numPage);
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
req.send(null);
|
||||||
|
},
|
||||||
|
|
||||||
|
showPage: function(numPage) {
|
||||||
|
this.numPage = parseInt(numPage, 10);
|
||||||
|
console.log('=== start rendering page ' + numPage + ' ===');
|
||||||
|
consoleUtils.time('>>> total page display time:');
|
||||||
|
this.worker.postMessage(numPage);
|
||||||
|
if (this.onChangePage) {
|
||||||
|
this.onChangePage(numPage);
|
||||||
}
|
}
|
||||||
}.bind(this);
|
},
|
||||||
req.send(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
WorkerPDFDoc.prototype.showPage = function(numPage) {
|
nextPage: function() {
|
||||||
this.numPage = parseInt(numPage, 10);
|
if (this.numPage != this.numPages)
|
||||||
console.log('=== start rendering page ' + numPage + ' ===');
|
this.showPage(++this.numPage);
|
||||||
console.time('>>> total page display time:');
|
},
|
||||||
this.worker.postMessage(numPage);
|
|
||||||
if (this.onChangePage) {
|
prevPage: function() {
|
||||||
this.onChangePage(numPage);
|
if (this.numPage != 1)
|
||||||
|
this.showPage(--this.numPage);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
WorkerPDFDoc.prototype.nextPage = function() {
|
|
||||||
if (this.numPage != this.numPages)
|
|
||||||
this.showPage(++this.numPage);
|
|
||||||
};
|
|
||||||
|
|
||||||
WorkerPDFDoc.prototype.prevPage = function() {
|
|
||||||
if (this.numPage != 1)
|
|
||||||
this.showPage(--this.numPage);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
@ -56,12 +56,12 @@ var actionHandler = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Listen to the MainThread for data and call actionHandler on it.
|
// Listen to the MainThread for data and call actionHandler on it.
|
||||||
this.onmessage = function(event) {
|
addEventListener('message', function(event) {
|
||||||
var data = event.data;
|
var data = event.data;
|
||||||
if (data.action in actionHandler) {
|
if (data.action in actionHandler) {
|
||||||
actionHandler[data.action].call(this, data.data);
|
actionHandler[data.action].call(this, data.data);
|
||||||
} else {
|
} else {
|
||||||
throw 'Unkown action from worker: ' + data.action;
|
throw 'Unkown action from worker: ' + data.action;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
|
@ -11,8 +11,10 @@ var console = {
|
|||||||
action: 'log',
|
action: 'log',
|
||||||
data: args
|
data: args
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var consoleUtils = {
|
||||||
time: function(name) {
|
time: function(name) {
|
||||||
consoleTimer[name] = Date.now();
|
consoleTimer[name] = Date.now();
|
||||||
},
|
},
|
||||||
@ -22,7 +24,7 @@ var console = {
|
|||||||
if (time == null) {
|
if (time == null) {
|
||||||
throw 'Unkown timer name ' + name;
|
throw 'Unkown timer name ' + name;
|
||||||
}
|
}
|
||||||
this.log('Timer:', name, Date.now() - time);
|
console.log('Timer:', name, Date.now() - time);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -42,7 +44,7 @@ var canvas = new CanvasProxy(1224, 1584);
|
|||||||
|
|
||||||
// Listen for messages from the main thread.
|
// Listen for messages from the main thread.
|
||||||
var pdfDocument = null;
|
var pdfDocument = null;
|
||||||
onmessage = function(event) {
|
addEventListener('message', function(event) {
|
||||||
var data = event.data;
|
var data = event.data;
|
||||||
// If there is no pdfDocument yet, then the sent data is the PDFDocument.
|
// If there is no pdfDocument yet, then the sent data is the PDFDocument.
|
||||||
if (!pdfDocument) {
|
if (!pdfDocument) {
|
||||||
@ -55,7 +57,7 @@ onmessage = function(event) {
|
|||||||
}
|
}
|
||||||
// User requested to render a certain page.
|
// User requested to render a certain page.
|
||||||
else {
|
else {
|
||||||
console.time('compile');
|
consoleUtils.time('compile');
|
||||||
|
|
||||||
// Let's try to render the first page...
|
// Let's try to render the first page...
|
||||||
var page = pdfDocument.getPage(parseInt(data, 10));
|
var page = pdfDocument.getPage(parseInt(data, 10));
|
||||||
@ -77,19 +79,19 @@ onmessage = function(event) {
|
|||||||
var fonts = [];
|
var fonts = [];
|
||||||
var gfx = new CanvasGraphics(canvas.getContext('2d'), CanvasProxy);
|
var gfx = new CanvasGraphics(canvas.getContext('2d'), CanvasProxy);
|
||||||
page.compile(gfx, fonts);
|
page.compile(gfx, fonts);
|
||||||
console.timeEnd('compile');
|
consoleUtils.timeEnd('compile');
|
||||||
|
|
||||||
// Send fonts to the main thread.
|
// Send fonts to the main thread.
|
||||||
console.time('fonts');
|
consoleUtils.time('fonts');
|
||||||
postMessage({
|
postMessage({
|
||||||
action: 'fonts',
|
action: 'fonts',
|
||||||
data: fonts
|
data: fonts
|
||||||
});
|
});
|
||||||
console.timeEnd('fonts');
|
consoleUtils.timeEnd('fonts');
|
||||||
|
|
||||||
console.time('display');
|
consoleUtils.time('display');
|
||||||
page.display(gfx);
|
page.display(gfx);
|
||||||
canvas.flush();
|
canvas.flush();
|
||||||
console.timeEnd('display');
|
consoleUtils.timeEnd('display');
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user