1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/src/windows/msaa/Compatibility.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,112 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "Compatibility.h" 1.11 + 1.12 +#include "nsWinUtils.h" 1.13 +#include "Statistics.h" 1.14 + 1.15 +#include "mozilla/Preferences.h" 1.16 + 1.17 +using namespace mozilla; 1.18 +using namespace mozilla::a11y; 1.19 + 1.20 +/** 1.21 + * Return true if module version is lesser than the given version. 1.22 + */ 1.23 +bool 1.24 +IsModuleVersionLessThan(HMODULE aModuleHandle, DWORD aMajor, DWORD aMinor) 1.25 +{ 1.26 + wchar_t fileName[MAX_PATH]; 1.27 + ::GetModuleFileNameW(aModuleHandle, fileName, MAX_PATH); 1.28 + 1.29 + DWORD dummy = 0; 1.30 + DWORD length = ::GetFileVersionInfoSizeW(fileName, &dummy); 1.31 + 1.32 + LPBYTE versionInfo = new BYTE[length]; 1.33 + ::GetFileVersionInfoW(fileName, 0, length, versionInfo); 1.34 + 1.35 + UINT uLen; 1.36 + VS_FIXEDFILEINFO* fixedFileInfo = nullptr; 1.37 + ::VerQueryValueW(versionInfo, L"\\", (LPVOID*)&fixedFileInfo, &uLen); 1.38 + DWORD dwFileVersionMS = fixedFileInfo->dwFileVersionMS; 1.39 + DWORD dwFileVersionLS = fixedFileInfo->dwFileVersionLS; 1.40 + delete [] versionInfo; 1.41 + 1.42 + DWORD dwLeftMost = HIWORD(dwFileVersionMS); 1.43 + DWORD dwSecondRight = HIWORD(dwFileVersionLS); 1.44 + return (dwLeftMost < aMajor || 1.45 + (dwLeftMost == aMajor && dwSecondRight < aMinor)); 1.46 +} 1.47 + 1.48 + 1.49 +//////////////////////////////////////////////////////////////////////////////// 1.50 +// Compatibility 1.51 +//////////////////////////////////////////////////////////////////////////////// 1.52 + 1.53 +uint32_t Compatibility::sConsumers = Compatibility::UNKNOWN; 1.54 + 1.55 +void 1.56 +Compatibility::Init() 1.57 +{ 1.58 + // Note we collect some AT statistics/telemetry here for convenience. 1.59 + 1.60 + HMODULE jawsHandle = ::GetModuleHandleW(L"jhook"); 1.61 + if (jawsHandle) 1.62 + sConsumers |= (IsModuleVersionLessThan(jawsHandle, 8, 2173)) ? 1.63 + OLDJAWS : JAWS; 1.64 + 1.65 + if (::GetModuleHandleW(L"gwm32inc")) 1.66 + sConsumers |= WE; 1.67 + 1.68 + if (::GetModuleHandleW(L"dolwinhk")) 1.69 + sConsumers |= DOLPHIN; 1.70 + 1.71 + if (::GetModuleHandleW(L"STSA32")) 1.72 + sConsumers |= SEROTEK; 1.73 + 1.74 + if (::GetModuleHandleW(L"nvdaHelperRemote")) 1.75 + sConsumers |= NVDA; 1.76 + 1.77 + if (::GetModuleHandleW(L"OsmHooks")) 1.78 + sConsumers |= COBRA; 1.79 + 1.80 + if (::GetModuleHandleW(L"WebFinderRemote")) 1.81 + sConsumers |= ZOOMTEXT; 1.82 + 1.83 + if (::GetModuleHandleW(L"Kazahook")) 1.84 + sConsumers |= KAZAGURU; 1.85 + 1.86 + if (::GetModuleHandleW(L"TextExtractorImpl32") || 1.87 + ::GetModuleHandleW(L"TextExtractorImpl64")) 1.88 + sConsumers |= YOUDAO; 1.89 + 1.90 + if (::GetModuleHandleW(L"uiautomation") || 1.91 + ::GetModuleHandleW(L"uiautomationcore")) 1.92 + sConsumers |= UIAUTOMATION; 1.93 + 1.94 + // If we have a known consumer remove the unknown bit. 1.95 + if (sConsumers != Compatibility::UNKNOWN) 1.96 + sConsumers ^= Compatibility::UNKNOWN; 1.97 + 1.98 + // Gather telemetry 1.99 + uint32_t temp = sConsumers; 1.100 + for (int i = 0; temp; i++) { 1.101 + if (temp & 0x1) 1.102 + statistics::A11yConsumers(i); 1.103 + 1.104 + temp >>= 1; 1.105 + } 1.106 + 1.107 + // Turn off new tab switching for Jaws and WE. 1.108 + if (sConsumers & (JAWS | OLDJAWS | WE)) { 1.109 + // Check to see if the pref for disallowing CtrlTab is already set. If so, 1.110 + // bail out (respect the user settings). If not, set it. 1.111 + if (!Preferences::HasUserValue("browser.ctrlTab.disallowForScreenReaders")) 1.112 + Preferences::SetBool("browser.ctrlTab.disallowForScreenReaders", true); 1.113 + } 1.114 +} 1.115 +