Bug 783084 - Activate AccessFu when screen reader is enabled in B2G. r=davidb
authorEitan Isaacson <eitan@monotonous.org>
Fri, 17 Aug 2012 15:49:34 -0700
changeset 102687 3131d6765a0e611773a1657ffb9a9f765ab07a03
parent 102686 117688e8aa1d507c14f7c3ae8f1b40cdedf9afda
child 102688 2e24233c9339e69ed785b95a71efe004f0a97d2a
push id23303
push userryanvm@gmail.com
push dateSat, 18 Aug 2012 11:22:19 +0000
treeherdermozilla-central@9c48df21d744 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidb
bugs783084
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 783084 - Activate AccessFu when screen reader is enabled in B2G. r=davidb
accessible/src/jsat/AccessFu.jsm
--- a/accessible/src/jsat/AccessFu.jsm
+++ b/accessible/src/jsat/AccessFu.jsm
@@ -42,16 +42,24 @@ var AccessFu = {
     this.prefsBranch = Cc['@mozilla.org/preferences-service;1']
       .getService(Ci.nsIPrefService).getBranch('accessibility.accessfu.');
     this.prefsBranch.addObserver('activate', this, false);
     this.prefsBranch.addObserver('explorebytouch', this, false);
 
     if (Utils.MozBuildApp == 'mobile/android')
       Services.obs.addObserver(this, 'Accessibility:Settings', false);
 
+    if (Utils.MozBuildApp == 'b2g')
+      aWindow.addEventListener(
+        'ContentStart',
+        (function(event) {
+           let content = aWindow.shell.contentBrowser.contentWindow;
+           content.addEventListener('mozContentEvent', this, false, true);
+         }).bind(this), false);
+
     this._processPreferences();
   },
 
   /**
    * Start AccessFu mode, this primarily means controlling the virtual cursor
    * with arrow keys.
    */
   _enable: function _enable() {
@@ -187,16 +195,24 @@ var AccessFu = {
         break;
       }
       case 'scroll':
       case 'resize':
       {
         this.presenters.forEach(function(p) { p.viewportChanged(); });
         break;
       }
+      case 'mozContentEvent':
+      {
+        if (aEvent.detail.type == 'accessibility-screenreader') {
+          let pref = aEvent.detail.enabled + 0;
+          this._processPreferences(pref, pref);
+        }
+        break;
+      }
     }
   },
 
   observe: function observe(aSubject, aTopic, aData) {
     switch (aTopic) {
       case 'Accessibility:Settings':
         this._processPreferences(JSON.parse(aData).enabled + 0,
                                  JSON.parse(aData).exploreByTouch + 0);