2006-06-21 13:29:10 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
2006-06-21 13:29:10 +00:00
|
|
|
|
2012-05-31 08:04:41 +00:00
|
|
|
#ifndef mozilla_a11y_HyperTextAccessible_h__
|
|
|
|
#define mozilla_a11y_HyperTextAccessible_h__
|
2006-06-21 13:29:10 +00:00
|
|
|
|
|
|
|
#include "nsIAccessibleText.h"
|
|
|
|
#include "nsIAccessibleHyperText.h"
|
|
|
|
#include "nsIAccessibleEditableText.h"
|
2010-06-21 13:08:27 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
#include "AccessibleWrap.h"
|
2008-07-17 12:06:24 +00:00
|
|
|
|
2006-07-12 13:14:53 +00:00
|
|
|
#include "nsFrameSelection.h"
|
2006-06-21 13:29:10 +00:00
|
|
|
#include "nsISelectionController.h"
|
|
|
|
|
2012-04-06 18:08:24 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
2012-11-18 02:01:44 +00:00
|
|
|
|
2012-04-06 18:08:24 +00:00
|
|
|
struct DOMPoint {
|
|
|
|
nsINode* node;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t idx;
|
2012-04-06 18:08:24 +00:00
|
|
|
};
|
|
|
|
|
2006-06-21 13:29:10 +00:00
|
|
|
enum EGetTextType { eGetBefore=-1, eGetAt=0, eGetAfter=1 };
|
|
|
|
|
|
|
|
// This character marks where in the text returned via nsIAccessibleText(),
|
|
|
|
// that embedded object characters exist
|
|
|
|
const PRUnichar kEmbeddedObjectChar = 0xfffc;
|
2007-11-17 03:44:49 +00:00
|
|
|
const PRUnichar kImaginaryEmbeddedObjectChar = ' ';
|
2006-07-12 13:14:53 +00:00
|
|
|
const PRUnichar kForcedNewLineChar = '\n';
|
2006-06-21 13:29:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Special Accessible that knows how contain both text and embedded objects
|
|
|
|
*/
|
2012-05-31 08:04:41 +00:00
|
|
|
class HyperTextAccessible : public AccessibleWrap,
|
|
|
|
public nsIAccessibleText,
|
|
|
|
public nsIAccessibleHyperText,
|
|
|
|
public nsIAccessibleEditableText
|
2006-06-21 13:29:10 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-05-31 08:04:41 +00:00
|
|
|
HyperTextAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
|
|
|
virtual ~HyperTextAccessible() { }
|
2012-02-07 22:38:54 +00:00
|
|
|
|
2006-06-21 13:29:10 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIACCESSIBLETEXT
|
|
|
|
NS_DECL_NSIACCESSIBLEHYPERTEXT
|
|
|
|
NS_DECL_NSIACCESSIBLEEDITABLETEXT
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
// Accessible
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual int32_t GetLevelInternal();
|
2012-10-19 07:15:23 +00:00
|
|
|
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
2012-01-12 03:07:35 +00:00
|
|
|
virtual mozilla::a11y::role NativeRole();
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual uint64_t NativeState();
|
2006-06-21 13:29:10 +00:00
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
virtual void InvalidateChildren();
|
2012-05-29 01:18:45 +00:00
|
|
|
virtual bool RemoveChild(Accessible* aAccessible);
|
2010-06-21 13:08:27 +00:00
|
|
|
|
2012-05-31 08:04:41 +00:00
|
|
|
// HyperTextAccessible (static helper method)
|
2010-06-21 13:08:27 +00:00
|
|
|
|
2007-08-04 01:12:24 +00:00
|
|
|
// Convert content offset to rendered text offset
|
2013-04-05 08:15:26 +00:00
|
|
|
nsresult ContentToRenderedOffset(nsIFrame *aFrame, int32_t aContentOffset,
|
|
|
|
uint32_t *aRenderedOffset);
|
2007-08-04 01:12:24 +00:00
|
|
|
|
|
|
|
// Convert rendered text offset to content offset
|
2013-04-05 08:15:26 +00:00
|
|
|
nsresult RenderedToContentOffset(nsIFrame *aFrame, uint32_t aRenderedOffset,
|
|
|
|
int32_t *aContentOffset);
|
2007-08-04 01:12:24 +00:00
|
|
|
|
2011-01-25 03:33:47 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// HyperLinkAccessible
|
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
/**
|
|
|
|
* Return link count within this hypertext accessible.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t GetLinkCount()
|
2010-06-21 13:08:27 +00:00
|
|
|
{
|
2012-05-25 10:53:45 +00:00
|
|
|
return EmbeddedChildCount();
|
2010-06-21 13:08:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return link accessible at the given index.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
Accessible* GetLinkAt(uint32_t aIndex)
|
2010-06-21 13:08:27 +00:00
|
|
|
{
|
2010-08-15 11:28:49 +00:00
|
|
|
return GetEmbeddedChildAt(aIndex);
|
2010-06-21 13:08:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return index for the given link accessible.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t GetLinkIndex(Accessible* aLink)
|
2010-06-21 13:08:27 +00:00
|
|
|
{
|
2010-08-15 11:28:49 +00:00
|
|
|
return GetIndexOfEmbeddedChild(aLink);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return link accessible at the given text offset.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t GetLinkIndexAtOffset(uint32_t aOffset)
|
2010-08-15 11:28:49 +00:00
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* child = GetChildAtOffset(aOffset);
|
2010-08-25 02:08:59 +00:00
|
|
|
return child ? GetLinkIndex(child) : -1;
|
2010-06-21 13:08:27 +00:00
|
|
|
}
|
|
|
|
|
2011-01-25 03:33:47 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2012-05-31 08:04:41 +00:00
|
|
|
// HyperTextAccessible: DOM point to text offset conversions.
|
2011-01-25 03:33:47 +00:00
|
|
|
|
2007-07-25 11:54:15 +00:00
|
|
|
/**
|
|
|
|
* Turn a DOM Node and offset into a character offset into this hypertext.
|
|
|
|
* Will look for closest match when the DOM node does not have an accessible
|
|
|
|
* object associated with it. Will return an offset for the end of
|
|
|
|
* the string if the node is not found.
|
|
|
|
*
|
|
|
|
* @param aNode - the node to look for
|
|
|
|
* @param aNodeOffset - the offset to look for
|
2007-08-28 21:57:53 +00:00
|
|
|
* if -1 just look directly for the node
|
|
|
|
* if >=0 and aNode is text, this represents a char offset
|
|
|
|
* if >=0 and aNode is not text, this represents a child node offset
|
2007-07-25 11:54:15 +00:00
|
|
|
* @param aResultOffset - the character offset into the current
|
2012-05-31 08:04:41 +00:00
|
|
|
* HyperTextAccessible
|
2011-10-17 14:59:28 +00:00
|
|
|
* @param aIsEndOffset - if true, then then this offset is not inclusive. The character
|
2007-09-18 22:28:26 +00:00
|
|
|
* indicated by the offset returned is at [offset - 1]. This means
|
|
|
|
* if the passed-in offset is really in a descendant, then the offset returned
|
|
|
|
* will come just after the relevant embedded object characer.
|
2011-10-17 14:59:28 +00:00
|
|
|
* If false, then the offset is inclusive. The character indicated
|
2007-09-18 22:28:26 +00:00
|
|
|
* by the offset returned is at [offset]. If the passed-in offset in inside a
|
|
|
|
* descendant, then the returned offset will be on the relevant embedded object char.
|
2010-05-17 16:16:52 +00:00
|
|
|
*
|
|
|
|
* @return the accessible child which contained the offset, if
|
2012-05-31 08:04:41 +00:00
|
|
|
* it is within the current HyperTextAccessible,
|
2012-07-30 14:20:58 +00:00
|
|
|
* otherwise nullptr
|
2007-07-25 11:54:15 +00:00
|
|
|
*/
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* DOMPointToHypertextOffset(nsINode *aNode,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aNodeOffset,
|
|
|
|
int32_t* aHypertextOffset,
|
2012-05-29 01:18:45 +00:00
|
|
|
bool aIsEndOffset = false);
|
2007-07-25 11:54:15 +00:00
|
|
|
|
2007-09-25 05:48:51 +00:00
|
|
|
/**
|
|
|
|
* Turn a start and end hypertext offsets into DOM range.
|
|
|
|
*
|
|
|
|
* @param aStartHTOffset [in] the given start hypertext offset
|
|
|
|
* @param aEndHTOffset [in] the given end hypertext offset
|
2012-04-06 18:08:24 +00:00
|
|
|
* @param aRange [out] the range whose bounds to set
|
2007-09-25 05:48:51 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult HypertextOffsetsToDOMRange(int32_t aStartHTOffset,
|
|
|
|
int32_t aEndHTOffset,
|
2012-04-06 18:08:24 +00:00
|
|
|
nsRange* aRange);
|
2007-09-25 05:48:51 +00:00
|
|
|
|
2012-04-14 01:19:41 +00:00
|
|
|
/**
|
|
|
|
* Return true if the used ARIA role (if any) allows the hypertext accessible
|
|
|
|
* to expose text interfaces.
|
|
|
|
*/
|
|
|
|
bool IsTextRole();
|
|
|
|
|
2011-01-25 03:33:47 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// TextAccessible
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return character count within the hypertext accessible.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t CharacterCount()
|
2011-01-25 03:33:47 +00:00
|
|
|
{
|
2012-05-25 10:53:45 +00:00
|
|
|
return GetChildOffset(ChildCount());
|
2011-01-25 03:33:47 +00:00
|
|
|
}
|
|
|
|
|
2011-02-03 14:29:12 +00:00
|
|
|
/**
|
|
|
|
* Get a character before/at/after the given offset.
|
|
|
|
*
|
|
|
|
* @param aOffset [in] the given offset
|
|
|
|
* @param aShift [in] specifies whether to get a char before/at/after
|
|
|
|
* offset
|
|
|
|
* @param aChar [out] the character
|
|
|
|
* @param aStartOffset [out, optional] the start offset of the character
|
|
|
|
* @param aEndOffset [out, optional] the end offset of the character
|
|
|
|
* @return false if offset at the given shift is out of range
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
bool GetCharAt(int32_t aOffset, EGetTextType aShift, nsAString& aChar,
|
|
|
|
int32_t* aStartOffset = nullptr, int32_t* aEndOffset = nullptr);
|
2011-02-03 14:29:12 +00:00
|
|
|
|
2010-07-02 01:50:03 +00:00
|
|
|
/**
|
2010-08-15 11:28:49 +00:00
|
|
|
* Return text offset of the given child accessible within hypertext
|
|
|
|
* accessible.
|
2010-07-02 01:50:03 +00:00
|
|
|
*
|
|
|
|
* @param aChild [in] accessible child to get text offset for
|
|
|
|
* @param aInvalidateAfter [in, optional] indicates whether invalidate
|
|
|
|
* cached offsets for next siblings of the child
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t GetChildOffset(Accessible* aChild,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aInvalidateAfter = false)
|
2010-08-15 11:28:49 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t index = GetIndexOf(aChild);
|
2010-08-15 11:28:49 +00:00
|
|
|
return index == -1 ? -1 : GetChildOffset(index, aInvalidateAfter);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return text offset for the child accessible index.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t GetChildOffset(uint32_t aChildIndex,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aInvalidateAfter = false);
|
2010-07-02 01:50:03 +00:00
|
|
|
|
2010-08-15 11:28:49 +00:00
|
|
|
/**
|
|
|
|
* Return child accessible at the given text offset.
|
|
|
|
*
|
|
|
|
* @param aOffset [in] the given text offset
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t GetChildIndexAtOffset(uint32_t aOffset);
|
2009-12-10 19:12:19 +00:00
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
/**
|
2010-08-15 11:28:49 +00:00
|
|
|
* Return child accessible at the given text offset.
|
|
|
|
*
|
|
|
|
* @param aOffset [in] the given text offset
|
2010-06-21 13:08:27 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
Accessible* GetChildAtOffset(uint32_t aOffset)
|
2010-08-15 11:28:49 +00:00
|
|
|
{
|
|
|
|
return GetChildAt(GetChildIndexAtOffset(aOffset));
|
|
|
|
}
|
|
|
|
|
2012-03-23 18:54:55 +00:00
|
|
|
/**
|
|
|
|
* Return the bounds of the text between given start and end offset.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
nsIntRect GetTextBounds(int32_t aStartOffset, int32_t aEndOffset)
|
2012-03-23 18:54:55 +00:00
|
|
|
{
|
|
|
|
nsIntRect bounds;
|
2012-07-30 14:20:58 +00:00
|
|
|
GetPosAndText(aStartOffset, aEndOffset, nullptr, nullptr, &bounds);
|
2012-03-23 18:54:55 +00:00
|
|
|
return bounds;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide the line number for the caret.
|
|
|
|
* @return 1-based index for the line number with the caret
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t CaretLineNumber();
|
2012-03-23 18:54:55 +00:00
|
|
|
|
2012-03-08 03:28:38 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// EditableTextAccessible
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the editor associated with the accessible.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<nsIEditor> GetEditor() const;
|
|
|
|
|
2010-08-15 11:28:49 +00:00
|
|
|
protected:
|
2012-10-14 04:18:39 +00:00
|
|
|
// Accessible
|
2012-11-18 02:01:44 +00:00
|
|
|
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
|
2012-10-14 04:18:39 +00:00
|
|
|
|
2012-05-31 08:04:41 +00:00
|
|
|
// HyperTextAccessible
|
2010-06-21 13:08:27 +00:00
|
|
|
|
2011-02-03 14:29:12 +00:00
|
|
|
/**
|
|
|
|
* Transform magic offset into text offset.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t ConvertMagicOffset(int32_t aOffset)
|
2011-02-03 14:29:12 +00:00
|
|
|
{
|
|
|
|
if (aOffset == nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT)
|
|
|
|
return CharacterCount();
|
|
|
|
|
|
|
|
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t caretOffset = -1;
|
2011-02-03 14:29:12 +00:00
|
|
|
GetCaretOffset(&caretOffset);
|
|
|
|
return caretOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aOffset;
|
|
|
|
}
|
|
|
|
|
2013-07-09 17:32:07 +00:00
|
|
|
/**
|
|
|
|
* Adjust an offset the caret stays at to get a text by line boundary.
|
|
|
|
*/
|
|
|
|
int32_t AdjustCaretOffset(int32_t aOffset)
|
|
|
|
{
|
|
|
|
// It is the same character offset when the caret is visually at the very
|
|
|
|
// end of a line or the start of a new line (soft line break). Getting text
|
|
|
|
// at the line should provide the line with the visual caret, otherwise
|
|
|
|
// screen readers will announce the wrong line as the user presses up or
|
|
|
|
// down arrow and land at the end of a line.
|
|
|
|
if (aOffset > 0) {
|
|
|
|
nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
|
|
|
|
if (frameSelection &&
|
|
|
|
frameSelection->GetHint() == nsFrameSelection::HINTLEFT) {
|
|
|
|
return aOffset - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aOffset;
|
|
|
|
}
|
|
|
|
|
2013-07-12 17:34:13 +00:00
|
|
|
/**
|
|
|
|
* Return true if the given offset points to terminal empty line if any.
|
|
|
|
*/
|
|
|
|
bool IsEmptyLastLineOffset(int32_t aOffset)
|
|
|
|
{
|
|
|
|
if (aOffset != static_cast<int32_t>(CharacterCount()))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
nsAutoString lastChar;
|
|
|
|
GetText(aOffset -1, -1, lastChar);
|
|
|
|
return lastChar.EqualsLiteral("\n");
|
|
|
|
}
|
|
|
|
|
2013-03-31 13:39:29 +00:00
|
|
|
/**
|
|
|
|
* Return an offset of the found word boundary.
|
|
|
|
*/
|
|
|
|
int32_t FindWordBoundary(int32_t aOffset, nsDirection aDirection,
|
2013-07-02 12:57:29 +00:00
|
|
|
EWordMovementType aWordMovementType)
|
|
|
|
{
|
2013-07-16 17:13:34 +00:00
|
|
|
return FindOffset(aOffset, aDirection, eSelectWord, aWordMovementType);
|
2013-07-02 12:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-07-16 17:13:34 +00:00
|
|
|
* Used to get begin/end of previous/this/next line. Note: end of line
|
|
|
|
* is an offset right before '\n' character if any, the offset is right after
|
|
|
|
* '\n' character is begin of line. In case of wrap word breaks these offsets
|
|
|
|
* are equal.
|
2013-07-02 12:57:29 +00:00
|
|
|
*/
|
2013-07-16 17:13:34 +00:00
|
|
|
enum EWhichLineBoundary {
|
|
|
|
ePrevLineBegin,
|
|
|
|
ePrevLineEnd,
|
|
|
|
eThisLineBegin,
|
|
|
|
eThisLineEnd,
|
|
|
|
eNextLineBegin,
|
|
|
|
eNextLineEnd
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an offset for requested line boundary. See constants above.
|
|
|
|
*/
|
|
|
|
int32_t FindLineBoundary(int32_t aOffset,
|
|
|
|
EWhichLineBoundary aWhichLineBoundary);
|
2013-07-02 12:57:29 +00:00
|
|
|
|
|
|
|
/**
|
2013-07-16 17:13:34 +00:00
|
|
|
* Return an offset corresponding to the given direction and selection amount
|
|
|
|
* relative the given offset. A helper used to find word or line boundaries.
|
2013-07-02 12:57:29 +00:00
|
|
|
*/
|
2013-07-16 17:13:34 +00:00
|
|
|
int32_t FindOffset(int32_t aOffset, nsDirection aDirection,
|
|
|
|
nsSelectionAmount aAmount,
|
|
|
|
EWordMovementType aWordMovementType = eDefaultBehavior);
|
2013-03-31 13:39:29 +00:00
|
|
|
|
2007-03-06 13:44:42 +00:00
|
|
|
/**
|
2013-07-17 14:23:10 +00:00
|
|
|
* Used by FindOffset() to move backward/forward from a given point
|
2007-08-29 07:12:09 +00:00
|
|
|
* by word/line/etc.
|
|
|
|
*
|
|
|
|
* @param aPresShell the current presshell we're moving in
|
|
|
|
* @param aFromFrame the starting frame we're moving from
|
|
|
|
* @param aFromOffset the starting offset we're moving from
|
|
|
|
* @param aFromAccessible the starting accessible we're moving from
|
|
|
|
* @param aAmount how much are we moving (word/line/etc.) ?
|
|
|
|
* @param aDirection forward or backward?
|
|
|
|
* @param aNeedsStart for word and line cases, are we basing this on
|
|
|
|
* the start or end?
|
|
|
|
* @return the resulting offset into this hypertext
|
2007-03-06 13:44:42 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t GetRelativeOffset(nsIPresShell *aPresShell, nsIFrame *aFromFrame,
|
|
|
|
int32_t aFromOffset, Accessible* aFromAccessible,
|
2007-08-29 07:12:09 +00:00
|
|
|
nsSelectionAmount aAmount, nsDirection aDirection,
|
2013-03-24 00:57:06 +00:00
|
|
|
bool aNeedsStart,
|
|
|
|
EWordMovementType aWordMovementType);
|
2007-08-24 04:54:45 +00:00
|
|
|
|
2007-03-06 13:44:42 +00:00
|
|
|
/**
|
2007-08-24 04:54:45 +00:00
|
|
|
* Provides information for substring that is defined by the given start
|
|
|
|
* and end offsets for this hyper text.
|
|
|
|
*
|
|
|
|
* @param aStartOffset [inout] the start offset into the hyper text. This
|
|
|
|
* is also an out parameter used to return the offset
|
|
|
|
* into the start frame's rendered text content
|
|
|
|
* (start frame is the @return)
|
|
|
|
*
|
|
|
|
* @param aEndOffset [inout] the end offset into the hyper text. This is
|
|
|
|
* also an out parameter used to return
|
|
|
|
* the offset into the end frame's rendered
|
|
|
|
* text content.
|
|
|
|
*
|
|
|
|
* @param aText [out, optional] return the substring's text
|
|
|
|
* @param aEndFrame [out, optional] return the end frame for this
|
|
|
|
* substring
|
|
|
|
* @param aBoundsRect [out, optional] return the bounds rectangle for this
|
|
|
|
* substring
|
|
|
|
* @param aStartAcc [out, optional] return the start accessible for this
|
|
|
|
* substring
|
|
|
|
* @param aEndAcc [out, optional] return the end accessible for this
|
|
|
|
* substring
|
|
|
|
* @return the start frame for this substring
|
2007-03-06 13:44:42 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
nsIFrame* GetPosAndText(int32_t& aStartOffset, int32_t& aEndOffset,
|
2012-07-30 14:20:58 +00:00
|
|
|
nsAString *aText = nullptr,
|
|
|
|
nsIFrame **aEndFrame = nullptr,
|
|
|
|
nsIntRect *aBoundsRect = nullptr,
|
|
|
|
Accessible** aStartAcc = nullptr,
|
|
|
|
Accessible** aEndAcc = nullptr);
|
2007-07-25 11:54:15 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsIntRect GetBoundsForString(nsIFrame *aFrame, uint32_t aStartRenderedOffset, uint32_t aEndRenderedOffset);
|
2006-06-21 13:29:10 +00:00
|
|
|
|
|
|
|
// Selection helpers
|
2007-09-18 22:28:26 +00:00
|
|
|
|
2011-10-12 07:39:58 +00:00
|
|
|
/**
|
|
|
|
* Return frame selection object for the accessible.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<nsFrameSelection> FrameSelection();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return selection ranges within the accessible subtree.
|
2007-09-18 22:28:26 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
void GetSelectionDOMRanges(int16_t aType, nsTArray<nsRange*>* aRanges);
|
2008-07-17 12:06:24 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult SetSelectionRange(int32_t aStartPos, int32_t aEndPos);
|
2007-09-25 05:48:51 +00:00
|
|
|
|
|
|
|
// Helpers
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult GetDOMPointByFrameOffset(nsIFrame* aFrame, int32_t aOffset,
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* aAccessible,
|
2012-04-06 18:08:24 +00:00
|
|
|
mozilla::a11y::DOMPoint* aPoint);
|
2008-07-17 12:06:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return hyper text offset for the specified bound of the given DOM range.
|
|
|
|
* If the bound is outside of the hyper text then offset value is either
|
|
|
|
* 0 or number of characters of hyper text, it depends on type of requested
|
|
|
|
* offset. The method is a wrapper for DOMPointToHypertextOffset.
|
|
|
|
*
|
|
|
|
* @param aRange [in] the given range
|
|
|
|
* @param aIsStartBound [in] specifies whether the required range bound is
|
|
|
|
* start bound
|
|
|
|
* @param aIsStartOffset [in] the offset type, used when the range bound is
|
|
|
|
* outside of hyper text
|
|
|
|
* @param aHTOffset [out] the result offset
|
|
|
|
*/
|
2012-01-10 14:19:54 +00:00
|
|
|
nsresult RangeBoundToHypertextOffset(nsRange *aRange,
|
|
|
|
bool aIsStartBound,
|
|
|
|
bool aIsStartOffset,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t *aHTOffset);
|
2008-07-17 12:06:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set 'misspelled' text attribute and return range offsets where the
|
|
|
|
* attibute is stretched. If the text is not misspelled at the given offset
|
|
|
|
* then we expose only range offsets where text is not misspelled. The method
|
|
|
|
* is used by GetTextAttributes() method.
|
|
|
|
*
|
|
|
|
* @param aIncludeDefAttrs [in] points whether text attributes having default
|
|
|
|
* values of attributes should be included
|
|
|
|
* @param aSourceNode [in] the node we start to traverse from
|
|
|
|
* @param aStartOffset [in, out] the start offset
|
|
|
|
* @param aEndOffset [in, out] the end offset
|
2008-07-24 15:20:39 +00:00
|
|
|
* @param aAttributes [out, optional] result attributes
|
2008-07-17 12:06:24 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult GetSpellTextAttribute(nsINode* aNode, int32_t aNodeOffset,
|
|
|
|
int32_t *aStartOffset,
|
|
|
|
int32_t *aEndOffset,
|
2008-07-17 12:06:24 +00:00
|
|
|
nsIPersistentProperties *aAttributes);
|
2010-06-21 13:08:27 +00:00
|
|
|
|
|
|
|
private:
|
2010-07-02 01:50:03 +00:00
|
|
|
/**
|
|
|
|
* End text offsets array.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
nsTArray<uint32_t> mOffsets;
|
2006-06-21 13:29:10 +00:00
|
|
|
};
|
2007-04-17 06:52:52 +00:00
|
|
|
|
2011-01-28 05:15:13 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-05-29 01:18:45 +00:00
|
|
|
// Accessible downcasting method
|
2011-01-28 05:15:13 +00:00
|
|
|
|
2012-05-31 08:04:41 +00:00
|
|
|
inline HyperTextAccessible*
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible::AsHyperText()
|
2011-01-28 05:15:13 +00:00
|
|
|
{
|
2012-12-18 05:22:26 +00:00
|
|
|
return IsHyperText() ? static_cast<HyperTextAccessible*>(this) : nullptr;
|
2011-01-28 05:15:13 +00:00
|
|
|
}
|
|
|
|
|
2012-11-18 02:01:44 +00:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2012-05-31 08:04:41 +00:00
|
|
|
#endif
|
2007-07-25 11:54:15 +00:00
|
|
|
|