Bug 1049007 - Update pdf.js to version 1.0.577. r=yury

This commit is contained in:
Ryan VanderMeulen 2014-08-05 15:30:37 -04:00
parent 1a2aa88eae
commit 18fed45f4b
5 changed files with 412 additions and 7306 deletions

View File

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

View File

@ -15,14 +15,15 @@
* limitations under the License.
*/
/*jshint globalstrict: false */
/* globals PDFJS */
// Initializing PDFJS global object (if still undefined)
if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {};
}
PDFJS.version = '1.0.473';
PDFJS.build = '1694cd8';
PDFJS.version = '1.0.577';
PDFJS.build = '6865c28';
(function pdfjsWrapper() {
// Use strict in our context only - users might not want it
@ -51,7 +52,7 @@ PDFJS.build = '1694cd8';
var globalScope = (typeof window === 'undefined') ? this : window;
var isWorker = (typeof window == 'undefined');
var isWorker = (typeof window === 'undefined');
var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
@ -302,7 +303,7 @@ function combineUrl(baseUrl, url) {
return url;
}
var i;
if (url.charAt(0) == '/') {
if (url.charAt(0) === '/') {
// absolute path
i = baseUrl.indexOf('://');
if (url.charAt(1) === '/') {
@ -918,7 +919,7 @@ function isEmptyObj(obj) {
}
function isBool(v) {
return typeof v == 'boolean';
return typeof v === 'boolean';
}
function isInt(v) {
@ -1768,8 +1769,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
// this call to render.
this.pendingDestroy = false;
var renderingIntent = ('intent' in params ?
(params.intent == 'print' ? 'print' : 'display') : 'display');
var renderingIntent = (params.intent === 'print' ? 'print' : 'display');
if (!this.intentStates[renderingIntent]) {
this.intentStates[renderingIntent] = {};
@ -2258,7 +2258,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
messageHandler.on('JpegDecode', function(data) {
var imageUrl = data[0];
var components = data[1];
if (components != 3 && components != 1) {
if (components !== 3 && components !== 1) {
return Promise.reject(
new Error('Only 3 components or 1 component can be returned'));
}
@ -2277,13 +2277,13 @@ var WorkerTransport = (function WorkerTransportClosure() {
var data = tmpCtx.getImageData(0, 0, width, height).data;
var i, j;
if (components == 3) {
if (components === 3) {
for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
buf[j] = data[i];
buf[j + 1] = data[i + 1];
buf[j + 2] = data[i + 2];
}
} else if (components == 1) {
} else if (components === 1) {
for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
buf[j] = data[i];
}
@ -2667,8 +2667,8 @@ var Metadata = PDFJS.Metadata = (function MetadataClosure() {
var chars = '';
for (var i = 0; i < bytes.length; i += 2) {
var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
chars += code >= 32 && code < 127 && code != 60 && code != 62 &&
code != 38 && false ? String.fromCharCode(code) :
chars += code >= 32 && code < 127 && code !== 60 && code !== 62 &&
code !== 38 && false ? String.fromCharCode(code) :
'&#x' + (0x10000 + code).toString(16).substring(1) + ';';
}
return '>' + chars;
@ -3944,7 +3944,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
// the current transformation matrix before the fillText/strokeText.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=726227
var browserFontSize = size >= MIN_FONT_SIZE ? size : MIN_FONT_SIZE;
this.current.fontSizeScale = browserFontSize != MIN_FONT_SIZE ? 1.0 :
this.current.fontSizeScale = browserFontSize !== MIN_FONT_SIZE ? 1.0 :
size / MIN_FONT_SIZE;
var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
@ -4090,7 +4090,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
lineWidth /= scale;
}
if (fontSizeScale != 1.0) {
if (fontSizeScale !== 1.0) {
ctx.scale(fontSizeScale, fontSizeScale);
lineWidth /= fontSizeScale;
}
@ -4206,11 +4206,16 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
continue;
}
var operatorList = font.charProcOperatorList[glyph.operatorListId];
if (!operatorList) {
warn('Type3 character \"' + glyph.operatorListId +
'\" is not available');
continue;
}
this.processingType3 = glyph;
this.save();
ctx.scale(fontSize, fontSize);
ctx.transform.apply(ctx, fontMatrix);
var operatorList = font.charProcOperatorList[glyph.operatorListId];
this.executeOperatorList(operatorList);
this.restore();
@ -5623,7 +5628,7 @@ var TilingPattern = (function TilingPatternClosure() {
},
clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
if (bbox && isArray(bbox) && 4 == bbox.length) {
if (bbox && isArray(bbox) && bbox.length === 4) {
var bboxWidth = x1 - x0;
var bboxHeight = y1 - y0;
graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
@ -5840,7 +5845,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
return element;
}
function getHtmlElementForTextAnnotation(item, commonObjs) {
function getHtmlElementForTextAnnotation(item) {
var rect = item.rect;
// sanity check because of OOo-generated PDFs
@ -5957,8 +5962,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
return container;
}
function getHtmlElementForLinkAnnotation(item, commonObjs) {
function getHtmlElementForLinkAnnotation(item) {
var container = initContainer(item);
container.className = 'annotLink';
@ -5978,9 +5982,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
case AnnotationType.WIDGET:
return getHtmlElementForTextWidgetAnnotation(data, objs);
case AnnotationType.TEXT:
return getHtmlElementForTextAnnotation(data, objs);
return getHtmlElementForTextAnnotation(data);
case AnnotationType.LINK:
return getHtmlElementForLinkAnnotation(data, objs);
return getHtmlElementForLinkAnnotation(data);
default:
throw new Error('Unsupported annotationType: ' + data.annotationType);
}

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,7 @@ var FontInspector = (function FontInspectorClosure() {
var selects = document.getElementsByTagName('input');
for (var i = 0; i < selects.length; ++i) {
var select = selects[i];
if (select.dataset.fontName != fontName) {
if (select.dataset.fontName !== fontName) {
continue;
}
select.checked = !select.checked;
@ -216,7 +216,7 @@ var StepperManager = (function StepperManagerClosure() {
}
for (i = 0; i < steppers.length; ++i) {
var stepper = steppers[i];
if (stepper.pageIndex == pageIndex) {
if (stepper.pageIndex === pageIndex) {
stepper.panel.removeAttribute('hidden');
} else {
stepper.panel.setAttribute('hidden', true);
@ -225,7 +225,7 @@ var StepperManager = (function StepperManagerClosure() {
var options = stepperChooser.options;
for (i = 0; i < options.length; ++i) {
var option = options[i];
option.selected = option.value == pageIndex;
option.selected = (option.value | 0) === pageIndex;
}
},
saveBreakPoints: function saveBreakPoints(pageIndex, bps) {
@ -332,7 +332,7 @@ var Stepper = (function StepperClosure() {
line.className = 'line';
line.dataset.idx = i;
chunk.appendChild(line);
var checked = this.breakPoints.indexOf(i) != -1;
var checked = this.breakPoints.indexOf(i) !== -1;
var args = operatorList.argsArray[i] || [];
var breakCell = c('td');
@ -419,7 +419,7 @@ var Stepper = (function StepperClosure() {
var allRows = this.panel.getElementsByClassName('line');
for (var x = 0, xx = allRows.length; x < xx; ++x) {
var row = allRows[x];
if (row.dataset.idx == idx) {
if (parseInt(row.dataset.idx, 10) === idx) {
row.style.backgroundColor = 'rgb(251,250,207)';
row.scrollIntoView();
} else {
@ -597,7 +597,7 @@ var PDFBug = (function PDFBugClosure() {
activePanel = index;
var tools = this.tools;
for (var j = 0; j < tools.length; ++j) {
if (j == index) {
if (j === index) {
buttons[j].setAttribute('class', 'active');
tools[j].active = true;
tools[j].panel.removeAttribute('hidden');

View File

@ -76,7 +76,7 @@ var CustomStyle = (function CustomStyleClosure() {
CustomStyle.getProp = function get(propName, element) {
// check cache only when no element is given
if (arguments.length == 1 && typeof _cache[propName] == 'string') {
if (arguments.length === 1 && typeof _cache[propName] === 'string') {
return _cache[propName];
}
@ -84,7 +84,7 @@ var CustomStyle = (function CustomStyleClosure() {
var style = element.style, prefixed, uPropName;
// test standard property first
if (typeof style[propName] == 'string') {
if (typeof style[propName] === 'string') {
return (_cache[propName] = propName);
}
@ -94,7 +94,7 @@ var CustomStyle = (function CustomStyleClosure() {
// test vendor specific properties
for (var i = 0, l = prefixes.length; i < l; i++) {
prefixed = prefixes[i] + uPropName;
if (typeof style[prefixed] == 'string') {
if (typeof style[prefixed] === 'string') {
return (_cache[propName] = prefixed);
}
}
@ -105,7 +105,7 @@ var CustomStyle = (function CustomStyleClosure() {
CustomStyle.setProp = function set(propName, element, str) {
var prop = this.getProp(propName);
if (prop != 'undefined') {
if (prop !== 'undefined') {
element.style[prop] = str;
}
};
@ -139,7 +139,7 @@ function getOutputScale(ctx) {
return {
sx: pixelRatio,
sy: pixelRatio,
scaled: pixelRatio != 1
scaled: pixelRatio !== 1
};
}
@ -207,7 +207,7 @@ function getPDFFileNameFromURL(url) {
reFilename.exec(splitURI[3]);
if (suggestedFilename) {
suggestedFilename = suggestedFilename[0];
if (suggestedFilename.indexOf('%') != -1) {
if (suggestedFilename.indexOf('%') !== -1) {
// URL-encoded %2Fpath%2Fto%2Ffile.pdf should be file.pdf
try {
suggestedFilename =
@ -472,6 +472,7 @@ var Preferences = {
var FirefoxCom = (function FirefoxComClosure() {
return {
/**
@ -1617,7 +1618,9 @@ var SecondaryToolbar = {
},
lastPageClick: function secondaryToolbarLastPageClick(evt) {
PDFView.page = PDFView.pdfDocument.numPages;
if (PDFView.pdfDocument) {
PDFView.page = PDFView.pdfDocument.numPages;
}
this.close();
},
@ -2512,10 +2515,10 @@ var DocumentProperties = {
// As per spec, utRel = 'Z' means equal to universal time.
// The other cases ('-' and '+') have to be handled here.
if (utRel == '-') {
if (utRel === '-') {
hours += offsetHours;
minutes += offsetMinutes;
} else if (utRel == '+') {
} else if (utRel === '+') {
hours -= offsetHours;
minutes += offsetMinutes;
}
@ -2554,6 +2557,7 @@ var PDFView = {
isViewerEmbedded: (window.parent !== window),
idleTimeout: null,
currentPosition: null,
url: '',
// called once when the document is loaded
initialize: function pdfViewInitialize() {
@ -3204,7 +3208,7 @@ var PDFView = {
var pdfOpenParams = PDFView.getAnchorUrl('#page=' + pageNumber);
var destKind = dest[1];
if (typeof destKind === 'object' && 'name' in destKind &&
destKind.name == 'XYZ') {
destKind.name === 'XYZ') {
var scale = (dest[4] || this.currentScaleValue);
var scaleNumber = parseFloat(scale);
if (scaleNumber) {
@ -4019,9 +4023,9 @@ var PDFView = {
// In case we are already on the first or the last page there is no need
// to do anything.
if ((currentPage == 1 && pageFlipDirection == PageFlipDirection.UP) ||
(currentPage == this.pages.length &&
pageFlipDirection == PageFlipDirection.DOWN)) {
if ((currentPage === 1 && pageFlipDirection === PageFlipDirection.UP) ||
(currentPage === this.pages.length &&
pageFlipDirection === PageFlipDirection.DOWN)) {
return;
}
@ -5477,7 +5481,7 @@ function webViewerInitialized() {
document.getElementById('viewFind').classList.add('hidden');
}
// Listen for unsuporrted features to trigger the fallback UI.
// Listen for unsupported features to trigger the fallback UI.
PDFJS.UnsupportedManager.listen(PDFView.fallback.bind(PDFView));
// Suppress context menus for some controls
@ -5486,7 +5490,7 @@ function webViewerInitialized() {
var mainContainer = document.getElementById('mainContainer');
var outerContainer = document.getElementById('outerContainer');
mainContainer.addEventListener('transitionend', function(e) {
if (e.target == mainContainer) {
if (e.target === mainContainer) {
var event = document.createEvent('UIEvents');
event.initUIEvent('resize', false, false, window, 0);
window.dispatchEvent(event);
@ -5690,7 +5694,7 @@ function selectScaleOption(value) {
var predefinedValueFound = false;
for (var i = 0; i < options.length; i++) {
var option = options[i];
if (option.value != value) {
if (option.value !== value) {
option.selected = false;
continue;
}
@ -5948,8 +5952,8 @@ window.addEventListener('keydown', function keydown(evt) {
}
break;
case 35: // end
if (PresentationMode.active ||
PDFView.page < PDFView.pdfDocument.numPages) {
if (PresentationMode.active || (PDFView.pdfDocument &&
PDFView.page < PDFView.pdfDocument.numPages)) {
PDFView.page = PDFView.pdfDocument.numPages;
handled = true;
}