1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "Accessible-inl.h"
8 #include "xpcAccessibleDocument.h"
11 using namespace mozilla::a11y
;
14 xpcAccessibleHyperLink::GetStartIndex(int32_t* aStartIndex
)
16 NS_ENSURE_ARG_POINTER(aStartIndex
);
20 return NS_ERROR_FAILURE
;
22 if (Intl().IsAccessible()) {
23 *aStartIndex
= Intl().AsAccessible()->StartOffset();
26 return NS_ERROR_NOT_IMPLEMENTED
;
28 bool isIndexValid
= false;
29 uint32_t startOffset
= Intl().AsProxy()->StartOffset(&isIndexValid
);
31 return NS_ERROR_FAILURE
;
33 *aStartIndex
= startOffset
;
41 xpcAccessibleHyperLink::GetEndIndex(int32_t* aEndIndex
)
43 NS_ENSURE_ARG_POINTER(aEndIndex
);
47 return NS_ERROR_FAILURE
;
49 if (Intl().IsAccessible()) {
50 *aEndIndex
= Intl().AsAccessible()->EndOffset();
53 return NS_ERROR_NOT_IMPLEMENTED
;
55 bool isIndexValid
= false;
56 uint32_t endOffset
= Intl().AsProxy()->EndOffset(&isIndexValid
);
58 return NS_ERROR_FAILURE
;
60 *aEndIndex
= endOffset
;
68 xpcAccessibleHyperLink::GetAnchorCount(int32_t* aAnchorCount
)
70 NS_ENSURE_ARG_POINTER(aAnchorCount
);
74 return NS_ERROR_FAILURE
;
76 if (Intl().IsAccessible()) {
77 *aAnchorCount
= Intl().AsAccessible()->AnchorCount();
80 return NS_ERROR_NOT_IMPLEMENTED
;
82 bool isCountValid
= false;
83 uint32_t anchorCount
= Intl().AsProxy()->AnchorCount(&isCountValid
);
85 return NS_ERROR_FAILURE
;
87 *aAnchorCount
= anchorCount
;
95 xpcAccessibleHyperLink::GetURI(int32_t aIndex
, nsIURI
** aURI
)
97 NS_ENSURE_ARG_POINTER(aURI
);
100 return NS_ERROR_FAILURE
;
103 return NS_ERROR_INVALID_ARG
;
105 if (Intl().IsAccessible()) {
106 if (aIndex
>= static_cast<int32_t>(Intl().AsAccessible()->AnchorCount()))
107 return NS_ERROR_INVALID_ARG
;
109 RefPtr
<nsIURI
>(Intl().AsAccessible()->AnchorURIAt(aIndex
)).forget(aURI
);
112 return NS_ERROR_NOT_IMPLEMENTED
;
115 bool isURIValid
= false;
116 Intl().AsProxy()->AnchorURIAt(aIndex
, spec
, &isURIValid
);
118 return NS_ERROR_FAILURE
;
120 nsCOMPtr
<nsIURI
> uri
;
121 nsresult rv
= NS_NewURI(getter_AddRefs(uri
), spec
);
122 NS_ENSURE_SUCCESS(rv
, rv
);
133 xpcAccessibleHyperLink::GetAnchor(int32_t aIndex
, nsIAccessible
** aAccessible
)
135 NS_ENSURE_ARG_POINTER(aAccessible
);
136 *aAccessible
= nullptr;
139 return NS_ERROR_FAILURE
;
142 return NS_ERROR_INVALID_ARG
;
144 if (Intl().IsAccessible()) {
145 if (aIndex
>= static_cast<int32_t>(Intl().AsAccessible()->AnchorCount()))
146 return NS_ERROR_INVALID_ARG
;
148 NS_IF_ADDREF(*aAccessible
= ToXPC(Intl().AsAccessible()->AnchorAt(aIndex
)));
151 return NS_ERROR_NOT_IMPLEMENTED
;
153 NS_IF_ADDREF(*aAccessible
= ToXPC(Intl().AsProxy()->AnchorAt(aIndex
)));
161 xpcAccessibleHyperLink::GetValid(bool* aValid
)
163 NS_ENSURE_ARG_POINTER(aValid
);
167 return NS_ERROR_FAILURE
;
169 if (Intl().IsAccessible()) {
170 *aValid
= Intl().AsAccessible()->IsLinkValid();
173 return NS_ERROR_NOT_IMPLEMENTED
;
175 *aValid
= Intl().AsProxy()->IsLinkValid();