Bug 1735722 part 6: Support QueryInterface to IAccessibleHypertext and IAccessibleHypertext::get_hyperlink for RemoteAccessible. r=morgan
authorJames Teh <jteh@mozilla.com>
Tue, 19 Oct 2021 03:57:20 +0000
changeset 596276 5ce097bae42653d4b8e8746f6c40876620449270
parent 596275 c4747685e885043bb7ebdc61dc8712c396ec0aef
child 596277 dad723b8fd70b42150d00c3c2948366885c20065
push id38893
push usermlaza@mozilla.com
push dateTue, 19 Oct 2021 09:53:57 +0000
treeherdermozilla-central@4185629111d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmorgan
bugs1735722
milestone95.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1735722 part 6: Support QueryInterface to IAccessibleHypertext and IAccessibleHypertext::get_hyperlink for RemoteAccessible. r=morgan Differential Revision: https://phabricator.services.mozilla.com/D128555
accessible/windows/ia2/ia2AccessibleHypertext.cpp
accessible/windows/ia2/ia2AccessibleHypertext.h
--- a/accessible/windows/ia2/ia2AccessibleHypertext.cpp
+++ b/accessible/windows/ia2/ia2AccessibleHypertext.cpp
@@ -9,16 +9,21 @@
 
 #include "AccessibleHypertext_i.c"
 
 #include "HyperTextAccessibleWrap.h"
 #include "IUnknownImpl.h"
 
 using namespace mozilla::a11y;
 
+HyperTextAccessibleBase* ia2AccessibleHypertext::TextAcc() {
+  Accessible* acc = Acc();
+  return acc ? acc->AsHyperTextBase() : nullptr;
+}
+
 HyperTextAccessibleWrap* ia2AccessibleHypertext::LocalTextAcc() {
   AccessibleWrap* acc = LocalAcc();
   return static_cast<HyperTextAccessibleWrap*>(acc);
 }
 
 // IUnknown
 STDMETHODIMP
 ia2AccessibleHypertext::QueryInterface(REFIID aIID, void** aInstancePtr) {
@@ -27,17 +32,17 @@ ia2AccessibleHypertext::QueryInterface(R
   *aInstancePtr = nullptr;
 
   Accessible* acc = Acc();
   if (acc && acc->IsTextRole()) {
     bool isLocal = acc->IsLocal();
     if (aIID == IID_IAccessibleText) {
       *aInstancePtr =
           static_cast<IAccessibleText*>(static_cast<ia2AccessibleText*>(this));
-    } else if (aIID == IID_IAccessibleHypertext && isLocal) {
+    } else if (aIID == IID_IAccessibleHypertext) {
       *aInstancePtr = static_cast<IAccessibleHypertext*>(this);
     } else if (aIID == IID_IAccessibleHypertext2 && isLocal) {
       *aInstancePtr = static_cast<IAccessibleHypertext2*>(this);
     } else if (aIID == IID_IAccessibleEditableText && isLocal) {
       *aInstancePtr = static_cast<IAccessibleEditableText*>(this);
     }
 
     if (*aInstancePtr) {
@@ -66,29 +71,25 @@ ia2AccessibleHypertext::get_nHyperlinks(
 
 STDMETHODIMP
 ia2AccessibleHypertext::get_hyperlink(long aLinkIndex,
                                       IAccessibleHyperlink** aHyperlink) {
   if (!aHyperlink) return E_INVALIDARG;
 
   *aHyperlink = nullptr;
 
-  LocalAccessible* hyperLink;
-  HyperTextAccessibleWrap* hyperText = LocalTextAcc();
+  HyperTextAccessibleBase* hyperText = TextAcc();
   if (!hyperText) {
     return CO_E_OBJNOTCONNECTED;
   }
 
-  hyperLink = hyperText->LinkAt(aLinkIndex);
+  Accessible* hyperLink = hyperText->LinkAt(aLinkIndex);
 
   if (!hyperLink) return E_FAIL;
 
-  // GetNativeInterface returns an IAccessible, but we need an
-  // IAccessibleHyperlink, so use MsaaAccessible::GetFrom instead and let
-  // RefPtr cast it.
   RefPtr<IAccessibleHyperlink> result = MsaaAccessible::GetFrom(hyperLink);
   result.forget(aHyperlink);
   return S_OK;
 }
 
 STDMETHODIMP
 ia2AccessibleHypertext::get_hyperlinkIndex(long aCharIndex,
                                            long* aHyperlinkIndex) {
--- a/accessible/windows/ia2/ia2AccessibleHypertext.h
+++ b/accessible/windows/ia2/ia2AccessibleHypertext.h
@@ -13,16 +13,17 @@
 #include "ia2AccessibleEditableText.h"
 #include "ia2AccessibleText.h"
 #include "AccessibleHypertext2.h"
 #include "IUnknownImpl.h"
 #include "MsaaAccessible.h"
 
 namespace mozilla {
 namespace a11y {
+class HyperTextAccessibleBase;
 class HyperTextAccessibleWrap;
 
 class ia2AccessibleHypertext : public ia2AccessibleText,
                                public IAccessibleHypertext2,
                                public ia2AccessibleEditableText,
                                public MsaaAccessible {
  public:
   // IUnknown
@@ -54,15 +55,16 @@ class ia2AccessibleHypertext : public ia
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_hyperlinks(
       /* [out, size_is(,*nHyperlinks)] */ IAccessibleHyperlink*** hyperlinks,
       /* [out, retval] */ long* nHyperlinks);
 
  protected:
   using MsaaAccessible::MsaaAccessible;
 
  private:
+  HyperTextAccessibleBase* TextAcc();
   HyperTextAccessibleWrap* LocalTextAcc();
 };
 
 }  // namespace a11y
 }  // namespace mozilla
 
 #endif