accessible/src/windows/msaa/Compatibility.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial