Bug 1205051 - Update pdf.js to version 1.1.469. r=bdahl

This commit is contained in:
Ryan VanderMeulen 2015-09-15 17:03:08 -04:00
parent 568fb76791
commit ae0441c960
12 changed files with 241 additions and 46 deletions

View File

@ -1,3 +1,3 @@
This is the pdf.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 1.1.403
Current extension version is: 1.1.469

View File

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {};
}
PDFJS.version = '1.1.403';
PDFJS.build = '88e0326';
PDFJS.version = '1.1.469';
PDFJS.build = 'f06aa6a';
(function pdfjsWrapper() {
// Use strict in our context only - users might not want it
@ -3953,6 +3953,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.current = this.stateStack.pop();
this.ctx.restore();
// Ensure that the clipping path is reset (fixes issue6413.pdf).
this.pendingClip = null;
this.cachedGetSinglePixelWidth = null;
}
},
@ -4340,6 +4343,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var textHScale = current.textHScale * fontDirection;
var glyphsLength = glyphs.length;
var vertical = font.vertical;
var spacingDir = vertical ? 1 : -1;
var defaultVMetrics = font.defaultVMetrics;
var widthAdvanceScale = fontSize * current.fontMatrix[0];
@ -4386,7 +4390,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
x += fontDirection * wordSpacing;
continue;
} else if (isNum(glyph)) {
x += -glyph * fontSize * 0.001;
x += spacingDir * glyph * fontSize / 1000;
continue;
}
@ -4456,6 +4460,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var font = current.font;
var fontSize = current.fontSize;
var fontDirection = current.fontDirection;
var spacingDir = font.vertical ? 1 : -1;
var charSpacing = current.charSpacing;
var wordSpacing = current.wordSpacing;
var textHScale = current.textHScale * fontDirection;
@ -4463,7 +4468,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var glyphsLength = glyphs.length;
var isTextInvisible =
current.textRenderingMode === TextRenderingMode.INVISIBLE;
var i, glyph, width;
var i, glyph, width, spacingLength;
if (isTextInvisible || fontSize === 0) {
return;
@ -4484,7 +4489,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
current.x += wordSpacing * textHScale;
continue;
} else if (isNum(glyph)) {
var spacingLength = -glyph * 0.001 * fontSize;
spacingLength = spacingDir * glyph * fontSize / 1000;
this.ctx.translate(spacingLength, 0);
current.x += spacingLength * textHScale;
continue;

View File

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {};
}
PDFJS.version = '1.1.403';
PDFJS.build = '88e0326';
PDFJS.version = '1.1.469';
PDFJS.build = 'f06aa6a';
(function pdfjsWrapper() {
// Use strict in our context only - users might not want it
@ -2506,12 +2506,11 @@ var PDFDocument = (function PDFDocumentClosure() {
return shadow(this, 'documentInfo', docInfo);
},
get fingerprint() {
var xref = this.xref, idArray, hash, fileID = '';
var xref = this.xref, hash, fileID = '';
var idArray = xref.trailer.get('ID');
if (xref.trailer.has('ID')) {
idArray = xref.trailer.get('ID');
}
if (idArray && isArray(idArray) && idArray[0] !== EMPTY_FINGERPRINT) {
if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) &&
idArray[0] !== EMPTY_FINGERPRINT) {
hash = stringToBytes(idArray[0]);
} else {
if (this.stream.ensureRange) {
@ -10902,11 +10901,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var arr = args[0];
var combinedGlyphs = [];
var arrLength = arr.length;
var state = stateManager.state;
for (i = 0; i < arrLength; ++i) {
var arrItem = arr[i];
if (isString(arrItem)) {
Array.prototype.push.apply(combinedGlyphs,
self.handleText(arrItem, stateManager.state));
self.handleText(arrItem, state));
} else if (isNum(arrItem)) {
combinedGlyphs.push(arrItem);
}
@ -11302,17 +11302,26 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
if (typeof items[j] === 'string') {
buildTextGeometry(items[j], textChunk);
} else {
var val = items[j] / 1000;
if (!textState.font.vertical) {
offset = -val * textState.fontSize * textState.textHScale *
textState.textMatrix[0];
textState.translateTextMatrix(offset, 0);
textChunk.width += offset;
} else {
offset = -val * textState.fontSize *
textState.textMatrix[3];
// PDF Specification 5.3.2 states:
// The number is expressed in thousandths of a unit of text
// space.
// This amount is subtracted from the current horizontal or
// vertical coordinate, depending on the writing mode.
// In the default coordinate system, a positive adjustment
// has the effect of moving the next glyph painted either to
// the left or down by the given amount.
var val = items[j] * textState.fontSize / 1000;
if (textState.font.vertical) {
offset = val * textState.textMatrix[3];
textState.translateTextMatrix(0, offset);
// Value needs to be added to height to paint down.
textChunk.height += offset;
} else {
offset = val * textState.textHScale *
textState.textMatrix[0];
textState.translateTextMatrix(offset, 0);
// Value needs to be subtracted from width to paint left.
textChunk.width -= offset;
}
if (items[j] < 0 && textState.font.spaceWidth > 0) {
var fakeSpaces = -items[j] / textState.font.spaceWidth;
@ -17036,7 +17045,7 @@ var Font = (function FontClosure() {
* Read the appropriate subtable from the cmap according to 9.6.6.4 from
* PDF spec
*/
function readCmapTable(cmap, font, isSymbolicFont) {
function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
var segment;
var start = (font.start ? font.start : 0) + cmap.offset;
font.pos = start;
@ -17067,7 +17076,7 @@ var Font = (function FontClosure() {
// Continue the loop since there still may be a higher priority
// table.
} else if (platformId === 3 && encodingId === 1 &&
(!isSymbolicFont || !potentialTable)) {
((!isSymbolicFont && hasEncoding) || !potentialTable)) {
useTable = true;
if (!isSymbolicFont) {
canBreak = true;
@ -17204,7 +17213,13 @@ var Font = (function FontClosure() {
});
}
} else {
error('cmap table has unsupported format: ' + format);
warn('cmap table has unsupported format: ' + format);
return {
platformId: -1,
encodingId: -1,
mappings: [],
hasShortCmap: false
};
}
// removing duplicate entries
@ -18010,13 +18025,14 @@ var Font = (function FontClosure() {
} else {
// Most of the following logic in this code branch is based on the
// 9.6.6.4 of the PDF spec.
var cmapTable = readCmapTable(tables.cmap, font, this.isSymbolicFont);
var hasEncoding =
properties.differences.length > 0 || !!properties.baseEncodingName;
var cmapTable =
readCmapTable(tables.cmap, font, this.isSymbolicFont, hasEncoding);
var cmapPlatformId = cmapTable.platformId;
var cmapEncodingId = cmapTable.encodingId;
var cmapMappings = cmapTable.mappings;
var cmapMappingsLength = cmapMappings.length;
var hasEncoding = properties.differences.length ||
!!properties.baseEncodingName;
// The spec seems to imply that if the font is symbolic the encoding
// should be ignored, this doesn't appear to work for 'preistabelle.pdf'
@ -29894,6 +29910,9 @@ var Parser = (function ParserClosure() {
this.shift();
return true;
} catch (e) {
if (e instanceof MissingDataException) {
throw e;
}
// Upon failure, the caller should reset this.lexer.pos to a known good
// state and call this.shift() twice to reset the buffers.
return false;
@ -30361,6 +30380,7 @@ var Parser = (function ParserClosure() {
},
makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
if (stream.dict.get('Length') === 0 && !maybeLength) {
warn('Empty "' + name + '" stream.');
return new NullStream(stream);
}
try {
@ -38862,14 +38882,13 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
// don't mirror as characters are already mirrored in the pdf
// Finally, return string
var result = '';
for (i = 0, ii = chars.length; i < ii; ++i) {
var ch = chars[i];
if (ch !== '<' && ch !== '>') {
result += ch;
if (ch === '<' || ch === '>') {
chars[i] = '';
}
}
return createBidiText(result, isLTR);
return createBidiText(chars.join(''), isLTR);
}
return bidi;

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

View File

@ -1235,10 +1235,12 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
padding: 3px 4px 0;
}
html[dir='ltr'] .outlineWithDeepNesting > .outlineItem,
html[dir='ltr'] .outlineItem > .outlineItems {
margin-left: 20px;
}
html[dir='rtl'] .outlineWithDeepNesting > .outlineItem,
html[dir='rtl'] .outlineItem > .outlineItems {
margin-right: 20px;
}
@ -1248,6 +1250,8 @@ html[dir='rtl'] .outlineItem > .outlineItems {
text-decoration: none;
display: inline-block;
min-width: 95%;
min-width: calc(100% - 4px); /* Subtract the right padding (left, in RTL mode)
of the container. */
height: auto;
margin-bottom: 1px;
border-radius: 2px;
@ -1266,7 +1270,7 @@ html[dir='rtl'] .outlineItem > .outlineItems {
}
html[dir='ltr'] .outlineItem > a {
padding: 2px 0 5px 10px;
padding: 2px 0 5px 4px;
}
html[dir='ltr'] .attachmentsItem > button {
padding: 2px 0 3px 7px;
@ -1274,13 +1278,49 @@ html[dir='ltr'] .attachmentsItem > button {
}
html[dir='rtl'] .outlineItem > a {
padding: 2px 10px 5px 0;
padding: 2px 4px 5px 0;
}
html[dir='rtl'] .attachmentsItem > button {
padding: 2px 7px 3px 0;
text-align: right;
}
.outlineItemToggler {
position: relative;
height: 0;
width: 0;
color: hsla(0,0%,100%,.5);
}
.outlineItemToggler::before {
content: url(images/treeitem-expanded.png);
display: inline-block;
position: absolute;
}
html[dir='ltr'] .outlineItemToggler.outlineItemsHidden::before {
content: url(images/treeitem-collapsed.png);
}
html[dir='rtl'] .outlineItemToggler.outlineItemsHidden::before {
content: url(images/treeitem-collapsed-rtl.png);
}
.outlineItemToggler.outlineItemsHidden ~ .outlineItems {
display: none;
}
html[dir='ltr'] .outlineItemToggler {
float: left;
}
html[dir='rtl'] .outlineItemToggler {
float: right;
}
html[dir='ltr'] .outlineItemToggler::before {
right: 4px;
}
html[dir='rtl'] .outlineItemToggler::before {
left: 4px;
}
.outlineItemToggler:hover,
.outlineItemToggler:hover + a,
.outlineItemToggler:hover ~ .outlineItems,
.outlineItem > a:hover,
.attachmentsItem > button:hover {
background-color: hsla(0,0%,100%,.02);
@ -1289,6 +1329,7 @@ html[dir='rtl'] .attachmentsItem > button {
box-shadow: 0 1px 0 hsla(0,0%,100%,.05) inset,
0 0 1px hsla(0,0%,100%,.2) inset,
0 0 1px hsla(0,0%,0%,.2);
border-radius: 2px;
color: hsla(0,0%,100%,.9);
}
@ -1704,6 +1745,24 @@ html[dir='rtl'] #documentPropertiesOverlay .row > * {
.secondaryToolbarButton.documentProperties::before {
content: url(images/secondaryToolbarButton-documentProperties@2x.png);
}
.outlineItemToggler::before {
transform: scale(0.5);
top: -1px;
content: url(images/treeitem-expanded@2x.png);
}
html[dir='ltr'] .outlineItemToggler.outlineItemsHidden::before {
content: url(images/treeitem-collapsed@2x.png);
}
html[dir='rtl'] .outlineItemToggler.outlineItemsHidden::before {
content: url(images/treeitem-collapsed-rtl@2x.png);
}
html[dir='ltr'] .outlineItemToggler::before {
right: 0;
}
html[dir='rtl'] .outlineItemToggler::before {
left: 0;
}
}
@media print {

View File

@ -104,6 +104,12 @@ var CustomStyle = (function CustomStyleClosure() {
return CustomStyle;
})();
var NullCharactersRegExp = /\x00/g;
function removeNullCharacters(str) {
return str.replace(NullCharactersRegExp, '');
}
function getFileName(url) {
var anchor = url.indexOf('#');
var query = url.indexOf('?');
@ -5373,6 +5379,10 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
this.canvas.height = 0;
delete this.canvas;
}
if (this.image) {
this.image.removeAttribute('src');
delete this.image;
}
},
update: function PDFThumbnailView_update(rotation) {
@ -5393,28 +5403,53 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
_getPageDrawContext:
function PDFThumbnailView_getPageDrawContext(noCtxScale) {
var canvas = document.createElement('canvas');
canvas.id = this.renderingId;
canvas.className = 'thumbnailImage';
canvas.setAttribute('aria-label', mozL10n.get('thumb_page_canvas',
{page: this.id}, 'Thumbnail of Page {{page}}'));
this.canvas = canvas;
this.div.setAttribute('data-loaded', true);
this.ring.appendChild(canvas);
var ctx = canvas.getContext('2d');
var outputScale = getOutputScale(ctx);
canvas.width = (this.canvasWidth * outputScale.sx) | 0;
canvas.height = (this.canvasHeight * outputScale.sy) | 0;
canvas.style.width = this.canvasWidth + 'px';
canvas.style.height = this.canvasHeight + 'px';
if (!noCtxScale && outputScale.scaled) {
ctx.scale(outputScale.sx, outputScale.sy);
}
var image = document.createElement('img');
this.image = image;
image.id = this.renderingId;
image.className = 'thumbnailImage';
image.setAttribute('aria-label', mozL10n.get('thumb_page_canvas',
{ page: this.id }, 'Thumbnail of Page {{page}}'));
image.style.width = canvas.style.width;
image.style.height = canvas.style.height;
return ctx;
},
/**
* @private
*/
_convertCanvasToImage: function PDFThumbnailView_convertCanvasToImage() {
if (!this.canvas) {
return;
}
this.image.src = this.canvas.toDataURL();
this.div.setAttribute('data-loaded', true);
this.ring.appendChild(this.image);
// Zeroing the width and height causes Firefox to release graphics
// resources immediately, which can greatly reduce memory consumption.
this.canvas.width = 0;
this.canvas.height = 0;
delete this.canvas;
},
draw: function PDFThumbnailView_draw() {
if (this.renderingState !== RenderingStates.INITIAL) {
console.error('Must be in new state before drawing');
@ -5444,6 +5479,7 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
return;
}
self.renderingState = RenderingStates.FINISHED;
self._convertCanvasToImage();
if (!error) {
resolveRenderPromise(undefined);
@ -5501,6 +5537,7 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
if (img.width <= 2 * canvas.width) {
ctx.drawImage(img, 0, 0, img.width, img.height,
0, 0, canvas.width, canvas.height);
this._convertCanvasToImage();
return;
}
// drawImage does an awful job of rescaling the image, doing it gradually.
@ -5525,6 +5562,7 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
}
ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight,
0, 0, canvas.width, canvas.height);
this._convertCanvasToImage();
}
};
@ -5736,6 +5774,7 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {
this.container = options.container;
this.outline = options.outline;
this.linkService = options.linkService;
this.lastToggleIsShow = true;
}
PDFOutlineView.prototype = {
@ -5744,6 +5783,7 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {
while (container.firstChild) {
container.removeChild(container.firstChild);
}
this.lastToggleIsShow = true;
},
/**
@ -5769,6 +5809,51 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {
};
},
/**
* Prepend a button before an outline item which allows the user to toggle
* the visibility of all outline items at that level.
*
* @private
*/
_addToggleButton: function PDFOutlineView_addToggleButton(div) {
var toggler = document.createElement('div');
toggler.className = 'outlineItemToggler';
toggler.onclick = function(event) {
event.stopPropagation();
toggler.classList.toggle('outlineItemsHidden');
if (event.shiftKey) {
var shouldShowAll = !toggler.classList.contains('outlineItemsHidden');
this._toggleOutlineItem(div, shouldShowAll);
}
}.bind(this);
div.insertBefore(toggler, div.firstChild);
},
/**
* Toggle the visibility of the subtree of an outline item.
*
* @param {Element} root - the root of the outline (sub)tree.
* @param {boolean} state - whether to show the outline (sub)tree. If false,
* the outline subtree rooted at |root| will be collapsed.
*
* @private
*/
_toggleOutlineItem: function PDFOutlineView_toggleOutlineItem(root, show) {
this.lastToggleIsShow = show;
var togglers = root.querySelectorAll('.outlineItemToggler');
for (var i = 0, ii = togglers.length; i < ii; ++i) {
togglers[i].classList[show ? 'remove' : 'add']('outlineItemsHidden');
}
},
/**
* Collapse or expand all subtrees of the outline.
*/
toggleOutlineTree: function PDFOutlineView_toggleOutlineTree() {
this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
},
render: function PDFOutlineView_render() {
var outline = this.outline;
var outlineCount = 0;
@ -5780,7 +5865,9 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {
return;
}
var queue = [{ parent: this.container, items: this.outline }];
var fragment = document.createDocumentFragment();
var queue = [{ parent: fragment, items: this.outline }];
var hasAnyNesting = false;
while (queue.length > 0) {
var levelData = queue.shift();
for (var i = 0, len = levelData.items.length; i < len; i++) {
@ -5789,10 +5876,13 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {
div.className = 'outlineItem';
var element = document.createElement('a');
this._bindLink(element, item);
element.textContent = item.title;
element.textContent = removeNullCharacters(item.title);
div.appendChild(element);
if (item.items.length > 0) {
hasAnyNesting = true;
this._addToggleButton(div);
var itemsDiv = document.createElement('div');
itemsDiv.className = 'outlineItems';
div.appendChild(itemsDiv);
@ -5803,6 +5893,11 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {
outlineCount++;
}
}
if (hasAnyNesting) {
this.container.classList.add('outlineWithDeepNesting');
}
this.container.appendChild(fragment);
this._dispatchEvent(outlineCount);
}
@ -5885,7 +5980,7 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {
div.className = 'attachmentsItem';
var button = document.createElement('button');
this._bindLink(button, item.content, filename);
button.textContent = filename;
button.textContent = removeNullCharacters(filename);
div.appendChild(button);
this.container.appendChild(div);
}
@ -6083,6 +6178,12 @@ var PDFViewerApplication = {
}
PDFJS.disableRange = value;
}),
Preferences.get('disableStream').then(function resolved(value) {
if (PDFJS.disableStream === true) {
return;
}
PDFJS.disableStream = value;
}),
Preferences.get('disableAutoFetch').then(function resolved(value) {
PDFJS.disableAutoFetch = value;
}),
@ -7072,6 +7173,11 @@ function webViewerInitialized() {
PDFViewerApplication.switchSidebarView('outline');
});
document.getElementById('viewOutline').addEventListener('dblclick',
function() {
PDFViewerApplication.outline.toggleOutlineTree();
});
document.getElementById('viewAttachments').addEventListener('click',
function() {
PDFViewerApplication.switchSidebarView('attachments');

View File

@ -67,7 +67,11 @@ document_properties.title=Document Properties…
document_properties_label=Document Properties…
document_properties_file_name=File name:
document_properties_file_size=File size:
# LOCALIZATION NOTE (document_properties_kb): "{{size_kb}}" and "{{size_b}}"
# will be replaced by the PDF file size in kilobytes, respectively in bytes.
document_properties_kb={{size_kb}} KB ({{size_b}} bytes)
# LOCALIZATION NOTE (document_properties_mb): "{{size_mb}}" and "{{size_b}}"
# will be replaced by the PDF file size in megabytes, respectively in bytes.
document_properties_mb={{size_mb}} MB ({{size_b}} bytes)
document_properties_title=Title:
document_properties_author=Author:
@ -75,6 +79,8 @@ document_properties_subject=Subject:
document_properties_keywords=Keywords:
document_properties_creation_date=Creation Date:
document_properties_modification_date=Modification Date:
# LOCALIZATION NOTE (document_properties_date_string): "{{date}}" and "{{time}}"
# will be replaced by the creation/modification date, and time, of the PDF file.
document_properties_date_string={{date}}, {{time}}
document_properties_creator=Creator:
document_properties_producer=PDF Producer: