bug 1159828 - make ia2Hyperlink use proxies r=davidb
authorTrevor Saunders <tbsaunde@tbsaunde.org>
Wed, 29 Apr 2015 13:59:47 -0400
changeset 274220 603d4c01ca0a3e569020cf9e63106a6d448019d2
parent 274219 b6aa5c3d357933d065e1d302768a807b9d0624db
child 274221 d5a70f4292a641c5e4e55e7e139e3214b16fc0ec
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidb
bugs1159828
milestone40.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 1159828 - make ia2Hyperlink use proxies r=davidb
accessible/windows/ia2/ia2AccessibleHyperlink.cpp
--- a/accessible/windows/ia2/ia2AccessibleHyperlink.cpp
+++ b/accessible/windows/ia2/ia2AccessibleHyperlink.cpp
@@ -45,16 +45,26 @@ ia2AccessibleHyperlink::get_anchor(long 
   A11Y_TRYBLOCK_BEGIN
 
   if (!aAnchor)
     return E_INVALIDARG;
 
   VariantInit(aAnchor);
 
   Accessible* thisObj = static_cast<AccessibleWrap*>(this);
+  if (thisObj->IsProxy()) {
+    ProxyAccessible* anchor = thisObj->Proxy()->AnchorAt(aIndex);
+    if (!anchor)
+      return S_FALSE;
+
+    aAnchor->punkVal = static_cast<IAccessibleHyperlink*>(WrapperFor(anchor));
+    aAnchor->vt = VT_UNKNOWN;
+    return S_OK;
+  }
+
   if (thisObj->IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
   if (aIndex < 0 || aIndex >= static_cast<long>(thisObj->AnchorCount()))
     return E_INVALIDARG;
 
   if (!thisObj->IsLink())
     return S_FALSE;
@@ -83,42 +93,44 @@ ia2AccessibleHyperlink::get_anchorTarget
   A11Y_TRYBLOCK_BEGIN
 
   if (!aAnchorTarget)
     return E_INVALIDARG;
 
   VariantInit(aAnchorTarget);
 
   Accessible* thisObj = static_cast<AccessibleWrap*>(this);
-  if (thisObj->IsDefunct())
-    return CO_E_OBJNOTCONNECTED;
+  nsAutoCString uriStr;
+  if (thisObj->IsProxy()) {
+    bool ok;
+    thisObj->Proxy()->AnchorURIAt(aIndex, uriStr, &ok);
+    if (!ok)
+      return S_FALSE;
 
-  if (aIndex < 0 || aIndex >= static_cast<long>(thisObj->AnchorCount()))
-    return E_INVALIDARG;
-
-  if (!thisObj->IsLink())
-    return S_FALSE;
+  } else {
+    if (thisObj->IsDefunct())
+      return CO_E_OBJNOTCONNECTED;
 
-  nsCOMPtr<nsIURI> uri = thisObj->AnchorURIAt(aIndex);
-  if (!uri)
-    return S_FALSE;
+    if (aIndex < 0 || aIndex >= static_cast<long>(thisObj->AnchorCount()))
+      return E_INVALIDARG;
+
+    if (!thisObj->IsLink())
+      return S_FALSE;
 
-  nsAutoCString prePath;
-  nsresult rv = uri->GetPrePath(prePath);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+    nsCOMPtr<nsIURI> uri = thisObj->AnchorURIAt(aIndex);
+    if (!uri)
+      return S_FALSE;
 
-  nsAutoCString path;
-  rv = uri->GetPath(path);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+    nsresult rv = uri->GetSpec(uriStr);
+    if (NS_FAILED(rv))
+      return GetHRESULT(rv);
+  }
 
   nsAutoString stringURI;
-  AppendUTF8toUTF16(prePath, stringURI);
-  AppendUTF8toUTF16(path, stringURI);
+  AppendUTF8toUTF16(uriStr, stringURI);
 
   aAnchorTarget->vt = VT_BSTR;
   aAnchorTarget->bstrVal = ::SysAllocStringLen(stringURI.get(),
                                                stringURI.Length());
   return aAnchorTarget->bstrVal ? S_OK : E_OUTOFMEMORY;
 
   A11Y_TRYBLOCK_END
 }
@@ -128,16 +140,22 @@ ia2AccessibleHyperlink::get_startIndex(l
 {
   A11Y_TRYBLOCK_BEGIN
 
   if (!aIndex)
     return E_INVALIDARG;
 
   *aIndex = 0;
 
+  if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
+    bool valid;
+    *aIndex = proxy->StartOffset(&valid);
+    return valid ? S_OK : S_FALSE;
+  }
+
   Accessible* thisObj = static_cast<AccessibleWrap*>(this);
   if (thisObj->IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
   if (!thisObj->IsLink())
     return S_FALSE;
 
   *aIndex = thisObj->StartOffset();
@@ -151,16 +169,22 @@ ia2AccessibleHyperlink::get_endIndex(lon
 {
   A11Y_TRYBLOCK_BEGIN
 
   if (!aIndex)
     return E_INVALIDARG;
 
   *aIndex = 0;
 
+  if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
+    bool valid;
+    *aIndex = proxy->EndOffset(&valid);
+    return valid ? S_OK : S_FALSE;
+  }
+
   Accessible* thisObj = static_cast<AccessibleWrap*>(this);
   if (thisObj->IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
   if (!thisObj->IsLink())
     return S_FALSE;
 
   *aIndex = thisObj->EndOffset();
@@ -174,16 +198,21 @@ ia2AccessibleHyperlink::get_valid(boolea
 {
   A11Y_TRYBLOCK_BEGIN
 
   if (!aValid)
     return E_INVALIDARG;
 
   *aValid = false;
 
+  if (ProxyAccessible* proxy = HyperTextProxyFor(this)) {
+    *aValid = proxy->IsLinkValid();
+    return S_OK;
+  }
+
   Accessible* thisObj = static_cast<AccessibleWrap*>(this);
   if (thisObj->IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
   if (!thisObj->IsLink())
     return S_FALSE;
 
   *aValid = thisObj->IsLinkValid();