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
Current extension version is: 1.5.281
Current extension version is: 1.5.305

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

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

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

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

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

@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdf = {}));
// Use strict in our context only - users might not want it
'use strict';
var pdfjsVersion = '1.5.281';
var pdfjsBuild = '5a5bb99';
var pdfjsVersion = '1.5.305';
var pdfjsBuild = '546e223';
var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ?
@ -1070,6 +1070,11 @@ function isArrayBuffer(v) {
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.
*
@ -1441,6 +1446,7 @@ exports.isEmptyObj = isEmptyObj;
exports.isInt = isInt;
exports.isNum = isNum;
exports.isString = isString;
exports.isSpace = isSpace;
exports.isSameOrigin = isSameOrigin;
exports.isValidUrl = isValidUrl;
exports.isLittleEndian = isLittleEndian;
@ -7815,7 +7821,12 @@ var WorkerTransport = (function WorkerTransportClosure() {
},
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) {

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

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

@ -18,6 +18,7 @@
var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
var pdfjsWebLibs = {
pdfjsWebPDFJS: window.pdfjsDistBuildPdf
};
@ -4590,6 +4591,11 @@ exports.PDFFindBar = PDFFindBar;
var parseQueryString = uiUtils.parseQueryString;
var PageNumberRegExp = /^\d+$/;
function isPageNumber(str) {
return PageNumberRegExp.test(str);
}
/**
* @typedef {Object} PDFLinkServiceOptions
* @property {EventBus} eventBus - The application event bus.
@ -4601,7 +4607,7 @@ var parseQueryString = uiUtils.parseQueryString;
* @class
* @implements {IPDFLinkService}
*/
var PDFLinkService = (function () {
var PDFLinkService = (function PDFLinkServiceClosure() {
/**
* @constructs PDFLinkService
* @param {PDFLinkServiceOptions} options
@ -4661,7 +4667,7 @@ var PDFLinkService = (function () {
var self = this;
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 ?
self._pagesRefCache[destRef.num + ' ' + destRef.gen + ' R'] :
(destRef + 1);
@ -4711,30 +4717,15 @@ var PDFLinkService = (function () {
*/
getDestinationHash: function PDFLinkService_getDestinationHash(dest) {
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) {
var destRef = dest[0]; // see navigateTo method for dest format
var pageNumber = destRef instanceof Object ?
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;
}
var str = JSON.stringify(dest);
return this.getAnchorUrl('#' + escape(str));
}
return this.getAnchorUrl('');
},
@ -4753,6 +4744,7 @@ var PDFLinkService = (function () {
* @param {string} hash
*/
setHash: function PDFLinkService_setHash(hash) {
var pageNumber, dest;
if (hash.indexOf('=') >= 0) {
var params = parseQueryString(hash);
if ('search' in params) {
@ -4770,7 +4762,6 @@ var PDFLinkService = (function () {
this.navigateTo(params.nameddest);
return;
}
var pageNumber, dest;
if ('page' in params) {
pageNumber = (params.page | 0) || 1;
}
@ -4820,13 +4811,23 @@ var PDFLinkService = (function () {
mode: params.pagemode
});
}
} else if (/^\d+$/.test(hash)) { // page number
this.page = hash;
} else { // named destination
if (this.pdfHistory) {
this.pdfHistory.updateNextHashParam(unescape(hash));
} else if (isPageNumber(hash)) { // Page number.
this.page = hash | 0;
} else { // Named (or explicit) destination.
dest = 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;
})();
@ -6723,6 +6778,8 @@ var PDFViewer = (function pdfViewer() {
scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
break;
default:
console.error('PDFViewer_scrollPageIntoView: \'' + dest[1].name +
'\' is not a valid destination type.');
return;
}
@ -7692,6 +7749,7 @@ var PDFViewerApplication = {
pdfViewer.setDocument(pdfDocument);
var firstPagePromise = pdfViewer.firstPagePromise;
var pagesPromise = pdfViewer.pagesPromise;
var onePageRendered = pdfViewer.onePageRendered;
this.pageRotation = 0;
@ -7797,9 +7855,8 @@ var PDFViewerApplication = {
}
});
// outline depends on pagesRefMap
var promises = [pagesPromise, this.animationStartedPromise];
Promise.all(promises).then(function() {
Promise.all([onePageRendered, this.animationStartedPromise]).then(
function() {
pdfDocument.getOutline().then(function(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.
window.FirefoxCom = pdfjsWebLibs.pdfjsWebFirefoxCom.FirefoxCom;
function getViewerConfiguration() {
return {
appContainer: document.body,