Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1377)

Unified Diff: third_party/google_input_tools/third_party/closure_library/closure/goog/a11y/aria/announcer.js

Issue 1257313003: Update Google Input Tools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Free up grd resources. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/google_input_tools/third_party/closure_library/closure/goog/a11y/aria/announcer.js
diff --git a/third_party/google_input_tools/third_party/closure_library/closure/goog/a11y/aria/announcer.js b/third_party/google_input_tools/third_party/closure_library/closure/goog/a11y/aria/announcer.js
index ee87199bc9991871f23cebf7d8fbf590fab7c2e6..681826442d35415281171891cbb6a76e88c01bbb 100644
--- a/third_party/google_input_tools/third_party/closure_library/closure/goog/a11y/aria/announcer.js
+++ b/third_party/google_input_tools/third_party/closure_library/closure/goog/a11y/aria/announcer.js
@@ -21,10 +21,12 @@
goog.provide('goog.a11y.aria.Announcer');
goog.require('goog.Disposable');
+goog.require('goog.Timer');
goog.require('goog.a11y.aria');
goog.require('goog.a11y.aria.LivePriority');
goog.require('goog.a11y.aria.State');
goog.require('goog.dom');
+goog.require('goog.dom.TagName');
goog.require('goog.object');
@@ -50,7 +52,7 @@ goog.a11y.aria.Announcer = function(opt_domHelper) {
/**
* Map of priority to live region elements to use for communicating updates.
* Elements are created on demand.
- * @type {Object.<goog.a11y.aria.LivePriority, !Element>}
+ * @type {Object<goog.a11y.aria.LivePriority, !Element>}
* @private
*/
this.liveRegions_ = {};
@@ -76,8 +78,17 @@ goog.a11y.aria.Announcer.prototype.disposeInternal = function() {
* message. Defaults to POLITE.
*/
goog.a11y.aria.Announcer.prototype.say = function(message, opt_priority) {
- goog.dom.setTextContent(this.getLiveRegion_(
- opt_priority || goog.a11y.aria.LivePriority.POLITE), message);
+ var priority = opt_priority || goog.a11y.aria.LivePriority.POLITE;
+ var liveRegion = this.getLiveRegion_(priority);
+ // Resets text content to force a DOM mutation (so that the setTextContent
+ // post-timeout function will be noticed by the screen reader). This is to
+ // avoid the problem of when the same message is "said" twice, which doesn't
+ // trigger a DOM mutation.
+ goog.dom.setTextContent(liveRegion, '');
+ // Uses non-zero timer to make VoiceOver and NVDA work
+ goog.Timer.callOnce(function() {
+ goog.dom.setTextContent(liveRegion, message);
+ }, 1);
};
@@ -94,7 +105,8 @@ goog.a11y.aria.Announcer.prototype.getLiveRegion_ = function(priority) {
goog.a11y.aria.removeState(liveRegion, goog.a11y.aria.State.HIDDEN);
return liveRegion;
}
- liveRegion = this.domHelper_.createElement('div');
+
+ liveRegion = this.domHelper_.createElement(goog.dom.TagName.DIV);
// Note that IE has a habit of declaring things that aren't display:none as
// invisible to third-party tools like JAWs, so we can't just use height:0.
liveRegion.style.position = 'absolute';

Powered by Google App Engine
This is Rietveld 408576698