summaryrefslogtreecommitdiffstats
path: root/accessible/windows/uia
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /accessible/windows/uia
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'accessible/windows/uia')
-rw-r--r--accessible/windows/uia/moz.build22
-rw-r--r--accessible/windows/uia/uiaRawElmProvider.cpp246
-rw-r--r--accessible/windows/uia/uiaRawElmProvider.h75
3 files changed, 343 insertions, 0 deletions
diff --git a/accessible/windows/uia/moz.build b/accessible/windows/uia/moz.build
new file mode 100644
index 000000000..afc150e11
--- /dev/null
+++ b/accessible/windows/uia/moz.build
@@ -0,0 +1,22 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+SOURCES += [
+ 'uiaRawElmProvider.cpp',
+]
+
+LOCAL_INCLUDES += [
+ '/accessible/base',
+ '/accessible/generic',
+ '/accessible/html',
+ '/accessible/windows/msaa',
+ '/accessible/xpcom',
+ '/accessible/xul',
+]
+
+include('/ipc/chromium/chromium-config.mozbuild')
+
+FINAL_LIBRARY = 'xul'
diff --git a/accessible/windows/uia/uiaRawElmProvider.cpp b/accessible/windows/uia/uiaRawElmProvider.cpp
new file mode 100644
index 000000000..54e54766d
--- /dev/null
+++ b/accessible/windows/uia/uiaRawElmProvider.cpp
@@ -0,0 +1,246 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* 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 "uiaRawElmProvider.h"
+
+#include "AccessibleWrap.h"
+#include "ARIAMap.h"
+#include "nsIPersistentProperties2.h"
+
+using namespace mozilla;
+using namespace mozilla::a11y;
+
+////////////////////////////////////////////////////////////////////////////////
+// uiaRawElmProvider
+////////////////////////////////////////////////////////////////////////////////
+
+IMPL_IUNKNOWN2(uiaRawElmProvider,
+ IAccessibleEx,
+ IRawElementProviderSimple)
+
+////////////////////////////////////////////////////////////////////////////////
+// IAccessibleEx
+
+STDMETHODIMP
+uiaRawElmProvider::GetObjectForChild(long aIdChild,
+ __RPC__deref_out_opt IAccessibleEx** aAccEx)
+{
+ A11Y_TRYBLOCK_BEGIN
+
+ if (!aAccEx)
+ return E_INVALIDARG;
+
+ *aAccEx = nullptr;
+
+ return mAcc->IsDefunct() ? CO_E_OBJNOTCONNECTED : S_OK;
+
+ A11Y_TRYBLOCK_END
+}
+
+STDMETHODIMP
+uiaRawElmProvider::GetIAccessiblePair(__RPC__deref_out_opt IAccessible** aAcc,
+ __RPC__out long* aIdChild)
+{
+ A11Y_TRYBLOCK_BEGIN
+
+ if (!aAcc || !aIdChild)
+ return E_INVALIDARG;
+
+ *aAcc = nullptr;
+ *aIdChild = 0;
+
+ if (mAcc->IsDefunct())
+ return CO_E_OBJNOTCONNECTED;
+
+ *aIdChild = CHILDID_SELF;
+ *aAcc = mAcc;
+ mAcc->AddRef();
+
+ return S_OK;
+
+ A11Y_TRYBLOCK_END
+}
+
+STDMETHODIMP
+uiaRawElmProvider::GetRuntimeId(__RPC__deref_out_opt SAFEARRAY** aRuntimeIds)
+{
+ A11Y_TRYBLOCK_BEGIN
+
+ if (!aRuntimeIds)
+ return E_INVALIDARG;
+
+ int ids[] = { UiaAppendRuntimeId, static_cast<int>(reinterpret_cast<intptr_t>(mAcc->UniqueID())) };
+ *aRuntimeIds = SafeArrayCreateVector(VT_I4, 0, 2);
+ if (!*aRuntimeIds)
+ return E_OUTOFMEMORY;
+
+ for (LONG i = 0; i < (LONG)ArrayLength(ids); i++)
+ SafeArrayPutElement(*aRuntimeIds, &i, (void*)&(ids[i]));
+
+ return S_OK;
+
+ A11Y_TRYBLOCK_END
+}
+
+STDMETHODIMP
+uiaRawElmProvider::ConvertReturnedElement(__RPC__in_opt IRawElementProviderSimple* aRawElmProvider,
+ __RPC__deref_out_opt IAccessibleEx** aAccEx)
+{
+ A11Y_TRYBLOCK_BEGIN
+
+ if (!aRawElmProvider || !aAccEx)
+ return E_INVALIDARG;
+
+ *aAccEx = nullptr;
+
+ void* instancePtr = nullptr;
+ HRESULT hr = aRawElmProvider->QueryInterface(IID_IAccessibleEx, &instancePtr);
+ if (SUCCEEDED(hr))
+ *aAccEx = static_cast<IAccessibleEx*>(instancePtr);
+
+ return hr;
+
+ A11Y_TRYBLOCK_END
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// IRawElementProviderSimple
+
+STDMETHODIMP
+uiaRawElmProvider::get_ProviderOptions(__RPC__out enum ProviderOptions* aOptions)
+{
+ A11Y_TRYBLOCK_BEGIN
+
+ if (!aOptions)
+ return E_INVALIDARG;
+
+ // This method is not used with IAccessibleEx implementations.
+ *aOptions = ProviderOptions_ServerSideProvider;
+ return S_OK;
+
+ A11Y_TRYBLOCK_END
+}
+
+STDMETHODIMP
+uiaRawElmProvider::GetPatternProvider(PATTERNID aPatternId,
+ __RPC__deref_out_opt IUnknown** aPatternProvider)
+{
+ A11Y_TRYBLOCK_BEGIN
+
+ if (!aPatternProvider)
+ return E_INVALIDARG;
+
+ *aPatternProvider = nullptr;
+ return S_OK;
+
+ A11Y_TRYBLOCK_END
+}
+
+STDMETHODIMP
+uiaRawElmProvider::GetPropertyValue(PROPERTYID aPropertyId,
+ __RPC__out VARIANT* aPropertyValue)
+{
+ A11Y_TRYBLOCK_BEGIN
+
+ if (!aPropertyValue)
+ return E_INVALIDARG;
+
+ if (mAcc->IsDefunct())
+ return CO_E_OBJNOTCONNECTED;
+
+ aPropertyValue->vt = VT_EMPTY;
+
+ switch (aPropertyId) {
+ // Accelerator Key / shortcut.
+ case UIA_AcceleratorKeyPropertyId: {
+ nsAutoString keyString;
+
+ mAcc->KeyboardShortcut().ToString(keyString);
+
+ if (!keyString.IsEmpty()) {
+ aPropertyValue->vt = VT_BSTR;
+ aPropertyValue->bstrVal = ::SysAllocString(keyString.get());
+ return S_OK;
+ }
+
+ break;
+ }
+
+ // Access Key / mneumonic.
+ case UIA_AccessKeyPropertyId: {
+ nsAutoString keyString;
+
+ mAcc->AccessKey().ToString(keyString);
+
+ if (!keyString.IsEmpty()) {
+ aPropertyValue->vt = VT_BSTR;
+ aPropertyValue->bstrVal = ::SysAllocString(keyString.get());
+ return S_OK;
+ }
+
+ break;
+ }
+
+ //ARIA Role / shortcut
+ case UIA_AriaRolePropertyId: {
+ nsAutoString xmlRoles;
+
+ nsCOMPtr<nsIPersistentProperties> attributes = mAcc->Attributes();
+ attributes->GetStringProperty(NS_LITERAL_CSTRING("xml-roles"), xmlRoles);
+
+ if(!xmlRoles.IsEmpty()) {
+ aPropertyValue->vt = VT_BSTR;
+ aPropertyValue->bstrVal = ::SysAllocString(xmlRoles.get());
+ return S_OK;
+ }
+
+ break;
+ }
+
+ //ARIA Properties
+ case UIA_AriaPropertiesPropertyId: {
+ nsAutoString ariaProperties;
+
+ aria::AttrIterator attribIter(mAcc->GetContent());
+ nsAutoString attribName, attribValue;
+ while (attribIter.Next(attribName, attribValue)) {
+ ariaProperties.Append(attribName);
+ ariaProperties.Append('=');
+ ariaProperties.Append(attribValue);
+ ariaProperties.Append(';');
+ }
+
+ if (!ariaProperties.IsEmpty()) {
+ //remove last delimiter:
+ ariaProperties.Truncate(ariaProperties.Length()-1);
+ aPropertyValue->vt = VT_BSTR;
+ aPropertyValue->bstrVal = ::SysAllocString(ariaProperties.get());
+ return S_OK;
+ }
+
+ break;
+ }
+ }
+
+ return S_OK;
+
+ A11Y_TRYBLOCK_END
+}
+
+STDMETHODIMP
+uiaRawElmProvider::get_HostRawElementProvider(__RPC__deref_out_opt IRawElementProviderSimple** aRawElmProvider)
+{
+ A11Y_TRYBLOCK_BEGIN
+
+ if (!aRawElmProvider)
+ return E_INVALIDARG;
+
+ // This method is not used with IAccessibleEx implementations.
+ *aRawElmProvider = nullptr;
+ return S_OK;
+
+ A11Y_TRYBLOCK_END
+}
diff --git a/accessible/windows/uia/uiaRawElmProvider.h b/accessible/windows/uia/uiaRawElmProvider.h
new file mode 100644
index 000000000..f32daa19b
--- /dev/null
+++ b/accessible/windows/uia/uiaRawElmProvider.h
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* 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_uiaRawElmProvider_h__
+#define mozilla_a11y_uiaRawElmProvider_h__
+
+#include "objbase.h"
+#include "AccessibleWrap.h"
+#include "IUnknownImpl.h"
+#include "uiautomation.h"
+
+namespace mozilla {
+namespace a11y {
+
+class AccessibleWrap;
+
+/**
+ * IRawElementProviderSimple implementation (maintains IAccessibleEx approach).
+ */
+class uiaRawElmProvider final : public IAccessibleEx,
+ public IRawElementProviderSimple
+{
+public:
+ uiaRawElmProvider(AccessibleWrap* aAcc) : mAcc(aAcc) { }
+
+ // IUnknown
+ DECL_IUNKNOWN
+
+ // IAccessibleEx
+ virtual HRESULT STDMETHODCALLTYPE GetObjectForChild(
+ /* [in] */ long aIdChild,
+ /* [retval][out] */ __RPC__deref_out_opt IAccessibleEx** aAccEx);
+
+ virtual HRESULT STDMETHODCALLTYPE GetIAccessiblePair(
+ /* [out] */ __RPC__deref_out_opt IAccessible** aAcc,
+ /* [out] */ __RPC__out long* aIdChild);
+
+ virtual HRESULT STDMETHODCALLTYPE GetRuntimeId(
+ /* [retval][out] */ __RPC__deref_out_opt SAFEARRAY** aRuntimeIds);
+
+ virtual HRESULT STDMETHODCALLTYPE ConvertReturnedElement(
+ /* [in] */ __RPC__in_opt IRawElementProviderSimple* aRawElmProvider,
+ /* [out] */ __RPC__deref_out_opt IAccessibleEx** aAccEx);
+
+ // IRawElementProviderSimple
+ virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ProviderOptions(
+ /* [retval][out] */ __RPC__out enum ProviderOptions* aProviderOptions);
+
+ virtual HRESULT STDMETHODCALLTYPE GetPatternProvider(
+ /* [in] */ PATTERNID aPatternId,
+ /* [retval][out] */ __RPC__deref_out_opt IUnknown** aPatternProvider);
+
+ virtual HRESULT STDMETHODCALLTYPE GetPropertyValue(
+ /* [in] */ PROPERTYID aPropertyId,
+ /* [retval][out] */ __RPC__out VARIANT* aPropertyValue);
+
+ virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_HostRawElementProvider(
+ /* [retval][out] */ __RPC__deref_out_opt IRawElementProviderSimple** aRawElmProvider);
+
+private:
+ uiaRawElmProvider() = delete;
+ uiaRawElmProvider& operator =(const uiaRawElmProvider&) = delete;
+ uiaRawElmProvider(const uiaRawElmProvider&) = delete;
+
+protected:
+ RefPtr<AccessibleWrap> mAcc;
+};
+
+} // a11y namespace
+} // mozilla namespace
+
+#endif