accessible/src/windows/msaa/Compatibility.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #include "Compatibility.h"
     9 #include "nsWinUtils.h"
    10 #include "Statistics.h"
    12 #include "mozilla/Preferences.h"
    14 using namespace mozilla;
    15 using namespace mozilla::a11y;
    17 /**
    18  * Return true if module version is lesser than the given version.
    19  */
    20 bool
    21 IsModuleVersionLessThan(HMODULE aModuleHandle, DWORD aMajor, DWORD aMinor)
    22 {
    23   wchar_t fileName[MAX_PATH];
    24   ::GetModuleFileNameW(aModuleHandle, fileName, MAX_PATH);
    26   DWORD dummy = 0;
    27   DWORD length = ::GetFileVersionInfoSizeW(fileName, &dummy);
    29   LPBYTE versionInfo = new BYTE[length];
    30   ::GetFileVersionInfoW(fileName, 0, length, versionInfo);
    32   UINT uLen;
    33   VS_FIXEDFILEINFO* fixedFileInfo = nullptr;
    34   ::VerQueryValueW(versionInfo, L"\\", (LPVOID*)&fixedFileInfo, &uLen);
    35   DWORD dwFileVersionMS = fixedFileInfo->dwFileVersionMS;
    36   DWORD dwFileVersionLS = fixedFileInfo->dwFileVersionLS;
    37   delete [] versionInfo;
    39   DWORD dwLeftMost = HIWORD(dwFileVersionMS);
    40   DWORD dwSecondRight = HIWORD(dwFileVersionLS);
    41   return (dwLeftMost < aMajor ||
    42     (dwLeftMost == aMajor && dwSecondRight < aMinor));
    43 }
    46 ////////////////////////////////////////////////////////////////////////////////
    47 // Compatibility
    48 ////////////////////////////////////////////////////////////////////////////////
    50 uint32_t Compatibility::sConsumers = Compatibility::UNKNOWN;
    52 void
    53 Compatibility::Init()
    54 {
    55   // Note we collect some AT statistics/telemetry here for convenience.
    57   HMODULE jawsHandle = ::GetModuleHandleW(L"jhook");
    58   if (jawsHandle)
    59     sConsumers |= (IsModuleVersionLessThan(jawsHandle, 8, 2173)) ?
    60                    OLDJAWS : JAWS;
    62   if (::GetModuleHandleW(L"gwm32inc"))
    63     sConsumers |= WE;
    65   if (::GetModuleHandleW(L"dolwinhk"))
    66     sConsumers |= DOLPHIN;
    68   if (::GetModuleHandleW(L"STSA32"))
    69     sConsumers |= SEROTEK;
    71   if (::GetModuleHandleW(L"nvdaHelperRemote"))
    72     sConsumers |= NVDA;
    74   if (::GetModuleHandleW(L"OsmHooks"))
    75     sConsumers |= COBRA;
    77   if (::GetModuleHandleW(L"WebFinderRemote"))
    78     sConsumers |= ZOOMTEXT;
    80   if (::GetModuleHandleW(L"Kazahook"))
    81     sConsumers |= KAZAGURU;
    83   if (::GetModuleHandleW(L"TextExtractorImpl32") ||
    84       ::GetModuleHandleW(L"TextExtractorImpl64"))
    85     sConsumers |= YOUDAO;
    87   if (::GetModuleHandleW(L"uiautomation") ||
    88       ::GetModuleHandleW(L"uiautomationcore"))
    89     sConsumers |= UIAUTOMATION;
    91   // If we have a known consumer remove the unknown bit.
    92   if (sConsumers != Compatibility::UNKNOWN)
    93     sConsumers ^= Compatibility::UNKNOWN;
    95   // Gather telemetry
    96   uint32_t temp = sConsumers;
    97   for (int i = 0; temp; i++) {
    98     if (temp & 0x1)
    99       statistics::A11yConsumers(i);
   101     temp >>= 1;
   102   }
   104   // Turn off new tab switching for Jaws and WE.
   105   if (sConsumers & (JAWS | OLDJAWS | WE)) {
   106     // Check to see if the pref for disallowing CtrlTab is already set. If so,
   107     // bail out (respect the user settings). If not, set it.
   108     if (!Preferences::HasUserValue("browser.ctrlTab.disallowForScreenReaders"))
   109       Preferences::SetBool("browser.ctrlTab.disallowForScreenReaders", true);
   110   }
   111 }

mercurial