STDMETHODIMP nsAccessNodeWrap::QueryService(REFGUID guidService, REFIID iid, void** ppv) { // Can get to IAccessibleApplication from any node via QS if (iid == IID_IAccessibleApplication) { nsRefPtr<nsApplicationAccessibleWrap> app = GetApplicationAccessible(); nsresult rv = app->QueryNativeInterface(iid, ppv); return NS_SUCCEEDED(rv) ? S_OK : E_NOINTERFACE; } /** * To get an ISimpleDOMNode, ISimpleDOMDocument, ISimpleDOMText * or any IAccessible2 interface on should use IServiceProvider like this: * ----------------------------------------------------------------------- * ISimpleDOMDocument *pAccDoc = NULL; * IServiceProvider *pServProv = NULL; * pAcc->QueryInterface(IID_IServiceProvider, (void**)&pServProv); * if (pServProv) { * const GUID unused; * pServProv->QueryService(unused, IID_ISimpleDOMDocument, (void**)&pAccDoc); * pServProv->Release(); * } */ return QueryInterface(iid, ppv); }
STDMETHODIMP nsAccessNodeWrap::QueryService(REFGUID guidService, REFIID iid, void** ppv) { static const GUID IID_SimpleDOMDeprecated = {0x0c539790,0x12e4,0x11cf,0xb6,0x61,0x00,0xaa,0x00,0x4c,0xd6,0xd8}; if (guidService != IID_ISimpleDOMNode && guidService != IID_SimpleDOMDeprecated && guidService != IID_IAccessible && guidService != IID_IAccessible2 && guidService != IID_IAccessibleApplication) return E_INVALIDARG; // Can get to IAccessibleApplication from any node via QS if (iid == IID_IAccessibleApplication) { nsApplicationAccessible *applicationAcc = GetApplicationAccessible(); if (!applicationAcc) return E_NOINTERFACE; nsresult rv = applicationAcc->QueryNativeInterface(iid, ppv); return NS_SUCCEEDED(rv) ? S_OK : E_NOINTERFACE; } /** * To get an ISimpleDOMNode, ISimpleDOMDocument, ISimpleDOMText * or any IAccessible2 interface on should use IServiceProvider like this: * ----------------------------------------------------------------------- * ISimpleDOMDocument *pAccDoc = NULL; * IServiceProvider *pServProv = NULL; * pAcc->QueryInterface(IID_IServiceProvider, (void**)&pServProv); * if (pServProv) { * const GUID unused; * pServProv->QueryService(unused, IID_ISimpleDOMDocument, (void**)&pAccDoc); * pServProv->Release(); * } */ return QueryInterface(iid, ppv); }
STDMETHODIMP nsAccessNodeWrap::QueryService(REFGUID guidService, REFIID iid, void** ppv) { *ppv = nsnull; static const GUID IID_SimpleDOMDeprecated = {0x0c539790,0x12e4,0x11cf,0xb6,0x61,0x00,0xaa,0x00,0x4c,0xd6,0xd8}; // Provide a special service ID for getting the accessible for the browser tab // document that contains this accessible object. If this accessible object // is not inside a browser tab then the service fails with E_NOINTERFACE. // A use case for this is for screen readers that need to switch context or // 'virtual buffer' when focus moves from one browser tab area to another. static const GUID SID_IAccessibleContentDocument = {0xa5d8e1f3,0x3571,0x4d8f,0x95,0x21,0x07,0xed,0x28,0xfb,0x07,0x2e}; if (guidService != IID_ISimpleDOMNode && guidService != IID_SimpleDOMDeprecated && guidService != IID_IAccessible && guidService != IID_IAccessible2 && guidService != IID_IAccessibleApplication && guidService != SID_IAccessibleContentDocument) return E_INVALIDARG; if (guidService == SID_IAccessibleContentDocument) { if (iid != IID_IAccessible) return E_NOINTERFACE; nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem = nsCoreUtils::GetDocShellTreeItemFor(mContent); if (!docShellTreeItem) return E_UNEXPECTED; // Walk up the parent chain without crossing the boundary at which item // types change, preventing us from walking up out of tab content. nsCOMPtr<nsIDocShellTreeItem> root; docShellTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(root)); if (!root) return E_UNEXPECTED; // If the item type is typeContent, we assume we are in browser tab content. // Note this includes content such as about:addons, for consistency. PRInt32 itemType; root->GetItemType(&itemType); if (itemType != nsIDocShellTreeItem::typeContent) return E_NOINTERFACE; // Make sure this is a document. nsDocAccessible* docAcc = nsAccUtils::GetDocAccessibleFor(root); if (!docAcc) return E_UNEXPECTED; *ppv = static_cast<IAccessible*>(docAcc); (reinterpret_cast<IUnknown*>(*ppv))->AddRef(); return NS_OK; } // Can get to IAccessibleApplication from any node via QS if (iid == IID_IAccessibleApplication) { nsApplicationAccessible *applicationAcc = GetApplicationAccessible(); if (!applicationAcc) return E_NOINTERFACE; nsresult rv = applicationAcc->QueryNativeInterface(iid, ppv); return NS_SUCCEEDED(rv) ? S_OK : E_NOINTERFACE; } /** * To get an ISimpleDOMNode, ISimpleDOMDocument, ISimpleDOMText * or any IAccessible2 interface on should use IServiceProvider like this: * ----------------------------------------------------------------------- * ISimpleDOMDocument *pAccDoc = NULL; * IServiceProvider *pServProv = NULL; * pAcc->QueryInterface(IID_IServiceProvider, (void**)&pServProv); * if (pServProv) { * const GUID unused; * pServProv->QueryService(unused, IID_ISimpleDOMDocument, (void**)&pAccDoc); * pServProv->Release(); * } */ return QueryInterface(iid, ppv); }