Bug 873444: Implement IAccessibleHypertext2::hyperlinks. r=surkov
☠☠ backed out by 96744c9221ae ☠ ☠
authorJames Teh <jteh@mozilla.com>
Fri, 27 Oct 2017 09:40:11 +1000
changeset 389226 ae94e40d58e0856114cbc7a8ea8c792b2c0cd900
parent 389225 ddaa6cbd666ecfb37f15579a6c397c7f2b33dcf7
child 389227 5599898d9bad8c3d0ff20a4f623136d54241d821
push id32779
push userebalazs@mozilla.com
push dateTue, 31 Oct 2017 10:45:04 +0000
treeherdermozilla-central@a16cc603d061 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs873444
milestone58.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 873444: Implement IAccessibleHypertext2::hyperlinks. r=surkov This allows for fetching of all hyperlinks instead of one at a time, which improves performance for a cross-process client. MozReview-Commit-ID: 8wso3EqBqwP
accessible/windows/ia2/ia2AccessibleHypertext.cpp
accessible/windows/ia2/ia2AccessibleHypertext.h
accessible/windows/msaa/HyperTextAccessibleWrap.cpp
--- a/accessible/windows/ia2/ia2AccessibleHypertext.cpp
+++ b/accessible/windows/ia2/ia2AccessibleHypertext.cpp
@@ -74,8 +74,45 @@ ia2AccessibleHypertext::get_hyperlinkInd
   HyperTextAccessibleWrap* hyperAcc = static_cast<HyperTextAccessibleWrap*>(this);
   if (hyperAcc->IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
   *aHyperlinkIndex = hyperAcc->LinkIndexAtOffset(aCharIndex);
   return S_OK;
 }
 
+STDMETHODIMP
+ia2AccessibleHypertext::get_hyperlinks(IAccessibleHyperlink*** aHyperlinks,
+                                      long* aNHyperlinks)
+{
+  if (!aHyperlinks || !aNHyperlinks) {
+    return E_INVALIDARG;
+  }
+
+  *aHyperlinks = nullptr;
+  *aNHyperlinks = 0;
+
+  MOZ_ASSERT(!HyperTextProxyFor(this));
+
+  HyperTextAccessibleWrap* hyperText = static_cast<HyperTextAccessibleWrap*>(this);
+  if (hyperText->IsDefunct()) {
+    return CO_E_OBJNOTCONNECTED;
+  }
+
+  uint32_t count = hyperText->LinkCount();
+  *aNHyperlinks = count;
+
+  *aHyperlinks = static_cast<IAccessibleHyperlink**>(::CoTaskMemAlloc(
+    sizeof(IAccessibleHyperlink*) * count));
+  if (!*aHyperlinks) {
+    return E_OUTOFMEMORY;
+  }
+
+  for (uint32_t i = 0; i < count; ++i) {
+    AccessibleWrap* hyperLink =
+      static_cast<AccessibleWrap*>(hyperText->LinkAt(i));
+    MOZ_ASSERT(hyperlink);
+    (*aHyperlinks)[i] = static_cast<IAccessibleHyperlink*>(hyperLink);
+    (*aHyperlinks)[i]->AddRef();
+  }
+
+  return S_OK;
+}
--- a/accessible/windows/ia2/ia2AccessibleHypertext.h
+++ b/accessible/windows/ia2/ia2AccessibleHypertext.h
@@ -6,23 +6,23 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _ACCESSIBLE_HYPERTEXT_H
 #define _ACCESSIBLE_HYPERTEXT_H
 
 #include "nsISupports.h"
 
 #include "ia2AccessibleText.h"
-#include "AccessibleHypertext.h"
+#include "AccessibleHypertext2.h"
 
 namespace mozilla {
 namespace a11y {
 
 class ia2AccessibleHypertext : public ia2AccessibleText,
-                               public IAccessibleHypertext
+                               public IAccessibleHypertext2
 {
 public:
 
   // IAccessibleText
   FORWARD_IACCESSIBLETEXT(ia2AccessibleText)
 
   // IAccessibleHypertext
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_nHyperlinks(
@@ -30,14 +30,19 @@ public:
 
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_hyperlink(
       /* [in] */ long index,
       /* [retval][out] */ IAccessibleHyperlink** hyperlink);
 
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_hyperlinkIndex(
       /* [in] */ long charIndex,
       /* [retval][out] */ long* hyperlinkIndex);
+
+  // IAccessibleHypertext2
+  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_hyperlinks(
+      /* [out, size_is(,*nHyperlinks)] */ IAccessibleHyperlink*** hyperlinks,
+      /* [out, retval] */ long* nHyperlinks);
 };
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif
--- a/accessible/windows/msaa/HyperTextAccessibleWrap.cpp
+++ b/accessible/windows/msaa/HyperTextAccessibleWrap.cpp
@@ -27,16 +27,18 @@ HyperTextAccessibleWrap::QueryInterface(
   *aInstancePtr = nullptr;
 
   if (IsTextRole()) {
     if (aIID == IID_IAccessibleText)
       *aInstancePtr =
         static_cast<IAccessibleText*>(static_cast<ia2AccessibleText*>(this));
     else if (aIID == IID_IAccessibleHypertext)
       *aInstancePtr = static_cast<IAccessibleHypertext*>(this);
+    else if (aIID == IID_IAccessibleHypertext2)
+      *aInstancePtr = static_cast<IAccessibleHypertext2*>(this);
     else if (aIID == IID_IAccessibleEditableText)
       *aInstancePtr = static_cast<IAccessibleEditableText*>(this);
 
     if (*aInstancePtr) {
       AddRef();
       return S_OK;
     }
   }