gecko-dev/accessible/windows/msaa/Compatibility.h

121 lines
3.1 KiB
C
Raw Normal View History

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
2012-05-21 11:12:37 +00:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef COMPATIBILITY_MANAGER_H
#define COMPATIBILITY_MANAGER_H
#include "mozilla/Maybe.h"
#include "nsString.h"
#include <stdint.h>
namespace mozilla {
namespace a11y {
/**
* Used to get compatibility modes. Note, modes are computed at accessibility
* start up time and aren't changed during lifetime.
*/
class Compatibility
{
public:
/**
* Return true if JAWS mode is enabled.
*/
static bool IsJAWS() { return !!(sConsumers & (JAWS | OLDJAWS)); }
/**
* Return true if using an e10s incompatible Jaws.
*/
static bool IsOldJAWS() { return !!(sConsumers & OLDJAWS); }
/**
* Return true if WE mode is enabled.
*/
static bool IsWE() { return !!(sConsumers & WE); }
/**
* Return true if Dolphin mode is enabled.
*/
static bool IsDolphin() { return !!(sConsumers & DOLPHIN); }
/**
* @return ID of a11y manifest resource to be passed to
* mscom::ActivationContext
*/
static uint16_t GetActCtxResourceId();
/**
* Return a string describing sConsumers suitable for about:support.
* Exposed through nsIXULRuntime.accessibilityInstantiator.
*/
static void GetHumanReadableConsumersStr(nsAString &aResult);
/**
* Initialize compatibility mode information.
*/
static void Init();
static Maybe<bool> OnUIAMessage(WPARAM aWParam, LPARAM aLParam);
static Maybe<DWORD> GetUiaRemotePid() { return sUiaRemotePid; }
/**
* return true if a known, non-UIA a11y consumer is present
*/
static bool HasKnownNonUiaConsumer();
Bug 1437417 part 1: a11y: Fix some issues in IsModuleVersionLessThan and make it reusable. r=MarcoZ 1. Move IsModuleVersionLessThan into the Compatibility class and export it in the header file. 2. The function previously referred to the third component of the version as the minor version; i.e. it was testing major.bbbb.minor.dddd. This is incorrect and might confuse people using this in future code. The minor version is the second component; i.e. major.minor.cccc.dddd. cccc and dddd are often named build and revision, but the naming here is less consistent. 3. Rather than accepting separate version components, the function now accepts a single 64 bit value. This makes comparison easier and also allows for comparison against magic values in other code; e.g. a value meaning "all versions". This value can be created from separate components using the MAKE_FILE_VERSION macro. 4. Previously, it was assumed that a dll path could not be longer than MAX_PATH, but it can actually be longer. The function now handles this. 5. The function previously didn't do any error checking, which could have led to null pointer dereferences and possibly other pain. This was fine when it was only being used for JAWS, which we know always has version info, but this could be problematic for other callers. We return true if there is a failure, assuming that no version info implies an earlier version. 6. The code now uses smart pointers instead of raw pointers, making memory management simpler. 7. Updated the JAWS version check accordingly. MozReview-Commit-ID: 9Y6gUQSX0P5 --HG-- extra : rebase_source : 595408140d8611d38fef1211ef41c53e4b65e90c
2018-02-13 06:48:16 +00:00
/**
* Return true if a module's version is lesser than the given version.
* Generally, the version should be provided using the MAKE_FILE_VERSION
* macro.
* If the version information cannot be retrieved, true is returned; i.e.
* no version information implies an earlier version.
*/
static bool IsModuleVersionLessThan(HMODULE aModuleHandle,
unsigned long long aVersion);
private:
Compatibility();
Compatibility(const Compatibility&);
Compatibility& operator = (const Compatibility&);
static void InitConsumers();
/**
* List of detected consumers of a11y (used for statistics/telemetry and compat)
*/
enum {
NVDA = 1 << 0,
JAWS = 1 << 1,
OLDJAWS = 1 << 2,
WE = 1 << 3,
DOLPHIN = 1 << 4,
SEROTEK = 1 << 5,
COBRA = 1 << 6,
ZOOMTEXT = 1 << 7,
KAZAGURU = 1 << 8,
YOUDAO = 1 << 9,
UNKNOWN = 1 << 10,
UIAUTOMATION = 1 << 11
};
#define CONSUMERS_ENUM_LEN 12
private:
static uint32_t sConsumers;
static Maybe<DWORD> sUiaRemotePid;
};
} // a11y namespace
} // mozilla namespace
Bug 1437417 part 1: a11y: Fix some issues in IsModuleVersionLessThan and make it reusable. r=MarcoZ 1. Move IsModuleVersionLessThan into the Compatibility class and export it in the header file. 2. The function previously referred to the third component of the version as the minor version; i.e. it was testing major.bbbb.minor.dddd. This is incorrect and might confuse people using this in future code. The minor version is the second component; i.e. major.minor.cccc.dddd. cccc and dddd are often named build and revision, but the naming here is less consistent. 3. Rather than accepting separate version components, the function now accepts a single 64 bit value. This makes comparison easier and also allows for comparison against magic values in other code; e.g. a value meaning "all versions". This value can be created from separate components using the MAKE_FILE_VERSION macro. 4. Previously, it was assumed that a dll path could not be longer than MAX_PATH, but it can actually be longer. The function now handles this. 5. The function previously didn't do any error checking, which could have led to null pointer dereferences and possibly other pain. This was fine when it was only being used for JAWS, which we know always has version info, but this could be problematic for other callers. We return true if there is a failure, assuming that no version info implies an earlier version. 6. The code now uses smart pointers instead of raw pointers, making memory management simpler. 7. Updated the JAWS version check accordingly. MozReview-Commit-ID: 9Y6gUQSX0P5 --HG-- extra : rebase_source : 595408140d8611d38fef1211ef41c53e4b65e90c
2018-02-13 06:48:16 +00:00
// Convert the 4 (decimal) components of a DLL version number into a
// single unsigned long long, as needed by
// mozilla::a11y::Compatibility::IsModuleVersionLessThan.
#define MAKE_FILE_VERSION(a,b,c,d)\
((a##ULL << 48) + (b##ULL << 32) + (c##ULL << 16) + d##ULL)
#endif