Refactor the text layer code in order to avoid to recompute it on each draw

The idea is just to resuse what we got on the first draw.
Now, we only update the scaleX of the different spans and the other values
are dependant of --scale-factor.
Move some properties in the CSS in order to avoid any updates in JS.
This commit is contained in:
Calixte Denizet 2022-11-21 17:15:39 +01:00
parent fa54a58790
commit eed9bf71c5
13 changed files with 362 additions and 240 deletions

View file

@ -95,6 +95,7 @@ class TextHighlighter {
);
this._onUpdateTextLayerMatches = null;
}
this._updateMatches(/* reset = */ true);
}
_convertMatches(matches, matchesLength) {
@ -264,8 +265,8 @@ class TextHighlighter {
}
}
_updateMatches() {
if (!this.enabled) {
_updateMatches(reset = false) {
if (!this.enabled && !reset) {
return;
}
const { findController, matches, pageIdx } = this;
@ -283,7 +284,7 @@ class TextHighlighter {
clearedUntilDivIdx = match.end.divIdx + 1;
}
if (!findController?.highlightMatches) {
if (!findController?.highlightMatches || reset) {
return;
}
// Convert the matches on the `findController` into the match format