diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/fg/js/dom-text-scanner.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/ext/fg/js/dom-text-scanner.js b/ext/fg/js/dom-text-scanner.js index 2de65041..8fa67ede 100644 --- a/ext/fg/js/dom-text-scanner.js +++ b/ext/fg/js/dom-text-scanner.js @@ -60,6 +60,15 @@ class DOMTextScanner { } /** + * Gets the remaining number of characters that weren't scanned in the last seek() call. + * This value is usually 0 unless the end of the document was reached. + * @returns An integer. + */ + get remainder() { + return this._remainder; + } + + /** * Gets the accumulated content string resulting from calls to seek(). * @returns A string. */ @@ -85,6 +94,7 @@ class DOMTextScanner { const generateLayoutContent = this._generateLayoutContent; let node = this._node; + let lastNode = node; let resetOffset = this._resetOffset; let newlines = 0; while (node !== null) { @@ -92,6 +102,7 @@ class DOMTextScanner { const nodeType = node.nodeType; if (nodeType === TEXT_NODE) { + lastNode = node; if (!( forward ? this._seekTextNodeForward(node, resetOffset) : @@ -101,6 +112,8 @@ class DOMTextScanner { break; } } else if (nodeType === ELEMENT_NODE) { + lastNode = node; + this._offset = 0; [enterable, newlines] = DOMTextScanner.getElementSeekInfo(node); if (newlines > this._newlines && generateLayoutContent) { this._newlines = newlines; @@ -121,7 +134,7 @@ class DOMTextScanner { resetOffset = true; } - this._node = node; + this._node = lastNode; this._resetOffset = resetOffset; return this; |