зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1694865 part 15: Move XULMenuitemAccessibleWrap's MSAA overrides to a new MsaaXULMenuitemAccessible class. r=morgan
For now, XULMenuitemAccessibleWrap inherits from MsaaXULMenuitemAccessible and MsaaXULMenuitemAccessible inherits from XULMenuitemAccessible. Accessible calls are made via MsaaAccessible::LocalAcc(). Since MsaaAccessible::LocalAcc() returns null if defunct, defunct checks have been adjusted accordingly. Differential Revision: https://phabricator.services.mozilla.com/D112947
This commit is contained in:
Родитель
eebe3a1f74
Коммит
efaf13c0ed
|
@ -0,0 +1,41 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#include "MsaaXULMenuAccessible.h"
|
||||
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// MsaaXULMenuitemAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
STDMETHODIMP
|
||||
MsaaXULMenuitemAccessible::get_accKeyboardShortcut(
|
||||
/* [optional][in] */ VARIANT varChild,
|
||||
/* [retval][out] */ BSTR __RPC_FAR* pszKeyboardShortcut) {
|
||||
if (!pszKeyboardShortcut) return E_INVALIDARG;
|
||||
*pszKeyboardShortcut = nullptr;
|
||||
|
||||
if (varChild.vt != VT_I4 || varChild.lVal != CHILDID_SELF) {
|
||||
return MsaaAccessible::get_accKeyboardShortcut(varChild,
|
||||
pszKeyboardShortcut);
|
||||
}
|
||||
|
||||
LocalAccessible* acc = LocalAcc();
|
||||
if (!acc) {
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
|
||||
KeyBinding keyBinding = acc->AccessKey();
|
||||
if (keyBinding.IsEmpty()) {
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
nsAutoString shortcut;
|
||||
keyBinding.ToString(shortcut);
|
||||
|
||||
*pszKeyboardShortcut = ::SysAllocStringLen(shortcut.get(), shortcut.Length());
|
||||
return *pszKeyboardShortcut ? S_OK : E_OUTOFMEMORY;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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 mozilla_a11y_MsaaXULMenuAccessible_h__
|
||||
#define mozilla_a11y_MsaaXULMenuAccessible_h__
|
||||
|
||||
#include "XULMenuAccessible.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
// XXX This should inherit from MsaaAccessible. Inheriting from
|
||||
// XULMenuitemAccessible is a necessary hack until we remove the inheritance of
|
||||
// XULMenuitemAccessibleWrap.
|
||||
class MsaaXULMenuitemAccessible : public XULMenuitemAccessible {
|
||||
public:
|
||||
using XULMenuitemAccessible::XULMenuitemAccessible;
|
||||
|
||||
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accKeyboardShortcut(
|
||||
/* [optional][in] */ VARIANT varChild,
|
||||
/* [retval][out] */ BSTR __RPC_FAR* pszKeyboardShortcut) override;
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
|
@ -3,8 +3,6 @@
|
|||
* 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/. */
|
||||
|
||||
#include "AccessibleWrap.h"
|
||||
#include "EnumVariant.h"
|
||||
#include "XULMenuAccessibleWrap.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
|
||||
|
@ -16,7 +14,7 @@ using namespace mozilla::a11y;
|
|||
|
||||
XULMenuitemAccessibleWrap::XULMenuitemAccessibleWrap(nsIContent* aContent,
|
||||
DocAccessible* aDoc)
|
||||
: XULMenuitemAccessible(aContent, aDoc) {}
|
||||
: MsaaXULMenuitemAccessible(aContent, aDoc) {}
|
||||
|
||||
ENameValueFlag XULMenuitemAccessibleWrap::Name(nsString& aName) const {
|
||||
// XXX This should be done in MSAA's get_accName() so that
|
||||
|
@ -33,31 +31,3 @@ ENameValueFlag XULMenuitemAccessibleWrap::Name(nsString& aName) const {
|
|||
|
||||
return eNameOK;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
XULMenuitemAccessibleWrap::get_accKeyboardShortcut(
|
||||
/* [optional][in] */ VARIANT varChild,
|
||||
/* [retval][out] */ BSTR __RPC_FAR* pszKeyboardShortcut) {
|
||||
if (!pszKeyboardShortcut) return E_INVALIDARG;
|
||||
*pszKeyboardShortcut = nullptr;
|
||||
|
||||
if (varChild.vt != VT_I4 || varChild.lVal != CHILDID_SELF) {
|
||||
return AccessibleWrap::get_accKeyboardShortcut(varChild,
|
||||
pszKeyboardShortcut);
|
||||
}
|
||||
|
||||
if (IsDefunct()) {
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
|
||||
KeyBinding keyBinding = AccessKey();
|
||||
if (keyBinding.IsEmpty()) {
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
nsAutoString shortcut;
|
||||
keyBinding.ToString(shortcut);
|
||||
|
||||
*pszKeyboardShortcut = ::SysAllocStringLen(shortcut.get(), shortcut.Length());
|
||||
return *pszKeyboardShortcut ? S_OK : E_OUTOFMEMORY;
|
||||
}
|
||||
|
|
|
@ -6,22 +6,18 @@
|
|||
#ifndef mozilla_a11y_XULMenuAccessibleWrap_h__
|
||||
#define mozilla_a11y_XULMenuAccessibleWrap_h__
|
||||
|
||||
#include "XULMenuAccessible.h"
|
||||
#include "MsaaXULMenuAccessible.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
class XULMenuitemAccessibleWrap : public XULMenuitemAccessible {
|
||||
class XULMenuitemAccessibleWrap : public MsaaXULMenuitemAccessible {
|
||||
public:
|
||||
XULMenuitemAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc);
|
||||
virtual ~XULMenuitemAccessibleWrap() {}
|
||||
|
||||
// nsIAccessible
|
||||
virtual mozilla::a11y::ENameValueFlag Name(nsString& aName) const override;
|
||||
|
||||
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accKeyboardShortcut(
|
||||
/* [optional][in] */ VARIANT varChild,
|
||||
/* [retval][out] */ BSTR __RPC_FAR* pszKeyboardShortcut) override;
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
|
|
|
@ -35,6 +35,7 @@ UNIFIED_SOURCES += [
|
|||
"MsaaDocAccessible.cpp",
|
||||
"MsaaIdGenerator.cpp",
|
||||
"MsaaRootAccessible.cpp",
|
||||
"MsaaXULMenuAccessible.cpp",
|
||||
"nsWinUtils.cpp",
|
||||
"Platform.cpp",
|
||||
"RootAccessibleWrap.cpp",
|
||||
|
|
Загрузка…
Ссылка в новой задаче