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 "xpcAccessibleHyperLink.h"
9 #include "xpcAccessibleDocument.h"
11 using namespace mozilla::a11y
;
14 xpcAccessibleHyperLink::GetStartIndex(int32_t* aStartIndex
) {
15 NS_ENSURE_ARG_POINTER(aStartIndex
);
18 if (!Intl()) return NS_ERROR_FAILURE
;
20 *aStartIndex
= static_cast<int32_t>(Intl()->StartOffset());
25 xpcAccessibleHyperLink::GetEndIndex(int32_t* aEndIndex
) {
26 NS_ENSURE_ARG_POINTER(aEndIndex
);
29 if (!Intl()) return NS_ERROR_FAILURE
;
31 *aEndIndex
= static_cast<int32_t>(Intl()->EndOffset());
36 xpcAccessibleHyperLink::GetAnchorCount(int32_t* aAnchorCount
) {
37 NS_ENSURE_ARG_POINTER(aAnchorCount
);
40 if (!Intl()) return NS_ERROR_FAILURE
;
42 *aAnchorCount
= Intl()->AnchorCount();
48 xpcAccessibleHyperLink::GetURI(int32_t aIndex
, nsIURI
** aURI
) {
49 NS_ENSURE_ARG_POINTER(aURI
);
52 return NS_ERROR_FAILURE
;
55 if (aIndex
< 0 || aIndex
>= static_cast<int32_t>(Intl()->AnchorCount())) {
56 return NS_ERROR_INVALID_ARG
;
59 RefPtr
<nsIURI
>(Intl()->AnchorURIAt(aIndex
)).forget(aURI
);
65 xpcAccessibleHyperLink::GetAnchor(int32_t aIndex
, nsIAccessible
** aAccessible
) {
66 NS_ENSURE_ARG_POINTER(aAccessible
);
67 *aAccessible
= nullptr;
69 if (!Intl()) return NS_ERROR_FAILURE
;
71 if (aIndex
< 0) return NS_ERROR_INVALID_ARG
;
73 if (aIndex
>= static_cast<int32_t>(Intl()->AnchorCount())) {
74 return NS_ERROR_INVALID_ARG
;
77 NS_IF_ADDREF(*aAccessible
= ToXPC(Intl()->AnchorAt(aIndex
)));
83 xpcAccessibleHyperLink::GetValid(bool* aValid
) {
84 NS_ENSURE_ARG_POINTER(aValid
);
87 if (!Intl()) return NS_ERROR_FAILURE
;
89 *aValid
= Intl()->IsLinkValid();