From dc6e2ed6f8c451a9dbb4ca58df0df7303d8cb265 Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Mon, 28 Mar 2022 02:34:00 +0200 Subject: [PATCH] PDFScriptingManager: Bind mousedown listener with capture=true PDFScriptingManager uses the `mousedown` and `mouseup` listeners to keep track of whether the mouse pointer is pressed in the `isDown` flag. These listeners were registered to run during the bubbling phase of the event dispatch, which can be interrupted if any of the previous event listeners stopped the event propagation. An example of that is by `GrabToPan` in web/grab_to_pan.js. Since the mousedown (and mouseup) listeners of PDFScriptingManager are free of side effects, and the intention is to always run them, it makes most sense to register them with the capture flag. --- web/pdf_scripting_manager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/pdf_scripting_manager.js b/web/pdf_scripting_manager.js index a07cad2b3..a65d2c02a 100644 --- a/web/pdf_scripting_manager.js +++ b/web/pdf_scripting_manager.js @@ -154,7 +154,7 @@ class PDFScriptingManager { this._eventBus._on(name, listener); } for (const [name, listener] of this._domEvents) { - window.addEventListener(name, listener); + window.addEventListener(name, listener, true); } try { @@ -507,7 +507,7 @@ class PDFScriptingManager { this._internalEvents.clear(); for (const [name, listener] of this._domEvents) { - window.removeEventListener(name, listener); + window.removeEventListener(name, listener, true); } this._domEvents.clear();