Bug 1854550 - pt 10. Allow LOG() with zero extra arguments r=glandium
[gecko.git] / accessible / atk / nsMaiInterfaceHypertext.cpp
blob1e073c87d2b4a3df62b52700383e27faf6c2c122
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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "InterfaceInitFuncs.h"
9 #include "LocalAccessible-inl.h"
10 #include "HyperTextAccessible.h"
11 #include "nsMai.h"
12 #include "nsMaiHyperlink.h"
13 #include "RemoteAccessible.h"
14 #include "mozilla/Likely.h"
16 using namespace mozilla::a11y;
18 extern "C" {
20 static AtkHyperlink* getLinkCB(AtkHypertext* aText, gint aLinkIndex) {
21 if (Accessible* acc = GetInternalObj(ATK_OBJECT(aText))) {
22 if (HyperTextAccessibleBase* hyperText = acc->AsHyperTextBase()) {
23 Accessible* linkAcc = hyperText->LinkAt(aLinkIndex);
24 AtkObject* atkHyperLink = GetWrapperFor(linkAcc);
25 NS_ENSURE_TRUE(IS_MAI_OBJECT(atkHyperLink), nullptr);
26 return MAI_ATK_OBJECT(atkHyperLink)->GetAtkHyperlink();
30 return nullptr;
33 static gint getLinkCountCB(AtkHypertext* aText) {
34 if (Accessible* acc = GetInternalObj(ATK_OBJECT(aText))) {
35 if (HyperTextAccessibleBase* hyperText = acc->AsHyperTextBase()) {
36 return static_cast<gint>(hyperText->LinkCount());
39 return -1;
42 static gint getLinkIndexCB(AtkHypertext* aText, gint aCharIndex) {
43 Accessible* acc = GetInternalObj(ATK_OBJECT(aText));
44 if (!acc) {
45 return -1;
47 HyperTextAccessibleBase* hyperText = acc->AsHyperTextBase();
48 if (!hyperText) {
49 return -1;
51 return hyperText->LinkIndexAtOffset(aCharIndex);
54 } // extern "C"
56 void hypertextInterfaceInitCB(AtkHypertextIface* aIface) {
57 NS_ASSERTION(aIface, "no interface!");
58 if (MOZ_UNLIKELY(!aIface)) return;
60 aIface->get_link = getLinkCB;
61 aIface->get_n_links = getLinkCountCB;
62 aIface->get_link_index = getLinkIndexCB;