Bug 1282095 - Update pdf.js to version 1.5.305. r=bdahl

This commit is contained in:
Ryan VanderMeulen 2016-06-24 11:55:02 -04:00
Родитель 75c86d739f
Коммит c9ebf6bbda
6 изменённых файлов: 1111 добавлений и 1030 удалений

Просмотреть файл

@ -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.5.281 Current extension version is: 1.5.305

Просмотреть файл

@ -65,22 +65,15 @@ function getFindBar(domWindow) {
if (PdfjsContentUtils.isRemote) { if (PdfjsContentUtils.isRemote) {
throw new Error('FindBar is not accessible from the content process.'); throw new Error('FindBar is not accessible from the content process.');
} }
var browser = getContainingBrowser(domWindow);
try { try {
var browser = getContainingBrowser(domWindow);
var tabbrowser = browser.getTabBrowser(); var tabbrowser = browser.getTabBrowser();
var tab; var tab = tabbrowser.getTabForBrowser(browser);
tab = tabbrowser.getTabForBrowser(browser);
return tabbrowser.getFindBar(tab); return tabbrowser.getFindBar(tab);
} catch (e) { } catch (e) {
try { // Suppress errors for PDF files opened in the bookmark sidebar, see
// FF22 has no _getTabForBrowser, and FF24 has no getFindBar // https://bugzilla.mozilla.org/show_bug.cgi?id=1248959.
var chromeWindow = browser.ownerDocument.defaultView; return null;
return chromeWindow.gFindBar;
} catch (ex) {
// Suppress errors for PDF files opened in the bookmark sidebar, see
// https://bugzilla.mozilla.org/show_bug.cgi?id=1248959.
return null;
}
} }
} }
@ -155,18 +148,17 @@ function getLocalizedString(strings, id, property) {
return id; return id;
} }
function makeContentReadable(obj, window) { function createNewChannel(uri, node) {
/* jshint -W027 */
return Cu.cloneInto(obj, window);
}
function createNewChannel(uri) {
return NetUtil.newChannel({ return NetUtil.newChannel({
uri: uri, uri: uri,
loadUsingSystemPrincipal: true loadUsingSystemPrincipal: true,
}); });
} }
function asyncOpenChannel(channel, listener, context) {
return channel.asyncOpen2(listener);
}
function asyncFetchChannel(channel, callback) { function asyncFetchChannel(channel, callback) {
return NetUtil.asyncFetch(channel, callback); return NetUtil.asyncFetch(channel, callback);
} }
@ -264,7 +256,7 @@ ChromeActions.prototype = {
getService(Ci.nsIExternalHelperAppService); getService(Ci.nsIExternalHelperAppService);
var docIsPrivate = this.isInPrivateBrowsing(); var docIsPrivate = this.isInPrivateBrowsing();
var netChannel = createNewChannel(blobUri); var netChannel = createNewChannel(blobUri, this.domWindow.document);
if ('nsIPrivateBrowsingChannel' in Ci && if ('nsIPrivateBrowsingChannel' in Ci &&
netChannel instanceof Ci.nsIPrivateBrowsingChannel) { netChannel instanceof Ci.nsIPrivateBrowsingChannel) {
netChannel.setPrivate(docIsPrivate); netChannel.setPrivate(docIsPrivate);
@ -327,7 +319,7 @@ ChromeActions.prototype = {
} }
}; };
channel.asyncOpen2(listener); asyncOpenChannel(channel, listener, null);
}); });
}, },
getLocale: function() { getLocale: function() {
@ -367,11 +359,7 @@ ChromeActions.prototype = {
return (!!prefBrowser && prefGfx); return (!!prefBrowser && prefGfx);
}, },
supportsDocumentColors: function() { supportsDocumentColors: function() {
if (getIntPref('browser.display.document_color_use', 0) === 2 || return getIntPref('browser.display.document_color_use', 0) !== 2;
!getBoolPref('browser.display.use_document_colors', true)) {
return false;
}
return true;
}, },
supportedMouseWheelZoomModifierKeys: function() { supportedMouseWheelZoomModifierKeys: function() {
return { return {
@ -783,7 +771,7 @@ RequestListener.prototype.receive = function(event) {
var response; var response;
if (sync) { if (sync) {
response = actions[action].call(this.actions, data); response = actions[action].call(this.actions, data);
event.detail.response = makeContentReadable(response, doc.defaultView); event.detail.response = Cu.cloneInto(response, doc.defaultView);
} else { } else {
if (!event.detail.responseExpected) { if (!event.detail.responseExpected) {
doc.documentElement.removeChild(message); doc.documentElement.removeChild(message);
@ -792,8 +780,7 @@ RequestListener.prototype.receive = function(event) {
response = function sendResponse(response) { response = function sendResponse(response) {
try { try {
var listener = doc.createEvent('CustomEvent'); var listener = doc.createEvent('CustomEvent');
let detail = makeContentReadable({response: response}, let detail = Cu.cloneInto({ response: response }, doc.defaultView);
doc.defaultView);
listener.initCustomEvent('pdf.js.response', true, false, detail); listener.initCustomEvent('pdf.js.response', true, false, detail);
return message.dispatchEvent(listener); return message.dispatchEvent(listener);
} catch (e) { } catch (e) {
@ -837,7 +824,7 @@ FindEventManager.prototype.receiveMessage = function(msg) {
var type = msg.data.type; var type = msg.data.type;
var contentWindow = this.contentWindow; var contentWindow = this.contentWindow;
detail = makeContentReadable(detail, contentWindow); detail = Cu.cloneInto(detail, contentWindow);
var forward = contentWindow.document.createEvent('CustomEvent'); var forward = contentWindow.document.createEvent('CustomEvent');
forward.initCustomEvent(type, true, true, detail); forward.initCustomEvent(type, true, true, detail);
contentWindow.dispatchEvent(forward); contentWindow.dispatchEvent(forward);
@ -972,7 +959,7 @@ PdfStreamConverter.prototype = {
.createInstance(Ci.nsIBinaryInputStream); .createInstance(Ci.nsIBinaryInputStream);
// Create a new channel that is viewer loaded as a resource. // Create a new channel that is viewer loaded as a resource.
var channel = createNewChannel(PDF_VIEWER_WEB_PAGE); var channel = createNewChannel(PDF_VIEWER_WEB_PAGE, null);
var listener = this.listener; var listener = this.listener;
var dataListener = this.dataListener; var dataListener = this.dataListener;
@ -1024,18 +1011,17 @@ PdfStreamConverter.prototype = {
channel.loadGroup = aRequest.loadGroup; channel.loadGroup = aRequest.loadGroup;
channel.loadInfo.originAttributes = aRequest.loadInfo.originAttributes; channel.loadInfo.originAttributes = aRequest.loadInfo.originAttributes;
// We can use resource principal when data is fetched by the chrome // We can use the resource principal when data is fetched by the chrome,
// make sure we reuse the origin attributes from the request channel to keep // e.g. useful for NoScript. Make make sure we reuse the origin attributes
// isolation consistent. // from the request channel to keep isolation consistent.
// e.g. useful for NoScript
var ssm = Cc['@mozilla.org/scriptsecuritymanager;1'] var ssm = Cc['@mozilla.org/scriptsecuritymanager;1']
.getService(Ci.nsIScriptSecurityManager); .getService(Ci.nsIScriptSecurityManager);
var uri = NetUtil.newURI(PDF_VIEWER_WEB_PAGE, null, null); var uri = NetUtil.newURI(PDF_VIEWER_WEB_PAGE, null, null);
var attrs = aRequest.loadInfo.originAttributes;
var resourcePrincipal; var resourcePrincipal;
resourcePrincipal = ssm.createCodebasePrincipal(uri, attrs); resourcePrincipal =
ssm.createCodebasePrincipal(uri, aRequest.loadInfo.originAttributes);
aRequest.owner = resourcePrincipal; aRequest.owner = resourcePrincipal;
channel.asyncOpen2(proxy); asyncOpenChannel(channel, proxy, aContext);
}, },
// nsIRequestObserver::onStopRequest // nsIRequestObserver::onStopRequest

Просмотреть файл

@ -181,8 +181,7 @@ var PdfjsChromeUtils = {
_findbarFromMessage: function(aMsg) { _findbarFromMessage: function(aMsg) {
let browser = aMsg.target; let browser = aMsg.target;
let tabbrowser = browser.getTabBrowser(); let tabbrowser = browser.getTabBrowser();
let tab; let tab = tabbrowser.getTabForBrowser(browser);
tab = tabbrowser.getTabForBrowser(browser);
return tabbrowser.getFindBar(tab); return tabbrowser.getFindBar(tab);
}, },

Просмотреть файл

@ -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.5.281'; var pdfjsVersion = '1.5.305';
var pdfjsBuild = '5a5bb99'; var pdfjsBuild = '546e223';
var pdfjsFilePath = var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ? typeof document !== 'undefined' && document.currentScript ?
@ -1070,6 +1070,11 @@ function isArrayBuffer(v) {
return typeof v === 'object' && v !== null && v.byteLength !== undefined; return typeof v === 'object' && v !== null && v.byteLength !== undefined;
} }
// Checks if ch is one of the following characters: SPACE, TAB, CR or LF.
function isSpace(ch) {
return (ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A);
}
/** /**
* Promise Capability object. * Promise Capability object.
* *
@ -1441,6 +1446,7 @@ exports.isEmptyObj = isEmptyObj;
exports.isInt = isInt; exports.isInt = isInt;
exports.isNum = isNum; exports.isNum = isNum;
exports.isString = isString; exports.isString = isString;
exports.isSpace = isSpace;
exports.isSameOrigin = isSameOrigin; exports.isSameOrigin = isSameOrigin;
exports.isValidUrl = isValidUrl; exports.isValidUrl = isValidUrl;
exports.isLittleEndian = isLittleEndian; exports.isLittleEndian = isLittleEndian;
@ -7815,7 +7821,12 @@ var WorkerTransport = (function WorkerTransportClosure() {
}, },
getPageIndex: function WorkerTransport_getPageIndexByRef(ref) { getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }); return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).
then(function (pageIndex) {
return pageIndex;
}, function (reason) {
return Promise.reject(new Error(reason));
});
}, },
getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) { getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -18,6 +18,7 @@
var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf'; var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
var pdfjsWebLibs = { var pdfjsWebLibs = {
pdfjsWebPDFJS: window.pdfjsDistBuildPdf pdfjsWebPDFJS: window.pdfjsDistBuildPdf
}; };
@ -4590,6 +4591,11 @@ exports.PDFFindBar = PDFFindBar;
var parseQueryString = uiUtils.parseQueryString; var parseQueryString = uiUtils.parseQueryString;
var PageNumberRegExp = /^\d+$/;
function isPageNumber(str) {
return PageNumberRegExp.test(str);
}
/** /**
* @typedef {Object} PDFLinkServiceOptions * @typedef {Object} PDFLinkServiceOptions
* @property {EventBus} eventBus - The application event bus. * @property {EventBus} eventBus - The application event bus.
@ -4601,7 +4607,7 @@ var parseQueryString = uiUtils.parseQueryString;
* @class * @class
* @implements {IPDFLinkService} * @implements {IPDFLinkService}
*/ */
var PDFLinkService = (function () { var PDFLinkService = (function PDFLinkServiceClosure() {
/** /**
* @constructs PDFLinkService * @constructs PDFLinkService
* @param {PDFLinkServiceOptions} options * @param {PDFLinkServiceOptions} options
@ -4661,7 +4667,7 @@ var PDFLinkService = (function () {
var self = this; var self = this;
var goToDestination = function(destRef) { var goToDestination = function(destRef) {
// dest array looks like that: <page-ref> </XYZ|FitXXX> <args..> // dest array looks like that: <page-ref> </XYZ|/FitXXX> <args..>
var pageNumber = destRef instanceof Object ? var pageNumber = destRef instanceof Object ?
self._pagesRefCache[destRef.num + ' ' + destRef.gen + ' R'] : self._pagesRefCache[destRef.num + ' ' + destRef.gen + ' R'] :
(destRef + 1); (destRef + 1);
@ -4711,30 +4717,15 @@ var PDFLinkService = (function () {
*/ */
getDestinationHash: function PDFLinkService_getDestinationHash(dest) { getDestinationHash: function PDFLinkService_getDestinationHash(dest) {
if (typeof dest === 'string') { if (typeof dest === 'string') {
return this.getAnchorUrl('#' + escape(dest)); // In practice, a named destination may contain only a number.
// If that happens, use the '#nameddest=' form to avoid the link
// redirecting to a page, instead of the correct destination.
return this.getAnchorUrl(
'#' + (isPageNumber(dest) ? 'nameddest=' : '') + escape(dest));
} }
if (dest instanceof Array) { if (dest instanceof Array) {
var destRef = dest[0]; // see navigateTo method for dest format var str = JSON.stringify(dest);
var pageNumber = destRef instanceof Object ? return this.getAnchorUrl('#' + escape(str));
this._pagesRefCache[destRef.num + ' ' + destRef.gen + ' R'] :
(destRef + 1);
if (pageNumber) {
var pdfOpenParams = this.getAnchorUrl('#page=' + pageNumber);
var destKind = dest[1];
if (typeof destKind === 'object' && 'name' in destKind &&
destKind.name === 'XYZ') {
var scale = (dest[4] || this.pdfViewer.currentScaleValue);
var scaleNumber = parseFloat(scale);
if (scaleNumber) {
scale = scaleNumber * 100;
}
pdfOpenParams += '&zoom=' + scale;
if (dest[2] || dest[3]) {
pdfOpenParams += ',' + (dest[2] || 0) + ',' + (dest[3] || 0);
}
}
return pdfOpenParams;
}
} }
return this.getAnchorUrl(''); return this.getAnchorUrl('');
}, },
@ -4753,6 +4744,7 @@ var PDFLinkService = (function () {
* @param {string} hash * @param {string} hash
*/ */
setHash: function PDFLinkService_setHash(hash) { setHash: function PDFLinkService_setHash(hash) {
var pageNumber, dest;
if (hash.indexOf('=') >= 0) { if (hash.indexOf('=') >= 0) {
var params = parseQueryString(hash); var params = parseQueryString(hash);
if ('search' in params) { if ('search' in params) {
@ -4770,7 +4762,6 @@ var PDFLinkService = (function () {
this.navigateTo(params.nameddest); this.navigateTo(params.nameddest);
return; return;
} }
var pageNumber, dest;
if ('page' in params) { if ('page' in params) {
pageNumber = (params.page | 0) || 1; pageNumber = (params.page | 0) || 1;
} }
@ -4820,13 +4811,23 @@ var PDFLinkService = (function () {
mode: params.pagemode mode: params.pagemode
}); });
} }
} else if (/^\d+$/.test(hash)) { // page number } else if (isPageNumber(hash)) { // Page number.
this.page = hash; this.page = hash | 0;
} else { // named destination } else { // Named (or explicit) destination.
if (this.pdfHistory) { dest = unescape(hash);
this.pdfHistory.updateNextHashParam(unescape(hash)); try {
dest = JSON.parse(dest);
} catch (ex) {}
if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
if (this.pdfHistory) {
this.pdfHistory.updateNextHashParam(dest);
}
this.navigateTo(dest);
return;
} }
this.navigateTo(unescape(hash)); console.error('PDFLinkService_setHash: \'' + unescape(hash) +
'\' is not a valid destination.');
} }
}, },
@ -4884,6 +4885,60 @@ var PDFLinkService = (function () {
} }
}; };
function isValidExplicitDestination(dest) {
if (!(dest instanceof Array)) {
return false;
}
var destLength = dest.length, allowNull = true;
if (destLength < 2) {
return false;
}
var page = dest[0];
if (!(typeof page === 'object' &&
typeof page.num === 'number' && (page.num | 0) === page.num &&
typeof page.gen === 'number' && (page.gen | 0) === page.gen) &&
!(typeof page === 'number' && (page | 0) === page && page >= 0)) {
return false;
}
var zoom = dest[1];
if (!(typeof zoom === 'object' && typeof zoom.name === 'string')) {
return false;
}
switch (zoom.name) {
case 'XYZ':
if (destLength !== 5) {
return false;
}
break;
case 'Fit':
case 'FitB':
return destLength === 2;
case 'FitH':
case 'FitBH':
case 'FitV':
case 'FitBV':
if (destLength !== 3) {
return false;
}
break;
case 'FitR':
if (destLength !== 6) {
return false;
}
allowNull = false;
break;
default:
return false;
}
for (var i = 2; i < destLength; i++) {
var param = dest[i];
if (!(typeof param === 'number' || (allowNull && param === null))) {
return false;
}
}
return true;
}
return PDFLinkService; return PDFLinkService;
})(); })();
@ -6723,6 +6778,8 @@ var PDFViewer = (function pdfViewer() {
scale = Math.min(Math.abs(widthScale), Math.abs(heightScale)); scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
break; break;
default: default:
console.error('PDFViewer_scrollPageIntoView: \'' + dest[1].name +
'\' is not a valid destination type.');
return; return;
} }
@ -7692,6 +7749,7 @@ var PDFViewerApplication = {
pdfViewer.setDocument(pdfDocument); pdfViewer.setDocument(pdfDocument);
var firstPagePromise = pdfViewer.firstPagePromise; var firstPagePromise = pdfViewer.firstPagePromise;
var pagesPromise = pdfViewer.pagesPromise; var pagesPromise = pdfViewer.pagesPromise;
var onePageRendered = pdfViewer.onePageRendered;
this.pageRotation = 0; this.pageRotation = 0;
@ -7797,9 +7855,8 @@ var PDFViewerApplication = {
} }
}); });
// outline depends on pagesRefMap Promise.all([onePageRendered, this.animationStartedPromise]).then(
var promises = [pagesPromise, this.animationStartedPromise]; function() {
Promise.all(promises).then(function() {
pdfDocument.getOutline().then(function(outline) { pdfDocument.getOutline().then(function(outline) {
self.pdfOutlineViewer.render({ outline: outline }); self.pdfOutlineViewer.render({ outline: outline });
}); });
@ -9226,7 +9283,6 @@ exports.FirefoxCom = FirefoxCom;
// FIXME the l10n.js file in the Firefox extension needs global FirefoxCom. // FIXME the l10n.js file in the Firefox extension needs global FirefoxCom.
window.FirefoxCom = pdfjsWebLibs.pdfjsWebFirefoxCom.FirefoxCom; window.FirefoxCom = pdfjsWebLibs.pdfjsWebFirefoxCom.FirefoxCom;
function getViewerConfiguration() { function getViewerConfiguration() {
return { return {
appContainer: document.body, appContainer: document.body,