Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "ServiceProvider.h" |
michael@0 | 8 | |
michael@0 | 9 | #include "ApplicationAccessibleWrap.h" |
michael@0 | 10 | #include "Compatibility.h" |
michael@0 | 11 | #include "DocAccessible.h" |
michael@0 | 12 | #include "nsAccUtils.h" |
michael@0 | 13 | #include "nsCoreUtils.h" |
michael@0 | 14 | #include "Relation.h" |
michael@0 | 15 | #include "uiaRawElmProvider.h" |
michael@0 | 16 | |
michael@0 | 17 | #include "mozilla/Preferences.h" |
michael@0 | 18 | #include "nsIDocShell.h" |
michael@0 | 19 | |
michael@0 | 20 | #include "ISimpleDOMNode_i.c" |
michael@0 | 21 | |
michael@0 | 22 | namespace mozilla { |
michael@0 | 23 | namespace a11y { |
michael@0 | 24 | |
michael@0 | 25 | IMPL_IUNKNOWN_QUERY_HEAD(ServiceProvider) |
michael@0 | 26 | IMPL_IUNKNOWN_QUERY_IFACE(IServiceProvider) |
michael@0 | 27 | IMPL_IUNKNOWN_QUERY_TAIL_AGGREGATED(mAccessible) |
michael@0 | 28 | |
michael@0 | 29 | |
michael@0 | 30 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 31 | // IServiceProvider |
michael@0 | 32 | |
michael@0 | 33 | STDMETHODIMP |
michael@0 | 34 | ServiceProvider::QueryService(REFGUID aGuidService, REFIID aIID, |
michael@0 | 35 | void** aInstancePtr) |
michael@0 | 36 | { |
michael@0 | 37 | if (!aInstancePtr) |
michael@0 | 38 | return E_INVALIDARG; |
michael@0 | 39 | |
michael@0 | 40 | *aInstancePtr = nullptr; |
michael@0 | 41 | |
michael@0 | 42 | // UIA IAccessibleEx |
michael@0 | 43 | if (aGuidService == IID_IAccessibleEx && |
michael@0 | 44 | Preferences::GetBool("accessibility.uia.enable")) { |
michael@0 | 45 | uiaRawElmProvider* accEx = new uiaRawElmProvider(mAccessible); |
michael@0 | 46 | HRESULT hr = accEx->QueryInterface(aIID, aInstancePtr); |
michael@0 | 47 | if (FAILED(hr)) |
michael@0 | 48 | delete accEx; |
michael@0 | 49 | |
michael@0 | 50 | return hr; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | // Provide a special service ID for getting the accessible for the browser tab |
michael@0 | 54 | // document that contains this accessible object. If this accessible object |
michael@0 | 55 | // is not inside a browser tab then the service fails with E_NOINTERFACE. |
michael@0 | 56 | // A use case for this is for screen readers that need to switch context or |
michael@0 | 57 | // 'virtual buffer' when focus moves from one browser tab area to another. |
michael@0 | 58 | static const GUID SID_IAccessibleContentDocument = |
michael@0 | 59 | { 0xa5d8e1f3,0x3571,0x4d8f,{0x95,0x21,0x07,0xed,0x28,0xfb,0x07,0x2e} }; |
michael@0 | 60 | if (aGuidService == SID_IAccessibleContentDocument) { |
michael@0 | 61 | if (aIID != IID_IAccessible) |
michael@0 | 62 | return E_NOINTERFACE; |
michael@0 | 63 | |
michael@0 | 64 | Relation rel = mAccessible->RelationByType(RelationType::CONTAINING_TAB_PANE); |
michael@0 | 65 | AccessibleWrap* tabDoc = static_cast<AccessibleWrap*>(rel.Next()); |
michael@0 | 66 | if (!tabDoc) |
michael@0 | 67 | return E_NOINTERFACE; |
michael@0 | 68 | |
michael@0 | 69 | *aInstancePtr = static_cast<IAccessible*>(tabDoc); |
michael@0 | 70 | (reinterpret_cast<IUnknown*>(*aInstancePtr))->AddRef(); |
michael@0 | 71 | return S_OK; |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | // Can get to IAccessibleApplication from any node via QS |
michael@0 | 75 | if (aGuidService == IID_IAccessibleApplication || |
michael@0 | 76 | (Compatibility::IsJAWS() && aIID == IID_IAccessibleApplication)) { |
michael@0 | 77 | ApplicationAccessibleWrap* applicationAcc = |
michael@0 | 78 | static_cast<ApplicationAccessibleWrap*>(ApplicationAcc()); |
michael@0 | 79 | if (!applicationAcc) |
michael@0 | 80 | return E_NOINTERFACE; |
michael@0 | 81 | |
michael@0 | 82 | return applicationAcc->QueryInterface(aIID, aInstancePtr); |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | static const GUID IID_SimpleDOMDeprecated = |
michael@0 | 86 | { 0x0c539790,0x12e4,0x11cf,{0xb6,0x61,0x00,0xaa,0x00,0x4c,0xd6,0xd8} }; |
michael@0 | 87 | if (aGuidService == IID_ISimpleDOMNode || |
michael@0 | 88 | aGuidService == IID_SimpleDOMDeprecated || |
michael@0 | 89 | aGuidService == IID_IAccessible || aGuidService == IID_IAccessible2) |
michael@0 | 90 | return mAccessible->QueryInterface(aIID, aInstancePtr); |
michael@0 | 91 | |
michael@0 | 92 | return E_INVALIDARG; |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | } // namespace a11y |
michael@0 | 96 | } // namespace mozilla |