зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1495403 - Update pdf.js to version 2.0.892. r=bdahl
--HG-- extra : rebase_source : c0426ff3a4020486bc6d81e94b90e86dea4e1020
This commit is contained in:
Родитель
e7fedf66f4
Коммит
669caa7d79
|
@ -1,5 +1,5 @@
|
|||
This is the PDF.js project output, https://github.com/mozilla/pdf.js
|
||||
|
||||
Current extension version is: 2.0.866
|
||||
Current extension version is: 2.0.892
|
||||
|
||||
Taken from upstream commit: 0e41eb16
|
||||
Taken from upstream commit: ec10cae5
|
||||
|
|
|
@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
"use strict";
|
||||
|
||||
|
||||
var pdfjsVersion = '2.0.866';
|
||||
var pdfjsBuild = '0e41eb16';
|
||||
var pdfjsVersion = '2.0.892';
|
||||
var pdfjsBuild = 'ec10cae5';
|
||||
var pdfjsSharedUtil = __w_pdfjs_require__(1);
|
||||
var pdfjsDisplayAPI = __w_pdfjs_require__(7);
|
||||
var pdfjsDisplayTextLayer = __w_pdfjs_require__(19);
|
||||
|
@ -4226,7 +4226,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|||
}
|
||||
return worker.messageHandler.sendWithPromise('GetDocRequest', {
|
||||
docId,
|
||||
apiVersion: '2.0.866',
|
||||
apiVersion: '2.0.892',
|
||||
source: {
|
||||
data: source.data,
|
||||
url: source.url,
|
||||
|
@ -5553,8 +5553,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
|
|||
}();
|
||||
var version, build;
|
||||
{
|
||||
exports.version = version = '2.0.866';
|
||||
exports.build = build = '0e41eb16';
|
||||
exports.version = version = '2.0.892';
|
||||
exports.build = build = 'ec10cae5';
|
||||
}
|
||||
exports.getDocument = getDocument;
|
||||
exports.LoopbackPort = LoopbackPort;
|
||||
|
|
|
@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
"use strict";
|
||||
|
||||
|
||||
var pdfjsVersion = '2.0.866';
|
||||
var pdfjsBuild = '0e41eb16';
|
||||
var pdfjsVersion = '2.0.892';
|
||||
var pdfjsBuild = 'ec10cae5';
|
||||
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.866';
|
||||
let workerVersion = '2.0.892';
|
||||
if (apiVersion !== workerVersion) {
|
||||
throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
|
||||
}
|
||||
|
@ -20445,18 +20445,18 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
|
|||
switch (glyphName[0]) {
|
||||
case 'G':
|
||||
if (glyphName.length === 3) {
|
||||
code = parseInt(glyphName.substr(1), 16);
|
||||
code = parseInt(glyphName.substring(1), 16);
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
if (glyphName.length === 5) {
|
||||
code = parseInt(glyphName.substr(1), 16);
|
||||
code = parseInt(glyphName.substring(1), 16);
|
||||
}
|
||||
break;
|
||||
case 'C':
|
||||
case 'c':
|
||||
if (glyphName.length >= 3) {
|
||||
code = +glyphName.substr(1);
|
||||
code = +glyphName.substring(1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -21614,7 +21614,7 @@ class CMap {
|
|||
var lastByte = dstLow.length - 1;
|
||||
while (low <= high) {
|
||||
this._map[low++] = dstLow;
|
||||
dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
|
||||
dstLow = dstLow.substring(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
|
||||
}
|
||||
}
|
||||
mapBfRangeToArray(low, high, array) {
|
||||
|
@ -26016,7 +26016,7 @@ var CFFCompiler = function CFFCompilerClosure() {
|
|||
nibbles += nibbles.length & 1 ? 'f' : 'ff';
|
||||
var out = [30];
|
||||
for (i = 0, ii = nibbles.length; i < ii; i += 2) {
|
||||
out.push(parseInt(nibbles.substr(i, 2), 16));
|
||||
out.push(parseInt(nibbles.substring(i, i + 2), 16));
|
||||
}
|
||||
return out;
|
||||
},
|
||||
|
@ -31683,9 +31683,9 @@ function getUnicodeForGlyph(name, glyphsUnicodeMap) {
|
|||
if (name[0] === 'u') {
|
||||
var nameLen = name.length, hexStr;
|
||||
if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
|
||||
hexStr = name.substr(3);
|
||||
hexStr = name.substring(3);
|
||||
} else if (nameLen >= 5 && nameLen <= 7) {
|
||||
hexStr = name.substr(1);
|
||||
hexStr = name.substring(1);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ var Stepper = (function StepperClosure() {
|
|||
if (typeof args === 'string') {
|
||||
var MAX_STRING_LENGTH = 75;
|
||||
return args.length <= MAX_STRING_LENGTH ? args :
|
||||
args.substr(0, MAX_STRING_LENGTH) + '...';
|
||||
args.substring(0, MAX_STRING_LENGTH) + '...';
|
||||
}
|
||||
if (typeof args !== 'object' || args === null) {
|
||||
return args;
|
||||
|
|
|
@ -491,6 +491,11 @@ let PDFViewerApplication = {
|
|||
this.pdfLinkService = pdfLinkService;
|
||||
let downloadManager = this.externalServices.createDownloadManager({ disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL') });
|
||||
this.downloadManager = downloadManager;
|
||||
const findController = new _pdf_find_controller.PDFFindController({
|
||||
linkService: pdfLinkService,
|
||||
eventBus
|
||||
});
|
||||
this.findController = findController;
|
||||
let container = appConfig.mainContainer;
|
||||
let viewer = appConfig.viewerContainer;
|
||||
this.pdfViewer = new _pdf_viewer.PDFViewer({
|
||||
|
@ -500,6 +505,7 @@ let PDFViewerApplication = {
|
|||
renderingQueue: pdfRenderingQueue,
|
||||
linkService: pdfLinkService,
|
||||
downloadManager,
|
||||
findController,
|
||||
renderer: _app_options.AppOptions.get('renderer'),
|
||||
enableWebGL: _app_options.AppOptions.get('enableWebGL'),
|
||||
l10n: this.l10n,
|
||||
|
@ -525,31 +531,7 @@ let PDFViewerApplication = {
|
|||
eventBus
|
||||
});
|
||||
pdfLinkService.setHistory(this.pdfHistory);
|
||||
this.findController = new _pdf_find_controller.PDFFindController({
|
||||
pdfViewer: this.pdfViewer,
|
||||
eventBus
|
||||
});
|
||||
this.findController.onUpdateResultsCount = matchesCount => {
|
||||
if (this.supportsIntegratedFind) {
|
||||
this.externalServices.updateFindMatchesCount(matchesCount);
|
||||
} else {
|
||||
this.findBar.updateResultsCount(matchesCount);
|
||||
}
|
||||
};
|
||||
this.findController.onUpdateState = (state, previous, matchesCount) => {
|
||||
if (this.supportsIntegratedFind) {
|
||||
this.externalServices.updateFindControlState({
|
||||
result: state,
|
||||
findPrevious: previous,
|
||||
matchesCount
|
||||
});
|
||||
} else {
|
||||
this.findBar.updateUIState(state, previous, matchesCount);
|
||||
}
|
||||
};
|
||||
this.pdfViewer.setFindController(this.findController);
|
||||
let findBarConfig = Object.create(appConfig.findBar);
|
||||
findBarConfig.findController = this.findController;
|
||||
findBarConfig.eventBus = eventBus;
|
||||
this.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig, this.l10n);
|
||||
this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n);
|
||||
|
@ -710,10 +692,11 @@ let PDFViewerApplication = {
|
|||
this.pdfLoadingTask = null;
|
||||
if (this.pdfDocument) {
|
||||
this.pdfDocument = null;
|
||||
this.findController.setDocument(null);
|
||||
this.pdfThumbnailViewer.setDocument(null);
|
||||
this.pdfViewer.setDocument(null);
|
||||
this.pdfLinkService.setDocument(null, null);
|
||||
this.pdfDocumentProperties.setDocument(null, null);
|
||||
this.pdfLinkService.setDocument(null);
|
||||
this.pdfDocumentProperties.setDocument(null);
|
||||
}
|
||||
this.store = null;
|
||||
this.isInitialViewSet = false;
|
||||
|
@ -724,7 +707,6 @@ let PDFViewerApplication = {
|
|||
this.pdfSidebar.reset();
|
||||
this.pdfOutlineViewer.reset();
|
||||
this.pdfAttachmentViewer.reset();
|
||||
this.findController.reset();
|
||||
this.findBar.reset();
|
||||
this.toolbar.reset();
|
||||
this.secondaryToolbar.reset();
|
||||
|
@ -891,6 +873,7 @@ let PDFViewerApplication = {
|
|||
const store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
|
||||
let baseDocumentUrl;
|
||||
baseDocumentUrl = this.baseUrl;
|
||||
this.findController.setDocument(pdfDocument);
|
||||
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
|
||||
this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
|
||||
let pdfViewer = this.pdfViewer;
|
||||
|
@ -1196,6 +1179,8 @@ let PDFViewerApplication = {
|
|||
eventBus.on('documentproperties', webViewerDocumentProperties);
|
||||
eventBus.on('find', webViewerFind);
|
||||
eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
|
||||
eventBus.on('updatefindmatchescount', webViewerUpdateFindMatchesCount);
|
||||
eventBus.on('updatefindcontrolstate', webViewerUpdateFindControlState);
|
||||
},
|
||||
bindWindowEvents() {
|
||||
let { eventBus, _boundEvents } = this;
|
||||
|
@ -1259,6 +1244,8 @@ let PDFViewerApplication = {
|
|||
eventBus.off('documentproperties', webViewerDocumentProperties);
|
||||
eventBus.off('find', webViewerFind);
|
||||
eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
|
||||
eventBus.off('updatefindmatchescount', webViewerUpdateFindMatchesCount);
|
||||
eventBus.off('updatefindcontrolstate', webViewerUpdateFindControlState);
|
||||
_boundEvents.beforePrint = null;
|
||||
_boundEvents.afterPrint = null;
|
||||
},
|
||||
|
@ -1558,6 +1545,24 @@ function webViewerFindFromUrlHash(evt) {
|
|||
findPrevious: false
|
||||
});
|
||||
}
|
||||
function webViewerUpdateFindMatchesCount({ matchesCount }) {
|
||||
if (PDFViewerApplication.supportsIntegratedFind) {
|
||||
PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
|
||||
} else {
|
||||
PDFViewerApplication.findBar.updateResultsCount(matchesCount);
|
||||
}
|
||||
}
|
||||
function webViewerUpdateFindControlState({ state, previous, matchesCount }) {
|
||||
if (PDFViewerApplication.supportsIntegratedFind) {
|
||||
PDFViewerApplication.externalServices.updateFindControlState({
|
||||
result: state,
|
||||
findPrevious: previous,
|
||||
matchesCount
|
||||
});
|
||||
} else {
|
||||
PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
|
||||
}
|
||||
}
|
||||
function webViewerScaleChanging(evt) {
|
||||
PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
|
||||
PDFViewerApplication.pdfViewer.update();
|
||||
|
@ -2194,9 +2199,12 @@ function isDataSchema(url) {
|
|||
while (i < ii && url[i].trim() === '') {
|
||||
i++;
|
||||
}
|
||||
return url.substr(i, 5).toLowerCase() === 'data:';
|
||||
return url.substring(i, i + 5).toLowerCase() === 'data:';
|
||||
}
|
||||
function getPDFFileNameFromURL(url, defaultFilename = 'document.pdf') {
|
||||
if (typeof url !== 'string') {
|
||||
return defaultFilename;
|
||||
}
|
||||
if (isDataSchema(url)) {
|
||||
console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
|
||||
return defaultFilename;
|
||||
|
@ -2298,11 +2306,12 @@ class EventBus {
|
|||
let eventListeners = this._listeners[eventName];
|
||||
if (!eventListeners || eventListeners.length === 0) {
|
||||
if (this._dispatchToDOM) {
|
||||
this._dispatchDOMEvent(eventName);
|
||||
const args = Array.prototype.slice.call(arguments, 1);
|
||||
this._dispatchDOMEvent(eventName, args);
|
||||
}
|
||||
return;
|
||||
}
|
||||
let args = Array.prototype.slice.call(arguments, 1);
|
||||
const args = Array.prototype.slice.call(arguments, 1);
|
||||
eventListeners.slice(0).forEach(function (listener) {
|
||||
listener.apply(null, args);
|
||||
});
|
||||
|
@ -3787,7 +3796,7 @@ class PDFDocumentProperties {
|
|||
return;
|
||||
}
|
||||
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 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);
|
||||
}), this._parseLinearization(info.IsLinearized)]);
|
||||
}).then(([info, metadata, fileName, fileSize, creationDate, modDate, pageSize, isLinearized]) => {
|
||||
|
@ -3828,7 +3837,7 @@ class PDFDocumentProperties {
|
|||
close() {
|
||||
this.overlayManager.close(this.overlayName);
|
||||
}
|
||||
setDocument(pdfDocument, url) {
|
||||
setDocument(pdfDocument, url = null) {
|
||||
if (this.pdfDocument) {
|
||||
this._reset();
|
||||
this._updateUI(true);
|
||||
|
@ -4006,12 +4015,8 @@ class PDFFindBar {
|
|||
this.findResultsCount = options.findResultsCount || null;
|
||||
this.findPreviousButton = options.findPreviousButton || null;
|
||||
this.findNextButton = options.findNextButton || null;
|
||||
this.findController = options.findController || null;
|
||||
this.eventBus = options.eventBus;
|
||||
this.l10n = l10n;
|
||||
if (this.findController === null) {
|
||||
throw new Error('PDFFindBar cannot be used without a ' + 'PDFFindController instance.');
|
||||
}
|
||||
this.toggleButton.addEventListener('click', () => {
|
||||
this.toggle();
|
||||
});
|
||||
|
@ -4135,7 +4140,7 @@ class PDFFindBar {
|
|||
this.opened = false;
|
||||
this.toggleButton.classList.remove('toggled');
|
||||
this.bar.classList.add('hidden');
|
||||
this.findController.active = false;
|
||||
this.eventBus.dispatch('findbarclose', { source: this });
|
||||
}
|
||||
toggle() {
|
||||
if (this.opened) {
|
||||
|
@ -4197,15 +4202,23 @@ const CHARACTERS_TO_NORMALIZE = {
|
|||
'\u00BE': '3/4'
|
||||
};
|
||||
class PDFFindController {
|
||||
constructor({ pdfViewer, eventBus = (0, _dom_events.getGlobalEventBus)() }) {
|
||||
this._pdfViewer = pdfViewer;
|
||||
constructor({ linkService, eventBus = (0, _dom_events.getGlobalEventBus)() }) {
|
||||
this._linkService = linkService;
|
||||
this._eventBus = eventBus;
|
||||
this.onUpdateResultsCount = null;
|
||||
this.onUpdateState = null;
|
||||
this.reset();
|
||||
this._reset();
|
||||
eventBus.on('findbarclose', () => {
|
||||
this._highlightMatches = false;
|
||||
eventBus.dispatch('updatetextlayermatches', {
|
||||
source: this,
|
||||
pageIndex: -1
|
||||
});
|
||||
});
|
||||
const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
|
||||
this._normalizationRegex = new RegExp(`[${replace}]`, 'g');
|
||||
}
|
||||
get highlightMatches() {
|
||||
return this._highlightMatches;
|
||||
}
|
||||
get pageMatches() {
|
||||
return this._pageMatches;
|
||||
}
|
||||
|
@ -4218,8 +4231,37 @@ class PDFFindController {
|
|||
get state() {
|
||||
return this._state;
|
||||
}
|
||||
reset() {
|
||||
this.active = false;
|
||||
setDocument(pdfDocument) {
|
||||
if (this._pdfDocument) {
|
||||
this._reset();
|
||||
}
|
||||
if (!pdfDocument) {
|
||||
return;
|
||||
}
|
||||
this._pdfDocument = pdfDocument;
|
||||
}
|
||||
executeCommand(cmd, state) {
|
||||
if (!this._pdfDocument) {
|
||||
return;
|
||||
}
|
||||
if (this._state === null || cmd !== 'findagain') {
|
||||
this._dirtyMatch = true;
|
||||
}
|
||||
this._state = state;
|
||||
this._updateUIState(FindState.PENDING);
|
||||
this._firstPagePromise.then(() => {
|
||||
this._extractText();
|
||||
clearTimeout(this._findTimeout);
|
||||
if (cmd === 'find') {
|
||||
this._findTimeout = setTimeout(this._nextMatch.bind(this), FIND_TIMEOUT);
|
||||
} else {
|
||||
this._nextMatch();
|
||||
}
|
||||
});
|
||||
}
|
||||
_reset() {
|
||||
this._highlightMatches = false;
|
||||
this._pdfDocument = null;
|
||||
this._pageMatches = [];
|
||||
this._pageMatchesLength = null;
|
||||
this._state = null;
|
||||
|
@ -4247,22 +4289,6 @@ class PDFFindController {
|
|||
});
|
||||
});
|
||||
}
|
||||
executeCommand(cmd, state) {
|
||||
if (this._state === null || cmd !== 'findagain') {
|
||||
this._dirtyMatch = true;
|
||||
}
|
||||
this._state = state;
|
||||
this._updateUIState(FindState.PENDING);
|
||||
this._firstPagePromise.then(() => {
|
||||
this._extractText();
|
||||
clearTimeout(this._findTimeout);
|
||||
if (cmd === 'find') {
|
||||
this._findTimeout = setTimeout(this._nextMatch.bind(this), FIND_TIMEOUT);
|
||||
} else {
|
||||
this._nextMatch();
|
||||
}
|
||||
});
|
||||
}
|
||||
_normalize(text) {
|
||||
return text.replace(this._normalizationRegex, function (ch) {
|
||||
return CHARACTERS_TO_NORMALIZE[ch];
|
||||
|
@ -4397,11 +4423,13 @@ class PDFFindController {
|
|||
return;
|
||||
}
|
||||
let promise = Promise.resolve();
|
||||
for (let i = 0, ii = this._pdfViewer.pagesCount; i < ii; i++) {
|
||||
for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
|
||||
const extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
|
||||
this._extractTextPromises[i] = extractTextCapability.promise;
|
||||
promise = promise.then(() => {
|
||||
return this._pdfViewer.getPageTextContent(i).then(textContent => {
|
||||
return this._pdfDocument.getPage(i + 1).then(pdfPage => {
|
||||
return pdfPage.getTextContent({ normalizeWhitespace: true });
|
||||
}).then(textContent => {
|
||||
const textItems = textContent.items;
|
||||
const strBuf = [];
|
||||
for (let j = 0, jj = textItems.length; j < jj; j++) {
|
||||
|
@ -4419,18 +4447,18 @@ class PDFFindController {
|
|||
}
|
||||
_updatePage(index) {
|
||||
if (this._selected.pageIdx === index) {
|
||||
this._pdfViewer.currentPageNumber = index + 1;
|
||||
}
|
||||
const page = this._pdfViewer.getPageView(index);
|
||||
if (page.textLayer) {
|
||||
page.textLayer.updateMatches();
|
||||
this._linkService.page = index + 1;
|
||||
}
|
||||
this._eventBus.dispatch('updatetextlayermatches', {
|
||||
source: this,
|
||||
pageIndex: index
|
||||
});
|
||||
}
|
||||
_nextMatch() {
|
||||
const previous = this._state.findPrevious;
|
||||
const currentPageIndex = this._pdfViewer.currentPageNumber - 1;
|
||||
const numPages = this._pdfViewer.pagesCount;
|
||||
this.active = true;
|
||||
const currentPageIndex = this._linkService.page - 1;
|
||||
const numPages = this._linkService.pagesCount;
|
||||
this._highlightMatches = true;
|
||||
if (this._dirtyMatch) {
|
||||
this._dirtyMatch = false;
|
||||
this._selected.pageIdx = this._selected.matchIdx = -1;
|
||||
|
@ -4506,7 +4534,7 @@ class PDFFindController {
|
|||
}
|
||||
_advanceOffsetPage(previous) {
|
||||
const offset = this._offset;
|
||||
const numPages = this._extractTextPromises.length;
|
||||
const numPages = this._linkService.pagesCount;
|
||||
offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
|
||||
offset.matchIdx = null;
|
||||
this._pagesToSearch--;
|
||||
|
@ -4521,8 +4549,8 @@ class PDFFindController {
|
|||
this._offset.wrapped = false;
|
||||
if (found) {
|
||||
const previousPage = this._selected.pageIdx;
|
||||
this.selected.pageIdx = this._offset.pageIdx;
|
||||
this.selected.matchIdx = this._offset.matchIdx;
|
||||
this._selected.pageIdx = this._offset.pageIdx;
|
||||
this._selected.matchIdx = this._offset.matchIdx;
|
||||
state = wrapped ? FindState.WRAPPED : FindState.FOUND;
|
||||
if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
|
||||
this._updatePage(previousPage);
|
||||
|
@ -4552,18 +4580,18 @@ class PDFFindController {
|
|||
};
|
||||
}
|
||||
_updateUIResultsCount() {
|
||||
if (!this.onUpdateResultsCount) {
|
||||
return;
|
||||
}
|
||||
const matchesCount = this._requestMatchesCount();
|
||||
this.onUpdateResultsCount(matchesCount);
|
||||
this._eventBus.dispatch('updatefindmatchescount', {
|
||||
source: this,
|
||||
matchesCount: this._requestMatchesCount()
|
||||
});
|
||||
}
|
||||
_updateUIState(state, previous) {
|
||||
if (!this.onUpdateState) {
|
||||
return;
|
||||
}
|
||||
const matchesCount = this._requestMatchesCount();
|
||||
this.onUpdateState(state, previous, matchesCount);
|
||||
this._eventBus.dispatch('updatefindcontrolstate', {
|
||||
source: this,
|
||||
state,
|
||||
previous,
|
||||
matchesCount: this._requestMatchesCount()
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.FindState = FindState;
|
||||
|
@ -5053,7 +5081,7 @@ class PDFLinkService {
|
|||
this.pdfHistory = null;
|
||||
this._pagesRefCache = null;
|
||||
}
|
||||
setDocument(pdfDocument, baseUrl) {
|
||||
setDocument(pdfDocument, baseUrl = null) {
|
||||
this.baseUrl = baseUrl;
|
||||
this.pdfDocument = pdfDocument;
|
||||
this._pagesRefCache = Object.create(null);
|
||||
|
@ -6612,6 +6640,7 @@ class BaseViewer {
|
|||
this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
|
||||
this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
|
||||
this.downloadManager = options.downloadManager || null;
|
||||
this.findController = options.findController || null;
|
||||
this.removePageBorders = options.removePageBorders || false;
|
||||
this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
|
||||
this.imageResourcesPath = options.imageResourcesPath || '';
|
||||
|
@ -7177,11 +7206,6 @@ class BaseViewer {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
getPageTextContent(pageIndex) {
|
||||
return this.pdfDocument.getPage(pageIndex + 1).then(function (page) {
|
||||
return page.getTextContent({ normalizeWhitespace: true });
|
||||
});
|
||||
}
|
||||
createTextLayerBuilder(textLayerDiv, pageIndex, viewport, enhanceTextSelection = false) {
|
||||
return new _text_layer_builder.TextLayerBuilder({
|
||||
textLayerDiv,
|
||||
|
@ -7203,9 +7227,6 @@ class BaseViewer {
|
|||
l10n
|
||||
});
|
||||
}
|
||||
setFindController(findController) {
|
||||
this.findController = findController;
|
||||
}
|
||||
get hasEqualPageSizes() {
|
||||
let firstPageView = this._pages[0];
|
||||
for (let i = 1, ii = this._pages.length; i < ii; ++i) {
|
||||
|
@ -7597,6 +7618,7 @@ class PDFPageView {
|
|||
this.reset(true, true);
|
||||
}
|
||||
cancelRendering(keepAnnotations = false) {
|
||||
const renderingState = this.renderingState;
|
||||
if (this.paintTask) {
|
||||
this.paintTask.cancel();
|
||||
this.paintTask = null;
|
||||
|
@ -7611,6 +7633,13 @@ class PDFPageView {
|
|||
this.annotationLayer.cancel();
|
||||
this.annotationLayer = null;
|
||||
}
|
||||
if (renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
|
||||
this.eventBus.dispatch('pagecancelled', {
|
||||
source: this,
|
||||
pageNumber: this.id,
|
||||
renderingState
|
||||
});
|
||||
}
|
||||
}
|
||||
cssTransform(target, redrawAnnotations = false) {
|
||||
let width = this.viewport.width;
|
||||
|
@ -7912,6 +7941,8 @@ class TextLayerBuilder {
|
|||
this.findController = findController;
|
||||
this.textLayerRenderTask = null;
|
||||
this.enhanceTextSelection = enhanceTextSelection;
|
||||
this._boundEvents = Object.create(null);
|
||||
this._bindEvents();
|
||||
this._bindMouse();
|
||||
}
|
||||
_finishRendering() {
|
||||
|
@ -8103,7 +8134,7 @@ class TextLayerBuilder {
|
|||
}
|
||||
clearedUntilDivIdx = match.end.divIdx + 1;
|
||||
}
|
||||
if (this.findController === null || !this.findController.active) {
|
||||
if (!this.findController || !this.findController.highlightMatches) {
|
||||
return;
|
||||
}
|
||||
let pageMatches, pageMatchesLength;
|
||||
|
@ -8114,6 +8145,30 @@ class TextLayerBuilder {
|
|||
this.matches = this.convertMatches(pageMatches, pageMatchesLength);
|
||||
this.renderMatches(this.matches);
|
||||
}
|
||||
_bindEvents() {
|
||||
const { eventBus, _boundEvents } = this;
|
||||
_boundEvents.pageCancelled = evt => {
|
||||
if (evt.pageNumber !== this.pageNumber) {
|
||||
return;
|
||||
}
|
||||
if (this.textLayerRenderTask) {
|
||||
console.error('TextLayerBuilder._bindEvents: `this.cancel()` should ' + 'have been called when the page was reset, or rendering cancelled.');
|
||||
return;
|
||||
}
|
||||
for (const name in _boundEvents) {
|
||||
eventBus.off(name.toLowerCase(), _boundEvents[name]);
|
||||
delete _boundEvents[name];
|
||||
}
|
||||
};
|
||||
_boundEvents.updateTextLayerMatches = evt => {
|
||||
if (evt.pageIndex !== this.pageIdx && evt.pageIndex !== -1) {
|
||||
return;
|
||||
}
|
||||
this.updateMatches();
|
||||
};
|
||||
eventBus.on('pagecancelled', _boundEvents.pageCancelled);
|
||||
eventBus.on('updatetextlayermatches', _boundEvents.updateTextLayerMatches);
|
||||
}
|
||||
_bindMouse() {
|
||||
let div = this.textLayerDiv;
|
||||
let expandDivsTimer = null;
|
||||
|
@ -8944,20 +8999,24 @@ class MozL10n {
|
|||
}
|
||||
}
|
||||
(function listenFindEvents() {
|
||||
const events = ['find', 'findagain', 'findhighlightallchange', 'findcasesensitivitychange', 'findentirewordchange'];
|
||||
let handleEvent = function (evt) {
|
||||
const events = ['find', 'findagain', 'findhighlightallchange', 'findcasesensitivitychange', 'findentirewordchange', 'findbarclose'];
|
||||
let handleEvent = function ({ type, detail }) {
|
||||
if (!_app.PDFViewerApplication.initialized) {
|
||||
return;
|
||||
}
|
||||
if (type === 'findbarclose') {
|
||||
_app.PDFViewerApplication.eventBus.dispatch('findbarclose', { source: window });
|
||||
return;
|
||||
}
|
||||
_app.PDFViewerApplication.eventBus.dispatch('find', {
|
||||
source: window,
|
||||
type: evt.type.substring('find'.length),
|
||||
query: evt.detail.query,
|
||||
type: type.substring('find'.length),
|
||||
query: detail.query,
|
||||
phraseSearch: true,
|
||||
caseSensitive: !!evt.detail.caseSensitive,
|
||||
entireWord: !!evt.detail.entireWord,
|
||||
highlightAll: !!evt.detail.highlightAll,
|
||||
findPrevious: !!evt.detail.findPrevious
|
||||
caseSensitive: !!detail.caseSensitive,
|
||||
entireWord: !!detail.entireWord,
|
||||
highlightAll: !!detail.highlightAll,
|
||||
findPrevious: !!detail.findPrevious
|
||||
});
|
||||
};
|
||||
for (let event of events) {
|
||||
|
|
|
@ -20,7 +20,7 @@ origin:
|
|||
|
||||
# Human-readable identifier for this version/release
|
||||
# Generally "version NNN", "tag SSS", "bookmark SSS"
|
||||
release: version 2.0.866
|
||||
release: version 2.0.892
|
||||
|
||||
# The package's license, where possible using the mnemonic from
|
||||
# https://spdx.org/licenses/
|
||||
|
|
Загрузка…
Ссылка в новой задаче