2014-09-16 21:30:23 +04: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-22 04:49:28 +04:00
|
|
|
#include "xpcAccessibleDocument.h"
|
2014-09-16 21:30:23 +04:00
|
|
|
|
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperLink::GetStartIndex(int32_t* aStartIndex)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aStartIndex);
|
|
|
|
*aStartIndex = 0;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2014-09-16 21:30:23 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aStartIndex = Intl()->StartOffset();
|
2014-09-16 21:30:23 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperLink::GetEndIndex(int32_t* aEndIndex)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aEndIndex);
|
|
|
|
*aEndIndex = 0;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2014-09-16 21:30:23 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aEndIndex = Intl()->EndOffset();
|
2014-09-16 21:30:23 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperLink::GetAnchorCount(int32_t* aAnchorCount)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAnchorCount);
|
|
|
|
*aAnchorCount = 0;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2014-09-16 21:30:23 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aAnchorCount = Intl()->AnchorCount();
|
2014-09-16 21:30:23 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperLink::GetURI(int32_t aIndex, nsIURI** aURI)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aURI);
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2014-09-16 21:30:23 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (aIndex < 0 || aIndex >= static_cast<int32_t>(Intl()->AnchorCount()))
|
2014-09-16 21:30:23 +04:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
nsRefPtr<nsIURI>(Intl()->AnchorURIAt(aIndex)).forget(aURI);
|
2014-09-16 21:30:23 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperLink::GetAnchor(int32_t aIndex, nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAccessible);
|
|
|
|
*aAccessible = nullptr;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2014-09-16 21:30:23 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (aIndex < 0 || aIndex >= static_cast<int32_t>(Intl()->AnchorCount()))
|
2014-09-16 21:30:23 +04:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IF_ADDREF(*aAccessible = ToXPC(Intl()->AnchorAt(aIndex)));
|
2014-09-16 21:30:23 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperLink::GetValid(bool* aValid)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aValid);
|
|
|
|
*aValid = false;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2014-09-16 21:30:23 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aValid = Intl()->IsLinkValid();
|
2014-09-16 21:30:23 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|