1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/src/windows/msaa/ServiceProvider.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,96 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "ServiceProvider.h" 1.11 + 1.12 +#include "ApplicationAccessibleWrap.h" 1.13 +#include "Compatibility.h" 1.14 +#include "DocAccessible.h" 1.15 +#include "nsAccUtils.h" 1.16 +#include "nsCoreUtils.h" 1.17 +#include "Relation.h" 1.18 +#include "uiaRawElmProvider.h" 1.19 + 1.20 +#include "mozilla/Preferences.h" 1.21 +#include "nsIDocShell.h" 1.22 + 1.23 +#include "ISimpleDOMNode_i.c" 1.24 + 1.25 +namespace mozilla { 1.26 +namespace a11y { 1.27 + 1.28 +IMPL_IUNKNOWN_QUERY_HEAD(ServiceProvider) 1.29 + IMPL_IUNKNOWN_QUERY_IFACE(IServiceProvider) 1.30 +IMPL_IUNKNOWN_QUERY_TAIL_AGGREGATED(mAccessible) 1.31 + 1.32 + 1.33 +//////////////////////////////////////////////////////////////////////////////// 1.34 +// IServiceProvider 1.35 + 1.36 +STDMETHODIMP 1.37 +ServiceProvider::QueryService(REFGUID aGuidService, REFIID aIID, 1.38 + void** aInstancePtr) 1.39 +{ 1.40 + if (!aInstancePtr) 1.41 + return E_INVALIDARG; 1.42 + 1.43 + *aInstancePtr = nullptr; 1.44 + 1.45 + // UIA IAccessibleEx 1.46 + if (aGuidService == IID_IAccessibleEx && 1.47 + Preferences::GetBool("accessibility.uia.enable")) { 1.48 + uiaRawElmProvider* accEx = new uiaRawElmProvider(mAccessible); 1.49 + HRESULT hr = accEx->QueryInterface(aIID, aInstancePtr); 1.50 + if (FAILED(hr)) 1.51 + delete accEx; 1.52 + 1.53 + return hr; 1.54 + } 1.55 + 1.56 + // Provide a special service ID for getting the accessible for the browser tab 1.57 + // document that contains this accessible object. If this accessible object 1.58 + // is not inside a browser tab then the service fails with E_NOINTERFACE. 1.59 + // A use case for this is for screen readers that need to switch context or 1.60 + // 'virtual buffer' when focus moves from one browser tab area to another. 1.61 + static const GUID SID_IAccessibleContentDocument = 1.62 + { 0xa5d8e1f3,0x3571,0x4d8f,{0x95,0x21,0x07,0xed,0x28,0xfb,0x07,0x2e} }; 1.63 + if (aGuidService == SID_IAccessibleContentDocument) { 1.64 + if (aIID != IID_IAccessible) 1.65 + return E_NOINTERFACE; 1.66 + 1.67 + Relation rel = mAccessible->RelationByType(RelationType::CONTAINING_TAB_PANE); 1.68 + AccessibleWrap* tabDoc = static_cast<AccessibleWrap*>(rel.Next()); 1.69 + if (!tabDoc) 1.70 + return E_NOINTERFACE; 1.71 + 1.72 + *aInstancePtr = static_cast<IAccessible*>(tabDoc); 1.73 + (reinterpret_cast<IUnknown*>(*aInstancePtr))->AddRef(); 1.74 + return S_OK; 1.75 + } 1.76 + 1.77 + // Can get to IAccessibleApplication from any node via QS 1.78 + if (aGuidService == IID_IAccessibleApplication || 1.79 + (Compatibility::IsJAWS() && aIID == IID_IAccessibleApplication)) { 1.80 + ApplicationAccessibleWrap* applicationAcc = 1.81 + static_cast<ApplicationAccessibleWrap*>(ApplicationAcc()); 1.82 + if (!applicationAcc) 1.83 + return E_NOINTERFACE; 1.84 + 1.85 + return applicationAcc->QueryInterface(aIID, aInstancePtr); 1.86 + } 1.87 + 1.88 + static const GUID IID_SimpleDOMDeprecated = 1.89 + { 0x0c539790,0x12e4,0x11cf,{0xb6,0x61,0x00,0xaa,0x00,0x4c,0xd6,0xd8} }; 1.90 + if (aGuidService == IID_ISimpleDOMNode || 1.91 + aGuidService == IID_SimpleDOMDeprecated || 1.92 + aGuidService == IID_IAccessible || aGuidService == IID_IAccessible2) 1.93 + return mAccessible->QueryInterface(aIID, aInstancePtr); 1.94 + 1.95 + return E_INVALIDARG; 1.96 +} 1.97 + 1.98 +} // namespace a11y 1.99 +} // namespace mozilla