Commit 2464cf89 authored by Anastasia Helfinstein's avatar Anastasia Helfinstein Committed by Commit Bot

Use EventHandler in autoclick extension

This is a pure refactor.

AX-Relnotes: n/a.
Bug: None.
Change-Id: Ie49ab8152b5fdd7b876dbf07346015c15717740a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391605Reviewed-by: default avatarAbigail Klein <abigailbklein@google.com>
Commit-Queue: Anastasia Helfinstein <anastasi@google.com>
Cr-Commit-Position: refs/heads/master@{#812398}
parent 29736b94
...@@ -97,6 +97,7 @@ js_library("accessibility_common") { ...@@ -97,6 +97,7 @@ js_library("accessibility_common") {
js_library("autoclick") { js_library("autoclick") {
sources = [ "autoclick/autoclick.js" ] sources = [ "autoclick/autoclick.js" ]
deps = [ "../common:event_handler" ]
externs_list = [ externs_list = [
"$externs_path/accessibility_private.js", "$externs_path/accessibility_private.js",
"$externs_path/automation.js", "$externs_path/automation.js",
......
...@@ -39,9 +39,11 @@ class Autoclick { ...@@ -39,9 +39,11 @@ class Autoclick {
this.scrollableBoundsListener_ = null; this.scrollableBoundsListener_ = null;
/** /**
* @private {?function(!chrome.automation.AutomationEvent)} * @private {!EventHandler}
*/ */
this.hitTestListener_ = null; this.hitTestHandler_ = new EventHandler(
[], chrome.automation.EventType.MOUSE_PRESSED,
this.onAutomationHitTestResult_.bind(this), {capture: true});
this.init_(); this.init_();
} }
...@@ -60,12 +62,7 @@ class Autoclick { ...@@ -60,12 +62,7 @@ class Autoclick {
this.scrollableBoundsListener_ = null; this.scrollableBoundsListener_ = null;
} }
if (this.desktop_ && this.hitTestListener_) { this.hitTestHandler_.stop();
this.desktop_.removeEventListener(
chrome.automation.EventType.MOUSE_PRESSED, this.hitTestListener_,
true);
this.hitTestListener_ = null;
}
} }
/** /**
...@@ -78,13 +75,11 @@ class Autoclick { ...@@ -78,13 +75,11 @@ class Autoclick {
chrome.automation.getDesktop((desktop) => { chrome.automation.getDesktop((desktop) => {
this.desktop_ = desktop; this.desktop_ = desktop;
this.hitTestListener_ = this.onAutomationHitTestResult_.bind(this);
// We use a hit test at a point to determine what automation node is // We use a hit test at a point to determine what automation node is
// at that point, in order to find the scrollable area. // at that point, in order to find the scrollable area.
this.desktop_.addEventListener( this.hitTestHandler_.setNodes(this.desktop_);
chrome.automation.EventType.MOUSE_PRESSED, this.hitTestListener_, this.hitTestHandler_.start();
true);
}); });
chrome.accessibilityPrivate.onScrollableBoundsForPointRequested.addListener( chrome.accessibilityPrivate.onScrollableBoundsForPointRequested.addListener(
...@@ -180,4 +175,4 @@ class Autoclick { ...@@ -180,4 +175,4 @@ class Autoclick {
// which will do the logic for finding the scrolling container. // which will do the logic for finding the scrolling container.
this.desktop_.hitTest(x, y, chrome.automation.EventType.MOUSE_PRESSED); this.desktop_.hitTest(x, y, chrome.automation.EventType.MOUSE_PRESSED);
} }
} }
\ No newline at end of file
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
"scripts": [ "scripts": [
"accessibility_common/autoclick/autoclick.js", "accessibility_common/autoclick/autoclick.js",
"accessibility_common/magnifier/magnifier.js", "accessibility_common/magnifier/magnifier.js",
"accessibility_common/accessibility_common_loader.js" "accessibility_common/accessibility_common_loader.js",
"common/event_handler.js"
] ]
}, },
"permissions": [ "permissions": [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment