Refactoring PDFFindController in the text layer builder
This commit is contained in:
parent
a968da8887
commit
fa33b9c643
@ -39,10 +39,7 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
|
|||||||
this.viewport = options.viewport;
|
this.viewport = options.viewport;
|
||||||
this.isViewerInPresentationMode = options.isViewerInPresentationMode;
|
this.isViewerInPresentationMode = options.isViewerInPresentationMode;
|
||||||
this.textDivs = [];
|
this.textDivs = [];
|
||||||
|
this.findController = window.PDFFindController || null;
|
||||||
if (typeof PDFFindController === 'undefined') {
|
|
||||||
window.PDFFindController = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextLayerBuilder.prototype = {
|
TextLayerBuilder.prototype = {
|
||||||
@ -152,8 +149,8 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
|
|||||||
var iIndex = 0;
|
var iIndex = 0;
|
||||||
var bidiTexts = this.textContent.items;
|
var bidiTexts = this.textContent.items;
|
||||||
var end = bidiTexts.length - 1;
|
var end = bidiTexts.length - 1;
|
||||||
var queryLen = (PDFFindController === null ?
|
var queryLen = (this.findController === null ?
|
||||||
0 : PDFFindController.state.query.length);
|
0 : this.findController.state.query.length);
|
||||||
var ret = [];
|
var ret = [];
|
||||||
|
|
||||||
for (var m = 0, len = matches.length; m < len; m++) {
|
for (var m = 0, len = matches.length; m < len; m++) {
|
||||||
@ -206,12 +203,12 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
|
|||||||
var bidiTexts = this.textContent.items;
|
var bidiTexts = this.textContent.items;
|
||||||
var textDivs = this.textDivs;
|
var textDivs = this.textDivs;
|
||||||
var prevEnd = null;
|
var prevEnd = null;
|
||||||
var isSelectedPage = (PDFFindController === null ?
|
var isSelectedPage = (this.findController === null ?
|
||||||
false : (this.pageIdx === PDFFindController.selected.pageIdx));
|
false : (this.pageIdx === this.findController.selected.pageIdx));
|
||||||
var selectedMatchIdx = (PDFFindController === null ?
|
var selectedMatchIdx = (this.findController === null ?
|
||||||
-1 : PDFFindController.selected.matchIdx);
|
-1 : this.findController.selected.matchIdx);
|
||||||
var highlightAll = (PDFFindController === null ?
|
var highlightAll = (this.findController === null ?
|
||||||
false : PDFFindController.state.highlightAll);
|
false : this.findController.state.highlightAll);
|
||||||
var infinity = {
|
var infinity = {
|
||||||
divIdx: -1,
|
divIdx: -1,
|
||||||
offset: undefined
|
offset: undefined
|
||||||
@ -314,14 +311,14 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
|
|||||||
clearedUntilDivIdx = match.end.divIdx + 1;
|
clearedUntilDivIdx = match.end.divIdx + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDFFindController === null || !PDFFindController.active) {
|
if (this.findController === null || !this.findController.active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the matches on the page controller into the match format
|
// Convert the matches on the page controller into the match format
|
||||||
// used for the textLayer.
|
// used for the textLayer.
|
||||||
this.matches = this.convertMatches(PDFFindController === null ?
|
this.matches = this.convertMatches(this.findController === null ?
|
||||||
[] : (PDFFindController.pageMatches[this.pageIdx] || []));
|
[] : (this.findController.pageMatches[this.pageIdx] || []));
|
||||||
this.renderMatches(this.matches);
|
this.renderMatches(this.matches);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user