|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim:expandtab:shiftwidth=2:tabstop=2: |
|
3 */ |
|
4 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
7 |
|
8 #include "ia2AccessibleHypertext.h" |
|
9 |
|
10 #include "AccessibleHypertext_i.c" |
|
11 |
|
12 #include "HyperTextAccessibleWrap.h" |
|
13 #include "IUnknownImpl.h" |
|
14 |
|
15 using namespace mozilla::a11y; |
|
16 |
|
17 // IAccessibleHypertext |
|
18 |
|
19 STDMETHODIMP |
|
20 ia2AccessibleHypertext::get_nHyperlinks(long* aHyperlinkCount) |
|
21 { |
|
22 A11Y_TRYBLOCK_BEGIN |
|
23 |
|
24 if (!aHyperlinkCount) |
|
25 return E_INVALIDARG; |
|
26 |
|
27 *aHyperlinkCount = 0; |
|
28 |
|
29 HyperTextAccessibleWrap* hyperText = static_cast<HyperTextAccessibleWrap*>(this); |
|
30 if (hyperText->IsDefunct()) |
|
31 return CO_E_OBJNOTCONNECTED; |
|
32 |
|
33 *aHyperlinkCount = hyperText->LinkCount(); |
|
34 return S_OK; |
|
35 |
|
36 A11Y_TRYBLOCK_END |
|
37 } |
|
38 |
|
39 STDMETHODIMP |
|
40 ia2AccessibleHypertext::get_hyperlink(long aLinkIndex, |
|
41 IAccessibleHyperlink** aHyperlink) |
|
42 { |
|
43 A11Y_TRYBLOCK_BEGIN |
|
44 |
|
45 if (!aHyperlink) |
|
46 return E_INVALIDARG; |
|
47 |
|
48 *aHyperlink = nullptr; |
|
49 |
|
50 HyperTextAccessibleWrap* hyperText = static_cast<HyperTextAccessibleWrap*>(this); |
|
51 if (hyperText->IsDefunct()) |
|
52 return CO_E_OBJNOTCONNECTED; |
|
53 |
|
54 Accessible* hyperLink = hyperText->LinkAt(aLinkIndex); |
|
55 if (!hyperLink) |
|
56 return E_FAIL; |
|
57 |
|
58 *aHyperlink = |
|
59 static_cast<IAccessibleHyperlink*>(static_cast<AccessibleWrap*>(hyperLink)); |
|
60 (*aHyperlink)->AddRef(); |
|
61 return S_OK; |
|
62 |
|
63 A11Y_TRYBLOCK_END |
|
64 } |
|
65 |
|
66 STDMETHODIMP |
|
67 ia2AccessibleHypertext::get_hyperlinkIndex(long aCharIndex, long* aHyperlinkIndex) |
|
68 { |
|
69 A11Y_TRYBLOCK_BEGIN |
|
70 |
|
71 if (!aHyperlinkIndex) |
|
72 return E_INVALIDARG; |
|
73 |
|
74 *aHyperlinkIndex = 0; |
|
75 |
|
76 HyperTextAccessibleWrap* hyperAcc = static_cast<HyperTextAccessibleWrap*>(this); |
|
77 if (hyperAcc->IsDefunct()) |
|
78 return CO_E_OBJNOTCONNECTED; |
|
79 |
|
80 *aHyperlinkIndex = hyperAcc->LinkIndexAtOffset(aCharIndex); |
|
81 return S_OK; |
|
82 |
|
83 A11Y_TRYBLOCK_END |
|
84 } |
|
85 |