From 5f324eb9ddfb4a502c3d124e2ee78ebc288fe8c5 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Fri, 3 Feb 2017 15:26:26 -0800 Subject: [PATCH] Bug 1336637 - Support relation methods in xpc on windows. r=tbsaunde MozReview-Commit-ID: BcyE0Vy1Fu4 --- accessible/ipc/win/ProxyAccessible.cpp | 45 +++++++++++++++++++++++ accessible/tests/browser/e10s/browser.ini | 2 +- accessible/xpcom/xpcAccessible.cpp | 4 -- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/accessible/ipc/win/ProxyAccessible.cpp b/accessible/ipc/win/ProxyAccessible.cpp index 1bef1fc3a652..d6aa13cc2b2b 100644 --- a/accessible/ipc/win/ProxyAccessible.cpp +++ b/accessible/ipc/win/ProxyAccessible.cpp @@ -6,6 +6,7 @@ #include "Accessible2.h" #include "ProxyAccessible.h" +#include "ia2AccessibleRelation.h" #include "ia2AccessibleValue.h" #include "IGeckoCustom.h" #include "mozilla/a11y/DocAccessibleParent.h" @@ -80,6 +81,12 @@ struct InterfaceIID static REFIID Value() { return IID_IGeckoCustom; } }; +template<> +struct InterfaceIID +{ + static REFIID Value() { return IID_IAccessible2_2; } +}; + /** * Get the COM proxy for this proxy accessible and QueryInterface it with the * correct IID @@ -363,6 +370,44 @@ ProxyAccessible::Attributes(nsTArray* aAttrs) const aAttrs); } +nsTArray +ProxyAccessible::RelationByType(RelationType aType) const +{ + RefPtr acc = QueryInterface(this); + if (!acc) { + nsTArray(); + } + + _bstr_t relationType; + for (uint32_t idx = 0; idx < ArrayLength(sRelationTypePairs); idx++) { + if (aType == sRelationTypePairs[idx].first) { + relationType = sRelationTypePairs[idx].second; + break; + } + } + + if (!relationType) { + nsTArray(); + } + + IUnknown** targets; + long nTargets = 0; + HRESULT hr = acc->get_relationTargetsOfType(relationType, 0, &targets, &nTargets); + if (FAILED(hr)) { + nsTArray(); + } + + nsTArray proxies; + for (long idx = 0; idx < nTargets; idx++) { + IUnknown* target = targets[idx]; + proxies.AppendElement(GetProxyFor(Document(), target)); + target->Release(); + } + CoTaskMemFree(targets); + + return Move(proxies); +} + double ProxyAccessible::CurValue() { diff --git a/accessible/tests/browser/e10s/browser.ini b/accessible/tests/browser/e10s/browser.ini index 0b7b5adad1dd..79a62c996575 100644 --- a/accessible/tests/browser/e10s/browser.ini +++ b/accessible/tests/browser/e10s/browser.ini @@ -21,7 +21,7 @@ skip-if = e10s && os == 'win' && os_version == '5.1' [browser_caching_name.js] skip-if = e10s && os == 'win' && os_version == '5.1' [browser_caching_relations.js] -skip-if = e10s && os == 'win' # Bug 1288839 +skip-if = e10s && os == 'win' && os_version == '5.1' [browser_caching_states.js] skip-if = e10s && os == 'win' && os_version == '5.1' [browser_caching_value.js] diff --git a/accessible/xpcom/xpcAccessible.cpp b/accessible/xpcom/xpcAccessible.cpp index 10204ae7b270..dede700d19d6 100644 --- a/accessible/xpcom/xpcAccessible.cpp +++ b/accessible/xpcom/xpcAccessible.cpp @@ -504,16 +504,12 @@ xpcAccessible::GetRelationByType(uint32_t aType, return NS_OK; } -#if defined(XP_WIN) - return NS_ERROR_NOT_IMPLEMENTED; -#else ProxyAccessible* proxy = IntlGeneric().AsProxy(); nsTArray targets = proxy->RelationByType(static_cast(aType)); NS_ADDREF(*aRelation = new nsAccessibleRelation(aType, &targets)); return NS_OK; -#endif } NS_IMETHODIMP