2013-11-18 17:19:33 +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 "xpcAccessibleHyperText.h"
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
#include "Accessible-inl.h"
|
2013-11-18 17:19:33 +04:00
|
|
|
#include "HyperTextAccessible-inl.h"
|
2014-02-27 20:33:09 +04:00
|
|
|
#include "TextRange.h"
|
2014-10-22 04:49:28 +04:00
|
|
|
#include "xpcAccessibleDocument.h"
|
2014-02-27 20:33:09 +04:00
|
|
|
#include "xpcAccessibleTextRange.h"
|
2013-11-18 17:19:33 +04:00
|
|
|
|
|
|
|
#include "nsIPersistentProperties2.h"
|
2014-02-27 20:33:09 +04:00
|
|
|
#include "nsIMutableArray.h"
|
2013-11-18 17:19:33 +04:00
|
|
|
|
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsISupports
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN(xpcAccessibleHyperText)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleText,
|
|
|
|
mSupportedIfaces & eText)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleEditableText,
|
|
|
|
mSupportedIfaces & eText)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAccessibleHyperText,
|
|
|
|
mSupportedIfaces & eText)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(xpcAccessibleGeneric)
|
2013-11-18 17:19:33 +04:00
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(xpcAccessibleHyperText, xpcAccessibleGeneric)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(xpcAccessibleHyperText, xpcAccessibleGeneric)
|
2013-11-18 17:19:33 +04:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIAccessibleText
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetCharacterCount(int32_t* aCharacterCount)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCharacterCount);
|
|
|
|
*aCharacterCount = 0;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aCharacterCount = Intl()->CharacterCount();
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetText(int32_t aStartOffset, int32_t aEndOffset,
|
|
|
|
nsAString& aText)
|
|
|
|
{
|
|
|
|
aText.Truncate();
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->TextSubstring(aStartOffset, aEndOffset, aText);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetTextBeforeOffset(int32_t aOffset,
|
|
|
|
AccessibleTextBoundary aBoundaryType,
|
|
|
|
int32_t* aStartOffset,
|
|
|
|
int32_t* aEndOffset,
|
|
|
|
nsAString& aText)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aStartOffset);
|
|
|
|
NS_ENSURE_ARG_POINTER(aEndOffset);
|
|
|
|
*aStartOffset = *aEndOffset = 0;
|
|
|
|
aText.Truncate();
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->TextBeforeOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetTextAtOffset(int32_t aOffset,
|
|
|
|
AccessibleTextBoundary aBoundaryType,
|
|
|
|
int32_t* aStartOffset,
|
|
|
|
int32_t* aEndOffset, nsAString& aText)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aStartOffset);
|
|
|
|
NS_ENSURE_ARG_POINTER(aEndOffset);
|
|
|
|
*aStartOffset = *aEndOffset = 0;
|
|
|
|
aText.Truncate();
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->TextAtOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetTextAfterOffset(int32_t aOffset,
|
|
|
|
AccessibleTextBoundary aBoundaryType,
|
|
|
|
int32_t* aStartOffset,
|
|
|
|
int32_t* aEndOffset, nsAString& aText)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aStartOffset);
|
|
|
|
NS_ENSURE_ARG_POINTER(aEndOffset);
|
|
|
|
*aStartOffset = *aEndOffset = 0;
|
|
|
|
aText.Truncate();
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->TextAfterOffset(aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetCharacterAtOffset(int32_t aOffset,
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t* aCharacter)
|
2013-11-18 17:19:33 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCharacter);
|
|
|
|
*aCharacter = L'\0';
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aCharacter = Intl()->CharAt(aOffset);
|
2013-12-19 23:28:51 +04:00
|
|
|
return NS_OK;
|
2013-11-18 17:19:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetTextAttributes(bool aIncludeDefAttrs,
|
|
|
|
int32_t aOffset,
|
|
|
|
int32_t* aStartOffset,
|
|
|
|
int32_t* aEndOffset,
|
|
|
|
nsIPersistentProperties** aAttributes)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aStartOffset);
|
|
|
|
NS_ENSURE_ARG_POINTER(aEndOffset);
|
|
|
|
NS_ENSURE_ARG_POINTER(aAttributes);
|
|
|
|
*aStartOffset = *aEndOffset = 0;
|
|
|
|
*aAttributes = nullptr;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPersistentProperties> attrs =
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->TextAttributes(aIncludeDefAttrs, aOffset, aStartOffset, aEndOffset);
|
2013-11-18 17:19:33 +04:00
|
|
|
attrs.swap(*aAttributes);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetDefaultTextAttributes(nsIPersistentProperties** aAttributes)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAttributes);
|
|
|
|
*aAttributes = nullptr;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
nsCOMPtr<nsIPersistentProperties> attrs = Intl()->DefaultTextAttributes();
|
2013-11-18 17:19:33 +04:00
|
|
|
attrs.swap(*aAttributes);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetCharacterExtents(int32_t aOffset,
|
|
|
|
int32_t* aX, int32_t* aY,
|
|
|
|
int32_t* aWidth, int32_t* aHeight,
|
|
|
|
uint32_t aCoordType)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aX);
|
|
|
|
NS_ENSURE_ARG_POINTER(aY);
|
|
|
|
NS_ENSURE_ARG_POINTER(aWidth);
|
|
|
|
NS_ENSURE_ARG_POINTER(aHeight);
|
|
|
|
*aX = *aY = *aWidth = *aHeight;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
nsIntRect rect = Intl()->CharBounds(aOffset, aCoordType);
|
2013-11-18 17:19:33 +04:00
|
|
|
*aX = rect.x; *aY = rect.y;
|
|
|
|
*aWidth = rect.width; *aHeight = rect.height;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetRangeExtents(int32_t aStartOffset, int32_t aEndOffset,
|
|
|
|
int32_t* aX, int32_t* aY,
|
|
|
|
int32_t* aWidth, int32_t* aHeight,
|
|
|
|
uint32_t aCoordType)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aX);
|
|
|
|
NS_ENSURE_ARG_POINTER(aY);
|
|
|
|
NS_ENSURE_ARG_POINTER(aWidth);
|
|
|
|
NS_ENSURE_ARG_POINTER(aHeight);
|
|
|
|
*aX = *aY = *aWidth = *aHeight = 0;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
nsIntRect rect = Intl()->TextBounds(aStartOffset, aEndOffset, aCoordType);
|
2013-11-18 17:19:33 +04:00
|
|
|
*aX = rect.x; *aY = rect.y;
|
|
|
|
*aWidth = rect.width; *aHeight = rect.height;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetOffsetAtPoint(int32_t aX, int32_t aY,
|
|
|
|
uint32_t aCoordType, int32_t* aOffset)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aOffset);
|
|
|
|
*aOffset = -1;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aOffset = Intl()->OffsetAtPoint(aX, aY, aCoordType);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-22 04:49:28 +04:00
|
|
|
xpcAccessibleHyperText::GetCaretOffset(int32_t* aCaretOffset)
|
2013-11-18 17:19:33 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCaretOffset);
|
|
|
|
*aCaretOffset = -1;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aCaretOffset = Intl()->CaretOffset();
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-22 04:49:28 +04:00
|
|
|
xpcAccessibleHyperText::SetCaretOffset(int32_t aCaretOffset)
|
2013-11-18 17:19:33 +04:00
|
|
|
{
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->SetCaretOffset(aCaretOffset);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetSelectionCount(int32_t* aSelectionCount)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSelectionCount);
|
|
|
|
*aSelectionCount = 0;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aSelectionCount = Intl()->SelectionCount();
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetSelectionBounds(int32_t aSelectionNum,
|
|
|
|
int32_t* aStartOffset,
|
|
|
|
int32_t* aEndOffset)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aStartOffset);
|
|
|
|
NS_ENSURE_ARG_POINTER(aEndOffset);
|
|
|
|
*aStartOffset = *aEndOffset = 0;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (aSelectionNum < 0 || aSelectionNum >= Intl()->SelectionCount())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->SelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::SetSelectionBounds(int32_t aSelectionNum,
|
|
|
|
int32_t aStartOffset,
|
|
|
|
int32_t aEndOffset)
|
|
|
|
{
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
if (aSelectionNum < 0 ||
|
2014-10-22 04:49:28 +04:00
|
|
|
!Intl()->SetSelectionBoundsAt(aSelectionNum, aStartOffset, aEndOffset))
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::AddSelection(int32_t aStartOffset, int32_t aEndOffset)
|
|
|
|
{
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->AddToSelection(aStartOffset, aEndOffset);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::RemoveSelection(int32_t aSelectionNum)
|
|
|
|
{
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->RemoveFromSelection(aSelectionNum);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-22 04:49:28 +04:00
|
|
|
xpcAccessibleHyperText::ScrollSubstringTo(int32_t aStartOffset,
|
|
|
|
int32_t aEndOffset,
|
|
|
|
uint32_t aScrollType)
|
2013-11-18 17:19:33 +04:00
|
|
|
{
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->ScrollSubstringTo(aStartOffset, aEndOffset, aScrollType);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-22 04:49:28 +04:00
|
|
|
xpcAccessibleHyperText::ScrollSubstringToPoint(int32_t aStartOffset,
|
|
|
|
int32_t aEndOffset,
|
|
|
|
uint32_t aCoordinateType,
|
|
|
|
int32_t aX, int32_t aY)
|
2013-11-18 17:19:33 +04:00
|
|
|
{
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->ScrollSubstringToPoint(aStartOffset, aEndOffset, aCoordinateType, aX, aY);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-27 20:33:09 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetEnclosingRange(nsIAccessibleTextRange** aRange)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRange);
|
|
|
|
*aRange = nullptr;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2014-02-27 20:33:09 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsRefPtr<xpcAccessibleTextRange> range = new xpcAccessibleTextRange;
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->EnclosingRange(range->mRange);
|
2014-02-27 20:33:09 +04:00
|
|
|
NS_ASSERTION(range->mRange.IsValid(),
|
|
|
|
"Should always have an enclosing range!");
|
|
|
|
|
|
|
|
range.forget(aRange);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetSelectionRanges(nsIArray** aRanges)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRanges);
|
|
|
|
*aRanges = nullptr;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2014-02-27 20:33:09 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIMutableArray> xpcRanges =
|
|
|
|
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsAutoTArray<TextRange, 1> ranges;
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->SelectionRanges(&ranges);
|
2014-02-27 20:33:09 +04:00
|
|
|
uint32_t len = ranges.Length();
|
|
|
|
for (uint32_t idx = 0; idx < len; idx++)
|
|
|
|
xpcRanges->AppendElement(new xpcAccessibleTextRange(Move(ranges[idx])),
|
|
|
|
false);
|
|
|
|
|
|
|
|
xpcRanges.forget(aRanges);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetVisibleRanges(nsIArray** aRanges)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRanges);
|
|
|
|
*aRanges = nullptr;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2014-02-27 20:33:09 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIMutableArray> xpcRanges =
|
|
|
|
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsTArray<TextRange> ranges;
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->VisibleRanges(&ranges);
|
2014-02-27 20:33:09 +04:00
|
|
|
uint32_t len = ranges.Length();
|
|
|
|
for (uint32_t idx = 0; idx < len; idx++)
|
|
|
|
xpcRanges->AppendElement(new xpcAccessibleTextRange(Move(ranges[idx])),
|
|
|
|
false);
|
|
|
|
|
|
|
|
xpcRanges.forget(aRanges);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetRangeByChild(nsIAccessible* aChild,
|
|
|
|
nsIAccessibleTextRange** aRange)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRange);
|
|
|
|
*aRange = nullptr;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2014-02-27 20:33:09 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Accessible* child = aChild->ToInternalAccessible();
|
2014-02-27 20:33:09 +04:00
|
|
|
if (child) {
|
|
|
|
nsRefPtr<xpcAccessibleTextRange> range = new xpcAccessibleTextRange;
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->RangeByChild(child, range->mRange);
|
2014-02-27 20:33:09 +04:00
|
|
|
if (range->mRange.IsValid())
|
|
|
|
range.forget(aRange);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetRangeAtPoint(int32_t aX, int32_t aY,
|
|
|
|
nsIAccessibleTextRange** aRange)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRange);
|
|
|
|
*aRange = nullptr;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2014-02-27 20:33:09 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsRefPtr<xpcAccessibleTextRange> range = new xpcAccessibleTextRange;
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->RangeAtPoint(aX, aY, range->mRange);
|
2014-02-27 20:33:09 +04:00
|
|
|
if (range->mRange.IsValid())
|
|
|
|
range.forget(aRange);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-11-18 17:19:33 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIAccessibleEditableText
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::SetTextContents(const nsAString& aText)
|
|
|
|
{
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->ReplaceText(aText);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-22 04:49:28 +04:00
|
|
|
xpcAccessibleHyperText::InsertText(const nsAString& aText, int32_t aOffset)
|
2013-11-18 17:19:33 +04:00
|
|
|
{
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->InsertText(aText, aOffset);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-22 04:49:28 +04:00
|
|
|
xpcAccessibleHyperText::CopyText(int32_t aStartOffset, int32_t aEndOffset)
|
2013-11-18 17:19:33 +04:00
|
|
|
{
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->CopyText(aStartOffset, aEndOffset);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-22 04:49:28 +04:00
|
|
|
xpcAccessibleHyperText::CutText(int32_t aStartOffset, int32_t aEndOffset)
|
2013-11-18 17:19:33 +04:00
|
|
|
{
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->CutText(aStartOffset, aEndOffset);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-22 04:49:28 +04:00
|
|
|
xpcAccessibleHyperText::DeleteText(int32_t aStartOffset, int32_t aEndOffset)
|
2013-11-18 17:19:33 +04:00
|
|
|
{
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->DeleteText(aStartOffset, aEndOffset);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-22 04:49:28 +04:00
|
|
|
xpcAccessibleHyperText::PasteText(int32_t aOffset)
|
2013-11-18 17:19:33 +04:00
|
|
|
{
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->PasteText(aOffset);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIAccessibleHyperText
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetLinkCount(int32_t* aLinkCount)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aLinkCount);
|
|
|
|
*aLinkCount = 0;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aLinkCount = Intl()->LinkCount();
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetLinkAt(int32_t aIndex, nsIAccessibleHyperLink** aLink)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aLink);
|
|
|
|
*aLink = nullptr;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IF_ADDREF(*aLink = ToXPC(Intl()->LinkAt(aIndex)));
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetLinkIndex(nsIAccessibleHyperLink* aLink,
|
|
|
|
int32_t* aIndex)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aLink);
|
|
|
|
NS_ENSURE_ARG_POINTER(aIndex);
|
|
|
|
*aIndex = -1;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
nsCOMPtr<nsIAccessible> xpcLink(do_QueryInterface(aLink));
|
|
|
|
Accessible* link = xpcLink->ToInternalAccessible();
|
|
|
|
if (link)
|
|
|
|
*aIndex = Intl()->LinkIndexOf(link);
|
|
|
|
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
xpcAccessibleHyperText::GetLinkIndexAtOffset(int32_t aOffset,
|
|
|
|
int32_t* aLinkIndex)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aLinkIndex);
|
|
|
|
*aLinkIndex = -1; // API says this magic value means 'not found'
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aLinkIndex = Intl()->LinkIndexAtOffset(aOffset);
|
2013-11-18 17:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|