diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /accessible/windows/msaa/MsaaXULMenuAccessible.cpp | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'accessible/windows/msaa/MsaaXULMenuAccessible.cpp')
-rw-r--r-- | accessible/windows/msaa/MsaaXULMenuAccessible.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/accessible/windows/msaa/MsaaXULMenuAccessible.cpp b/accessible/windows/msaa/MsaaXULMenuAccessible.cpp new file mode 100644 index 0000000000..5a6d41c1b8 --- /dev/null +++ b/accessible/windows/msaa/MsaaXULMenuAccessible.cpp @@ -0,0 +1,78 @@ +/* -*- 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; +} + +STDMETHODIMP +MsaaXULMenuitemAccessible::get_accName( + /* [optional][in] */ VARIANT varChild, + /* [retval][out] */ BSTR __RPC_FAR* pszName) { + if (varChild.vt != VT_I4 || varChild.lVal != CHILDID_SELF) { + return MsaaAccessible::get_accName(varChild, pszName); + } + if (!pszName) { + return E_INVALIDARG; + } + LocalAccessible* acc = LocalAcc(); + if (!acc) { + return CO_E_OBJNOTCONNECTED; + } + + *pszName = nullptr; + nsAutoString name; + acc->Name(name); + if (name.IsVoid()) { + return S_FALSE; + } + + nsAutoString accel; + if (dom::Element* el = acc->Elm()) { + el->GetAttr(kNameSpaceID_None, nsGkAtoms::acceltext, accel); + } + if (!accel.IsEmpty()) { + name += u"\t"_ns + accel; + } + + *pszName = ::SysAllocStringLen(name.get(), name.Length()); + if (!*pszName) { + return E_OUTOFMEMORY; + } + return S_OK; +} |