Bug 1480202 - Update pdf.js to version 2.0.719. r=bdahl

This commit is contained in:
Ryan VanderMeulen 2018-08-01 16:25:11 -04:00
Родитель beccfd4a6a
Коммит c49c9c1831
7 изменённых файлов: 142 добавлений и 156 удалений

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

@ -1,5 +1,5 @@
This is the PDF.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 2.0.694
Current extension version is: 2.0.719
Taken from upstream commit: 1aaeaf33
Taken from upstream commit: 35214245

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

@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap
"use strict";
var pdfjsVersion = '2.0.694';
var pdfjsBuild = '1aaeaf33';
var pdfjsVersion = '2.0.719';
var pdfjsBuild = '35214245';
var pdfjsSharedUtil = __w_pdfjs_require__(1);
var pdfjsDisplayAPI = __w_pdfjs_require__(7);
var pdfjsDisplayTextLayer = __w_pdfjs_require__(19);
@ -4223,7 +4223,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
}
return worker.messageHandler.sendWithPromise('GetDocRequest', {
docId,
apiVersion: '2.0.694',
apiVersion: '2.0.719',
source: {
data: source.data,
url: source.url,
@ -5563,8 +5563,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
}();
var version, build;
{
exports.version = version = '2.0.694';
exports.build = build = '1aaeaf33';
exports.version = version = '2.0.719';
exports.build = build = '35214245';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;

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

@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap
"use strict";
var pdfjsVersion = '2.0.694';
var pdfjsBuild = '1aaeaf33';
var pdfjsVersion = '2.0.719';
var pdfjsBuild = '35214245';
var pdfjsCoreWorker = __w_pdfjs_require__(1);
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
@ -327,7 +327,7 @@ var WorkerMessageHandler = {
var cancelXHRs = null;
var WorkerTasks = [];
let apiVersion = docParams.apiVersion;
let workerVersion = '2.0.694';
let workerVersion = '2.0.719';
if (apiVersion !== workerVersion) {
throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
}
@ -5226,12 +5226,12 @@ Object.defineProperty(exports, "__esModule", {
});
exports.PDFDocument = exports.Page = undefined;
var _util = __w_pdfjs_require__(2);
var _obj = __w_pdfjs_require__(11);
var _primitives = __w_pdfjs_require__(12);
var _util = __w_pdfjs_require__(2);
var _stream = __w_pdfjs_require__(14);
var _annotation = __w_pdfjs_require__(26);
@ -5492,6 +5492,7 @@ var PDFDocument = function PDFDocumentClosure() {
xref: this.xref,
isEvalSupported: evaluatorOptions.isEvalSupported
});
this._pagePromises = [];
}
function find(stream, needle, limit, backwards) {
var pos = stream.pos;
@ -5512,20 +5513,16 @@ var PDFDocument = function PDFDocumentClosure() {
stream.pos += index;
return true;
}
var DocumentInfoValidators = {
get entries() {
return (0, _util.shadow)(this, 'entries', {
Title: _util.isString,
Author: _util.isString,
Subject: _util.isString,
Keywords: _util.isString,
Creator: _util.isString,
Producer: _util.isString,
CreationDate: _util.isString,
ModDate: _util.isString,
Trapped: _primitives.isName
});
}
const DocumentInfoValidators = {
Title: _util.isString,
Author: _util.isString,
Subject: _util.isString,
Keywords: _util.isString,
Creator: _util.isString,
Producer: _util.isString,
CreationDate: _util.isString,
ModDate: _util.isString,
Trapped: _primitives.isName
};
PDFDocument.prototype = {
parse: function PDFDocument_parse(recoveryMode) {
@ -5552,16 +5549,14 @@ var PDFDocument = function PDFDocumentClosure() {
}
},
get linearization() {
var linearization = null;
if (this.stream.length) {
try {
linearization = _parser.Linearization.create(this.stream);
} catch (err) {
if (err instanceof _util.MissingDataException) {
throw err;
}
(0, _util.info)(err);
let linearization = null;
try {
linearization = _parser.Linearization.create(this.stream);
} catch (err) {
if (err instanceof _util.MissingDataException) {
throw err;
}
(0, _util.info)(err);
}
return (0, _util.shadow)(this, 'linearization', linearization);
},
@ -5639,21 +5634,7 @@ var PDFDocument = function PDFDocumentClosure() {
},
setup: function PDFDocument_setup(recoveryMode) {
this.xref.parse(recoveryMode);
var pageFactory = {
createPage: (pageIndex, dict, ref, fontCache, builtInCMapCache) => {
return new Page({
pdfManager: this.pdfManager,
xref: this.xref,
pageIndex,
pageDict: dict,
ref,
fontCache,
builtInCMapCache,
pdfFunctionFactory: this.pdfFunctionFactory
});
}
};
this.catalog = new _obj.Catalog(this.pdfManager, this.xref, pageFactory);
this.catalog = new _obj.Catalog(this.pdfManager, this.xref);
},
get numPages() {
var linearization = this.linearization;
@ -5661,12 +5642,13 @@ var PDFDocument = function PDFDocumentClosure() {
return (0, _util.shadow)(this, 'numPages', num);
},
get documentInfo() {
var docInfo = {
const docInfo = {
PDFFormatVersion: this.pdfFormatVersion,
IsLinearized: !!this.linearization,
IsAcroFormPresent: !!this.acroForm,
IsXFAPresent: !!this.xfa
};
var infoDict;
let infoDict;
try {
infoDict = this.xref.trailer.get('Info');
} catch (err) {
@ -5675,12 +5657,11 @@ var PDFDocument = function PDFDocumentClosure() {
}
(0, _util.info)('The document information dictionary is invalid.');
}
if (infoDict) {
var validEntries = DocumentInfoValidators.entries;
for (var key in validEntries) {
if ((0, _primitives.isDict)(infoDict)) {
for (let key in DocumentInfoValidators) {
if (infoDict.has(key)) {
var value = infoDict.get(key);
if (validEntries[key](value)) {
const value = infoDict.get(key);
if (DocumentInfoValidators[key](value)) {
docInfo[key] = typeof value !== 'string' ? value : (0, _util.stringToPDFString)(value);
} else {
(0, _util.info)('Bad value in document info for "' + key + '"');
@ -5709,8 +5690,41 @@ var PDFDocument = function PDFDocumentClosure() {
}
return (0, _util.shadow)(this, 'fingerprint', fileID);
},
getPage: function PDFDocument_getPage(pageIndex) {
return this.catalog.getPage(pageIndex);
_getLinearizationPage(pageIndex) {
const { catalog, linearization } = this;
(0, _util.assert)(linearization && linearization.pageFirst === pageIndex);
const ref = new _primitives.Ref(linearization.objectNumberFirst, 0);
return this.xref.fetchAsync(ref).then(obj => {
if ((0, _primitives.isDict)(obj, 'Page') || (0, _primitives.isDict)(obj) && !obj.has('Type') && obj.has('Contents')) {
if (ref && !catalog.pageKidsCountCache.has(ref)) {
catalog.pageKidsCountCache.put(ref, 1);
}
return [obj, ref];
}
throw new _util.FormatError('The Linearization dictionary doesn\'t point ' + 'to a valid Page dictionary.');
}).catch(reason => {
(0, _util.info)(reason);
return catalog.getPageDict(pageIndex);
});
},
getPage(pageIndex) {
if (this._pagePromises[pageIndex] !== undefined) {
return this._pagePromises[pageIndex];
}
const { catalog, linearization } = this;
const promise = linearization && linearization.pageFirst === pageIndex ? this._getLinearizationPage(pageIndex) : catalog.getPageDict(pageIndex);
return this._pagePromises[pageIndex] = promise.then(([pageDict, ref]) => {
return new Page({
pdfManager: this.pdfManager,
xref: this.xref,
pageIndex,
pageDict,
ref,
fontCache: catalog.fontCache,
builtInCMapCache: catalog.builtInCMapCache,
pdfFunctionFactory: this.pdfFunctionFactory
});
});
},
cleanup: function PDFDocument_cleanup() {
return this.catalog.cleanup();
@ -5746,7 +5760,7 @@ var _crypto = __w_pdfjs_require__(24);
var _colorspace = __w_pdfjs_require__(25);
var Catalog = function CatalogClosure() {
function Catalog(pdfManager, xref, pageFactory) {
function Catalog(pdfManager, xref) {
this.pdfManager = pdfManager;
this.xref = xref;
this.catDict = xref.getCatalogObj();
@ -5754,10 +5768,8 @@ var Catalog = function CatalogClosure() {
throw new _util.FormatError('catalog object is not a dictionary');
}
this.fontCache = new _primitives.RefSetCache();
this.builtInCMapCache = Object.create(null);
this.builtInCMapCache = new Map();
this.pageKidsCountCache = new _primitives.RefSetCache();
this.pageFactory = pageFactory;
this.pagePromises = [];
}
Catalog.prototype = {
get metadata() {
@ -6133,17 +6145,9 @@ var Catalog = function CatalogClosure() {
delete font.translated;
}
this.fontCache.clear();
this.builtInCMapCache = Object.create(null);
this.builtInCMapCache.clear();
});
},
getPage: function Catalog_getPage(pageIndex) {
if (!(pageIndex in this.pagePromises)) {
this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(([dict, ref]) => {
return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache, this.builtInCMapCache);
});
}
return this.pagePromises[pageIndex];
},
getPageDict: function Catalog_getPageDict(pageIndex) {
var capability = (0, _util.createPromiseCapability)();
var nodesToVisit = [this.catDict.getRaw('Pages')];
@ -8639,6 +8643,7 @@ var StringStream = function StringStreamClosure() {
var DecodeStream = function DecodeStreamClosure() {
var emptyBuffer = new Uint8Array(0);
function DecodeStream(maybeMinBufferLength) {
this._rawMinBufferLength = maybeMinBufferLength || 0;
this.pos = 0;
this.bufferLength = 0;
this.eof = false;
@ -8756,7 +8761,16 @@ var DecodeStream = function DecodeStreamClosure() {
var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
function StreamsSequenceStream(streams) {
this.streams = streams;
DecodeStream.call(this, null);
let maybeLength = 0;
for (let i = 0, ii = streams.length; i < ii; i++) {
const stream = streams[i];
if (stream instanceof DecodeStream) {
maybeLength += stream._rawMinBufferLength;
} else {
maybeLength += stream.length;
}
}
DecodeStream.call(this, maybeLength);
}
StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
@ -19008,13 +19022,12 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
this.options = options || DefaultPartialEvaluatorOptions;
this.pdfFunctionFactory = pdfFunctionFactory;
this.fetchBuiltInCMap = name => {
var cachedCMap = this.builtInCMapCache[name];
if (cachedCMap) {
return Promise.resolve(cachedCMap);
if (this.builtInCMapCache.has(name)) {
return Promise.resolve(this.builtInCMapCache.get(name));
}
return this.handler.sendWithPromise('FetchBuiltInCMap', { name }).then(data => {
if (data.compressionType !== _util.CMapCompressionType.NONE) {
this.builtInCMapCache[name] = data;
this.builtInCMapCache.set(name, data);
}
return data;
});

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

@ -356,6 +356,10 @@ See https://github.com/adobe-type-tools/cmap-resources
<div class="row">
<span data-l10n-id="document_properties_page_size">Page Size:</span> <p id="pageSizeField">-</p>
</div>
<div class="separator"></div>
<div class="row">
<span data-l10n-id="document_properties_linearized">Fast Web View:</span> <p id="linearizedField">-</p>
</div>
<div class="buttonRow">
<button id="documentPropertiesClose" class="overlayButton"><span data-l10n-id="document_properties_close">Close</span></button>
</div>

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

@ -231,7 +231,8 @@ function getViewerConfiguration() {
'producer': document.getElementById('producerField'),
'version': document.getElementById('versionField'),
'pageCount': document.getElementById('pageCountField'),
'pageSize': document.getElementById('pageSizeField')
'pageSize': document.getElementById('pageSizeField'),
'linearized': document.getElementById('linearizedField')
}
},
errorWrapper: {
@ -386,6 +387,9 @@ let PDFViewerApplication = {
}).then(() => {
return this._initializeL10n();
}).then(() => {
if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdfjsLib.LinkTarget.NONE) {
_app_options.AppOptions.set('externalLinkTarget', _pdfjsLib.LinkTarget.TOP);
}
return this._initializeViewerComponents();
}).then(() => {
this.bindEvents();
@ -394,74 +398,27 @@ let PDFViewerApplication = {
this.l10n.translate(appContainer).then(() => {
this.eventBus.dispatch('localized');
});
if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdfjsLib.LinkTarget.NONE) {
_app_options.AppOptions.set('externalLinkTarget', _pdfjsLib.LinkTarget.TOP);
}
this.initialized = true;
});
},
_readPreferences() {
let { preferences } = this;
return Promise.all([preferences.get('enableWebGL').then(function resolved(value) {
_app_options.AppOptions.set('enableWebGL', value);
}), preferences.get('sidebarViewOnLoad').then(function resolved(value) {
_app_options.AppOptions.set('sidebarViewOnLoad', value);
}), preferences.get('cursorToolOnLoad').then(function resolved(value) {
_app_options.AppOptions.set('cursorToolOnLoad', value);
}), preferences.get('pdfBugEnabled').then(function resolved(value) {
_app_options.AppOptions.set('pdfBugEnabled', value);
}), preferences.get('showPreviousViewOnLoad').then(function resolved(value) {
_app_options.AppOptions.set('showPreviousViewOnLoad', value);
}), preferences.get('defaultZoomValue').then(function resolved(value) {
_app_options.AppOptions.set('defaultZoomValue', value);
}), preferences.get('textLayerMode').then(function resolved(value) {
if (_app_options.AppOptions.get('textLayerMode') === _ui_utils.TextLayerMode.DISABLE) {
return;
const OVERRIDES = {
disableFontFace: true,
disableRange: true,
disableStream: true,
textLayerMode: _ui_utils.TextLayerMode.DISABLE
};
return this.preferences.getAll().then(function (prefs) {
for (let name in prefs) {
if (name in OVERRIDES && _app_options.AppOptions.get(name) === OVERRIDES[name]) {
continue;
}
_app_options.AppOptions.set(name, prefs[name]);
}
_app_options.AppOptions.set('textLayerMode', value);
}), preferences.get('disableRange').then(function resolved(value) {
if (_app_options.AppOptions.get('disableRange') === true) {
return;
}
_app_options.AppOptions.set('disableRange', value);
}), preferences.get('disableStream').then(function resolved(value) {
if (_app_options.AppOptions.get('disableStream') === true) {
return;
}
_app_options.AppOptions.set('disableStream', value);
}), preferences.get('disableAutoFetch').then(function resolved(value) {
_app_options.AppOptions.set('disableAutoFetch', value);
}), preferences.get('disableFontFace').then(function resolved(value) {
if (_app_options.AppOptions.get('disableFontFace') === true) {
return;
}
_app_options.AppOptions.set('disableFontFace', value);
}), preferences.get('useOnlyCssZoom').then(function resolved(value) {
_app_options.AppOptions.set('useOnlyCssZoom', value);
}), preferences.get('externalLinkTarget').then(function resolved(value) {
if (_app_options.AppOptions.get('externalLinkTarget') !== _pdfjsLib.LinkTarget.NONE) {
return;
}
_app_options.AppOptions.set('externalLinkTarget', value);
}), preferences.get('renderer').then(function resolved(value) {
_app_options.AppOptions.set('renderer', value);
}), preferences.get('renderInteractiveForms').then(function resolved(value) {
_app_options.AppOptions.set('renderInteractiveForms', value);
}), preferences.get('disablePageMode').then(function resolved(value) {
_app_options.AppOptions.set('disablePageMode', value);
}), preferences.get('disablePageLabels').then(function resolved(value) {
_app_options.AppOptions.set('disablePageLabels', value);
}), preferences.get('enablePrintAutoRotate').then(function resolved(value) {
_app_options.AppOptions.set('enablePrintAutoRotate', value);
}), preferences.get('scrollModeOnLoad').then(function resolved(value) {
_app_options.AppOptions.set('scrollModeOnLoad', value);
}), preferences.get('spreadModeOnLoad').then(function resolved(value) {
_app_options.AppOptions.set('spreadModeOnLoad', value);
})]).catch(function (reason) {});
}, function (reason) {});
},
_parseHashParameters() {
let { appConfig } = this;
let waitOn = [];
const waitOn = [];
if (_app_options.AppOptions.get('pdfBugEnabled')) {
let hash = document.location.hash.substring(1);
let hashParams = (0, _ui_utils.parseQueryString)(hash);
@ -500,7 +457,7 @@ let PDFViewerApplication = {
case 'visible':
case 'shadow':
case 'hover':
let viewer = appConfig.viewerContainer;
let viewer = this.appConfig.viewerContainer;
viewer.classList.add('textLayer-' + hashParams['textlayer']);
break;
}
@ -781,7 +738,6 @@ let PDFViewerApplication = {
open(file, args) {
if (this.pdfLoadingTask) {
return this.close().then(() => {
this.preferences.reload();
return this.open(file, args);
});
}
@ -3821,8 +3777,8 @@ class PDFDocumentProperties {
this.pdfDocument.getMetadata().then(({ info, metadata, contentDispositionFilename }) => {
return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url), this._parseFileSize(this.maybeFileSize), this._parseDate(info.CreationDate), this._parseDate(info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(pdfPage => {
return this._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
})]);
}).then(([info, metadata, fileName, fileSize, creationDate, modDate, pageSize]) => {
}), this._parseLinearization(info.IsLinearized)]);
}).then(([info, metadata, fileName, fileSize, creationDate, modDate, pageSize, isLinearized]) => {
freezeFieldData({
'fileName': fileName,
'fileSize': fileSize,
@ -3837,6 +3793,7 @@ class PDFDocumentProperties {
'version': info.PDFFormatVersion,
'pageCount': this.pdfDocument.numPages,
'pageSize': pageSize,
'linearized': isLinearized,
'_currentPageNumber': currentPageNumber,
'_pagesRotation': pagesRotation
});
@ -4001,6 +3958,9 @@ class PDFDocumentProperties {
time: timeString
}, '{{date}}, {{time}}');
}
_parseLinearization(isLinearized) {
return this.l10n.get('document_properties_linearized_' + (isLinearized ? 'yes' : 'no'), null, isLinearized ? 'Yes' : 'No');
}
}
exports.PDFDocumentProperties = PDFDocumentProperties;
@ -9113,9 +9073,17 @@ class BasePreferences {
});
this.prefs = Object.assign(Object.create(null), defaults);
return this._readFromStorage(defaults);
}).then(prefObj => {
if (prefObj) {
this.prefs = prefObj;
}).then(prefs => {
if (!prefs) {
return;
}
for (let name in prefs) {
const defaultValue = this.defaults[name],
prefValue = prefs[name];
if (defaultValue === undefined || typeof prefValue !== typeof defaultValue) {
continue;
}
this.prefs[name] = prefValue;
}
});
}
@ -9131,15 +9099,6 @@ class BasePreferences {
return this._writeToStorage(this.defaults);
});
}
reload() {
return this._initializedPromise.then(() => {
return this._readFromStorage(this.defaults);
}).then(prefObj => {
if (prefObj) {
this.prefs = prefObj;
}
});
}
set(name, value) {
return this._initializedPromise.then(() => {
if (this.defaults[name] === undefined) {
@ -9178,6 +9137,11 @@ class BasePreferences {
return defaultValue;
});
}
getAll() {
return this._initializedPromise.then(() => {
return Object.assign(Object.create(null), this.defaults, this.prefs);
});
}
}
exports.BasePreferences = BasePreferences;

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

@ -20,7 +20,7 @@ origin:
# Human-readable identifier for this version/release
# Generally "version NNN", "tag SSS", "bookmark SSS"
release: version 2.0.688
release: version 2.0.719
# The package's license, where possible using the mnemonic from
# https://spdx.org/licenses/

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

@ -120,6 +120,11 @@ document_properties_page_size_dimension_string={{width}} × {{height}} {{unit}}
# "{{width}}", "{{height}}", {{unit}}, {{name}}, and {{orientation}} will be replaced by
# the size, respectively their unit of measurement, name, and orientation, of the (current) page.
document_properties_page_size_dimension_name_string={{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})
# LOCALIZATION NOTE (document_properties_linearized): The linearization status of
# the document; usually called "Fast Web View" in English locales of Adobe software.
document_properties_linearized=Fast Web View:
document_properties_linearized_yes=Yes
document_properties_linearized_no=No
document_properties_close=Close
print_progress_message=Preparing document for printing…