mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
bug 1159828 - make ia2Hyperlink use proxies r=davidb
This commit is contained in:
parent
0a7a48758c
commit
579dc62f15
@ -50,6 +50,16 @@ ia2AccessibleHyperlink::get_anchor(long aIndex, VARIANT* aAnchor)
|
||||
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;
|
||||
|
||||
@ -88,32 +98,34 @@ ia2AccessibleHyperlink::get_anchorTarget(long aIndex, VARIANT* aAnchorTarget)
|
||||
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;
|
||||
} else {
|
||||
if (thisObj->IsDefunct())
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
if (!thisObj->IsLink())
|
||||
return S_FALSE;
|
||||
if (aIndex < 0 || aIndex >= static_cast<long>(thisObj->AnchorCount()))
|
||||
return E_INVALIDARG;
|
||||
|
||||
nsCOMPtr<nsIURI> uri = thisObj->AnchorURIAt(aIndex);
|
||||
if (!uri)
|
||||
return S_FALSE;
|
||||
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(),
|
||||
@ -133,6 +145,12 @@ ia2AccessibleHyperlink::get_startIndex(long* aIndex)
|
||||
|
||||
*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;
|
||||
@ -156,6 +174,12 @@ ia2AccessibleHyperlink::get_endIndex(long* aIndex)
|
||||
|
||||
*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;
|
||||
@ -179,6 +203,11 @@ ia2AccessibleHyperlink::get_valid(boolean* aValid)
|
||||
|
||||
*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;
|
||||
|
Loading…
Reference in New Issue
Block a user