mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 12:55:46 +00:00
Bug 594413 - Provide QueryService for main tab document accessible; r=marcoz,surkov a=blocking-b7
This commit is contained in:
parent
334689c512
commit
aaf6c6df6a
@ -134,13 +134,59 @@ STDMETHODIMP nsAccessNodeWrap::QueryInterface(REFIID iid, void** 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 != 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();
|
||||
|
Loading…
Reference in New Issue
Block a user