limit popup depth live

This commit is contained in:
siikamiika 2020-04-10 02:48:41 +03:00
parent 61a96e327a
commit 1df59d57b5
2 changed files with 9 additions and 2 deletions

View File

@ -30,7 +30,8 @@ class Frontend extends TextScanner {
super( super(
window, window,
popup.isProxy() ? [] : [popup.getContainer()], popup.isProxy() ? [] : [popup.getContainer()],
[(x, y) => this.popup.containsPoint(x, y)] [(x, y) => this.popup.containsPoint(x, y)],
() => this.popup.depth <= this.options.scanning.popupNestingMaxDepth
); );
this.popup = popup; this.popup = popup;

View File

@ -22,11 +22,13 @@
*/ */
class TextScanner { class TextScanner {
constructor(node, ignoreElements, ignorePoints) { constructor(node, ignoreElements, ignorePoints, canEnable=null) {
this.node = node; this.node = node;
this.ignoreElements = ignoreElements; this.ignoreElements = ignoreElements;
this.ignorePoints = ignorePoints; this.ignorePoints = ignorePoints;
this.canEnable = canEnable;
this.ignoreNodes = null; this.ignoreNodes = null;
this.scanTimerPromise = null; this.scanTimerPromise = null;
@ -225,6 +227,10 @@ class TextScanner {
} }
setEnabled(enabled) { setEnabled(enabled) {
if (this.canEnable !== null && !this.canEnable()) {
enabled = false;
}
if (enabled) { if (enabled) {
if (!this.enabled) { if (!this.enabled) {
this.hookEvents(); this.hookEvents();