diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /accessible/windows/msaa/ApplicationAccessibleWrap.cpp | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'accessible/windows/msaa/ApplicationAccessibleWrap.cpp')
-rw-r--r-- | accessible/windows/msaa/ApplicationAccessibleWrap.cpp | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/accessible/windows/msaa/ApplicationAccessibleWrap.cpp b/accessible/windows/msaa/ApplicationAccessibleWrap.cpp new file mode 100644 index 0000000000..ef84e471bb --- /dev/null +++ b/accessible/windows/msaa/ApplicationAccessibleWrap.cpp @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:expandtab:shiftwidth=4:tabstop=4: + */ +/* 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 "ApplicationAccessibleWrap.h" + +#include "AccessibleApplication_i.c" +#include "IUnknownImpl.h" + +#include "nsIGfxInfo.h" +#include "nsPersistentProperties.h" +#include "nsServiceManagerUtils.h" +#include "mozilla/Services.h" + +using namespace mozilla; +using namespace mozilla::a11y; + +//////////////////////////////////////////////////////////////////////////////// +// nsISupports +NS_IMPL_ISUPPORTS_INHERITED0(ApplicationAccessibleWrap, ApplicationAccessible) + +already_AddRefed<nsIPersistentProperties> +ApplicationAccessibleWrap::NativeAttributes() { + RefPtr<nsPersistentProperties> attributes = new nsPersistentProperties(); + + nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo(); + if (gfxInfo) { + bool isD2DEnabled = false; + gfxInfo->GetD2DEnabled(&isD2DEnabled); + nsAutoString unused; + attributes->SetStringProperty( + "D2D"_ns, isD2DEnabled ? u"true"_ns : u"false"_ns, unused); + } + + return attributes.forget(); +} + +//////////////////////////////////////////////////////////////////////////////// +// IUnknown + +STDMETHODIMP +ApplicationAccessibleWrap::QueryInterface(REFIID iid, void** ppv) { + if (!ppv) return E_INVALIDARG; + + *ppv = nullptr; + + if (IID_IAccessibleApplication == iid) { + *ppv = static_cast<IAccessibleApplication*>(this); + (reinterpret_cast<IUnknown*>(*ppv))->AddRef(); + return S_OK; + } + + return AccessibleWrap::QueryInterface(iid, ppv); +} + +//////////////////////////////////////////////////////////////////////////////// +// IAccessibleApplication + +STDMETHODIMP +ApplicationAccessibleWrap::get_appName(BSTR* aName) { + if (!aName) return E_INVALIDARG; + + *aName = nullptr; + + if (IsDefunct()) return CO_E_OBJNOTCONNECTED; + + nsAutoString name; + AppName(name); + if (name.IsEmpty()) return S_FALSE; + + *aName = ::SysAllocStringLen(name.get(), name.Length()); + return *aName ? S_OK : E_OUTOFMEMORY; +} + +STDMETHODIMP +ApplicationAccessibleWrap::get_appVersion(BSTR* aVersion) { + if (!aVersion) return E_INVALIDARG; + + *aVersion = nullptr; + + if (IsDefunct()) return CO_E_OBJNOTCONNECTED; + + nsAutoString version; + AppVersion(version); + if (version.IsEmpty()) return S_FALSE; + + *aVersion = ::SysAllocStringLen(version.get(), version.Length()); + return *aVersion ? S_OK : E_OUTOFMEMORY; +} + +STDMETHODIMP +ApplicationAccessibleWrap::get_toolkitName(BSTR* aName) { + if (!aName) return E_INVALIDARG; + + if (IsDefunct()) return CO_E_OBJNOTCONNECTED; + + nsAutoString name; + PlatformName(name); + if (name.IsEmpty()) return S_FALSE; + + *aName = ::SysAllocStringLen(name.get(), name.Length()); + return *aName ? S_OK : E_OUTOFMEMORY; +} + +STDMETHODIMP +ApplicationAccessibleWrap::get_toolkitVersion(BSTR* aVersion) { + if (!aVersion) return E_INVALIDARG; + + *aVersion = nullptr; + + if (IsDefunct()) return CO_E_OBJNOTCONNECTED; + + nsAutoString version; + PlatformVersion(version); + if (version.IsEmpty()) return S_FALSE; + + *aVersion = ::SysAllocStringLen(version.get(), version.Length()); + return *aVersion ? S_OK : E_OUTOFMEMORY; +} |