michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:expandtab:shiftwidth=2:tabstop=2: michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "ia2AccessibleHypertext.h" michael@0: michael@0: #include "AccessibleHypertext_i.c" michael@0: michael@0: #include "HyperTextAccessibleWrap.h" michael@0: #include "IUnknownImpl.h" michael@0: michael@0: using namespace mozilla::a11y; michael@0: michael@0: // IAccessibleHypertext michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleHypertext::get_nHyperlinks(long* aHyperlinkCount) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aHyperlinkCount) michael@0: return E_INVALIDARG; michael@0: michael@0: *aHyperlinkCount = 0; michael@0: michael@0: HyperTextAccessibleWrap* hyperText = static_cast(this); michael@0: if (hyperText->IsDefunct()) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: *aHyperlinkCount = hyperText->LinkCount(); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleHypertext::get_hyperlink(long aLinkIndex, michael@0: IAccessibleHyperlink** aHyperlink) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aHyperlink) michael@0: return E_INVALIDARG; michael@0: michael@0: *aHyperlink = nullptr; michael@0: michael@0: HyperTextAccessibleWrap* hyperText = static_cast(this); michael@0: if (hyperText->IsDefunct()) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: Accessible* hyperLink = hyperText->LinkAt(aLinkIndex); michael@0: if (!hyperLink) michael@0: return E_FAIL; michael@0: michael@0: *aHyperlink = michael@0: static_cast(static_cast(hyperLink)); michael@0: (*aHyperlink)->AddRef(); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleHypertext::get_hyperlinkIndex(long aCharIndex, long* aHyperlinkIndex) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aHyperlinkIndex) michael@0: return E_INVALIDARG; michael@0: michael@0: *aHyperlinkIndex = 0; michael@0: michael@0: HyperTextAccessibleWrap* hyperAcc = static_cast(this); michael@0: if (hyperAcc->IsDefunct()) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: *aHyperlinkIndex = hyperAcc->LinkIndexAtOffset(aCharIndex); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: