Commit 603dbe8b authored by Marco Zehe's avatar Marco Zehe
Browse files

bug 448660 - Turn off new visual Ctrl+tab switching when screen reader...

bug 448660 - Turn off new visual Ctrl+tab switching when screen reader present, r=aaronlev, r=gavin, sr=neil
parent 4782b78c
Loading
Loading
Loading
Loading
+40 −2
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@
 * ***** END LICENSE BLOCK ***** */

#include "nsAccessNodeWrap.h"
#include <tchar.h> 
#include "ISimpleDOMNode_i.c"
#include "nsAccessibilityAtoms.h"
#include "nsIAccessibilityService.h"
@@ -72,6 +71,10 @@ PRBool nsAccessNodeWrap::gIsIA2Disabled = PR_FALSE;

nsIAccessibleTextChangeEvent *nsAccessNodeWrap::gTextEvent = nsnull;

// Pref to disallow CtrlTab preview functionality if JAWS or Window-Eyes are
// running.
#define CTRLTAB_DISALLOW_FOR_SCREEN_READERS_PREF "browser.ctrlTab.disallowForScreenReaders"


/* For documentation of the accessibility architecture, 
 * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
@@ -662,7 +665,7 @@ GetHRESULT(nsresult aResult)

PRBool nsAccessNodeWrap::IsOnlyMsaaCompatibleJawsPresent()
{
  HMODULE jhookhandle = ::GetModuleHandleW(NS_LITERAL_STRING("jhook").get());
  HMODULE jhookhandle = ::GetModuleHandleW(L"jhook");
  if (!jhookhandle)
    return PR_FALSE;  // No JAWS, or some other screen reader, use IA2

@@ -691,9 +694,44 @@ PRBool nsAccessNodeWrap::IsOnlyMsaaCompatibleJawsPresent()
          || (dwLeftMost == 8 && dwSecondRight < 2173));
}

void nsAccessNodeWrap::TurnOffNewTabSwitchingForJawsAndWE()
{
  HMODULE srHandle = ::GetModuleHandleW(L"jhook");
  if (!srHandle) {
    // No JAWS, try Window-Eyes
    srHandle = ::GetModuleHandleW(L"gwm32inc");
    if (!srHandle) {
      // no screen reader we're interested in. Bail out.
      return;
    }
  }

  // Check to see if the pref for disallowing CtrlTab is already set.
  // If so, bail out.
  // If not, set it.
  nsCOMPtr<nsIPrefBranch> prefs (do_GetService(NS_PREFSERVICE_CONTRACTID));
  if (prefs) {
    PRBool hasDisallowNewCtrlTabPref = PR_FALSE;
    nsresult rv = prefs->PrefHasUserValue(CTRLTAB_DISALLOW_FOR_SCREEN_READERS_PREF,
             &hasDisallowNewCtrlTabPref);
    if (NS_SUCCEEDED(rv) && hasDisallowNewCtrlTabPref) {
      // This pref has been set before. There is no default for it.
      // Do nothing further, respect the setting that's there.
      // That way, if noone touches it, it'll stay on after toggled once.
      // If someone decided to turn it off, we respect that, too.
      return;
    }
    
    // Value has never been set, set it.
    prefs->SetBoolPref(CTRLTAB_DISALLOW_FOR_SCREEN_READERS_PREF, PR_TRUE);
  }
}

void nsAccessNodeWrap::DoATSpecificProcessing()
{
  if (IsOnlyMsaaCompatibleJawsPresent())
    // All versions below 8.0.2173 are not compatible
    gIsIA2Disabled  = PR_TRUE;

  TurnOffNewTabSwitchingForJawsAndWE();
}
+3 −0
Original line number Diff line number Diff line
@@ -159,6 +159,9 @@ class nsAccessNodeWrap : public nsAccessNode,
    static int FilterA11yExceptions(unsigned int aCode, EXCEPTION_POINTERS *aExceptionInfo);

    static PRBool IsOnlyMsaaCompatibleJawsPresent();

    static void TurnOffNewTabSwitchingForJawsAndWE();

    static void DoATSpecificProcessing();
  protected:
    void GetAccessibleFor(nsIDOMNode *node, nsIAccessible **newAcc);
+3 −1
Original line number Diff line number Diff line
@@ -1082,7 +1082,9 @@ function delayedStartup()
  gBrowser.addEventListener("command", BrowserOnCommand, false);

  tabPreviews.init();
  if (gPrefService.getBoolPref("browser.ctrlTab.mostRecentlyUsed"))
  if ((!gPrefService.prefHasUserValue("browser.ctrlTab.disallowForScreenReaders") ||
       !gPrefService.getBoolPref("browser.ctrlTab.disallowForScreenReaders")) &&
       gPrefService.getBoolPref("browser.ctrlTab.mostRecentlyUsed"))
    ctrlTab.init();

  // Delayed initialization of the livemarks update timer.