2014-09-16 10:30:23 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "Accessible-inl.h"
|
2014-10-21 17:49:28 -07:00
|
|
|
#include "xpcAccessibleDocument.h"
|
2014-09-16 10:30:23 -07:00
|
|
|
|
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperLink::GetStartIndex(int32_t* aStartIndex)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aStartIndex);
|
|
|
|
*aStartIndex = 0;
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
if (!Intl())
|
2014-09-16 10:30:23 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
*aStartIndex = Intl()->StartOffset();
|
2014-09-16 10:30:23 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperLink::GetEndIndex(int32_t* aEndIndex)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aEndIndex);
|
|
|
|
*aEndIndex = 0;
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
if (!Intl())
|
2014-09-16 10:30:23 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
*aEndIndex = Intl()->EndOffset();
|
2014-09-16 10:30:23 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperLink::GetAnchorCount(int32_t* aAnchorCount)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAnchorCount);
|
|
|
|
*aAnchorCount = 0;
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
if (!Intl())
|
2014-09-16 10:30:23 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
*aAnchorCount = Intl()->AnchorCount();
|
2014-09-16 10:30:23 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperLink::GetURI(int32_t aIndex, nsIURI** aURI)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aURI);
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
if (!Intl())
|
2014-09-16 10:30:23 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
if (aIndex < 0 || aIndex >= static_cast<int32_t>(Intl()->AnchorCount()))
|
2014-09-16 10:30:23 -07:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2015-10-17 22:24:48 -07:00
|
|
|
RefPtr<nsIURI>(Intl()->AnchorURIAt(aIndex)).forget(aURI);
|
2014-09-16 10:30:23 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperLink::GetAnchor(int32_t aIndex, nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAccessible);
|
|
|
|
*aAccessible = nullptr;
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
if (!Intl())
|
2014-09-16 10:30:23 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
if (aIndex < 0 || aIndex >= static_cast<int32_t>(Intl()->AnchorCount()))
|
2014-09-16 10:30:23 -07:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
NS_IF_ADDREF(*aAccessible = ToXPC(Intl()->AnchorAt(aIndex)));
|
2014-09-16 10:30:23 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperLink::GetValid(bool* aValid)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aValid);
|
|
|
|
*aValid = false;
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
if (!Intl())
|
2014-09-16 10:30:23 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
*aValid = Intl()->IsLinkValid();
|
2014-09-16 10:30:23 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|