Bug 856383 - Update pdf.js to version 0.7.423. r=yury

This commit is contained in:
Ryan VanderMeulen 2013-04-01 11:31:07 -04:00
parent a9123c3d10
commit dbd0f64e61
6 changed files with 308 additions and 108 deletions

View File

@ -1,4 +1,4 @@
This is the pdf.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 0.7.390
Current extension version is: 0.7.423

View File

@ -376,8 +376,9 @@ ChromeActions.prototype = {
'updateControlState' in getChromeWindow(this.domWindow).gFindBar;
},
supportsDocumentFonts: function() {
var pref = getIntPref('browser.display.use_document_fonts', 1);
return !!pref;
var prefBrowser = getIntPref('browser.display.use_document_fonts', 1);
var prefGfx = getBoolPref('gfx.downloadable_fonts.enabled', true);
return (!!prefBrowser && prefGfx);
},
fallback: function(url, sendResponse) {
var self = this;

View File

@ -192,6 +192,7 @@ let PdfJs = {
var handlerInfo = Svc.mime.
getFromTypeAndExtension('application/pdf', 'pdf');
return handlerInfo.alwaysAskBeforeHandling == false &&
handlerInfo.plugin == null &&
handlerInfo.preferredAction == Ci.nsIHandlerInfo.handleInternally;
},

View File

@ -16,8 +16,8 @@
*/
var PDFJS = {};
PDFJS.version = '0.7.390';
PDFJS.build = '921f321';
PDFJS.version = '0.7.423';
PDFJS.build = 'aa22bef';
(function pdfjsWrapper() {
// Use strict in our context only - users might not want it
@ -957,13 +957,19 @@ var Util = PDFJS.Util = (function UtilClosure() {
})();
var PageViewport = PDFJS.PageViewport = (function PageViewportClosure() {
function PageViewport(viewBox, scale, rotate, offsetX, offsetY) {
function PageViewport(viewBox, scale, rotation, offsetX, offsetY) {
this.viewBox = viewBox;
this.scale = scale;
this.rotation = rotation;
this.offsetX = offsetX;
this.offsetY = offsetY;
// creating transform to convert pdf coordinate system to the normal
// canvas like coordinates taking in account scale and rotation
var centerX = (viewBox[2] + viewBox[0]) / 2;
var centerY = (viewBox[3] + viewBox[1]) / 2;
var rotateA, rotateB, rotateC, rotateD;
switch (rotate % 360) {
switch (rotation % 360) {
case -180:
case 180:
rotateA = -1; rotateB = 0; rotateC = 0; rotateD = 1;
@ -1007,13 +1013,18 @@ var PageViewport = PDFJS.PageViewport = (function PageViewportClosure() {
offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
];
this.offsetX = offsetX;
this.offsetY = offsetY;
this.width = width;
this.height = height;
this.fontScale = scale;
}
PageViewport.prototype = {
clone: function PageViewPort_clone(args) {
args = args || {};
var scale = 'scale' in args ? args.scale : this.scale;
var rotation = 'rotation' in args ? args.rotation : this.rotation;
return new PageViewport(this.viewBox.slice(), scale, rotation,
this.offsetX, this.offsetY);
},
convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
return Util.applyTransform([x, y], this.transform);
},
@ -1725,11 +1736,11 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
var stats = this.stats;
stats.time('Rendering');
gfx.beginDrawing(viewport);
var operatorList = this.operatorList;
gfx.beginDrawing(viewport, operatorList.transparency);
var startIdx = 0;
var length = this.operatorList.fnArray.length;
var operatorList = this.operatorList;
var length = operatorList.fnArray.length;
var stepper = null;
if (PDFJS.pdfBug && 'StepperManager' in globalScope &&
globalScope['StepperManager'].enabled) {
@ -2467,7 +2478,24 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
'shadingFill': true
},
beginDrawing: function CanvasGraphics_beginDrawing(viewport) {
beginDrawing: function CanvasGraphics_beginDrawing(viewport, transparency) {
// For pdfs that use blend modes we have to clear the canvas else certain
// blend modes can look wrong since we'd be blending with a white
// backdrop. The problem with a transparent backdrop though is we then
// don't get sub pixel anti aliasing on text, so we fill with white if
// we can.
var width = this.ctx.canvas.width;
var height = this.ctx.canvas.height;
if (transparency) {
this.ctx.clearRect(0, 0, width, height);
} else {
this.ctx.mozOpaque = true;
this.ctx.save();
this.ctx.fillStyle = 'rgb(255, 255, 255)';
this.ctx.fillRect(0, 0, width, height);
this.ctx.restore();
}
var transform = viewport.transform;
this.ctx.save();
this.ctx.transform.apply(this.ctx, transform);
@ -12630,8 +12658,35 @@ var ColorSpace = (function ColorSpaceClosure() {
if (this.isPassthrough(bits)) {
return src.subarray(srcOffset);
}
var destLength = this.getOutputLength(count * this.numComps);
var dest = new Uint8Array(destLength);
var dest = new Uint8Array(count * 3);
var numComponentColors = 1 << bits;
// Optimization: create a color map when there is just one component and
// we are converting more colors than the size of the color map. We
// don't build the map if the colorspace is gray or rgb since those
// methods are faster than building a map. This mainly offers big speed
// ups for indexed and alternate colorspaces.
if (this.numComps === 1 && count > numComponentColors &&
this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
// TODO it may be worth while to cache the color map. While running
// testing I never hit a cache so I will leave that out for now (perhaps
// we are reparsing colorspaces too much?).
var allColors = bits <= 8 ? new Uint8Array(numComponentColors) :
new Uint16Array(numComponentColors);
for (var i = 0; i < numComponentColors; i++) {
allColors[i] = i;
}
var colorMap = new Uint8Array(numComponentColors * 3);
this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bits);
var destOffset = 0;
for (var i = 0; i < count; ++i) {
var key = src[srcOffset++] * 3;
dest[destOffset++] = colorMap[key];
dest[destOffset++] = colorMap[key + 1];
dest[destOffset++] = colorMap[key + 2];
}
return dest;
}
this.getRgbBuffer(src, srcOffset, count, dest, 0, bits);
return dest;
}
@ -13034,7 +13089,7 @@ var DeviceRgbCS = (function DeviceRgbCSClosure() {
var scale = 255 / ((1 << bits) - 1);
var j = srcOffset, q = destOffset;
for (var i = 0; i < length; ++i) {
dest[q++] = (scale * input[j++]) | 0;
dest[q++] = (scale * src[j++]) | 0;
}
},
getOutputLength: function DeviceRgbCS_getOutputLength(inputLength) {
@ -14909,8 +14964,11 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}, handler, xref, resources, image, inline);
}
if (!queue)
queue = {};
if (!queue) {
queue = {
transparency: false
};
}
if (!queue.argsArray) {
queue.argsArray = [];
@ -15080,7 +15138,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
case 'FL':
case 'CA':
case 'ca':
case 'BM':
gsStateObj.push([key, value]);
break;
case 'Font':
@ -15090,6 +15147,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
value[1]
]);
break;
case 'BM':
if (!isName(value) || value.name !== 'Normal') {
queue.transparency = true;
}
gsStateObj.push([key, value]);
break;
case 'SMask':
// We support the default so don't trigger the TODO.
if (!isName(value) || value.name != 'None')
@ -18173,6 +18236,10 @@ var Font = (function FontClosure() {
// Repair the TrueType file. It is can be damaged in the point of
// view of the sanitizer
data = this.checkAndRepair(name, file, properties);
if (!data) {
// TrueType data is not found, e.g. when the font is an OpenType font
warn('Font is not a TrueType font');
}
break;
default:
@ -19519,6 +19586,8 @@ var Font = (function FontClosure() {
prep = table;
else if (table.tag == 'cvt ')
cvt = table;
else if (table.tag == 'CFF ')
return null; // XXX: OpenType font is found, stopping
else // skipping table if it's not a required or optional table
continue;
}
@ -21152,6 +21221,7 @@ Type1Font.prototype = {
getOrderedCharStrings: function Type1Font_getOrderedCharStrings(glyphs,
properties) {
var charstrings = [];
var usedUnicodes = [];
var i, length, glyphName;
var unusedUnicode = CMAP_GLYPH_OFFSET;
for (i = 0, length = glyphs.length; i < length; i++) {
@ -21159,6 +21229,10 @@ Type1Font.prototype = {
var glyphName = item.glyph;
var unicode = glyphName in GlyphsUnicode ?
GlyphsUnicode[glyphName] : unusedUnicode++;
while (usedUnicodes[unicode]) {
unicode = unusedUnicode++;
}
usedUnicodes[unicode] = true;
charstrings.push({
glyph: glyphName,
unicode: unicode,

View File

@ -772,6 +772,10 @@ var PDFView = {
}, false);
},
getPage: function pdfViewGetPage(n) {
return this.pdfDocument.getPage(n);
},
// Helper function to keep track whether a div was scrolled up or down and
// then call a callback.
watchScroll: function pdfViewWatchScroll(viewAreaElement, state, callback) {
@ -1256,37 +1260,84 @@ var PDFView = {
PDFView.documentFingerprint = id;
var store = PDFView.store = new Settings(id);
var storePromise = store.initializedPromise;
this.pageRotation = 0;
var pages = this.pages = [];
this.pageText = [];
this.startedTextExtraction = false;
var pagesRefMap = {};
var pagesRefMap = this.pagesRefMap = {};
var thumbnails = this.thumbnails = [];
var pagePromises = [];
for (var i = 1; i <= pagesCount; i++)
pagePromises.push(pdfDocument.getPage(i));
var self = this;
var pagesPromise = PDFJS.Promise.all(pagePromises);
pagesPromise.then(function(promisedPages) {
for (var i = 1; i <= pagesCount; i++) {
var page = promisedPages[i - 1];
var pageView = new PageView(container, page, i, scale,
page.stats, self.navigateTo.bind(self));
var thumbnailView = new ThumbnailView(thumbsView, page, i);
bindOnAfterDraw(pageView, thumbnailView);
var pagesPromise = new PDFJS.Promise();
var self = this;
var firstPagePromise = pdfDocument.getPage(1);
// Fetch a single page so we can get a viewport that will be the default
// viewport for all pages
firstPagePromise.then(function(pdfPage) {
var viewport = pdfPage.getViewport(scale || 1.0);
var pagePromises = [];
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
var viewportClone = viewport.clone();
var pageView = new PageView(container, pageNum, scale,
self.navigateTo.bind(self),
viewportClone);
var thumbnailView = new ThumbnailView(thumbsView, pageNum,
viewportClone);
bindOnAfterDraw(pageView, thumbnailView);
pages.push(pageView);
thumbnails.push(thumbnailView);
var pageRef = page.ref;
pagesRefMap[pageRef.num + ' ' + pageRef.gen + ' R'] = i;
}
self.pagesRefMap = pagesRefMap;
var event = document.createEvent('CustomEvent');
event.initCustomEvent('documentload', true, true, {});
window.dispatchEvent(event);
// Wait to do this here so all the canvases are setup.
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
var pagePromise = pdfDocument.getPage(pageNum);
pagePromise.then(function(pdfPage) {
var pageNum = pdfPage.pageNumber;
var pageView = pages[pageNum - 1];
if (!pageView.pdfPage) {
// The pdfPage might already be set if we've already entered
// pageView.draw()
pageView.setPdfPage(pdfPage);
}
var thumbnailView = thumbnails[pageNum - 1];
if (!thumbnailView.pdfPage) {
thumbnailView.setPdfPage(pdfPage);
}
var pageRef = pdfPage.ref;
var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
pagesRefMap[refStr] = pdfPage.pageNumber;
});
pagePromises.push(pagePromise);
}
PDFJS.Promise.all(pagePromises).then(function(pages) {
pagesPromise.resolve(pages);
});
});
var storePromise = store.initializedPromise;
PDFJS.Promise.all([firstPagePromise, storePromise]).then(function() {
var storedHash = null;
if (store.get('exists', false)) {
var pageNum = store.get('page', '1');
var zoom = store.get('zoom', PDFView.currentScale);
var left = store.get('scrollLeft', '0');
var top = store.get('scrollTop', '0');
storedHash = 'page=' + pageNum + '&zoom=' + zoom + ',' +
left + ',' + top;
}
self.setInitialView(storedHash, scale);
});
pagesPromise.then(function() {
if (PDFView.supportsPrinting) {
pdfDocument.getJavaScript().then(function(javaScript) {
if (javaScript.length) {
@ -1313,26 +1364,14 @@ var PDFView = {
self.destinations = destinations;
});
// outline and initial view depends on destinations and pagesRefMap
var promises = [pagesPromise, destinationsPromise, storePromise,
// outline depends on destinations and pagesRefMap
var promises = [pagesPromise, destinationsPromise,
PDFView.animationStartedPromise];
PDFJS.Promise.all(promises).then(function() {
pdfDocument.getOutline().then(function(outline) {
self.outline = new DocumentOutlineView(outline);
});
var storedHash = null;
if (store.get('exists', false)) {
var page = store.get('page', '1');
var zoom = store.get('zoom', PDFView.currentScale);
var left = store.get('scrollLeft', '0');
var top = store.get('scrollTop', '0');
storedHash = 'page=' + page + '&zoom=' + zoom + ',' + left + ',' + top;
}
self.setInitialView(storedHash, scale);
// Make all navigation keys work on document load,
// unless the viewer is embedded in another page.
if (window.parent.location === window.location) {
@ -1649,6 +1688,25 @@ var PDFView = {
this.error(printMessage);
return;
}
var alertNotReady = false;
if (!this.pages.length) {
alertNotReady = true;
} else {
for (var i = 0, ii = this.pages.length; i < ii; ++i) {
if (!this.pages[i].pdfPage) {
alertNotReady = true;
break;
}
}
}
if (alertNotReady) {
var notReadyMessage = mozL10n.get('printing_not_ready', null,
'Warning: The PDF is not fully loaded for printing.');
window.alert(notReadyMessage);
return;
}
var body = document.querySelector('body');
body.setAttribute('data-mozPrintCallback', true);
for (var i = 0, ii = this.pages.length; i < ii; ++i) {
@ -1743,15 +1801,18 @@ var PDFView = {
for (var i = 0, l = this.thumbnails.length; i < l; i++) {
var thumb = this.thumbnails[i];
thumb.updateRotation(this.pageRotation);
thumb.update(this.pageRotation);
}
var currentPage = this.pages[this.page - 1];
this.parseScale(this.currentScaleValue, true);
this.renderHighestPriority();
var currentPage = this.pages[this.page - 1];
if (!currentPage) {
return;
}
// Wait for fullscreen to take effect
setTimeout(function() {
currentPage.scrollIntoView();
@ -1824,14 +1885,14 @@ var PDFView = {
}
};
var PageView = function pageView(container, pdfPage, id, scale,
stats, navigateTo) {
var PageView = function pageView(container, id, scale,
navigateTo, defaultViewport) {
this.id = id;
this.pdfPage = pdfPage;
this.rotation = 0;
this.scale = scale || 1.0;
this.viewport = this.pdfPage.getViewport(this.scale, this.pdfPage.rotate);
this.viewport = defaultViewport;
this.pdfPageRotate = defaultViewport.rotate;
this.renderingState = RenderingStates.INITIAL;
this.resume = null;
@ -1851,9 +1912,19 @@ var PageView = function pageView(container, pdfPage, id, scale,
container.appendChild(anchor);
container.appendChild(div);
this.setPdfPage = function pageViewSetPdfPage(pdfPage) {
this.pdfPage = pdfPage;
this.pdfPageRotate = pdfPage.rotate;
this.viewport = pdfPage.getViewport(this.scale);
this.stats = pdfPage.stats;
this.update();
};
this.destroy = function pageViewDestroy() {
this.update();
this.pdfPage.destroy();
if (this.pdfPage) {
this.pdfPage.destroy();
}
};
this.update = function pageViewUpdate(scale, rotation) {
@ -1866,12 +1937,14 @@ var PageView = function pageView(container, pdfPage, id, scale,
this.scale = scale || this.scale;
var totalRotation = (this.rotation + this.pdfPage.rotate) % 360;
var viewport = this.pdfPage.getViewport(this.scale, totalRotation);
var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
this.viewport = this.viewport.clone({
scale: this.scale,
rotation: totalRotation
});
this.viewport = viewport;
div.style.width = Math.floor(viewport.width) + 'px';
div.style.height = Math.floor(viewport.height) + 'px';
div.style.width = Math.floor(this.viewport.width) + 'px';
div.style.height = Math.floor(this.viewport.height) + 'px';
while (div.hasChildNodes())
div.removeChild(div.lastChild);
@ -2079,6 +2152,17 @@ var PageView = function pageView(container, pdfPage, id, scale,
};
this.draw = function pageviewDraw(callback) {
var pdfPage = this.pdfPage;
if (!pdfPage) {
var promise = PDFView.getPage(this.id);
promise.then(function(pdfPage) {
this.setPdfPage(pdfPage);
this.draw(callback);
}.bind(this));
return;
}
if (this.renderingState !== RenderingStates.INITIAL) {
console.error('Must be in new state before drawing');
}
@ -2090,20 +2174,22 @@ var PageView = function pageView(container, pdfPage, id, scale,
div.appendChild(canvas);
this.canvas = canvas;
var textLayerDiv = null;
if (!PDFJS.disableTextLayer) {
textLayerDiv = document.createElement('div');
textLayerDiv.className = 'textLayer';
div.appendChild(textLayerDiv);
}
var textLayer = this.textLayer =
textLayerDiv ? new TextLayerBuilder(textLayerDiv, this.id - 1) : null;
var scale = this.scale, viewport = this.viewport;
var outputScale = PDFView.getOutputScale();
canvas.width = Math.floor(viewport.width) * outputScale.sx;
canvas.height = Math.floor(viewport.height) * outputScale.sy;
var textLayerDiv = null;
if (!PDFJS.disableTextLayer) {
textLayerDiv = document.createElement('div');
textLayerDiv.className = 'textLayer';
textLayerDiv.style.width = canvas.width + 'px';
textLayerDiv.style.height = canvas.height + 'px';
div.appendChild(textLayerDiv);
}
var textLayer = this.textLayer =
textLayerDiv ? new TextLayerBuilder(textLayerDiv, this.id - 1) : null;
if (outputScale.scaled) {
var cssScale = 'scale(' + (1 / outputScale.sx) + ', ' +
(1 / outputScale.sy) + ')';
@ -2116,7 +2202,6 @@ var PageView = function pageView(container, pdfPage, id, scale,
}
var ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height);
// TODO(mack): use data attributes to store these
ctx._scaleX = outputScale.sx;
ctx._scaleY = outputScale.sy;
@ -2159,6 +2244,13 @@ var PageView = function pageView(container, pdfPage, id, scale,
self.onAfterDraw();
cache.push(self);
var event = document.createEvent('CustomEvent');
event.initCustomEvent('pagerender', true, true, {
pageNumber: pdfPage.pageNumber
});
div.dispatchEvent(event);
callback();
}
@ -2207,6 +2299,7 @@ var PageView = function pageView(container, pdfPage, id, scale,
this.beforePrint = function pageViewBeforePrint() {
var pdfPage = this.pdfPage;
var viewport = pdfPage.getViewport(1);
// Use the same hack we use for high dpi displays for printing to get better
// output until bug 811002 is fixed in FF.
@ -2257,6 +2350,10 @@ var PageView = function pageView(container, pdfPage, id, scale,
};
this.updateStats = function pageViewUpdateStats() {
if (!this.stats) {
return;
}
if (PDFJS.pdfBug && Stats.enabled) {
var stats = this.stats;
Stats.add(this.id, stats);
@ -2264,7 +2361,7 @@ var PageView = function pageView(container, pdfPage, id, scale,
};
};
var ThumbnailView = function thumbnailView(container, pdfPage, id) {
var ThumbnailView = function thumbnailView(container, id, defaultViewport) {
var anchor = document.createElement('a');
anchor.href = PDFView.getAnchorUrl('#page=' + id);
anchor.title = mozL10n.get('thumb_page_title', {page: id}, 'Page {{page}}');
@ -2273,18 +2370,20 @@ var ThumbnailView = function thumbnailView(container, pdfPage, id) {
return false;
};
var rotation = 0;
var totalRotation = (rotation + pdfPage.rotate) % 360;
var viewport = pdfPage.getViewport(1, totalRotation);
var pageWidth = this.width = viewport.width;
var pageHeight = this.height = viewport.height;
var pageRatio = pageWidth / pageHeight;
this.pdfPage = undefined;
this.viewport = defaultViewport;
this.pdfPageRotate = defaultViewport.rotate;
this.rotation = 0;
this.pageWidth = this.viewport.width;
this.pageHeight = this.viewport.height;
this.pageRatio = this.pageWidth / this.pageHeight;
this.id = id;
var canvasWidth = 98;
var canvasHeight = canvasWidth / this.width * this.height;
var scaleX = this.scaleX = (canvasWidth / pageWidth);
var scaleY = this.scaleY = (canvasHeight / pageHeight);
this.canvasWidth = 98;
this.canvasHeight = this.canvasWidth / this.pageWidth * this.pageHeight;
this.scale = (this.canvasWidth / this.pageWidth);
var div = this.el = document.createElement('div');
div.id = 'thumbnailContainer' + id;
@ -2298,8 +2397,8 @@ var ThumbnailView = function thumbnailView(container, pdfPage, id) {
var ring = document.createElement('div');
ring.className = 'thumbnailSelectionRing';
ring.style.width = canvasWidth + 'px';
ring.style.height = canvasHeight + 'px';
ring.style.width = this.canvasWidth + 'px';
ring.style.height = this.canvasHeight + 'px';
div.appendChild(ring);
anchor.appendChild(div);
@ -2308,35 +2407,50 @@ var ThumbnailView = function thumbnailView(container, pdfPage, id) {
this.hasImage = false;
this.renderingState = RenderingStates.INITIAL;
this.updateRotation = function(rot) {
this.setPdfPage = function thumbnailViewSetPdfPage(pdfPage) {
this.pdfPage = pdfPage;
this.pdfPageRotate = pdfPage.rotate;
this.viewport = pdfPage.getViewport(1);
this.update();
};
rotation = rot;
totalRotation = (rotation + pdfPage.rotate) % 360;
viewport = pdfPage.getViewport(1, totalRotation);
pageWidth = this.width = viewport.width;
pageHeight = this.height = viewport.height;
pageRatio = pageWidth / pageHeight;
this.update = function thumbnailViewUpdate(rot) {
if (!this.pdfPage) {
return;
}
canvasHeight = canvasWidth / this.width * this.height;
scaleX = this.scaleX = (canvasWidth / pageWidth);
scaleY = this.scaleY = (canvasHeight / pageHeight);
if (rot !== undefined) {
this.rotation = rot;
}
var totalRotation = (this.rotation + this.pdfPage.rotate) % 360;
this.viewport = this.viewport.clone({
scale: 1,
rotation: totalRotation
});
this.pageWidth = this.viewport.width;
this.pageHeight = this.viewport.height;
this.pageRatio = this.pageWidth / this.pageHeight;
this.canvasHeight = this.canvasWidth / this.pageWidth * this.pageHeight;
this.scale = (this.canvasWidth / this.pageWidth);
div.removeAttribute('data-loaded');
ring.textContent = '';
ring.style.width = canvasWidth + 'px';
ring.style.height = canvasHeight + 'px';
ring.style.width = this.canvasWidth + 'px';
ring.style.height = this.canvasHeight + 'px';
this.hasImage = false;
this.renderingState = RenderingStates.INITIAL;
this.resume = null;
};
function getPageDrawContext() {
this.getPageDrawContext = function thumbnailViewGetPageDrawContext() {
var canvas = document.createElement('canvas');
canvas.id = 'thumbnail' + id;
canvas.width = canvasWidth;
canvas.height = canvasHeight;
canvas.width = this.canvasWidth;
canvas.height = this.canvasHeight;
canvas.className = 'thumbnailImage';
canvas.setAttribute('aria-label', mozL10n.get('thumb_page_canvas',
{page: id}, 'Thumbnail of Page {{page}}'));
@ -2348,16 +2462,25 @@ var ThumbnailView = function thumbnailView(container, pdfPage, id) {
var ctx = canvas.getContext('2d');
ctx.save();
ctx.fillStyle = 'rgb(255, 255, 255)';
ctx.fillRect(0, 0, canvasWidth, canvasHeight);
ctx.fillRect(0, 0, this.canvasWidth, this.canvasHeight);
ctx.restore();
return ctx;
}
};
this.drawingRequired = function thumbnailViewDrawingRequired() {
return !this.hasImage;
};
this.draw = function thumbnailViewDraw(callback) {
if (!this.pdfPage) {
var promise = PDFView.getPage(this.id);
promise.then(function(pdfPage) {
this.setPdfPage(pdfPage);
this.draw(callback);
}.bind(this));
return;
}
if (this.renderingState !== RenderingStates.INITIAL) {
console.error('Must be in new state before drawing');
}
@ -2369,8 +2492,8 @@ var ThumbnailView = function thumbnailView(container, pdfPage, id) {
}
var self = this;
var ctx = getPageDrawContext();
var drawViewport = pdfPage.getViewport(scaleX, totalRotation);
var ctx = this.getPageDrawContext();
var drawViewport = this.viewport.clone({ scale: this.scale });
var renderContext = {
canvasContext: ctx,
viewport: drawViewport,
@ -2386,7 +2509,7 @@ var ThumbnailView = function thumbnailView(container, pdfPage, id) {
cont();
}
};
pdfPage.render(renderContext).then(
this.pdfPage.render(renderContext).then(
function pdfPageRenderCallback() {
self.renderingState = RenderingStates.FINISHED;
callback();
@ -2403,7 +2526,7 @@ var ThumbnailView = function thumbnailView(container, pdfPage, id) {
if (this.hasImage || !img)
return;
this.renderingState = RenderingStates.FINISHED;
var ctx = getPageDrawContext();
var ctx = this.getPageDrawContext();
ctx.drawImage(img, 0, 0, img.width, img.height,
0, 0, ctx.canvas.width, ctx.canvas.height);

View File

@ -121,4 +121,5 @@ text_annotation_type=[{{type}} Annotation]
request_password=PDF is protected by a password:
printing_not_supported=Warning: Printing is not fully supported by this browser.
printing_not_ready=Warning: The PDF is not fully loaded for printing.
web_fonts_disabled=Web fonts are disabled: unable to use embedded PDF fonts.