Skip to content

Instantly share code, notes, and snippets.

@takenspc
Last active December 19, 2015 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takenspc/5943284 to your computer and use it in GitHub Desktop.
Save takenspc/5943284 to your computer and use it in GitHub Desktop.
AccessFu: Display speech output
diff --git a/accessible/src/jsat/AccessFu.css b/accessible/src/jsat/AccessFu.css
--- a/accessible/src/jsat/AccessFu.css
+++ b/accessible/src/jsat/AccessFu.css
@@ -47,8 +47,23 @@
-moz-transition: opacity 0.2s linear;
}
#announce-box * {
text-align: center;
display: table-cell;
vertical-align: middle;
}
+
+#speech-box {
+ position: fixed;
+ pointer-events: none;
+ bottom: 0;
+ width: 100%;
+ max-height: 2rem;
+ overflow: hidden;
+ background: #a40000;
+ opacity: 0.5;
+ text-align: center;
+ color: white;
+ font-size: 0.75rem;
+ text-overflow: ellipsis;
+}
diff --git a/accessible/src/jsat/AccessFu.jsm b/accessible/src/jsat/AccessFu.jsm
--- a/accessible/src/jsat/AccessFu.jsm
+++ b/accessible/src/jsat/AccessFu.jsm
@@ -370,18 +370,39 @@ var Output = {
if (this.announceBox) {
Utils.win.document.documentElement.removeChild(this.announceBox.get());
delete this.announceBox;
}
},
Speech: function Speech(aDetails, aBrowser) {
- for each (let action in aDetails.actions)
+ for each (let action in aDetails.actions) {
Logger.info('tts.' + action.method, '"' + action.data + '"', JSON.stringify(action.options));
+ if (action.method === 'speak') {
+ let speechBox = null;
+ if (!this.speechBox) {
+ // Add speech box
+ speechBox = Utils.win.document.
+ createElementNS('http://www.w3.org/1999/xhtml', 'div');
+ Utils.win.document.documentElement.appendChild(speechBox);
+ speechBox.id = 'speech-box';
+ speechBox.setAttribute('aria-hidden', 'true');
+ speechBox.setAttribute('role', 'presentation');
+
+ this.speechBox = Cu.getWeakReference(speechBox);
+ } else {
+ speechBox = this.speechBox.get();
+ }
+
+ speechBox.style.display = 'none';
+ speechBox.textContent = action.data;
+ speechBox.style.display = 'block';
+ }
+ }
},
Visual: function Visual(aDetails, aBrowser) {
switch (aDetails.method) {
case 'showBounds':
{
let highlightBox = null;
if (!this.highlightBox) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment