Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
nsAccessibleHyperText Class Reference

#include <nsAccessibleHyperText.h>

Inheritance diagram for nsAccessibleHyperText:
Inheritance graph
[legend]
Collaboration diagram for nsAccessibleHyperText:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsAccessibleHyperText (nsIDOMNode *aDomNode, nsIWeakReference *aShell)
virtual ~nsAccessibleHyperText ()
nsresult GetBounds (nsIWeakReference *aShell, PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
void Shutdown ()
PRInt32 GetIndex ()
nsIAccessibleHyperLink getLink (in long index)
long getLinkIndex (in long charIndex)
long getSelectedLinkIndex ()
AString getText (in long startOffset, in long endOffset)
 String methods may need to return multibyte-encoded strings, since some locales can't be encoded using 16-bit chars.
AString getTextAfterOffset (in long offset, in nsAccessibleTextBoundary boundaryType, out long startOffset, out long endOffset)
AString getTextAtOffset (in long offset, in nsAccessibleTextBoundary boundaryType, out long startOffset, out long endOffset)
AString getTextBeforeOffset (in long offset, in nsAccessibleTextBoundary boundaryType, out long startOffset, out long endOffset)
wchar getCharacterAtOffset (in long offset)
 It would be better to return an unsigned long here, to allow unicode chars > 16 bits.
nsISupports getAttributeRange (in long offset, out long rangeStartOffset, out long rangeEndOffset)
void getCharacterExtents (in long offset, out long x, out long y, out long width, out long height, in nsAccessibleCoordType coordType)
long getOffsetAtPoint (in long x, in long y, in nsAccessibleCoordType coordType)
void getSelectionBounds (in long selectionNum, out long startOffset, out long endOffset)
void setSelectionBounds (in long selectionNum, in long startOffset, in long endOffset)
void addSelection (in long startOffset, in long endOffset)
void removeSelection (in long selectionNum)

Public Attributes

readonly attribute long links
const nsAccessibleTextBoundary BOUNDARY_CHAR = 0
const nsAccessibleTextBoundary BOUNDARY_WORD_START = 1
const nsAccessibleTextBoundary BOUNDARY_WORD_END = 2
const nsAccessibleTextBoundary BOUNDARY_SENTENCE_START = 3
const nsAccessibleTextBoundary BOUNDARY_SENTENCE_END = 4
const nsAccessibleTextBoundary BOUNDARY_LINE_START = 5
const nsAccessibleTextBoundary BOUNDARY_LINE_END = 6
const nsAccessibleTextBoundary BOUNDARY_ATTRIBUTE_RANGE = 7
const nsAccessibleCoordType COORD_TYPE_SCREEN = 0
const nsAccessibleCoordType COORD_TYPE_WINDOW = 1
attribute long caretOffset
readonly attribute long characterCount
readonly attribute long selectionCount

Protected Member Functions

PRBool GetAllTextChildren (nsPresContext *aPresContext, nsIFrame *aCurFrame, nsIDOMNode *aNode, PRBool &bSave)
nsIDOMNodeFindTextNodeByOffset (PRInt32 aOffset, PRInt32 &aBeforeLength)
nsresult GetTextHelper (EGetTextType aType, nsAccessibleTextBoundary aBoundaryType, PRInt32 aOffset, PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString &aText)
nsIDOMNodeGetLinkNode (nsIDOMNode *aNode)

Protected Attributes

nsCOMPtr< nsIMutableArraymTextChildren
PRInt32 mIndex

Detailed Description

Definition at line 49 of file nsAccessibleHyperText.h.


Constructor & Destructor Documentation

Definition at line 58 of file nsAccessibleHyperText.cpp.

{
  mIndex = -1;
  nsCOMPtr<nsIContent> content(do_QueryInterface(aDomNode));
  if (content) {
    nsCOMPtr<nsIContent> parentContent = content->GetParent();
    if (parentContent)
      mIndex = parentContent->IndexOf(content);
  }

  nsCOMPtr<nsIPresShell> shell(do_QueryReferent(aShell));
  if (shell) {
    NS_NewArray(getter_AddRefs(mTextChildren));
    if (mTextChildren) {
      nsIFrame *frame = nsnull;
      nsCOMPtr<nsIContent> content(do_QueryInterface(aDomNode));
      shell->GetPrimaryFrameFor(content, &frame);
      nsIFrame *parentFrame = nsAccessible::GetParentBlockFrame(frame);
      NS_ASSERTION(parentFrame, "Error: HyperText can't get parent block frame");
      if (parentFrame) {
        nsIFrame* childFrame = parentFrame->GetFirstChild(nsnull);
        PRBool bSave = PR_FALSE;
        GetAllTextChildren(shell->GetPresContext(), childFrame,
                           aDomNode, bSave);
      }
    }
  }
}

Here is the call graph for this function:

virtual nsAccessibleHyperText::~nsAccessibleHyperText ( ) [inline, virtual]

Definition at line 58 of file nsAccessibleHyperText.h.

{};

Member Function Documentation

void nsIAccessibleText::addSelection ( in long  startOffset,
in long  endOffset 
) [inherited]
nsIDOMNode * nsAccessibleHyperText::FindTextNodeByOffset ( PRInt32  aOffset,
PRInt32 aBeforeLength 
) [protected]

Definition at line 146 of file nsAccessibleHyperText.cpp.

{
  NS_ENSURE_TRUE(mTextChildren, nsnull);

  aBeforeLength = 0;

  PRUint32 index, count;
  mTextChildren->GetLength(&count);
  for (index = 0; index < count; index++) {
    nsCOMPtr<nsIDOMNode> domNode(do_QueryElementAt(mTextChildren, index));
    nsAccessibleText accText(domNode);
    PRInt32 charCount;
    if (NS_SUCCEEDED(accText.GetCharacterCount(&charCount))) {
      if (aOffset >= 0 && aOffset <= charCount) {
        return domNode;
      }
      aOffset -= charCount;
      aBeforeLength += charCount;
    }
  }

  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsAccessibleHyperText::GetAllTextChildren ( nsPresContext aPresContext,
nsIFrame aCurFrame,
nsIDOMNode aNode,
PRBool bSave 
) [protected]

Definition at line 92 of file nsAccessibleHyperText.cpp.

{
  NS_ENSURE_TRUE(mTextChildren, PR_FALSE);

  while (aCurFrame) {

    nsIAtom* frameType = aCurFrame->GetType();
    if (frameType == nsAccessibilityAtoms::blockFrame) {
      if (bSave)
        return PR_TRUE;
    }
    else {
      if (frameType == nsAccessibilityAtoms::textFrame) {
        // Skip the empty text frames that usually only consist of "\n"
        if (! aCurFrame->GetRect().IsEmpty()) {
          nsCOMPtr<nsIDOMNode> node(do_QueryInterface(aCurFrame->GetContent()));
          if (bSave || node == aNode) {
#ifdef DEBUG
            nsAutoString text;
            node->GetNodeValue(text);
            char buf[1024];
            text.ToCString(buf, sizeof(buf));
#endif
            // some long text node may be divided into several frames, 
            // so we must check whether this node is already in the array
            PRUint32 index;
            nsresult rv = mTextChildren->IndexOf(0, node, &index);
            if (NS_FAILED(rv)) {
              mTextChildren->AppendElement(node, PR_FALSE);
            }
            bSave = PR_TRUE;
          }
        }
      }

      nsIFrame* childFrame = aCurFrame->GetFirstChild(nsnull);
      if (GetAllTextChildren(aPresContext, childFrame, aNode, bSave))
        return PR_TRUE;
    }

    nsIFrame* siblingFrame = aCurFrame->GetNextSibling();
    aCurFrame = siblingFrame;
  }
  return PR_FALSE;
}

Here is the call graph for this function:

nsISupports nsIAccessibleText::getAttributeRange ( in long  offset,
out long  rangeStartOffset,
out long  rangeEndOffset 
) [inherited]
nsresult nsAccessibleHyperText::GetBounds ( nsIWeakReference aShell,
PRInt32 x,
PRInt32 y,
PRInt32 width,
PRInt32 height 
)

Definition at line 526 of file nsAccessibleHyperText.cpp.

{
  NS_ENSURE_TRUE(mTextChildren, NS_ERROR_FAILURE);

  *x = *y = *width = *height = 0;

  nsRect unionRectTwips;
  PRUint32 index, count;
  mTextChildren->GetLength(&count);
  for (index = 0; index < count; index++) {
    nsCOMPtr<nsIDOMNode> domNode(do_QueryElementAt(mTextChildren, index));
    nsHTMLTextAccessible *accText = new nsHTMLTextAccessible(domNode, aWeakShell, nsnull);
    if (!accText)
      return NS_ERROR_OUT_OF_MEMORY;

    nsRect frameRect;
    accText->GetBounds(&frameRect.x, &frameRect.y, &frameRect.width, &frameRect.height);
    unionRectTwips.UnionRect(unionRectTwips, frameRect);
    delete accText;
  }

  *x      = unionRectTwips.x; 
  *y      = unionRectTwips.y;
  *width  = unionRectTwips.width;
  *height = unionRectTwips.height;

  return NS_OK;
}

Here is the call graph for this function:

wchar nsIAccessibleText::getCharacterAtOffset ( in long  offset) [inherited]

It would be better to return an unsigned long here, to allow unicode chars > 16 bits.

void nsIAccessibleText::getCharacterExtents ( in long  offset,
out long  x,
out long  y,
out long  width,
out long  height,
in nsAccessibleCoordType  coordType 
) [inherited]

Definition at line 138 of file nsAccessibleHyperText.cpp.

{
  return mIndex;
}
long nsIAccessibleHyperText::getLinkIndex ( in long  charIndex) [inherited]

Definition at line 555 of file nsAccessibleHyperText.cpp.

{
  
  nsCOMPtr<nsIDOMNode> parentNode;
  nsCOMPtr<nsILink> link;
  while (aNode && link == nsnull) {
    // text node maybe a child (or grandchild, ...) of a link node
    aNode->GetParentNode(getter_AddRefs(parentNode));
    aNode = parentNode;
    link = do_QueryInterface(parentNode);
  }
  
  return parentNode;
}

Here is the call graph for this function:

void nsIAccessibleText::getSelectionBounds ( in long  selectionNum,
out long  startOffset,
out long  endOffset 
) [inherited]
AString nsIAccessibleText::getText ( in long  startOffset,
in long  endOffset 
) [inherited]

String methods may need to return multibyte-encoded strings, since some locales can't be encoded using 16-bit chars.

So the methods below might return UTF-16 strings, or they could return "string" values which are UTF-8.

AString nsIAccessibleText::getTextAfterOffset ( in long  offset,
in nsAccessibleTextBoundary  boundaryType,
out long  startOffset,
out long  endOffset 
) [inherited]
AString nsIAccessibleText::getTextAtOffset ( in long  offset,
in nsAccessibleTextBoundary  boundaryType,
out long  startOffset,
out long  endOffset 
) [inherited]
AString nsIAccessibleText::getTextBeforeOffset ( in long  offset,
in nsAccessibleTextBoundary  boundaryType,
out long  startOffset,
out long  endOffset 
) [inherited]
nsresult nsAccessibleHyperText::GetTextHelper ( EGetTextType  aType,
nsAccessibleTextBoundary  aBoundaryType,
PRInt32  aOffset,
PRInt32 aStartOffset,
PRInt32 aEndOffset,
nsAString &  aText 
) [protected]

Definition at line 170 of file nsAccessibleHyperText.cpp.

{
  PRInt32 beforeLength;
  nsIDOMNode* domNode = FindTextNodeByOffset(aOffset, beforeLength);
  if (domNode) {
    nsAccessibleText accText(domNode);
    // call nsAccessibleText::GetTextHelper directly so that it can adjust the aStartOffset/aEndOffset
    // according to the mTextChildren
    nsresult rv = accText.GetTextHelper(aType, aBoundaryType, aOffset - beforeLength, aStartOffset, aEndOffset, mTextChildren, aText);
    return rv;
  }

  return NS_ERROR_INVALID_ARG;
}

Here is the call graph for this function:

void nsIAccessibleText::removeSelection ( in long  selectionNum) [inherited]
void nsIAccessibleText::setSelectionBounds ( in long  selectionNum,
in long  startOffset,
in long  endOffset 
) [inherited]

Reimplemented in nsHTMLBlockAccessible, and nsHTMLTableCellAccessibleWrap.

Definition at line 87 of file nsAccessibleHyperText.cpp.


Member Data Documentation

Definition at line 57 of file nsIAccessibleText.idl.

Definition at line 50 of file nsIAccessibleText.idl.

Definition at line 56 of file nsIAccessibleText.idl.

Definition at line 55 of file nsIAccessibleText.idl.

Definition at line 54 of file nsIAccessibleText.idl.

Definition at line 53 of file nsIAccessibleText.idl.

Definition at line 52 of file nsIAccessibleText.idl.

Definition at line 51 of file nsIAccessibleText.idl.

Definition at line 62 of file nsIAccessibleText.idl.

Definition at line 64 of file nsIAccessibleText.idl.

Definition at line 59 of file nsIAccessibleText.idl.

Definition at line 60 of file nsIAccessibleText.idl.

Definition at line 48 of file nsIAccessibleHyperText.idl.

Definition at line 66 of file nsAccessibleHyperText.h.

Definition at line 65 of file nsAccessibleHyperText.h.

Definition at line 65 of file nsIAccessibleText.idl.


The documentation for this class was generated from the following files: