Bug 1754585 - Update pdf.js to version 2.13.133 r=pdfjs-reviewers,calixte

Differential Revision: https://phabricator.services.mozilla.com/D138359
This commit is contained in:
Brendan Dahl 2022-02-10 16:28:09 +00:00
Родитель 9fcb7f5716
Коммит bdbd290769
9 изменённых файлов: 5490 добавлений и 5288 удалений

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

@ -168,9 +168,10 @@ find_previous.title=Find the previous occurrence of the phrase
find_previous_label=Previous find_previous_label=Previous
find_next.title=Find the next occurrence of the phrase find_next.title=Find the next occurrence of the phrase
find_next_label=Next find_next_label=Next
find_highlight=Highlight all find_highlight=Highlight All
find_match_case_label=Match case find_match_case_label=Match Case
find_entire_word_label=Whole words find_match_diacritics_label=Match Diacritics
find_entire_word_label=Whole Words
find_reached_top=Reached top of document, continued from bottom find_reached_top=Reached top of document, continued from bottom
find_reached_bottom=Reached end of document, continued from top find_reached_bottom=Reached end of document, continued from top
# LOCALIZATION NOTE (find_match_count): The supported plural forms are # LOCALIZATION NOTE (find_match_count): The supported plural forms are

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

@ -1,5 +1,5 @@
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: 2.13.93 Current extension version is: 2.13.133
Taken from upstream commit: 6b9cc24d4 Taken from upstream commit: f8b2a99dd

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

@ -1344,7 +1344,7 @@ async function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
const workerId = await worker.messageHandler.sendWithPromise("GetDocRequest", { const workerId = await worker.messageHandler.sendWithPromise("GetDocRequest", {
docId, docId,
apiVersion: '2.13.93', apiVersion: '2.13.133',
source: { source: {
data: source.data, data: source.data,
url: source.url, url: source.url,
@ -1871,14 +1871,12 @@ class PDFPageProxy {
} }
streamTextContent({ streamTextContent({
normalizeWhitespace = false,
disableCombineTextItems = false, disableCombineTextItems = false,
includeMarkedContent = false includeMarkedContent = false
} = {}) { } = {}) {
const TEXT_CONTENT_CHUNK_SIZE = 100; const TEXT_CONTENT_CHUNK_SIZE = 100;
return this._transport.messageHandler.sendWithStream("GetTextContent", { return this._transport.messageHandler.sendWithStream("GetTextContent", {
pageIndex: this._pageIndex, pageIndex: this._pageIndex,
normalizeWhitespace: normalizeWhitespace === true,
combineTextItems: disableCombineTextItems !== true, combineTextItems: disableCombineTextItems !== true,
includeMarkedContent: includeMarkedContent === true includeMarkedContent: includeMarkedContent === true
}, { }, {
@ -2736,9 +2734,13 @@ class WorkerTransport {
if (loadingTask.onPassword) { if (loadingTask.onPassword) {
const updatePassword = password => { const updatePassword = password => {
this._passwordCapability.resolve({ if (password instanceof Error) {
password this._passwordCapability.reject(password);
}); } else {
this._passwordCapability.resolve({
password
});
}
}; };
try { try {
@ -3345,9 +3347,9 @@ class InternalRenderTask {
} }
const version = '2.13.93'; const version = '2.13.133';
exports.version = version; exports.version = version;
const build = '6b9cc24d4'; const build = 'f8b2a99dd';
exports.build = build; exports.build = build;
/***/ }), /***/ }),
@ -12382,8 +12384,8 @@ var _svg = __w_pdfjs_require__(22);
var _xfa_layer = __w_pdfjs_require__(20); var _xfa_layer = __w_pdfjs_require__(20);
const pdfjsVersion = '2.13.93'; const pdfjsVersion = '2.13.133';
const pdfjsBuild = '6b9cc24d4'; const pdfjsBuild = 'f8b2a99dd';
; ;
})(); })();

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

@ -4937,8 +4937,8 @@ Object.defineProperty(exports, "initSandbox", ({
var _initialization = __w_pdfjs_require__(1); var _initialization = __w_pdfjs_require__(1);
const pdfjsVersion = '2.13.93'; const pdfjsVersion = '2.13.133';
const pdfjsBuild = '6b9cc24d4'; const pdfjsBuild = 'f8b2a99dd';
})(); })();
/******/ return __webpack_exports__; /******/ return __webpack_exports__;

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

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

@ -1260,7 +1260,7 @@ html[dir="rtl"] #outerContainer.sidebarOpen #loadingBar {
.findbar.wrapContainers > div { .findbar.wrapContainers > div {
clear: both; clear: both;
} }
.findbar.wrapContainers > div#findbarMessageContainer { .findbar.wrapContainers > div.findbarMessageContainer {
height: auto; height: auto;
} }
html[dir="ltr"] .findbar { html[dir="ltr"] .findbar {
@ -1317,7 +1317,7 @@ html[dir="rtl"] .findbar .splitToolbarButton > .findNext {
} }
.findbar label:hover, .findbar label:hover,
.findbar input:focus + label { .findbar input:focus-visible + label {
color: var(--toggled-btn-color); color: var(--toggled-btn-color);
background-color: var(--button-hover-color); background-color: var(--button-hover-color);
} }
@ -1445,6 +1445,8 @@ html[dir="ltr"] .doorHangerRight:before {
#findMsg { #findMsg {
color: rgba(251, 0, 0, 1); color: rgba(251, 0, 0, 1);
} }
#findResultsCount:empty,
#findMsg:empty { #findMsg:empty {
display: none; display: none;
} }
@ -1507,12 +1509,12 @@ html[dir="rtl"] .splitToolbarButton > .toolbarButton {
} }
.overlayButton:hover, .overlayButton:hover,
.overlayButton:focus { .overlayButton:focus-visible {
background-color: var(--overlay-button-hover-bg-color); background-color: var(--overlay-button-hover-bg-color);
} }
.overlayButton:hover > span, .overlayButton:hover > span,
.overlayButton:focus > span { .overlayButton:focus-visible > span {
color: var(--overlay-button-hover-color); color: var(--overlay-button-hover-color);
} }
@ -1534,10 +1536,10 @@ html[dir="rtl"] .splitToolbarButton > .toolbarButton {
} }
.splitToolbarButton > .toolbarButton:hover, .splitToolbarButton > .toolbarButton:hover,
.splitToolbarButton > .toolbarButton:focus, .splitToolbarButton > .toolbarButton:focus-visible,
.dropdownToolbarButton:hover, .dropdownToolbarButton:hover,
.toolbarButton.textButton:hover, .toolbarButton.textButton:hover,
.toolbarButton.textButton:focus { .toolbarButton.textButton:focus-visible {
background-color: var(--button-hover-color); background-color: var(--button-hover-color);
z-index: 199; z-index: 199;
} }
@ -1601,11 +1603,11 @@ html[dir="rtl"] #toolbarViewerLeft > .toolbarButton:first-child {
margin-right: 2px; margin-right: 2px;
} }
.toolbarButton:hover, .toolbarButton:hover,
.toolbarButton:focus { .toolbarButton:focus-visible {
background-color: var(--button-hover-color); background-color: var(--button-hover-color);
} }
.secondaryToolbarButton:hover, .secondaryToolbarButton:hover,
.secondaryToolbarButton:focus { .secondaryToolbarButton:focus-visible {
background-color: var(--doorhanger-hover-bg-color); background-color: var(--doorhanger-hover-bg-color);
color: var(--doorhanger-hover-color); color: var(--doorhanger-hover-color);
} }
@ -1670,7 +1672,7 @@ html[dir="rtl"] .dropdownToolbarButton > select {
padding-right: 4px; padding-right: 4px;
} }
.dropdownToolbarButton > select:hover, .dropdownToolbarButton > select:hover,
.dropdownToolbarButton > select:focus { .dropdownToolbarButton > select:focus-visible {
background-color: var(--button-hover-color); background-color: var(--button-hover-color);
color: var(--toggled-btn-color); color: var(--toggled-btn-color);
} }
@ -1711,7 +1713,7 @@ html[dir="rtl"] .dropdownToolbarButton > select {
} }
.dropdownToolbarButton:hover::after, .dropdownToolbarButton:hover::after,
.dropdownToolbarButton:focus::after, .dropdownToolbarButton:focus-visible::after,
.dropdownToolbarButton:active::after { .dropdownToolbarButton:active::after {
background-color: var(--toolbar-icon-hover-bg-color); background-color: var(--toolbar-icon-hover-bg-color);
} }
@ -1723,9 +1725,9 @@ html[dir="rtl"] .dropdownToolbarButton > select {
} }
.toolbarButton:hover::before, .toolbarButton:hover::before,
.toolbarButton:focus::before, .toolbarButton:focus-visible::before,
.secondaryToolbarButton:hover::before, .secondaryToolbarButton:hover::before,
.secondaryToolbarButton:focus::before { .secondaryToolbarButton:focus-visible::before {
background-color: var(--toolbar-icon-hover-bg-color); background-color: var(--toolbar-icon-hover-bg-color);
} }

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

@ -101,17 +101,21 @@ See https://github.com/adobe-type-tools/cmap-resources
<div id="findbarOptionsOneContainer"> <div id="findbarOptionsOneContainer">
<input type="checkbox" id="findHighlightAll" class="toolbarField" tabindex="94"> <input type="checkbox" id="findHighlightAll" class="toolbarField" tabindex="94">
<label for="findHighlightAll" class="toolbarLabel" data-l10n-id="find_highlight">Highlight all</label> <label for="findHighlightAll" class="toolbarLabel" data-l10n-id="find_highlight">Highlight All</label>
<input type="checkbox" id="findMatchCase" class="toolbarField" tabindex="95"> <input type="checkbox" id="findMatchCase" class="toolbarField" tabindex="95">
<label for="findMatchCase" class="toolbarLabel" data-l10n-id="find_match_case_label">Match case</label> <label for="findMatchCase" class="toolbarLabel" data-l10n-id="find_match_case_label">Match Case</label>
</div> </div>
<div id="findbarOptionsTwoContainer"> <div id="findbarOptionsTwoContainer">
<input type="checkbox" id="findEntireWord" class="toolbarField" tabindex="96"> <input type="checkbox" id="findMatchDiacritics" class="toolbarField" tabindex="96">
<label for="findEntireWord" class="toolbarLabel" data-l10n-id="find_entire_word_label">Whole words</label> <label for="findMatchDiacritics" class="toolbarLabel" data-l10n-id="find_match_diacritics_label">Match Diacritics</label>
<span id="findResultsCount" class="toolbarLabel hidden"></span> <input type="checkbox" id="findEntireWord" class="toolbarField" tabindex="97">
<label for="findEntireWord" class="toolbarLabel" data-l10n-id="find_entire_word_label">Whole Words</label>
</div> </div>
<div id="findbarMessageContainer"> <div class="findbarMessageContainer">
<span id="findResultsCount" class="toolbarLabel"></span>
</div>
<div class="findbarMessageContainer">
<span id="findMsg" class="toolbarLabel"></span> <span id="findMsg" class="toolbarLabel"></span>
</div> </div>
</div> <!-- findbar --> </div> <!-- findbar -->

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

@ -2448,7 +2448,8 @@ function webViewerFindFromUrlHash(evt) {
caseSensitive: false, caseSensitive: false,
entireWord: false, entireWord: false,
highlightAll: true, highlightAll: true,
findPrevious: false findPrevious: false,
matchDiacritics: true
}); });
} }
@ -3105,8 +3106,8 @@ function removeNullCharacters(str, replaceInvisible = false) {
return str.replace(NullCharactersRegExp, ""); return str.replace(NullCharactersRegExp, "");
} }
function binarySearchFirstItem(items, condition) { function binarySearchFirstItem(items, condition, start = 0) {
let minIndex = 0; let minIndex = start;
let maxIndex = items.length - 1; let maxIndex = items.length - 1;
if (maxIndex < 0 || !condition(items[maxIndex])) { if (maxIndex < 0 || !condition(items[maxIndex])) {
@ -4632,14 +4633,14 @@ class PasswordPrompt {
this._isViewerEmbedded = isViewerEmbedded; this._isViewerEmbedded = isViewerEmbedded;
this.updateCallback = null; this.updateCallback = null;
this.reason = null; this.reason = null;
this.submitButton.addEventListener("click", this.verify.bind(this)); this.submitButton.addEventListener("click", this.#verify.bind(this));
this.cancelButton.addEventListener("click", this.close.bind(this)); this.cancelButton.addEventListener("click", this.#cancel.bind(this));
this.input.addEventListener("keydown", e => { this.input.addEventListener("keydown", e => {
if (e.keyCode === 13) { if (e.keyCode === 13) {
this.verify(); this.#verify();
} }
}); });
this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true); this.overlayManager.register(this.overlayName, this.container, this.#cancel.bind(this), true);
} }
async open() { async open() {
@ -4659,7 +4660,7 @@ class PasswordPrompt {
}); });
} }
verify() { #verify() {
const password = this.input.value; const password = this.input.value;
if (password?.length > 0) { if (password?.length > 0) {
@ -4668,6 +4669,11 @@ class PasswordPrompt {
} }
} }
#cancel() {
this.close();
this.updateCallback(new Error("PasswordPrompt cancelled."));
}
setUpdateCallback(updateCallback, reason) { setUpdateCallback(updateCallback, reason) {
this.updateCallback = updateCallback; this.updateCallback = updateCallback;
this.reason = reason; this.reason = reason;
@ -5261,6 +5267,7 @@ class PDFFindBar {
this.findField = options.findField; this.findField = options.findField;
this.highlightAll = options.highlightAllCheckbox; this.highlightAll = options.highlightAllCheckbox;
this.caseSensitive = options.caseSensitiveCheckbox; this.caseSensitive = options.caseSensitiveCheckbox;
this.matchDiacritics = options.matchDiacriticsCheckbox;
this.entireWord = options.entireWordCheckbox; this.entireWord = options.entireWordCheckbox;
this.findMsg = options.findMsg; this.findMsg = options.findMsg;
this.findResultsCount = options.findResultsCount; this.findResultsCount = options.findResultsCount;
@ -5303,6 +5310,9 @@ class PDFFindBar {
this.entireWord.addEventListener("click", () => { this.entireWord.addEventListener("click", () => {
this.dispatchEvent("entirewordchange"); this.dispatchEvent("entirewordchange");
}); });
this.matchDiacritics.addEventListener("click", () => {
this.dispatchEvent("diacriticmatchingchange");
});
this.eventBus._on("resize", this._adjustWidth.bind(this)); this.eventBus._on("resize", this._adjustWidth.bind(this));
} }
@ -5320,7 +5330,8 @@ class PDFFindBar {
caseSensitive: this.caseSensitive.checked, caseSensitive: this.caseSensitive.checked,
entireWord: this.entireWord.checked, entireWord: this.entireWord.checked,
highlightAll: this.highlightAll.checked, highlightAll: this.highlightAll.checked,
findPrevious: findPrev findPrevious: findPrev,
matchDiacritics: this.matchDiacritics.checked
}); });
} }
@ -5381,7 +5392,6 @@ class PDFFindBar {
matchCountMsg.then(msg => { matchCountMsg.then(msg => {
this.findResultsCount.textContent = msg; this.findResultsCount.textContent = msg;
this.findResultsCount.classList.toggle("hidden", !total);
this._adjustWidth(); this._adjustWidth();
}); });
@ -5452,12 +5462,12 @@ Object.defineProperty(exports, "__esModule", ({
})); }));
exports.PDFFindController = exports.FindState = void 0; exports.PDFFindController = exports.FindState = void 0;
var _ui_utils = __webpack_require__(3);
var _pdfjsLib = __webpack_require__(5); var _pdfjsLib = __webpack_require__(5);
var _pdf_find_utils = __webpack_require__(16); var _pdf_find_utils = __webpack_require__(16);
var _ui_utils = __webpack_require__(3);
const FindState = { const FindState = {
FOUND: 0, FOUND: 0,
NOT_FOUND: 1, NOT_FOUND: 1,
@ -5482,51 +5492,105 @@ const CHARACTERS_TO_NORMALIZE = {
"\u00BD": "1/2", "\u00BD": "1/2",
"\u00BE": "3/4" "\u00BE": "3/4"
}; };
const DIACRITICS_EXCEPTION = new Set([0x3099, 0x309a, 0x094d, 0x09cd, 0x0a4d, 0x0acd, 0x0b4d, 0x0bcd, 0x0c4d, 0x0ccd, 0x0d3b, 0x0d3c, 0x0d4d, 0x0dca, 0x0e3a, 0x0eba, 0x0f84, 0x1039, 0x103a, 0x1714, 0x1734, 0x17d2, 0x1a60, 0x1b44, 0x1baa, 0x1bab, 0x1bf2, 0x1bf3, 0x2d7f, 0xa806, 0xa82c, 0xa8c4, 0xa953, 0xa9c0, 0xaaf6, 0xabed, 0x0c56, 0x0f71, 0x0f72, 0x0f7a, 0x0f7b, 0x0f7c, 0x0f7d, 0x0f80, 0x0f74]);
const DIACRITICS_EXCEPTION_STR = [...DIACRITICS_EXCEPTION.values()].map(x => String.fromCharCode(x)).join("");
const DIACRITICS_REG_EXP = /\p{M}+/gu;
const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu;
const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u;
const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u;
let normalizationRegex = null; let normalizationRegex = null;
function normalize(text) { function normalize(text) {
if (!normalizationRegex) { if (!normalizationRegex) {
const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join(""); const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
normalizationRegex = new RegExp(`[${replace}]`, "g"); normalizationRegex = new RegExp(`([${replace}])|(\\S-\\n)|(\\n)|(\\p{M}+)`, "gum");
} }
let diffs = null; const rawDiacriticsPositions = [];
const normalizedText = text.replace(normalizationRegex, function (ch, index) { let m;
const normalizedCh = CHARACTERS_TO_NORMALIZE[ch],
diff = normalizedCh.length - ch.length;
if (diff !== 0) { while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) {
(diffs ||= []).push([index, diff]); rawDiacriticsPositions.push([m[0].length, m.index]);
}
let normalized = text.normalize("NFD");
const positions = [[0, 0]];
let k = 0;
let shift = 0;
let shiftOrigin = 0;
let eol = 0;
let hasDiacritics = false;
normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, i) => {
i -= shiftOrigin;
if (p1) {
const replacement = CHARACTERS_TO_NORMALIZE[match];
const jj = replacement.length;
for (let j = 1; j < jj; j++) {
positions.push([i - shift + j, shift - j]);
}
shift -= jj - 1;
return replacement;
} }
return normalizedCh; if (p2) {
positions.push([i - shift, 1 + shift]);
shift += 1;
shiftOrigin += 1;
eol += 1;
return p2.charAt(0);
}
if (p3) {
positions.push([i - shift + 1, shift - 1]);
shift -= 1;
shiftOrigin += 1;
eol += 1;
return " ";
}
hasDiacritics = true;
let jj = p4.length;
if (i + eol === rawDiacriticsPositions[k]?.[1]) {
jj -= rawDiacriticsPositions[k][0];
++k;
}
for (let j = 1; j < jj + 1; j++) {
positions.push([i - 1 - shift + j, shift - j]);
}
shift -= jj;
shiftOrigin += jj;
return p4;
}); });
return [normalizedText, diffs]; positions.push([normalized.length, shift]);
return [normalized, positions, hasDiacritics];
} }
function getOriginalIndex(matchIndex, diffs = null) { function getOriginalIndex(diffs, pos, len) {
if (!diffs) { if (!diffs) {
return matchIndex; return [pos, len];
} }
let totalDiff = 0; const start = pos;
const end = pos + len;
let i = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= start);
for (const [index, diff] of diffs) { if (diffs[i][0] > start) {
const currentIndex = index + totalDiff; --i;
if (currentIndex >= matchIndex) {
break;
}
if (currentIndex + diff > matchIndex) {
totalDiff += matchIndex - currentIndex;
break;
}
totalDiff += diff;
} }
return matchIndex - totalDiff; let j = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= end, i);
if (diffs[j][0] > end) {
--j;
}
return [start + diffs[i][1], len + diffs[j][1] - diffs[i][1]];
} }
class PDFFindController { class PDFFindController {
@ -5682,6 +5746,7 @@ class PDFFindController {
this._extractTextPromises = []; this._extractTextPromises = [];
this._pageContents = []; this._pageContents = [];
this._pageDiffs = []; this._pageDiffs = [];
this._hasDiacritics = [];
this._matchesCountTotal = 0; this._matchesCountTotal = 0;
this._pagesToSearch = null; this._pagesToSearch = null;
this._pendingFindMatches = new Set(); this._pendingFindMatches = new Set();
@ -5724,65 +5789,23 @@ class PDFFindController {
return true; return true;
} }
_prepareMatches(matchesWithLength, matches, matchesLength) {
function isSubTerm(currentIndex) {
const currentElem = matchesWithLength[currentIndex];
const nextElem = matchesWithLength[currentIndex + 1];
if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
currentElem.skipped = true;
return true;
}
for (let i = currentIndex - 1; i >= 0; i--) {
const prevElem = matchesWithLength[i];
if (prevElem.skipped) {
continue;
}
if (prevElem.match + prevElem.matchLength < currentElem.match) {
break;
}
if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
currentElem.skipped = true;
return true;
}
}
return false;
}
matchesWithLength.sort(function (a, b) {
return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
});
for (let i = 0, len = matchesWithLength.length; i < len; i++) {
if (isSubTerm(i)) {
continue;
}
matches.push(matchesWithLength[i].match);
matchesLength.push(matchesWithLength[i].matchLength);
}
}
_isEntireWord(content, startIdx, length) { _isEntireWord(content, startIdx, length) {
if (startIdx > 0) { let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP);
if (match) {
const first = content.charCodeAt(startIdx); const first = content.charCodeAt(startIdx);
const limit = content.charCodeAt(startIdx - 1); const limit = match[1].charCodeAt(0);
if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) { if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
return false; return false;
} }
} }
const endIdx = startIdx + length - 1; match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP);
if (endIdx < content.length - 1) { if (match) {
const last = content.charCodeAt(endIdx); const last = content.charCodeAt(startIdx + length - 1);
const limit = content.charCodeAt(endIdx + 1); const limit = match[1].charCodeAt(0);
if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(limit)) { if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(limit)) {
return false; return false;
@ -5792,96 +5815,114 @@ class PDFFindController {
return true; return true;
} }
_calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord) { _calculateRegExpMatch(query, entireWord, pageIndex, pageContent) {
const matches = [], const matches = [],
matchesLength = []; matchesLength = [];
const queryLen = query.length; const diffs = this._pageDiffs[pageIndex];
let matchIdx = -queryLen; let match;
while (true) { while ((match = query.exec(pageContent)) !== null) {
matchIdx = pageContent.indexOf(query, matchIdx + queryLen); if (entireWord && !this._isEntireWord(pageContent, match.index, match[0].length)) {
if (matchIdx === -1) {
break;
}
if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
continue; continue;
} }
const originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs), const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length);
matchEnd = matchIdx + queryLen - 1,
originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1; if (matchLen) {
matches.push(originalMatchIdx); matches.push(matchPos);
matchesLength.push(originalQueryLen); matchesLength.push(matchLen);
}
} }
this._pageMatches[pageIndex] = matches; this._pageMatches[pageIndex] = matches;
this._pageMatchesLength[pageIndex] = matchesLength; this._pageMatchesLength[pageIndex] = matchesLength;
} }
_calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord) { _convertToRegExpString(query, hasDiacritics) {
const matchesWithLength = []; const {
const queryArray = query.match(/\S+/g); matchDiacritics
} = this._state;
let isUnicode = false;
query = query.replace(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => {
if (p1) {
return `[ ]*\\${p1}[ ]*`;
}
for (let i = 0, len = queryArray.length; i < len; i++) { if (p2) {
const subquery = queryArray[i]; return `[ ]*${p2}[ ]*`;
const subqueryLen = subquery.length; }
let matchIdx = -subqueryLen;
while (true) { if (p3) {
matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen); return "[ ]+";
}
if (matchIdx === -1) { if (matchDiacritics) {
break; return p4 || p5;
} }
if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) { if (p4) {
continue; return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : "";
} }
const originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs), if (hasDiacritics) {
matchEnd = matchIdx + subqueryLen - 1, isUnicode = true;
originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1; return `${p5}\\p{M}*`;
matchesWithLength.push({ }
match: originalMatchIdx,
matchLength: originalQueryLen, return p5;
skipped: false });
}); const trailingSpaces = "[ ]*";
if (query.endsWith(trailingSpaces)) {
query = query.slice(0, query.length - trailingSpaces.length);
}
if (matchDiacritics) {
if (hasDiacritics) {
isUnicode = true;
query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`;
} }
} }
this._pageMatchesLength[pageIndex] = []; return [isUnicode, query];
this._pageMatches[pageIndex] = [];
this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
} }
_calculateMatch(pageIndex) { _calculateMatch(pageIndex) {
let pageContent = this._pageContents[pageIndex];
const pageDiffs = this._pageDiffs[pageIndex];
let query = this._query; let query = this._query;
const {
caseSensitive,
entireWord,
phraseSearch
} = this._state;
if (query.length === 0) { if (query.length === 0) {
return; return;
} }
if (!caseSensitive) { const {
pageContent = pageContent.toLowerCase(); caseSensitive,
query = query.toLowerCase(); entireWord,
} phraseSearch
} = this._state;
const pageContent = this._pageContents[pageIndex];
const hasDiacritics = this._hasDiacritics[pageIndex];
let isUnicode = false;
if (phraseSearch) { if (phraseSearch) {
this._calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord); [isUnicode, query] = this._convertToRegExpString(query, hasDiacritics);
} else { } else {
this._calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord); const match = query.match(/\S+/g);
if (match) {
query = match.sort().reverse().map(q => {
const [isUnicodePart, queryPart] = this._convertToRegExpString(q, hasDiacritics);
isUnicode ||= isUnicodePart;
return `(${queryPart})`;
}).join("|");
}
} }
const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`;
query = new RegExp(query, flags);
this._calculateRegExpMatch(query, entireWord, pageIndex, pageContent);
if (this._state.highlightAll) { if (this._state.highlightAll) {
this._updatePage(pageIndex); this._updatePage(pageIndex);
} }
@ -5913,23 +5954,26 @@ class PDFFindController {
this._extractTextPromises[i] = extractTextCapability.promise; this._extractTextPromises[i] = extractTextCapability.promise;
promise = promise.then(() => { promise = promise.then(() => {
return this._pdfDocument.getPage(i + 1).then(pdfPage => { return this._pdfDocument.getPage(i + 1).then(pdfPage => {
return pdfPage.getTextContent({ return pdfPage.getTextContent();
normalizeWhitespace: true
});
}).then(textContent => { }).then(textContent => {
const textItems = textContent.items; const textItems = textContent.items;
const strBuf = []; const strBuf = [];
for (let j = 0, jj = textItems.length; j < jj; j++) { for (let j = 0, jj = textItems.length; j < jj; j++) {
strBuf.push(textItems[j].str); strBuf.push(textItems[j].str);
if (textItems[j].hasEOL) {
strBuf.push("\n");
}
} }
[this._pageContents[i], this._pageDiffs[i]] = normalize(strBuf.join("")); [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join(""));
extractTextCapability.resolve(i); extractTextCapability.resolve(i);
}, reason => { }, reason => {
console.error(`Unable to get text content for page ${i + 1}`, reason); console.error(`Unable to get text content for page ${i + 1}`, reason);
this._pageContents[i] = ""; this._pageContents[i] = "";
this._pageDiffs[i] = null; this._pageDiffs[i] = null;
this._hasDiacritics[i] = false;
extractTextCapability.resolve(i); extractTextCapability.resolve(i);
}); });
}); });
@ -9745,7 +9789,7 @@ class BaseViewer {
throw new Error("Cannot initialize BaseViewer."); throw new Error("Cannot initialize BaseViewer.");
} }
const viewerVersion = '2.13.93'; const viewerVersion = '2.13.133';
if (_pdfjsLib.version !== viewerVersion) { if (_pdfjsLib.version !== viewerVersion) {
throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`); throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`);
@ -12184,7 +12228,6 @@ class PDFPageView {
return finishPaintTask(null).then(() => { return finishPaintTask(null).then(() => {
if (textLayer) { if (textLayer) {
const readableStream = pdfPage.streamTextContent({ const readableStream = pdfPage.streamTextContent({
normalizeWhitespace: true,
includeMarkedContent: true includeMarkedContent: true
}); });
textLayer.setTextContentStream(readableStream); textLayer.setTextContentStream(readableStream);
@ -13878,7 +13921,7 @@ class MozL10n {
} }
(function listenFindEvents() { (function listenFindEvents() {
const events = ["find", "findagain", "findhighlightallchange", "findcasesensitivitychange", "findentirewordchange", "findbarclose"]; const events = ["find", "findagain", "findhighlightallchange", "findcasesensitivitychange", "findentirewordchange", "findbarclose", "finddiacriticmatchingchange"];
const findLen = "find".length; const findLen = "find".length;
const handleEvent = function ({ const handleEvent = function ({
@ -13905,7 +13948,8 @@ class MozL10n {
caseSensitive: !!detail.caseSensitive, caseSensitive: !!detail.caseSensitive,
entireWord: !!detail.entireWord, entireWord: !!detail.entireWord,
highlightAll: !!detail.highlightAll, highlightAll: !!detail.highlightAll,
findPrevious: !!detail.findPrevious findPrevious: !!detail.findPrevious,
matchDiacritics: !!detail.matchDiacritics
}); });
}; };
@ -14593,8 +14637,8 @@ var _app_options = __webpack_require__(1);
var _app = __webpack_require__(2); var _app = __webpack_require__(2);
const pdfjsVersion = '2.13.93'; const pdfjsVersion = '2.13.133';
const pdfjsBuild = '6b9cc24d4'; const pdfjsBuild = 'f8b2a99dd';
window.PDFViewerApplication = _app.PDFViewerApplication; window.PDFViewerApplication = _app.PDFViewerApplication;
window.PDFViewerApplicationOptions = _app_options.AppOptions; window.PDFViewerApplicationOptions = _app_options.AppOptions;
; ;
@ -14679,6 +14723,7 @@ function getViewerConfiguration() {
findField: document.getElementById("findInput"), findField: document.getElementById("findInput"),
highlightAllCheckbox: document.getElementById("findHighlightAll"), highlightAllCheckbox: document.getElementById("findHighlightAll"),
caseSensitiveCheckbox: document.getElementById("findMatchCase"), caseSensitiveCheckbox: document.getElementById("findMatchCase"),
matchDiacriticsCheckbox: document.getElementById("findMatchDiacritics"),
entireWordCheckbox: document.getElementById("findEntireWord"), entireWordCheckbox: document.getElementById("findEntireWord"),
findMsg: document.getElementById("findMsg"), findMsg: document.getElementById("findMsg"),
findResultsCount: document.getElementById("findResultsCount"), findResultsCount: document.getElementById("findResultsCount"),

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

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