Browse Source

PDF.js version 2.0.357 - See mozilla/pdf.js@be2674a0e8d4bf239e08eb33a42d1f4d15fde7ee

master v2.0.357
pdfjsbot 7 years ago
parent
commit
0d219a1c55
  1. 2
      bower.json
  2. 14
      build/pdf.js
  3. 2
      build/pdf.js.map
  4. 2
      build/pdf.min.js
  5. 6
      build/pdf.worker.js
  6. 2
      build/pdf.worker.js.map
  7. 2
      build/pdf.worker.min.js
  8. 2
      lib/core/worker.js
  9. 6
      lib/display/api.js
  10. 4
      lib/display/global.js
  11. 4
      lib/pdf.js
  12. 4
      lib/pdf.worker.js
  13. 164
      lib/web/pdf_find_controller.js
  14. 2
      package.json
  15. 164
      web/pdf_viewer.js
  16. 2
      web/pdf_viewer.js.map

2
bower.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "pdfjs-dist",
"version": "2.0.354",
"version": "2.0.357",
"main": [
"build/pdf.js",
"build/pdf.worker.js"

14
build/pdf.js

@ -3299,7 +3299,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { @@ -3299,7 +3299,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
if (worker.destroyed) {
return Promise.reject(new Error('Worker was destroyed'));
}
var apiVersion = '2.0.354';
var apiVersion = '2.0.357';
source.disableRange = (0, _dom_utils.getDefaultSetting)('disableRange');
source.disableAutoFetch = (0, _dom_utils.getDefaultSetting)('disableAutoFetch');
source.disableStream = (0, _dom_utils.getDefaultSetting)('disableStream');
@ -4698,8 +4698,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() { @@ -4698,8 +4698,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
}();
var version, build;
{
exports.version = version = '2.0.354';
exports.build = build = 'b3557483';
exports.version = version = '2.0.357';
exports.build = build = 'be2674a0';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;
@ -7457,8 +7457,8 @@ exports.SVGGraphics = SVGGraphics; @@ -7457,8 +7457,8 @@ exports.SVGGraphics = SVGGraphics;
"use strict";
var pdfjsVersion = '2.0.354';
var pdfjsBuild = 'b3557483';
var pdfjsVersion = '2.0.357';
var pdfjsBuild = 'be2674a0';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(120);
var pdfjsDisplayAPI = __w_pdfjs_require__(58);
@ -12743,8 +12743,8 @@ if (!_global_scope2.default.PDFJS) { @@ -12743,8 +12743,8 @@ if (!_global_scope2.default.PDFJS) {
}
var PDFJS = _global_scope2.default.PDFJS;
{
PDFJS.version = '2.0.354';
PDFJS.build = 'b3557483';
PDFJS.version = '2.0.357';
PDFJS.build = 'be2674a0';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {

2
build/pdf.js.map

File diff suppressed because one or more lines are too long

2
build/pdf.min.js vendored

File diff suppressed because one or more lines are too long

6
build/pdf.worker.js vendored

@ -22295,8 +22295,8 @@ exports.PostScriptCompiler = PostScriptCompiler; @@ -22295,8 +22295,8 @@ exports.PostScriptCompiler = PostScriptCompiler;
"use strict";
var pdfjsVersion = '2.0.354';
var pdfjsBuild = 'b3557483';
var pdfjsVersion = '2.0.357';
var pdfjsBuild = 'be2674a0';
var pdfjsCoreWorker = __w_pdfjs_require__(74);
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
@ -22509,7 +22509,7 @@ var WorkerMessageHandler = { @@ -22509,7 +22509,7 @@ var WorkerMessageHandler = {
var cancelXHRs = null;
var WorkerTasks = [];
var apiVersion = docParams.apiVersion;
var workerVersion = '2.0.354';
var workerVersion = '2.0.357';
if (apiVersion !== null && apiVersion !== workerVersion) {
throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".'));
}

2
build/pdf.worker.js.map vendored

File diff suppressed because one or more lines are too long

2
build/pdf.worker.min.js vendored

File diff suppressed because one or more lines are too long

2
lib/core/worker.js

@ -223,7 +223,7 @@ var WorkerMessageHandler = { @@ -223,7 +223,7 @@ var WorkerMessageHandler = {
var cancelXHRs = null;
var WorkerTasks = [];
var apiVersion = docParams.apiVersion;
var workerVersion = '2.0.354';
var workerVersion = '2.0.357';
if (apiVersion !== null && apiVersion !== workerVersion) {
throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".'));
}

6
lib/display/api.js

@ -178,7 +178,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { @@ -178,7 +178,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
if (worker.destroyed) {
return Promise.reject(new Error('Worker was destroyed'));
}
var apiVersion = '2.0.354';
var apiVersion = '2.0.357';
source.disableRange = (0, _dom_utils.getDefaultSetting)('disableRange');
source.disableAutoFetch = (0, _dom_utils.getDefaultSetting)('disableAutoFetch');
source.disableStream = (0, _dom_utils.getDefaultSetting)('disableStream');
@ -1577,8 +1577,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() { @@ -1577,8 +1577,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
}();
var version, build;
{
exports.version = version = '2.0.354';
exports.build = build = 'b3557483';
exports.version = version = '2.0.357';
exports.build = build = 'be2674a0';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;

4
lib/display/global.js

@ -51,8 +51,8 @@ if (!_global_scope2.default.PDFJS) { @@ -51,8 +51,8 @@ if (!_global_scope2.default.PDFJS) {
}
var PDFJS = _global_scope2.default.PDFJS;
{
PDFJS.version = '2.0.354';
PDFJS.build = 'b3557483';
PDFJS.version = '2.0.357';
PDFJS.build = 'be2674a0';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {

4
lib/pdf.js

@ -21,8 +21,8 @@ @@ -21,8 +21,8 @@
*/
'use strict';
var pdfjsVersion = '2.0.354';
var pdfjsBuild = 'b3557483';
var pdfjsVersion = '2.0.357';
var pdfjsBuild = 'be2674a0';
var pdfjsSharedUtil = require('./shared/util.js');
var pdfjsDisplayGlobal = require('./display/global.js');
var pdfjsDisplayAPI = require('./display/api.js');

4
lib/pdf.worker.js vendored

@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
*/
'use strict';
var pdfjsVersion = '2.0.354';
var pdfjsBuild = 'b3557483';
var pdfjsVersion = '2.0.357';
var pdfjsBuild = 'be2674a0';
var pdfjsCoreWorker = require('./core/worker.js');
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

164
lib/web/pdf_find_controller.js

@ -102,8 +102,39 @@ var PDFFindController = function () { @@ -102,8 +102,39 @@ var PDFFindController = function () {
});
}
}, {
key: 'normalize',
value: function normalize(text) {
key: 'executeCommand',
value: function executeCommand(cmd, state) {
var _this2 = this;
if (this.state === null || cmd !== 'findagain') {
this.dirtyMatch = true;
}
this.state = state;
this._updateUIState(FindState.PENDING);
this._firstPagePromise.then(function () {
_this2._extractText();
clearTimeout(_this2.findTimeout);
if (cmd === 'find') {
_this2.findTimeout = setTimeout(_this2._nextMatch.bind(_this2), FIND_TIMEOUT);
} else {
_this2._nextMatch();
}
});
}
}, {
key: 'updateMatchPosition',
value: function updateMatchPosition(pageIndex, matchIndex, elements, beginIdx) {
if (this.selected.matchIdx === matchIndex && this.selected.pageIdx === pageIndex) {
var spot = {
top: FIND_SCROLL_OFFSET_TOP,
left: FIND_SCROLL_OFFSET_LEFT
};
(0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true);
}
}
}, {
key: '_normalize',
value: function _normalize(text) {
return text.replace(this.normalizationRegex, function (ch) {
return CHARACTERS_TO_NORMALIZE[ch];
});
@ -145,8 +176,8 @@ var PDFFindController = function () { @@ -145,8 +176,8 @@ var PDFFindController = function () {
}
}
}, {
key: 'calcFindPhraseMatch',
value: function calcFindPhraseMatch(query, pageIndex, pageContent) {
key: '_calculatePhraseMatch',
value: function _calculatePhraseMatch(query, pageIndex, pageContent) {
var matches = [];
var queryLen = query.length;
var matchIdx = -queryLen;
@ -160,8 +191,8 @@ var PDFFindController = function () { @@ -160,8 +191,8 @@ var PDFFindController = function () {
this.pageMatches[pageIndex] = matches;
}
}, {
key: 'calcFindWordMatch',
value: function calcFindWordMatch(query, pageIndex, pageContent) {
key: '_calculateWordMatch',
value: function _calculateWordMatch(query, pageIndex, pageContent) {
var matchesWithLength = [];
var queryArray = query.match(/\S+/g);
for (var i = 0, len = queryArray.length; i < len; i++) {
@ -188,10 +219,10 @@ var PDFFindController = function () { @@ -188,10 +219,10 @@ var PDFFindController = function () {
this._prepareMatches(matchesWithLength, this.pageMatches[pageIndex], this.pageMatchesLength[pageIndex]);
}
}, {
key: 'calcFindMatch',
value: function calcFindMatch(pageIndex) {
var pageContent = this.normalize(this.pageContents[pageIndex]);
var query = this.normalize(this.state.query);
key: '_calculateMatch',
value: function _calculateMatch(pageIndex) {
var pageContent = this._normalize(this.pageContents[pageIndex]);
var query = this._normalize(this.state.query);
var caseSensitive = this.state.caseSensitive;
var phraseSearch = this.state.phraseSearch;
var queryLen = query.length;
@ -203,24 +234,24 @@ var PDFFindController = function () { @@ -203,24 +234,24 @@ var PDFFindController = function () {
query = query.toLowerCase();
}
if (phraseSearch) {
this.calcFindPhraseMatch(query, pageIndex, pageContent);
this._calculatePhraseMatch(query, pageIndex, pageContent);
} else {
this.calcFindWordMatch(query, pageIndex, pageContent);
this._calculateWordMatch(query, pageIndex, pageContent);
}
this.updatePage(pageIndex);
this._updatePage(pageIndex);
if (this.resumePageIdx === pageIndex) {
this.resumePageIdx = null;
this.nextPageMatch();
this._nextPageMatch();
}
if (this.pageMatches[pageIndex].length > 0) {
this.matchCount += this.pageMatches[pageIndex].length;
this.updateUIResultsCount();
this._updateUIResultsCount();
}
}
}, {
key: 'extractText',
value: function extractText() {
var _this2 = this;
key: '_extractText',
value: function _extractText() {
var _this3 = this;
if (this.startedTextExtraction) {
return;
@ -231,19 +262,19 @@ var PDFFindController = function () { @@ -231,19 +262,19 @@ var PDFFindController = function () {
var _loop = function _loop(i, ii) {
var extractTextCapability = (0, _pdf.createPromiseCapability)();
_this2.extractTextPromises[i] = extractTextCapability.promise;
_this3.extractTextPromises[i] = extractTextCapability.promise;
promise = promise.then(function () {
return _this2.pdfViewer.getPageTextContent(i).then(function (textContent) {
return _this3.pdfViewer.getPageTextContent(i).then(function (textContent) {
var textItems = textContent.items;
var strBuf = [];
for (var j = 0, jj = textItems.length; j < jj; j++) {
strBuf.push(textItems[j].str);
}
_this2.pageContents[i] = strBuf.join('');
_this3.pageContents[i] = strBuf.join('');
extractTextCapability.resolve(i);
}, function (reason) {
console.error('Unable to get page ' + (i + 1) + ' text content', reason);
_this2.pageContents[i] = '';
_this3.pageContents[i] = '';
extractTextCapability.resolve(i);
});
});
@ -254,28 +285,8 @@ var PDFFindController = function () { @@ -254,28 +285,8 @@ var PDFFindController = function () {
}
}
}, {
key: 'executeCommand',
value: function executeCommand(cmd, state) {
var _this3 = this;
if (this.state === null || cmd !== 'findagain') {
this.dirtyMatch = true;
}
this.state = state;
this.updateUIState(FindState.PENDING);
this._firstPagePromise.then(function () {
_this3.extractText();
clearTimeout(_this3.findTimeout);
if (cmd === 'find') {
_this3.findTimeout = setTimeout(_this3.nextMatch.bind(_this3), FIND_TIMEOUT);
} else {
_this3.nextMatch();
}
});
}
}, {
key: 'updatePage',
value: function updatePage(index) {
key: '_updatePage',
value: function _updatePage(index) {
if (this.selected.pageIdx === index) {
this.pdfViewer.currentPageNumber = index + 1;
}
@ -285,8 +296,8 @@ var PDFFindController = function () { @@ -285,8 +296,8 @@ var PDFFindController = function () {
}
}
}, {
key: 'nextMatch',
value: function nextMatch() {
key: '_nextMatch',
value: function _nextMatch() {
var _this4 = this;
var previous = this.state.findPrevious;
@ -304,18 +315,18 @@ var PDFFindController = function () { @@ -304,18 +315,18 @@ var PDFFindController = function () {
this.matchCount = 0;
this.pageMatchesLength = null;
for (var i = 0; i < numPages; i++) {
this.updatePage(i);
this._updatePage(i);
if (!(i in this.pendingFindMatches)) {
this.pendingFindMatches[i] = true;
this.extractTextPromises[i].then(function (pageIdx) {
delete _this4.pendingFindMatches[pageIdx];
_this4.calcFindMatch(pageIdx);
_this4._calculateMatch(pageIdx);
});
}
}
}
if (this.state.query === '') {
this.updateUIState(FindState.FOUND);
this._updateUIState(FindState.FOUND);
return;
}
if (this.resumePageIdx) {
@ -328,49 +339,38 @@ var PDFFindController = function () { @@ -328,49 +339,38 @@ var PDFFindController = function () {
if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
this.hadMatch = true;
offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
this.updateMatch(true);
this._updateMatch(true);
return;
}
this.advanceOffsetPage(previous);
this._advanceOffsetPage(previous);
}
this.nextPageMatch();
this._nextPageMatch();
}
}, {
key: 'matchesReady',
value: function matchesReady(matches) {
key: '_matchesReady',
value: function _matchesReady(matches) {
var offset = this.offset;
var numMatches = matches.length;
var previous = this.state.findPrevious;
if (numMatches) {
this.hadMatch = true;
offset.matchIdx = previous ? numMatches - 1 : 0;
this.updateMatch(true);
this._updateMatch(true);
return true;
}
this.advanceOffsetPage(previous);
this._advanceOffsetPage(previous);
if (offset.wrapped) {
offset.matchIdx = null;
if (this.pagesToSearch < 0) {
this.updateMatch(false);
this._updateMatch(false);
return true;
}
}
return false;
}
}, {
key: 'updateMatchPosition',
value: function updateMatchPosition(pageIndex, matchIndex, elements, beginIdx) {
if (this.selected.matchIdx === matchIndex && this.selected.pageIdx === pageIndex) {
var spot = {
top: FIND_SCROLL_OFFSET_TOP,
left: FIND_SCROLL_OFFSET_LEFT
};
(0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true);
}
}
}, {
key: 'nextPageMatch',
value: function nextPageMatch() {
key: '_nextPageMatch',
value: function _nextPageMatch() {
if (this.resumePageIdx !== null) {
console.error('There can only be one pending page.');
}
@ -382,11 +382,11 @@ var PDFFindController = function () { @@ -382,11 +382,11 @@ var PDFFindController = function () {
this.resumePageIdx = pageIdx;
break;
}
} while (!this.matchesReady(matches));
} while (!this._matchesReady(matches));
}
}, {
key: 'advanceOffsetPage',
value: function advanceOffsetPage(previous) {
key: '_advanceOffsetPage',
value: function _advanceOffsetPage(previous) {
var offset = this.offset;
var numPages = this.extractTextPromises.length;
offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
@ -398,8 +398,8 @@ var PDFFindController = function () { @@ -398,8 +398,8 @@ var PDFFindController = function () {
}
}
}, {
key: 'updateMatch',
value: function updateMatch() {
key: '_updateMatch',
value: function _updateMatch() {
var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var state = FindState.NOT_FOUND;
@ -411,24 +411,24 @@ var PDFFindController = function () { @@ -411,24 +411,24 @@ var PDFFindController = function () {
this.selected.matchIdx = this.offset.matchIdx;
state = wrapped ? FindState.WRAPPED : FindState.FOUND;
if (previousPage !== -1 && previousPage !== this.selected.pageIdx) {
this.updatePage(previousPage);
this._updatePage(previousPage);
}
}
this.updateUIState(state, this.state.findPrevious);
this._updateUIState(state, this.state.findPrevious);
if (this.selected.pageIdx !== -1) {
this.updatePage(this.selected.pageIdx);
this._updatePage(this.selected.pageIdx);
}
}
}, {
key: 'updateUIResultsCount',
value: function updateUIResultsCount() {
key: '_updateUIResultsCount',
value: function _updateUIResultsCount() {
if (this.onUpdateResultsCount) {
this.onUpdateResultsCount(this.matchCount);
}
}
}, {
key: 'updateUIState',
value: function updateUIState(state, previous) {
key: '_updateUIState',
value: function _updateUIState(state, previous) {
if (this.onUpdateState) {
this.onUpdateState(state, previous, this.matchCount);
}

2
package.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "pdfjs-dist",
"version": "2.0.354",
"version": "2.0.357",
"main": "build/pdf.js",
"description": "Generic build of Mozilla's PDF.js library.",
"keywords": [

164
web/pdf_viewer.js

@ -4139,8 +4139,39 @@ var PDFFindController = function () { @@ -4139,8 +4139,39 @@ var PDFFindController = function () {
});
}
}, {
key: 'normalize',
value: function normalize(text) {
key: 'executeCommand',
value: function executeCommand(cmd, state) {
var _this2 = this;
if (this.state === null || cmd !== 'findagain') {
this.dirtyMatch = true;
}
this.state = state;
this._updateUIState(FindState.PENDING);
this._firstPagePromise.then(function () {
_this2._extractText();
clearTimeout(_this2.findTimeout);
if (cmd === 'find') {
_this2.findTimeout = setTimeout(_this2._nextMatch.bind(_this2), FIND_TIMEOUT);
} else {
_this2._nextMatch();
}
});
}
}, {
key: 'updateMatchPosition',
value: function updateMatchPosition(pageIndex, matchIndex, elements, beginIdx) {
if (this.selected.matchIdx === matchIndex && this.selected.pageIdx === pageIndex) {
var spot = {
top: FIND_SCROLL_OFFSET_TOP,
left: FIND_SCROLL_OFFSET_LEFT
};
(0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true);
}
}
}, {
key: '_normalize',
value: function _normalize(text) {
return text.replace(this.normalizationRegex, function (ch) {
return CHARACTERS_TO_NORMALIZE[ch];
});
@ -4182,8 +4213,8 @@ var PDFFindController = function () { @@ -4182,8 +4213,8 @@ var PDFFindController = function () {
}
}
}, {
key: 'calcFindPhraseMatch',
value: function calcFindPhraseMatch(query, pageIndex, pageContent) {
key: '_calculatePhraseMatch',
value: function _calculatePhraseMatch(query, pageIndex, pageContent) {
var matches = [];
var queryLen = query.length;
var matchIdx = -queryLen;
@ -4197,8 +4228,8 @@ var PDFFindController = function () { @@ -4197,8 +4228,8 @@ var PDFFindController = function () {
this.pageMatches[pageIndex] = matches;
}
}, {
key: 'calcFindWordMatch',
value: function calcFindWordMatch(query, pageIndex, pageContent) {
key: '_calculateWordMatch',
value: function _calculateWordMatch(query, pageIndex, pageContent) {
var matchesWithLength = [];
var queryArray = query.match(/\S+/g);
for (var i = 0, len = queryArray.length; i < len; i++) {
@ -4225,10 +4256,10 @@ var PDFFindController = function () { @@ -4225,10 +4256,10 @@ var PDFFindController = function () {
this._prepareMatches(matchesWithLength, this.pageMatches[pageIndex], this.pageMatchesLength[pageIndex]);
}
}, {
key: 'calcFindMatch',
value: function calcFindMatch(pageIndex) {
var pageContent = this.normalize(this.pageContents[pageIndex]);
var query = this.normalize(this.state.query);
key: '_calculateMatch',
value: function _calculateMatch(pageIndex) {
var pageContent = this._normalize(this.pageContents[pageIndex]);
var query = this._normalize(this.state.query);
var caseSensitive = this.state.caseSensitive;
var phraseSearch = this.state.phraseSearch;
var queryLen = query.length;
@ -4240,24 +4271,24 @@ var PDFFindController = function () { @@ -4240,24 +4271,24 @@ var PDFFindController = function () {
query = query.toLowerCase();
}
if (phraseSearch) {
this.calcFindPhraseMatch(query, pageIndex, pageContent);
this._calculatePhraseMatch(query, pageIndex, pageContent);
} else {
this.calcFindWordMatch(query, pageIndex, pageContent);
this._calculateWordMatch(query, pageIndex, pageContent);
}
this.updatePage(pageIndex);
this._updatePage(pageIndex);
if (this.resumePageIdx === pageIndex) {
this.resumePageIdx = null;
this.nextPageMatch();
this._nextPageMatch();
}
if (this.pageMatches[pageIndex].length > 0) {
this.matchCount += this.pageMatches[pageIndex].length;
this.updateUIResultsCount();
this._updateUIResultsCount();
}
}
}, {
key: 'extractText',
value: function extractText() {
var _this2 = this;
key: '_extractText',
value: function _extractText() {
var _this3 = this;
if (this.startedTextExtraction) {
return;
@ -4268,19 +4299,19 @@ var PDFFindController = function () { @@ -4268,19 +4299,19 @@ var PDFFindController = function () {
var _loop = function _loop(i, ii) {
var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
_this2.extractTextPromises[i] = extractTextCapability.promise;
_this3.extractTextPromises[i] = extractTextCapability.promise;
promise = promise.then(function () {
return _this2.pdfViewer.getPageTextContent(i).then(function (textContent) {
return _this3.pdfViewer.getPageTextContent(i).then(function (textContent) {
var textItems = textContent.items;
var strBuf = [];
for (var j = 0, jj = textItems.length; j < jj; j++) {
strBuf.push(textItems[j].str);
}
_this2.pageContents[i] = strBuf.join('');
_this3.pageContents[i] = strBuf.join('');
extractTextCapability.resolve(i);
}, function (reason) {
console.error('Unable to get page ' + (i + 1) + ' text content', reason);
_this2.pageContents[i] = '';
_this3.pageContents[i] = '';
extractTextCapability.resolve(i);
});
});
@ -4291,28 +4322,8 @@ var PDFFindController = function () { @@ -4291,28 +4322,8 @@ var PDFFindController = function () {
}
}
}, {
key: 'executeCommand',
value: function executeCommand(cmd, state) {
var _this3 = this;
if (this.state === null || cmd !== 'findagain') {
this.dirtyMatch = true;
}
this.state = state;
this.updateUIState(FindState.PENDING);
this._firstPagePromise.then(function () {
_this3.extractText();
clearTimeout(_this3.findTimeout);
if (cmd === 'find') {
_this3.findTimeout = setTimeout(_this3.nextMatch.bind(_this3), FIND_TIMEOUT);
} else {
_this3.nextMatch();
}
});
}
}, {
key: 'updatePage',
value: function updatePage(index) {
key: '_updatePage',
value: function _updatePage(index) {
if (this.selected.pageIdx === index) {
this.pdfViewer.currentPageNumber = index + 1;
}
@ -4322,8 +4333,8 @@ var PDFFindController = function () { @@ -4322,8 +4333,8 @@ var PDFFindController = function () {
}
}
}, {
key: 'nextMatch',
value: function nextMatch() {
key: '_nextMatch',
value: function _nextMatch() {
var _this4 = this;
var previous = this.state.findPrevious;
@ -4341,18 +4352,18 @@ var PDFFindController = function () { @@ -4341,18 +4352,18 @@ var PDFFindController = function () {
this.matchCount = 0;
this.pageMatchesLength = null;
for (var i = 0; i < numPages; i++) {
this.updatePage(i);
this._updatePage(i);
if (!(i in this.pendingFindMatches)) {
this.pendingFindMatches[i] = true;
this.extractTextPromises[i].then(function (pageIdx) {
delete _this4.pendingFindMatches[pageIdx];
_this4.calcFindMatch(pageIdx);
_this4._calculateMatch(pageIdx);
});
}
}
}
if (this.state.query === '') {
this.updateUIState(FindState.FOUND);
this._updateUIState(FindState.FOUND);
return;
}
if (this.resumePageIdx) {
@ -4365,49 +4376,38 @@ var PDFFindController = function () { @@ -4365,49 +4376,38 @@ var PDFFindController = function () {
if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
this.hadMatch = true;
offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
this.updateMatch(true);
this._updateMatch(true);
return;
}
this.advanceOffsetPage(previous);
this._advanceOffsetPage(previous);
}
this.nextPageMatch();
this._nextPageMatch();
}
}, {
key: 'matchesReady',
value: function matchesReady(matches) {
key: '_matchesReady',
value: function _matchesReady(matches) {
var offset = this.offset;
var numMatches = matches.length;
var previous = this.state.findPrevious;
if (numMatches) {
this.hadMatch = true;
offset.matchIdx = previous ? numMatches - 1 : 0;
this.updateMatch(true);
this._updateMatch(true);
return true;
}
this.advanceOffsetPage(previous);
this._advanceOffsetPage(previous);
if (offset.wrapped) {
offset.matchIdx = null;
if (this.pagesToSearch < 0) {
this.updateMatch(false);
this._updateMatch(false);
return true;
}
}
return false;
}
}, {
key: 'updateMatchPosition',
value: function updateMatchPosition(pageIndex, matchIndex, elements, beginIdx) {
if (this.selected.matchIdx === matchIndex && this.selected.pageIdx === pageIndex) {
var spot = {
top: FIND_SCROLL_OFFSET_TOP,
left: FIND_SCROLL_OFFSET_LEFT
};
(0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true);
}
}
}, {
key: 'nextPageMatch',
value: function nextPageMatch() {
key: '_nextPageMatch',
value: function _nextPageMatch() {
if (this.resumePageIdx !== null) {
console.error('There can only be one pending page.');
}
@ -4419,11 +4419,11 @@ var PDFFindController = function () { @@ -4419,11 +4419,11 @@ var PDFFindController = function () {
this.resumePageIdx = pageIdx;
break;
}
} while (!this.matchesReady(matches));
} while (!this._matchesReady(matches));
}
}, {
key: 'advanceOffsetPage',
value: function advanceOffsetPage(previous) {
key: '_advanceOffsetPage',
value: function _advanceOffsetPage(previous) {
var offset = this.offset;
var numPages = this.extractTextPromises.length;
offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
@ -4435,8 +4435,8 @@ var PDFFindController = function () { @@ -4435,8 +4435,8 @@ var PDFFindController = function () {
}
}
}, {
key: 'updateMatch',
value: function updateMatch() {
key: '_updateMatch',
value: function _updateMatch() {
var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var state = FindState.NOT_FOUND;
@ -4448,24 +4448,24 @@ var PDFFindController = function () { @@ -4448,24 +4448,24 @@ var PDFFindController = function () {
this.selected.matchIdx = this.offset.matchIdx;
state = wrapped ? FindState.WRAPPED : FindState.FOUND;
if (previousPage !== -1 && previousPage !== this.selected.pageIdx) {
this.updatePage(previousPage);
this._updatePage(previousPage);
}
}
this.updateUIState(state, this.state.findPrevious);
this._updateUIState(state, this.state.findPrevious);
if (this.selected.pageIdx !== -1) {
this.updatePage(this.selected.pageIdx);
this._updatePage(this.selected.pageIdx);
}
}
}, {
key: 'updateUIResultsCount',
value: function updateUIResultsCount() {
key: '_updateUIResultsCount',
value: function _updateUIResultsCount() {
if (this.onUpdateResultsCount) {
this.onUpdateResultsCount(this.matchCount);
}
}
}, {
key: 'updateUIState',
value: function updateUIState(state, previous) {
key: '_updateUIState',
value: function _updateUIState(state, previous) {
if (this.onUpdateState) {
this.onUpdateState(state, previous, this.matchCount);
}

2
web/pdf_viewer.js.map

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save