Merge remote branch 'upstream/master'

This commit is contained in:
Rob Sayre 2011-06-25 09:47:37 -07:00
commit f69dad39ed
2 changed files with 22 additions and 12 deletions

12
pdf.js
View File

@ -3030,10 +3030,14 @@ var CanvasGraphics = (function() {
// we want the canvas to be as large as the step size
var botRight = applyMatrix([x0 + xstep, y0 + ystep], matrix);
var tmpCanvas = new this.ScratchCanvas(
Math.ceil(botRight[0] - topLeft[0]), // width
Math.ceil(botRight[1] - topLeft[1]) // height
);
var width = botRight[0] - topLeft[0];
var height = botRight[1] - topLeft[1];
// TODO: hack to avoid OOM, remove then pattern code is fixed
if (Math.abs(width) > 8192 || Math.abs(height) > 8192)
return false;
var tmpCanvas = new this.ScratchCanvas(width, height);
// set the new canvas element context as the graphics context
var tmpCtx = tmpCanvas.getContext("2d");

View File

@ -6,7 +6,7 @@
<script type="text/javascript" src="/fonts.js"></script>
<script type="text/javascript" src="/glyphlist.js"></script>
<script type="application/javascript">
var browser, canvas, currentTask, currentTaskIdx, failure, manifest, pdfDoc, stdout;
var browser, canvas, currentTask, currentTaskIdx, failure, manifest, numPages, pdfDoc, stdout;
function queryParams() {
var qs = window.location.search.substring(1);
@ -66,8 +66,9 @@ function nextTask() {
try {
pdfDoc = new PDFDoc(new Stream(data));
numPages = pdfDoc.numPages;
} catch(e) {
pdfDoc.numPages = 1;
numPages = 1;
failure = 'load PDF doc: '+ e.toString();
}
@ -78,7 +79,7 @@ function nextTask() {
}
function nextPage() {
if (currentTask.pageNum > pdfDoc.numPages) {
if (currentTask.pageNum > numPages) {
if (++currentTask.round < currentTask.rounds) {
log(" Round "+ (1 + currentTask.round) +"\n");
currentTask.pageNum = 1;
@ -95,8 +96,9 @@ function nextPage() {
clear(ctx);
var fonts = [];
var gfx = new CanvasGraphics(ctx);
var gfx = null;
try {
gfx = new CanvasGraphics(ctx);
currentPage = pdfDoc.getPage(currentTask.pageNum);
currentPage.compile(gfx, fonts);
} catch(e) {
@ -105,9 +107,13 @@ function nextPage() {
var fontLoaderTimer = null;
function checkFontsLoaded() {
if (!FontLoader.bind(fonts)) {
fontLoaderTimer = window.setTimeout(checkFontsLoaded, 10);
return;
try {
if (!FontLoader.bind(fonts)) {
fontLoaderTimer = window.setTimeout(checkFontsLoaded, 10);
return;
}
} catch(e) {
failure = 'fonts: '+ e.toString();
}
snapshotCurrentPage(gfx);
}
@ -166,7 +172,7 @@ var inFlightRequests = 0;
function sendTaskResult(snapshot) {
var result = { browser: browser,
id: currentTask.id,
numPages: pdfDoc.numPages,
numPages: numPages,
failure: failure,
file: currentTask.file,
round: currentTask.round,