Bug 1245832 - Update pdf.js to version 1.4.42. r=bdahl

This commit is contained in:
Ryan VanderMeulen
2016-02-04 09:29:47 -05:00
parent 8bfcc305df
commit f39edea11c
6 changed files with 10004 additions and 9714 deletions

View File

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

View File

@@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdf = {}));
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
'use strict'; 'use strict';
var pdfjsVersion = '1.3.231'; var pdfjsVersion = '1.4.42';
var pdfjsBuild = '58329f7'; var pdfjsBuild = '4c59712';
var pdfjsFilePath = var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ? typeof document !== 'undefined' && document.currentScript ?
@@ -94,7 +94,7 @@ var CustomStyle = (function CustomStyleClosure() {
// in some versions of IE9 it is critical that ms appear in this list // in some versions of IE9 it is critical that ms appear in this list
// before Moz // before Moz
var prefixes = ['ms', 'Moz', 'Webkit', 'O']; var prefixes = ['ms', 'Moz', 'Webkit', 'O'];
var _cache = {}; var _cache = Object.create(null);
function CustomStyle() {} function CustomStyle() {}
@@ -369,9 +369,9 @@ function warn(msg) {
} }
} }
// Deprecated API function -- treated as warnings. // Deprecated API function -- display regardless of the PDFJS.verbosity setting.
function deprecated(details) { function deprecated(details) {
warn('Deprecated API usage: ' + details); console.log('Deprecated API usage: ' + details);
} }
// Fatal errors that should trigger the fallback UI and halt execution by // Fatal errors that should trigger the fallback UI and halt execution by
@@ -416,6 +416,21 @@ function combineUrl(baseUrl, url) {
return new URL(url, baseUrl).href; return new URL(url, baseUrl).href;
} }
// Checks if URLs have the same origin. For non-HTTP based URLs, returns false.
function isSameOrigin(baseUrl, otherUrl) {
try {
var base = new URL(baseUrl);
if (!base.origin || base.origin === 'null') {
return false; // non-HTTP url
}
} catch (e) {
return false;
}
var other = new URL(otherUrl, base);
return base.origin === other.origin;
}
// Validates if URL is safe and allowed, e.g. to avoid XSS. // Validates if URL is safe and allowed, e.g. to avoid XSS.
function isValidUrl(url, allowRelative) { function isValidUrl(url, allowRelative) {
if (!url) { if (!url) {
@@ -470,6 +485,18 @@ function shadow(obj, prop, value) {
} }
PDFJS.shadow = shadow; PDFJS.shadow = shadow;
function getLookupTableFactory(initializer) {
var lookup;
return function () {
if (initializer) {
lookup = Object.create(null);
initializer(lookup);
initializer = null;
}
return lookup;
};
}
var LinkTarget = PDFJS.LinkTarget = { var LinkTarget = PDFJS.LinkTarget = {
NONE: 0, // Default value. NONE: 0, // Default value.
SELF: 1, SELF: 1,
@@ -1244,7 +1271,7 @@ var StatTimer = (function StatTimerClosure() {
return str; return str;
} }
function StatTimer() { function StatTimer() {
this.started = {}; this.started = Object.create(null);
this.times = []; this.times = [];
this.enabled = true; this.enabled = true;
} }
@@ -1338,8 +1365,8 @@ function MessageHandler(sourceName, targetName, comObj) {
this.comObj = comObj; this.comObj = comObj;
this.callbackIndex = 1; this.callbackIndex = 1;
this.postMessageTransfers = true; this.postMessageTransfers = true;
var callbacksCapabilities = this.callbacksCapabilities = {}; var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
var ah = this.actionHandler = {}; var ah = this.actionHandler = Object.create(null);
this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) { this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
var data = event.data; var data = event.data;
@@ -1510,6 +1537,7 @@ exports.combineUrl = combineUrl;
exports.createPromiseCapability = createPromiseCapability; exports.createPromiseCapability = createPromiseCapability;
exports.deprecated = deprecated; exports.deprecated = deprecated;
exports.error = error; exports.error = error;
exports.getLookupTableFactory = getLookupTableFactory;
exports.info = info; exports.info = info;
exports.isArray = isArray; exports.isArray = isArray;
exports.isArrayBuffer = isArrayBuffer; exports.isArrayBuffer = isArrayBuffer;
@@ -1519,6 +1547,7 @@ exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
exports.isInt = isInt; exports.isInt = isInt;
exports.isNum = isNum; exports.isNum = isNum;
exports.isString = isString; exports.isString = isString;
exports.isSameOrigin = isSameOrigin;
exports.isValidUrl = isValidUrl; exports.isValidUrl = isValidUrl;
exports.addLinkAttributes = addLinkAttributes; exports.addLinkAttributes = addLinkAttributes;
exports.loadJpegStream = loadJpegStream; exports.loadJpegStream = loadJpegStream;
@@ -2360,7 +2389,7 @@ FontLoader.prototype = {
var FontFaceObject = (function FontFaceObjectClosure() { var FontFaceObject = (function FontFaceObjectClosure() {
function FontFaceObject(translatedData) { function FontFaceObject(translatedData) {
this.compiledGlyphs = {}; this.compiledGlyphs = Object.create(null);
// importing translated data // importing translated data
for (var i in translatedData) { for (var i in translatedData) {
this[i] = translatedData[i]; this[i] = translatedData[i];
@@ -2496,7 +2525,7 @@ var Metadata = PDFJS.Metadata = (function MetadataClosure() {
} }
this.metaDocument = meta; this.metaDocument = meta;
this.metadata = {}; this.metadata = Object.create(null);
this.parse(); this.parse();
} }
@@ -5869,6 +5898,7 @@ var error = sharedUtil.error;
var deprecated = sharedUtil.deprecated; var deprecated = sharedUtil.deprecated;
var info = sharedUtil.info; var info = sharedUtil.info;
var isArrayBuffer = sharedUtil.isArrayBuffer; var isArrayBuffer = sharedUtil.isArrayBuffer;
var isSameOrigin = sharedUtil.isSameOrigin;
var loadJpegStream = sharedUtil.loadJpegStream; var loadJpegStream = sharedUtil.loadJpegStream;
var stringToBytes = sharedUtil.stringToBytes; var stringToBytes = sharedUtil.stringToBytes;
var warn = sharedUtil.warn; var warn = sharedUtil.warn;
@@ -6506,11 +6536,9 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
return this.transport.getDestination(id); return this.transport.getDestination(id);
}, },
/** /**
* @return {Promise} A promise that is resolved with: an Array containing * @return {Promise} A promise that is resolved with:
* the pageLabels that correspond to the pageIndexes; or null, when no * an Array containing the pageLabels that correspond to the pageIndexes,
* pageLabels are present in the PDF file. * or `null` when no pageLabels are present in the PDF file.
* NOTE: If the pageLabels are all identical to standard page numbering,
* i.e. [1, 2, 3, ...], the promise is resolved with an empty Array.
*/ */
getPageLabels: function PDFDocumentProxy_getPageLabels() { getPageLabels: function PDFDocumentProxy_getPageLabels() {
return this.transport.getPageLabels(); return this.transport.getPageLabels();
@@ -6688,7 +6716,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
this.objs = new PDFObjects(); this.objs = new PDFObjects();
this.cleanupAfterRender = false; this.cleanupAfterRender = false;
this.pendingCleanup = false; this.pendingCleanup = false;
this.intentStates = {}; this.intentStates = Object.create(null);
this.destroyed = false; this.destroyed = false;
} }
PDFPageProxy.prototype = /** @lends PDFPageProxy.prototype */ { PDFPageProxy.prototype = /** @lends PDFPageProxy.prototype */ {
@@ -6763,7 +6791,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
var renderingIntent = (params.intent === 'print' ? 'print' : 'display'); var renderingIntent = (params.intent === 'print' ? 'print' : 'display');
if (!this.intentStates[renderingIntent]) { if (!this.intentStates[renderingIntent]) {
this.intentStates[renderingIntent] = {}; this.intentStates[renderingIntent] = Object.create(null);
} }
var intentState = this.intentStates[renderingIntent]; var intentState = this.intentStates[renderingIntent];
@@ -6850,17 +6878,23 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
function operatorListChanged() { function operatorListChanged() {
if (intentState.operatorList.lastChunk) { if (intentState.operatorList.lastChunk) {
intentState.opListReadCapability.resolve(intentState.operatorList); intentState.opListReadCapability.resolve(intentState.operatorList);
var i = intentState.renderTasks.indexOf(opListTask);
if (i >= 0) {
intentState.renderTasks.splice(i, 1);
}
} }
} }
var renderingIntent = 'oplist'; var renderingIntent = 'oplist';
if (!this.intentStates[renderingIntent]) { if (!this.intentStates[renderingIntent]) {
this.intentStates[renderingIntent] = {}; this.intentStates[renderingIntent] = Object.create(null);
} }
var intentState = this.intentStates[renderingIntent]; var intentState = this.intentStates[renderingIntent];
var opListTask;
if (!intentState.opListReadCapability) { if (!intentState.opListReadCapability) {
var opListTask = {}; opListTask = {};
opListTask.operatorListChanged = operatorListChanged; opListTask.operatorListChanged = operatorListChanged;
intentState.receivingOperatorList = true; intentState.receivingOperatorList = true;
intentState.opListReadCapability = createPromiseCapability(); intentState.opListReadCapability = createPromiseCapability();
@@ -6903,6 +6937,10 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
var waitOn = []; var waitOn = [];
Object.keys(this.intentStates).forEach(function(intent) { Object.keys(this.intentStates).forEach(function(intent) {
if (intent === 'oplist') {
// Avoid errors below, since the renderTasks are just stubs.
return;
}
var intentState = this.intentStates[intent]; var intentState = this.intentStates[intent];
intentState.renderTasks.forEach(function(renderTask) { intentState.renderTasks.forEach(function(renderTask) {
var renderCompleted = renderTask.capability.promise. var renderCompleted = renderTask.capability.promise.
@@ -7030,6 +7068,14 @@ var PDFWorker = (function PDFWorkerClosure() {
return PDFJS.fakeWorkerFilesLoadedCapability.promise; return PDFJS.fakeWorkerFilesLoadedCapability.promise;
} }
function createCDNWrapper(url) {
// We will rely on blob URL's property to specify origin.
// We want this function to fail in case if createObjectURL or Blob do not
// exist or fail for some reason -- our Worker creation will fail anyway.
var wrapper = 'importScripts(\'' + url + '\');';
return URL.createObjectURL(new Blob([wrapper]));
}
function PDFWorker(name) { function PDFWorker(name) {
this.name = name; this.name = name;
this.destroyed = false; this.destroyed = false;
@@ -7653,7 +7699,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
*/ */
var PDFObjects = (function PDFObjectsClosure() { var PDFObjects = (function PDFObjectsClosure() {
function PDFObjects() { function PDFObjects() {
this.objs = {}; this.objs = Object.create(null);
} }
PDFObjects.prototype = { PDFObjects.prototype = {
@@ -7744,7 +7790,7 @@ var PDFObjects = (function PDFObjectsClosure() {
}, },
clear: function PDFObjects_clear() { clear: function PDFObjects_clear() {
this.objs = {}; this.objs = Object.create(null);
} }
}; };
return PDFObjects; return PDFObjects;

File diff suppressed because it is too large Load Diff

View File

@@ -50,8 +50,8 @@ var NetworkManager = (function NetworkManagerClosure() {
}; };
this.currXhrId = 0; this.currXhrId = 0;
this.pendingRequests = {}; this.pendingRequests = Object.create(null);
this.loadedRequests = {}; this.loadedRequests = Object.create(null);
} }
function getArrayBuffer(xhr) { function getArrayBuffer(xhr) {

View File

@@ -165,7 +165,7 @@ var StepperManager = (function StepperManagerClosure() {
var stepperDiv = null; var stepperDiv = null;
var stepperControls = null; var stepperControls = null;
var stepperChooser = null; var stepperChooser = null;
var breakPoints = {}; var breakPoints = Object.create(null);
return { return {
// Properties/functions needed by PDFBug. // Properties/functions needed by PDFBug.
id: 'Stepper', id: 'Stepper',

View File

@@ -1003,7 +1003,7 @@ var PDFFindController = (function PDFFindControllerClosure() {
function PDFFindController(options) { function PDFFindController(options) {
this.startedTextExtraction = false; this.startedTextExtraction = false;
this.extractTextPromises = []; this.extractTextPromises = [];
this.pendingFindMatches = {}; this.pendingFindMatches = Object.create(null);
this.active = false; // If active, find results will be highlighted. this.active = false; // If active, find results will be highlighted.
this.pageContents = []; // Stores the text for each page. this.pageContents = []; // Stores the text for each page.
this.pageMatches = []; this.pageMatches = [];
@@ -7099,6 +7099,7 @@ var PDFViewerApplication = {
}; };
function webViewerLoad(evt) { function webViewerLoad(evt) {
configure(PDFJS); configure(PDFJS);
PDFViewerApplication.initialize().then(webViewerInitialized); PDFViewerApplication.initialize().then(webViewerInitialized);