Commit f2624318 authored by Rose Garcia's avatar Rose Garcia Committed by Commit Bot

Put selection and cut/copy/paste listener behind text editing flag.

Put the selection change listener and the clipboard data change listener
behind the text editing improvements flag. This makes sure the menu isn't
reloading uncessarily when the flag is not used.

Bug: 982004
Change-Id: Iafde32d263e41030ba54a6b5ae98bed2c968d8f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1746790
Commit-Queue: Rose Garcia <rosalindag@google.com>
Reviewed-by: default avatarAnastasia Helfinstein <anastasi@google.com>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686611}
parent 414bb905
...@@ -79,7 +79,9 @@ class MenuManager { ...@@ -79,7 +79,9 @@ class MenuManager {
*/ */
this.menuPanel_; this.menuPanel_;
this.init_(); if (window.switchAccess.improvedTextInputEnabled()) {
this.init_();
}
} }
/** /**
...@@ -123,9 +125,12 @@ class MenuManager { ...@@ -123,9 +125,12 @@ class MenuManager {
chrome.accessibilityPrivate.setSwitchAccessMenuState( chrome.accessibilityPrivate.setSwitchAccessMenuState(
true, navNode.location, actions.length); true, navNode.location, actions.length);
this.menuOriginNode_ = navNode; this.menuOriginNode_ = navNode;
this.menuOriginNode_.addEventListener( if (window.switchAccess.improvedTextInputEnabled()) {
chrome.automation.EventType.TEXT_SELECTION_CHANGED, this.menuOriginNode_.addEventListener(
this.onSelectionChanged_.bind(this), false /** Don't use capture. */); chrome.automation.EventType.TEXT_SELECTION_CHANGED,
this.onSelectionChanged_.bind(this),
false /** Don't use capture. */);
}
} else { } else {
console.log('Unable to show Switch Access menu.'); console.log('Unable to show Switch Access menu.');
} }
...@@ -191,9 +196,11 @@ class MenuManager { ...@@ -191,9 +196,11 @@ class MenuManager {
if (this.node_) if (this.node_)
this.node_ = null; this.node_ = null;
this.menuOriginNode_.removeEventListener( if (window.switchAccess.improvedTextInputEnabled()) {
chrome.automation.EventType.TEXT_SELECTION_CHANGED, this.menuOriginNode_.removeEventListener(
this.onSelectionChanged_.bind(this), false /** Don't use capture. */); chrome.automation.EventType.TEXT_SELECTION_CHANGED,
this.onSelectionChanged_.bind(this), false /** Don't use capture. */);
}
chrome.accessibilityPrivate.setSwitchAccessMenuState( chrome.accessibilityPrivate.setSwitchAccessMenuState(
false /** Hide the menu. */, SAConstants.EMPTY_LOCATION, 0); false /** Hide the menu. */, SAConstants.EMPTY_LOCATION, 0);
} }
......
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
<button class="action" id="moveUpOneLineOfText"> <button class="action" id="moveUpOneLineOfText">
<img src="icons/moveUpOneLineOfText.svg"> <img src="icons/moveUpOneLineOfText.svg">
<p class="i18n" msgid="move_up_one_line_of_text"></p> <p class="i18n" msgid="move_up_one_line_of_text"></p>
</button>
<button class="action" id="selectStart"> <button class="action" id="selectStart">
<img src="icons/textSelectionStart.svg"> <img src="icons/textSelectionStart.svg">
<p class="i18n" msgid="selection_start"></p> <p class="i18n" msgid="selection_start"></p>
......
...@@ -62,6 +62,11 @@ class SwitchAccess { ...@@ -62,6 +62,11 @@ class SwitchAccess {
* @private * @private
*/ */
init_() { init_() {
chrome.commandLinePrivate.hasSwitch(
'enable-experimental-accessibility-switch-access-text', (result) => {
this.enableImprovedTextInput_ = result;
});
this.commands_ = new Commands(this); this.commands_ = new Commands(this);
this.autoScanManager_ = new AutoScanManager(this); this.autoScanManager_ = new AutoScanManager(this);
const onPrefsReady = const onPrefsReady =
...@@ -75,11 +80,6 @@ class SwitchAccess { ...@@ -75,11 +80,6 @@ class SwitchAccess {
if (this.navReadyCallback_) if (this.navReadyCallback_)
this.navReadyCallback_(); this.navReadyCallback_();
}.bind(this)); }.bind(this));
chrome.commandLinePrivate.hasSwitch(
'enable-experimental-accessibility-switch-access-text', (result) => {
this.enableImprovedTextInput_ = result;
});
} }
/** /**
......
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