hterm: Preserve selection when scrolling collapsed selections
Currently we don't preserve collapsed selections when scrolling the
terminal (collapsed selections are those where the start/end of the
selection is the same point). Usually there would be no need, but it's
useful to do this for screen readers because they may use collapsed
selection to indicate the point they are navigated to. If this selection
isn't preserved, the screen reader will navigate to the parent element
when the row is removed.
This behavior isn't enabled by default because it can cause extra work
to be done during the ScrollPort.redraw_() function which is called
often. Instead it's only enabled when a screen reader is active.
Bug: 822490, 646690
Change-Id: I74ca85a6cf87f7120ac04e2765a34f9e2a1a7da7
Reviewed-on: https://chromium-review.googlesource.com/1074573
Tested-by: Raymes Khoury <raymes@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/hterm/js/hterm_terminal.js b/hterm/js/hterm_terminal.js
index ac890ec..308fe3f 100644
--- a/hterm/js/hterm_terminal.js
+++ b/hterm/js/hterm_terminal.js
@@ -2286,16 +2286,19 @@
};
/**
- * Set live output for accessibility.
+ * Enable accessibility-friendly features that have a performance impact.
*
* This will generate additional DOM nodes in an aria-live region that will
- * cause Assitive Technology to announce the output of the terminal. This isn't
- * enabled by default as it can have a performance impact.
+ * cause Assitive Technology to announce the output of the terminal. It also
+ * enables other features that aid assistive technology. All the features gated
+ * behind this flag have a performance impact on the terminal which is why they
+ * are made optional.
*
- * @param {boolean} enabled Whether to enable live output.
+ * @param {boolean} enabled Whether to enable accessibility-friendly features.
*/
-hterm.Terminal.prototype.setLiveOutputForAccessibility = function(enabled) {
+hterm.Terminal.prototype.setAccessibilityEnabled = function(enabled) {
this.accessibilityEnabled_ = enabled;
+ this.scrollPort_.setAccessibilityEnabled(enabled);
};
/**