зеркало из https://github.com/mozilla/gecko-dev.git
Bug 202086 Move atk specific code from xp dir to accessible/src/atk
r=aaronl, sr=henry.jia Part 3: remove old files
This commit is contained in:
Родитель
b4cbc29c54
Коммит
e381bb7517
|
@ -1,51 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Marc Mulcahy (marc.mulcahy@sun.com)
|
||||
*
|
||||
* Contributor(s): Paul Sandoz (paul.sandoz@sun.com)
|
||||
* Bill Haneman (bill.haneman@sun.com)
|
||||
* John Gaunt (jgaunt@netscape.com)
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(829B36D4-125A-4279-ABC4-87D834664F82)]
|
||||
interface nsIAccessibleAction : nsISupports
|
||||
{
|
||||
readonly attribute long actions;
|
||||
|
||||
boolean doAction (in long index);
|
||||
|
||||
AString getDescription (in long index);
|
||||
void getDescriptionConst (in long index,
|
||||
[shared, retval] out string description);
|
||||
|
||||
AString getKeyBinding (in long index);
|
||||
void getKeyBindingConst (in long index,
|
||||
[shared, retval] out string keyBinding);
|
||||
};
|
||||
|
||||
/*
|
||||
Assumptions:
|
||||
|
||||
string is a UTF-8 or most likely ASCII
|
||||
encoding.
|
||||
|
||||
*/
|
|
@ -1,53 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Marc Mulcahy (marc.mulcahy@sun.com)
|
||||
*
|
||||
* Contributor(s): Paul Sandoz (paul.sandoz@sun.com)
|
||||
* Bill Haneman (bill.haneman@sun.com)
|
||||
* John Gaunt (jgaunt@netscape.com)
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(91F0A56C-11BE-47C7-8D02-7C15E00C05F5)]
|
||||
interface nsIAccessibleEditableText : nsISupports
|
||||
{
|
||||
/**
|
||||
* Set font styles, such as italic, bold...
|
||||
*/
|
||||
void setAttributes (in long startPos, in long endPos,
|
||||
in nsISupports attributes);
|
||||
void setTextContents (in AString text);
|
||||
void insertText (in AString text, in long position);
|
||||
void copyText (in long startPos, in long endPos);
|
||||
void cutText (in long startPos, in long endPos);
|
||||
void deleteText (in long startPos, in long endPos);
|
||||
void pasteText (in long position);
|
||||
};
|
||||
|
||||
/*
|
||||
Assumptions:
|
||||
|
||||
selectAttributes method takes an nsISupports parameter.
|
||||
'set' methods throw exception on failure.
|
||||
'wstring' inputs are potentially multibyte (UTF-16 for
|
||||
instance); 'string' and UTF-8 may be a better choice.
|
||||
|
||||
*/
|
|
@ -1,61 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Marc Mulcahy (marc.mulcahy@sun.com)
|
||||
*
|
||||
* Contributor(s): Bill Haneman (bill.haneman@sun.com)
|
||||
* John Gaunt (jgaunt@netscape.com)
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIAccessible.idl"
|
||||
|
||||
interface nsIURI;
|
||||
|
||||
[scriptable, uuid(a492c7d6-1dd1-11b2-9bc0-80614884799a)]
|
||||
interface nsIAccessibleHyperLink : nsISupports
|
||||
{
|
||||
readonly attribute long anchors;
|
||||
readonly attribute long startIndex;
|
||||
readonly attribute long endIndex;
|
||||
|
||||
nsIURI getURI (in long i);
|
||||
|
||||
nsIAccessible getObject (in long i);
|
||||
|
||||
boolean isValid ();
|
||||
boolean isSelected ();
|
||||
};
|
||||
|
||||
/*
|
||||
Assumptions:
|
||||
|
||||
The object associated with object or anchor index
|
||||
is an nsIAccessible.
|
||||
A URI can be represented by the nsIURI interface
|
||||
(or nsIURL interface).
|
||||
|
||||
Note that an object which supports nsIAccessibleHyperlink
|
||||
does *not* generally implement nsIAccessible, unlike the
|
||||
case of the other nsiAccessible* interfaces in this directory.
|
||||
|
||||
Aaron: would the nsISupports return from
|
||||
getObject be queryable for nsIURI and nsIURL directly?
|
||||
|
||||
*/
|
|
@ -1,39 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Marc Mulcahy (marc.mulcahy@sun.com)
|
||||
*
|
||||
* Contributor(s): Bill Haneman (bill.haneman@sun.com)
|
||||
* Paul Sandoz (paul.sandoz@sun.com)
|
||||
* John Gaunt (jgaunt@netscape.com)
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIAccessibleHyperLink.idl"
|
||||
|
||||
[scriptable, uuid(8f18d922-1dd2-11b2-82ea-829b78a44413)]
|
||||
interface nsIAccessibleHyperText : nsISupports
|
||||
{
|
||||
readonly attribute long links;
|
||||
|
||||
nsIAccessibleHyperLink getLink (in long index);
|
||||
|
||||
long getLinkIndex (in long charIndex);
|
||||
long getSelectedLinkIndex ();
|
||||
};
|
|
@ -1,66 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Marc Mulcahy (marc.mulcahy@sun.com)
|
||||
*
|
||||
* Contributor(s): Paul Sandoz (paul.sandoz@sun.com)
|
||||
* Bill Haneman (bill.haneman@sun.com)
|
||||
* John Gaunt (jgaunt@netscape.com)
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIAccessible.idl"
|
||||
|
||||
[scriptable, uuid(0A7E98A9-CA7D-42F0-BFE1-2CFC35256038)]
|
||||
interface nsIAccessibleTable : nsISupports
|
||||
{
|
||||
attribute nsIAccessible caption;
|
||||
attribute AString summary;
|
||||
readonly attribute long columns;
|
||||
readonly attribute nsIAccessibleTable columnHeader;
|
||||
readonly attribute long rows;
|
||||
readonly attribute nsIAccessibleTable rowHeader;
|
||||
|
||||
void getSelectedColumns (out unsigned long columnsSize,
|
||||
[retval, array, size_is(columnsSize)] out long columns);
|
||||
|
||||
void getSelectedRows (out unsigned long rowsSize,
|
||||
[retval, array, size_is(rowsSize)] out long rows);
|
||||
|
||||
/**
|
||||
* gets a cell
|
||||
*/
|
||||
nsIAccessible cellRefAt (in long row, in long column);
|
||||
|
||||
/**
|
||||
* get an index
|
||||
*/
|
||||
long getIndexAt (in long row, in long column);
|
||||
long getColumnAtIndex (in long index);
|
||||
long getRowAtIndex (in long index);
|
||||
long getColumnExtentAt (in long row, in long column);
|
||||
long getRowExtentAt (in long row, in long column);
|
||||
|
||||
AString getColumnDescription (in long column);
|
||||
AString getRowDescription (in long row);
|
||||
|
||||
boolean isColumnSelected (in long column);
|
||||
boolean isRowSelected (in long row);
|
||||
boolean isCellSelected (in long row, in long column);
|
||||
};
|
|
@ -1,129 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Marc Mulcahy (marc.mulcahy@sun.com)
|
||||
*
|
||||
* Contributor(s): Paul Sandoz (paul.sandoz@sun.com)
|
||||
* Bill Haneman (bill.haneman@sun.com)
|
||||
* John Gaunt (jgaunt@netscape.com)
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
typedef long nsAccessibleTextBoundary;
|
||||
typedef long nsAccessibleCoordType;
|
||||
|
||||
[scriptable, uuid(E44D3FA6-9CB2-432A-8BDB-69D72B6ADA00)]
|
||||
interface nsIAccessibleText : nsISupports
|
||||
{
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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 getText (in long startOffset, in long endOffset);
|
||||
|
||||
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);
|
||||
|
||||
/**
|
||||
* It would be better to return an unsigned long here,
|
||||
* to allow unicode chars > 16 bits
|
||||
*/
|
||||
wchar getCharacterAtOffset (in long offset);
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
/*
|
||||
Assumptions:
|
||||
|
||||
Using wstring (UCS2) instead of string encoded in UTF-8.
|
||||
Multibyte encodings (or at least potentially multi-byte
|
||||
encodings) would be preferred for the reasons cited above.
|
||||
|
||||
The following methods will throw an exception on failure
|
||||
(since not every text component will allow every operation):
|
||||
setSelectionBounds, addSelection, removeSelection, setCaretOffset.
|
||||
|
||||
getRangeAttributes defined to return an nsISupports
|
||||
interface instead of a pango specific data structure.
|
||||
It may be that some other return type is more appropriate
|
||||
for mozilla text attributes.
|
||||
|
||||
we assume that all text components support the idea of
|
||||
a caret offset, whether visible or "virtual". If this
|
||||
isn't the case, caretOffset can be made readonly and
|
||||
a setCaretOffset method provided which throws an exception
|
||||
on failure (as with *selection methods above).
|
||||
*/
|
|
@ -1,60 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Marc Mulcahy (marc.mulcahy@sun.com)
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Gaunt (jgaunt@netscape.com)
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(F4ABBC2F-0F28-47DC-A9E9-F7A1719AB2BE)]
|
||||
interface nsIAccessibleValue : nsISupports
|
||||
{
|
||||
readonly attribute double maximumValue;
|
||||
readonly attribute double minimumValue;
|
||||
readonly attribute double currentValue;
|
||||
|
||||
/**
|
||||
* We want to be able to return a success condition of the value
|
||||
* getting set. ie if the value is not within the interval of
|
||||
* minimumValue-maximumValue
|
||||
*/
|
||||
boolean setCurrentValue (in double value);
|
||||
};
|
||||
|
||||
/*
|
||||
Assumptions:
|
||||
|
||||
The attribute currentValue will throw an exception
|
||||
if it cannot be set i.e. if the value is not a
|
||||
member of the interval.
|
||||
This may not be the 'desired' behaviour given gObject
|
||||
equivalent. Thus it could be changed to be:
|
||||
|
||||
readonly attribute double currentValue;
|
||||
boolean setCurrentValue (double long value);
|
||||
|
||||
GValue can represent many basic types.
|
||||
Since this interface is designed to represent
|
||||
an interval and a member of double should
|
||||
cover the cases of char int and float.
|
||||
|
||||
*/
|
|
@ -1,456 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems, Inc.
|
||||
* Portions created by Sun Microsystems are Copyright (C) 2002 Sun
|
||||
* Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Original Author: Kyle Yuan (kyle.yuan@sun.com)
|
||||
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsAccessibilityService.h"
|
||||
#include "nsAccessible.h"
|
||||
#include "nsHTMLLinkAccessible.h"
|
||||
#include "nsHyperTextAccessible.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsILink.h"
|
||||
#include "nsAccessibilityAtoms.h"
|
||||
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
/*
|
||||
* nsAccessibleHyperText supports both nsIAccessibleHyperText and nsIAccessibleText.
|
||||
* It's mainly aimed at the compound content that consists of many text nodes and links.
|
||||
* Typically, it's a paragraph of text, a cell of table, etc.
|
||||
*/
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsAccessibleHyperText, nsIAccessibleHyperText, nsIAccessibleText)
|
||||
|
||||
nsAccessibleHyperText::nsAccessibleHyperText(nsIDOMNode* aDomNode, nsIWeakReference* aShell)
|
||||
{
|
||||
mIndex = -1;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aDomNode));
|
||||
if (content) {
|
||||
nsCOMPtr<nsIContent> parentContent;
|
||||
content->GetParent(*getter_AddRefs(parentContent));
|
||||
if (parentContent)
|
||||
parentContent->IndexOf(content, mIndex);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(aShell));
|
||||
if (shell) {
|
||||
NS_NewISupportsArray(getter_AddRefs(mTextChildren));
|
||||
if (mTextChildren)
|
||||
GetAllTextChildren(shell, aDomNode);
|
||||
}
|
||||
}
|
||||
|
||||
nsAccessibleHyperText::~nsAccessibleHyperText()
|
||||
{
|
||||
}
|
||||
|
||||
void nsAccessibleHyperText::GetAllTextChildren(nsIPresShell* aShell, nsIDOMNode* aCurrentNode)
|
||||
// A recursive function to find out all text children under the current dom node
|
||||
{
|
||||
nsCOMPtr<nsIDOMNodeList> childrenList;
|
||||
aCurrentNode->GetChildNodes(getter_AddRefs(childrenList));
|
||||
if (!childrenList)
|
||||
return;
|
||||
|
||||
PRUint32 index, length;
|
||||
childrenList->GetLength(&length);
|
||||
for (index = 0; index < length; index++) {
|
||||
nsCOMPtr<nsIDOMNode> childNode;
|
||||
childrenList->Item(index, getter_AddRefs(childNode));
|
||||
nsIFrame *frame = nsnull;
|
||||
nsCOMPtr<nsIContent> childContent(do_QueryInterface(childNode));
|
||||
aShell->GetPrimaryFrameFor(childContent, &frame);
|
||||
if (frame) {
|
||||
nsCOMPtr<nsIAtom> fType;
|
||||
frame->GetFrameType(getter_AddRefs(fType));
|
||||
if (fType == nsAccessibilityAtoms::textFrame) {
|
||||
nsRect frameRect;
|
||||
frame->GetRect(frameRect);
|
||||
// Skip the empty text frames that usually only consist of "\n"
|
||||
if (! frameRect.IsEmpty())
|
||||
mTextChildren->AppendElement(childNode);
|
||||
continue;
|
||||
}
|
||||
else if (fType == nsAccessibilityAtoms::blockFrame) {
|
||||
// we won't traverse the child blockframe that supposes to be another object
|
||||
continue;
|
||||
}
|
||||
|
||||
GetAllTextChildren(aShell, childNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 nsAccessibleHyperText::GetIndex()
|
||||
// XXX, this index is used for giving a hypertext a meaningful name, such as "Paragraph n",
|
||||
// but by now, we haven't found a better way to do that, just use the index of our parent's
|
||||
// children list as the number.
|
||||
{
|
||||
return mIndex;
|
||||
}
|
||||
|
||||
nsIDOMNode* nsAccessibleHyperText::FindTextNodeByOffset(PRInt32 aOffset, PRInt32& aBeforeLength)
|
||||
{
|
||||
aBeforeLength = 0;
|
||||
|
||||
PRUint32 index, count;
|
||||
mTextChildren->Count(&count);
|
||||
for (index = 0; index < count; index++) {
|
||||
nsIDOMNode* domNode = (nsIDOMNode *)mTextChildren->ElementAt(index);
|
||||
nsAccessibleText accText;
|
||||
accText.SetTextNode(domNode);
|
||||
PRInt32 charCount;
|
||||
if (NS_SUCCEEDED(accText.GetCharacterCount(&charCount))) {
|
||||
if (aOffset >= 0 && aOffset < charCount) {
|
||||
return domNode;
|
||||
}
|
||||
aOffset -= charCount;
|
||||
aBeforeLength += charCount;
|
||||
}
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsresult nsAccessibleHyperText::GetTextHelper(EGetTextType aType, nsAccessibleTextBoundary aBoundaryType,
|
||||
PRInt32 aOffset, PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText)
|
||||
{
|
||||
PRInt32 beforeLength;
|
||||
nsIDOMNode* domNode = FindTextNodeByOffset(aOffset, beforeLength);
|
||||
if (domNode) {
|
||||
nsAccessibleText accText;
|
||||
accText.SetTextNode(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;
|
||||
}
|
||||
|
||||
// ------- nsIAccessibleText ---------------
|
||||
/* attribute long caretOffset; */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetCaretOffset(PRInt32 *aCaretOffset)
|
||||
{
|
||||
*aCaretOffset = 0;
|
||||
|
||||
PRInt32 charCount, caretOffset;
|
||||
PRUint32 index, count;
|
||||
mTextChildren->Count(&count);
|
||||
for (index = 0; index < count; index++) {
|
||||
nsAccessibleText accText;
|
||||
accText.SetTextNode((nsIDOMNode *)mTextChildren->ElementAt(index));
|
||||
if (NS_SUCCEEDED(accText.GetCaretOffset(&caretOffset))) {
|
||||
*aCaretOffset += caretOffset;
|
||||
return NS_OK;
|
||||
}
|
||||
if (NS_SUCCEEDED(accText.GetCharacterCount(&charCount))) {
|
||||
*aCaretOffset += charCount;
|
||||
}
|
||||
}
|
||||
|
||||
// The current focus node is not inside us
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessibleHyperText::SetCaretOffset(PRInt32 aCaretOffset)
|
||||
{
|
||||
PRInt32 beforeLength;
|
||||
nsIDOMNode* domNode = FindTextNodeByOffset(aCaretOffset, beforeLength);
|
||||
if (domNode) {
|
||||
nsAccessibleText accText;
|
||||
accText.SetTextNode(domNode);
|
||||
return accText.SetCaretOffset(aCaretOffset - beforeLength);
|
||||
}
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* readonly attribute long characterCount; */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetCharacterCount(PRInt32 *aCharacterCount)
|
||||
{
|
||||
*aCharacterCount = 0;
|
||||
|
||||
PRInt32 charCount;
|
||||
PRUint32 index, count;
|
||||
mTextChildren->Count(&count);
|
||||
for (index = 0; index < count; index++) {
|
||||
nsAccessibleText accText;
|
||||
accText.SetTextNode((nsIDOMNode *)mTextChildren->ElementAt(index));
|
||||
if (NS_SUCCEEDED(accText.GetCharacterCount(&charCount)))
|
||||
*aCharacterCount += charCount;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute long selectionCount; */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetSelectionCount(PRInt32 *aSelectionCount)
|
||||
{
|
||||
*aSelectionCount = 0;
|
||||
|
||||
PRInt32 selCount;
|
||||
PRUint32 index, count;
|
||||
mTextChildren->Count(&count);
|
||||
for (index = 0; index < count; index++) {
|
||||
nsAccessibleText accText;
|
||||
accText.SetTextNode((nsIDOMNode *)mTextChildren->ElementAt(index));
|
||||
if (NS_SUCCEEDED(accText.GetSelectionCount(&selCount)))
|
||||
*aSelectionCount += selCount;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* AString getText (in long startOffset, in long endOffset); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetText(PRInt32 aStartOffset, PRInt32 aEndOffset, nsAString & aText)
|
||||
{
|
||||
if (aEndOffset == -1)
|
||||
GetCharacterCount(&aEndOffset);
|
||||
|
||||
PRInt32 charCount, totalCount = 0, currentStart, currentEnd;
|
||||
PRUint32 index, count;
|
||||
nsAutoString text, nodeText;
|
||||
mTextChildren->Count(&count);
|
||||
for (index = 0; index < count; index++) {
|
||||
nsAccessibleText accText;
|
||||
accText.SetTextNode((nsIDOMNode *)mTextChildren->ElementAt(index));
|
||||
if (NS_SUCCEEDED(accText.GetCharacterCount(&charCount))) {
|
||||
currentStart = aStartOffset - totalCount;
|
||||
currentEnd = aEndOffset - totalCount;
|
||||
if (currentStart >= 0 && currentStart < charCount) {
|
||||
accText.GetText(currentStart, NS_MIN(charCount, currentEnd), nodeText);
|
||||
text += nodeText;
|
||||
aStartOffset += charCount - currentStart;
|
||||
if (aStartOffset >= aEndOffset)
|
||||
break;
|
||||
}
|
||||
totalCount += charCount;
|
||||
}
|
||||
}
|
||||
|
||||
// Eliminate the new line character
|
||||
PRInt32 start = 0, length = text.Length();
|
||||
PRInt32 offset = text.FindCharInSet("\n\r");
|
||||
while (offset != kNotFound) {
|
||||
if (offset > start)
|
||||
aText += Substring(text, start, offset - start);
|
||||
|
||||
start = offset + 1;
|
||||
offset = text.FindCharInSet("\n\r", start);
|
||||
}
|
||||
// Consume the last bit of the string if there's any left
|
||||
if (start < length) {
|
||||
if (start)
|
||||
aText += Substring(text, start, length - start);
|
||||
else
|
||||
aText = text;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* AString getTextBeforeOffset (in long offset, in nsAccessibleTextBoundary boundaryType, out long startOffset, out long endOffset); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetTextBeforeOffset(PRInt32 aOffset, nsAccessibleTextBoundary aBoundaryType,
|
||||
PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText)
|
||||
{
|
||||
return GetTextHelper(eGetBefore, aBoundaryType, aOffset, aStartOffset, aEndOffset, aText);
|
||||
}
|
||||
|
||||
/* AString getTextAfterOffset (in long offset, in nsAccessibleTextBoundary boundaryType, out long startOffset, out long endOffset); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetTextAfterOffset(PRInt32 aOffset, nsAccessibleTextBoundary aBoundaryType,
|
||||
PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText)
|
||||
{
|
||||
return GetTextHelper(eGetAfter, aBoundaryType, aOffset, aStartOffset, aEndOffset, aText);
|
||||
}
|
||||
|
||||
/* AString getTextAtOffset (in long offset, in nsAccessibleTextBoundary boundaryType, out long startOffset, out long endOffset); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetTextAtOffset(PRInt32 aOffset, nsAccessibleTextBoundary aBoundaryType,
|
||||
PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText)
|
||||
{
|
||||
return GetTextHelper(eGetAt, aBoundaryType, aOffset, aStartOffset, aEndOffset, aText);
|
||||
}
|
||||
|
||||
/* wchar getCharacterAtOffset (in long offset); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetCharacterAtOffset(PRInt32 aOffset, PRUnichar *aCharacter)
|
||||
{
|
||||
PRInt32 beforeLength;
|
||||
nsIDOMNode* domNode = FindTextNodeByOffset(aOffset, beforeLength);
|
||||
if (domNode) {
|
||||
nsAccessibleText accText;
|
||||
accText.SetTextNode(domNode);
|
||||
return accText.GetCharacterAtOffset(aOffset - beforeLength, aCharacter);
|
||||
}
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* nsISupports getAttributeRange (in long offset, out long rangeStartOffset, out long rangeEndOffset); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetAttributeRange(PRInt32 aOffset, PRInt32 *aRangeStartOffset, PRInt32 *aRangeEndOffset, nsISupports **aAttributes)
|
||||
{
|
||||
*aRangeStartOffset = aOffset;
|
||||
GetCharacterCount(aRangeEndOffset);
|
||||
*aAttributes = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getCharacterExtents (in long offset, out long x, out long y, out long length, out long width, in nsAccessibleCoordType coordType); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetCharacterExtents(PRInt32 aOffset, PRInt32 *aX, PRInt32 *aY, PRInt32 *aLength, PRInt32 *aWidth, nsAccessibleCoordType aCoordType)
|
||||
{
|
||||
PRInt32 beforeLength;
|
||||
nsIDOMNode* domNode = FindTextNodeByOffset(aOffset, beforeLength);
|
||||
if (domNode) {
|
||||
nsAccessibleText accText;
|
||||
accText.SetTextNode(domNode);
|
||||
return accText.GetCharacterExtents(aOffset - beforeLength, aX, aY, aLength, aWidth, aCoordType);
|
||||
}
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* long getOffsetAtPoint (in long x, in long y, in nsAccessibleCoordType coordType); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY, nsAccessibleCoordType aCoordType, PRInt32 *aOffset)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void getSelectionBounds (in long selectionNum, out long startOffset, out long endOffset); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetSelectionBounds(PRInt32 aSelectionNum, PRInt32 *aStartOffset, PRInt32 *aEndOffset)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void setSelectionBounds (in long selectionNum, in long startOffset, in long endOffset); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::SetSelectionBounds(PRInt32 aSelectionNum, PRInt32 aStartOffset, PRInt32 aEndOffset)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void addSelection (in long startOffset, in long endOffset); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::AddSelection(PRInt32 aStartOffset, PRInt32 aEndOffset)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void removeSelection (in long selectionNum); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::RemoveSelection(PRInt32 aSelectionNum)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// ------- nsIAccessibleHyperText ---------------
|
||||
/* readonly attribute long links; */NS_IMETHODIMP nsAccessibleHyperText::GetLinks(PRInt32 *aLinks)
|
||||
{
|
||||
*aLinks = 0;
|
||||
|
||||
PRUint32 index, count;
|
||||
mTextChildren->Count(&count);
|
||||
for (index = 0; index < count; index++) {
|
||||
nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(mTextChildren->ElementAt(index)));
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
domNode->GetParentNode(getter_AddRefs(parentNode));
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(parentNode));
|
||||
if (link)
|
||||
(*aLinks)++;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessibleHyperLink getLink (in long index); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetLink(PRInt32 aIndex, nsIAccessibleHyperLink **aLink)
|
||||
{
|
||||
PRUint32 index, count, linkCount = 0;
|
||||
mTextChildren->Count(&count);
|
||||
for (index = 0; index < count; index++) {
|
||||
nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(mTextChildren->ElementAt(index)));
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
// text node maybe a child of a link node
|
||||
domNode->GetParentNode(getter_AddRefs(parentNode));
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(parentNode));
|
||||
if (link) {
|
||||
if (linkCount++ == NS_STATIC_CAST(PRUint32, aIndex)) {
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsAccessibilityService::GetShellFromNode(parentNode, getter_AddRefs(weakShell));
|
||||
NS_ENSURE_TRUE(weakShell, NS_ERROR_FAILURE);
|
||||
*aLink = new nsHTMLLinkAccessible(parentNode, weakShell);
|
||||
NS_IF_ADDREF(*aLink);
|
||||
nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(*aLink));
|
||||
accessNode->Init();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* long getLinkIndex (in long charIndex); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetLinkIndex(PRInt32 aCharIndex, PRInt32 *aLinkIndex)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* long getSelectedLinkIndex (); */
|
||||
NS_IMETHODIMP nsAccessibleHyperText::GetSelectedLinkIndex(PRInt32 *aSelectedLinkIndex)
|
||||
{
|
||||
*aSelectedLinkIndex = -1;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> focusedNode;
|
||||
NS_REINTERPRET_CAST(nsAccessible*, this)->GetFocusedNode(getter_AddRefs(focusedNode));
|
||||
|
||||
PRUint32 index, count, linkCount = 0;
|
||||
mTextChildren->Count(&count);
|
||||
for (index = 0; index < count; index++) {
|
||||
nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(mTextChildren->ElementAt(index)));
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
// text node maybe a child of a link node
|
||||
domNode->GetParentNode(getter_AddRefs(parentNode));
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(parentNode));
|
||||
if (link) {
|
||||
linkCount++;
|
||||
if (parentNode == focusedNode) {
|
||||
*aSelectedLinkIndex = linkCount;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#endif //MOZ_ACCESSIBILITY_ATK
|
|
@ -1,74 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems, Inc.
|
||||
* Portions created by Sun Microsystems are Copyright (C) 2002 Sun
|
||||
* Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Original Author: Kyle Yuan (kyle.yuan@sun.com)
|
||||
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _nsHyperTextAccessible_H_
|
||||
#define _nsHyperTextAccessible_H_
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsIAccessibleHyperText.h"
|
||||
#include "nsTextAccessible.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
class nsAccessibleHyperText : public nsIAccessibleHyperText,
|
||||
public nsIAccessibleText
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIACCESSIBLEHYPERTEXT
|
||||
NS_DECL_NSIACCESSIBLETEXT
|
||||
|
||||
public:
|
||||
nsAccessibleHyperText(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
virtual ~nsAccessibleHyperText();
|
||||
|
||||
PRInt32 GetIndex();
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISupportsArray> mTextChildren;
|
||||
PRInt32 mIndex;
|
||||
|
||||
void GetAllTextChildren(nsIPresShell* aShell, nsIDOMNode* aCurrentNode);
|
||||
nsIDOMNode* FindTextNodeByOffset(PRInt32 aOffset, PRInt32& aBeforeLength);
|
||||
nsresult GetTextHelper(EGetTextType aType, nsAccessibleTextBoundary aBoundaryType,
|
||||
PRInt32 aOffset, PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText);
|
||||
};
|
||||
|
||||
#endif //MOZ_ACCESSIBILITY_ATK
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче