зеркало из https://github.com/mozilla/pjs.git
Bug 195688 [ATK Accessibility] move nsIAccessibleHyperText support from nsHTMLIFrameAccessible to nsAccessibleHyperText
r=bolian.yin Not in the default build
This commit is contained in:
Родитель
2deaf1d2fe
Коммит
32bbad56ee
|
@ -1395,6 +1395,7 @@ NS_IMETHODIMP nsAccessibilityService::CreateXULToolbarSeparatorAccessible(nsIDOM
|
|||
NS_IMETHODIMP nsAccessibilityService::CreateXULTooltipAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
|
||||
{
|
||||
#ifdef MOZ_XUL
|
||||
#ifndef MOZ_ACCESSIBILITY_ATK
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
GetShellFromNode(aNode, getter_AddRefs(weakShell));
|
||||
|
||||
|
@ -1403,6 +1404,9 @@ NS_IMETHODIMP nsAccessibilityService::CreateXULTooltipAccessible(nsIDOMNode *aNo
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
#else
|
||||
*_retval = nsnull;
|
||||
#endif // MOZ_ACCESSIBILITY_ATK
|
||||
#else
|
||||
*_retval = nsnull;
|
||||
#endif // MOZ_XUL
|
||||
|
@ -1631,6 +1635,7 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
|||
|
||||
frame->GetAccessible(getter_AddRefs(newAcc));
|
||||
|
||||
#ifndef MOZ_ACCESSIBILITY_ATK
|
||||
// ---- If link, create link accessible ----
|
||||
if (!newAcc) {
|
||||
// is it a link?
|
||||
|
@ -1640,6 +1645,7 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
|||
newAcc = new nsHTMLLinkAccessible(aNode, weakShell);
|
||||
}
|
||||
}
|
||||
#endif //MOZ_ACCESSIBILITY_ATK
|
||||
|
||||
// ---- If <select> <option>, create select option accessible
|
||||
|
||||
|
|
|
@ -95,6 +95,8 @@ public:
|
|||
NS_IMETHOD AccTakeFocus(void);
|
||||
NS_IMETHOD AccGetDOMNode(nsIDOMNode **_retval);
|
||||
|
||||
NS_IMETHOD GetFocusedNode(nsIDOMNode **aFocusedNode);
|
||||
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
static nsresult GetParentBlockNode(nsIDOMNode *aCurrentNode, nsIDOMNode **aBlockNode);
|
||||
#endif
|
||||
|
@ -112,7 +114,6 @@ protected:
|
|||
NS_IMETHOD AppendFlatStringFromSubtree(nsIContent *aContent, nsAString *aFlatString);
|
||||
NS_IMETHOD AppendFlatStringFromContentNode(nsIContent *aContent, nsAString *aFlatString);
|
||||
NS_IMETHOD AppendStringWithSpaces(nsAString *aFlatString, const nsAString& textEquivalent);
|
||||
NS_IMETHOD GetFocusedNode(nsIDOMNode **aFocusedNode);
|
||||
NS_IMETHOD CacheOptimizations(nsIAccessible *aParent, PRInt32 aSiblingIndex, nsIDOMNodeList *aSiblingList);
|
||||
NS_IMETHOD HandleEvent(PRUint32 aEvent, nsIAccessible *aTarget, void * aData);
|
||||
// helper method to verify frames
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
* Typically, it's a paragraph of text, a cell of table, etc.
|
||||
*/
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsAccessibleHyperText, nsIAccessibleText)
|
||||
NS_IMPL_ISUPPORTS2(nsAccessibleHyperText, nsIAccessibleHyperText, nsIAccessibleText)
|
||||
|
||||
nsAccessibleHyperText::nsAccessibleHyperText(nsIDOMNode* aDomNode, nsIWeakReference* aShell)
|
||||
{
|
||||
|
@ -372,4 +372,84 @@ 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++ == 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);
|
||||
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
|
||||
|
|
|
@ -46,9 +46,11 @@
|
|||
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
|
||||
class nsAccessibleHyperText : public nsIAccessibleText
|
||||
class nsAccessibleHyperText : public nsIAccessibleHyperText,
|
||||
public nsIAccessibleText
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIACCESSIBLEHYPERTEXT
|
||||
NS_DECL_NSIACCESSIBLETEXT
|
||||
|
||||
public:
|
||||
|
|
|
@ -1,422 +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 Netscape 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/NPL/
|
||||
*
|
||||
* 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
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* 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 "nsHTMLIFrameRootAccessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLIFrameRootAccessible, nsRootAccessible);
|
||||
NS_IMPL_ISUPPORTS_INHERITED3(nsHTMLIFrameAccessible, nsBlockAccessible, nsIAccessibleDocument, nsIAccessibleHyperText, nsIAccessibleEventReceiver)
|
||||
|
||||
nsHTMLIFrameAccessible::nsHTMLIFrameAccessible(nsIDOMNode* aNode, nsIAccessible* aRoot, nsIWeakReference* aShell, nsIDocument *aDoc):
|
||||
nsBlockAccessible(aNode, aShell), nsDocAccessibleMixin(aDoc), mRootAccessible(aRoot)
|
||||
{
|
||||
}
|
||||
|
||||
/* attribute wstring accName; */
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccName(nsAString& aAccName)
|
||||
{
|
||||
nsresult rv = GetTitle(aAccName);
|
||||
if (NS_FAILED(rv) || aAccName.IsEmpty())
|
||||
rv = GetURL(aAccName);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccValue(nsAString& aAccValue)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccFirstChild (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccFirstChild(nsIAccessible **aChild)
|
||||
{
|
||||
NS_IF_ADDREF(*aChild = mRootAccessible);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible getAccLastChild (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccLastChild(nsIAccessible **aChild)
|
||||
{
|
||||
NS_IF_ADDREF(*aChild = mRootAccessible);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* long getAccChildCount (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccChildCount(PRInt32 *aNumChildren)
|
||||
{
|
||||
*aNumChildren = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* unsigned long getAccRole (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_CLIENT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccState(PRUint32 *aAccState)
|
||||
{
|
||||
return nsAccessible::GetAccState(aAccState);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetURL(nsAString& aURL)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetURL(aURL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetTitle(nsAString& aTitle)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetTitle(aTitle);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetMimeType(nsAString& aMimeType)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetMimeType(aMimeType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetDocType(nsAString& aDocType)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetDocType(aDocType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetNameSpaceURIForID(PRInt16 aNameSpaceID, nsAString& aNameSpaceURI)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetNameSpaceURIForID(aNameSpaceID, aNameSpaceURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetDocument(nsIDocument **doc)
|
||||
{
|
||||
return nsDocAccessibleMixin::GetDocument(doc);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetCaretAccessible(nsIAccessibleCaret **aCaretAccessible)
|
||||
{
|
||||
// Caret only owned by top level window's document
|
||||
*aCaretAccessible = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// ------- nsIAccessibleHyperText ---------------
|
||||
/* readonly attribute long links; */
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetLinks(PRInt32 *aLinks)
|
||||
{
|
||||
*aLinks = GetLinksFromAccNode(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessibleHyperLink getLink (in long index); */
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetLink(PRInt32 aIndex,
|
||||
nsIAccessibleHyperLink **aLink)
|
||||
{
|
||||
return GetLinkFromAccNode(aIndex, this, aLink);
|
||||
}
|
||||
|
||||
/* long getLinkIndex (in long charIndex); */
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetLinkIndex(PRInt32 aCharIndex,
|
||||
PRInt32 *aLinkIndex)
|
||||
{
|
||||
return GetLinkIndexFromAccNode(this, aCharIndex, aLinkIndex);
|
||||
}
|
||||
|
||||
/* long getSelectedLinkIndex (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetSelectedLinkIndex(PRInt32 *aSelectedLinkIndex)
|
||||
{
|
||||
*aSelectedLinkIndex = -1;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> focusedNode;
|
||||
GetFocusedNode(getter_AddRefs(focusedNode));
|
||||
|
||||
PRInt32 index, links = GetLinksFromAccNode(this);
|
||||
for (index = 0; index < links; index++) {
|
||||
nsCOMPtr<nsIAccessibleHyperLink> hyperLink;
|
||||
GetLink(index, getter_AddRefs(hyperLink));
|
||||
nsCOMPtr<nsIAccessible> acc(do_QueryInterface(hyperLink));
|
||||
if (acc) {
|
||||
nsCOMPtr<nsIDOMNode> linkNode;
|
||||
acc->AccGetDOMNode(getter_AddRefs(linkNode));
|
||||
if (focusedNode == linkNode) {
|
||||
*aSelectedLinkIndex = index;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//helper function for nsIAccessibleHyperText
|
||||
PRBool nsHTMLIFrameAccessible::IsHyperLink(nsIAccessible *aAccNode)
|
||||
{
|
||||
nsCOMPtr<nsIAccessibleHyperLink> hyperlink(do_QueryInterface(aAccNode));
|
||||
return hyperlink? PR_TRUE: PR_FALSE;
|
||||
}
|
||||
|
||||
PRInt32 nsHTMLIFrameAccessible::GetLinksFromAccNode(nsIAccessible *aAccNode)
|
||||
{
|
||||
PRInt32 rv = IsHyperLink(aAccNode) ? 1 : 0;
|
||||
|
||||
// Here, all the links of accChild should be summed up
|
||||
nsCOMPtr<nsIAccessible> childa;
|
||||
nsCOMPtr<nsIAccessible> child;
|
||||
|
||||
aAccNode->GetAccFirstChild(getter_AddRefs(child));
|
||||
while (child) {
|
||||
rv += GetLinksFromAccNode(child);
|
||||
child->GetAccNextSibling(getter_AddRefs(childa));
|
||||
child = childa;
|
||||
}
|
||||
//end for summing up accChildren's links
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsHTMLIFrameAccessible::GetLinkFromAccNode(PRInt32 aIndex,
|
||||
nsIAccessible *aAccNode,
|
||||
nsIAccessibleHyperLink **_retval)
|
||||
{
|
||||
PRInt32 links;
|
||||
|
||||
//firstly, to see whether beginning node is a hyperlink
|
||||
links = 0;
|
||||
if (aIndex < 0) {
|
||||
//of course, the aIndex is not right.
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
if (IsHyperLink(aAccNode)) {
|
||||
links = 1;
|
||||
if (0 == aIndex) {
|
||||
return CallQueryInterface(aAccNode, _retval);
|
||||
}
|
||||
}
|
||||
|
||||
//navigate all accChildren to getLink for the aIndex
|
||||
nsCOMPtr<nsIAccessible> child;
|
||||
nsCOMPtr<nsIAccessible> childa;
|
||||
|
||||
aIndex = aIndex - links;
|
||||
aAccNode->GetAccFirstChild(getter_AddRefs(child));
|
||||
while (child) {
|
||||
links = GetLinksFromAccNode(child);
|
||||
if (aIndex < links) {
|
||||
return GetLinkFromAccNode(aIndex, child, _retval);
|
||||
}
|
||||
aIndex -= links;
|
||||
child->GetAccNextSibling(getter_AddRefs(childa));
|
||||
child = childa;
|
||||
}
|
||||
//end of navigate accChild
|
||||
|
||||
*_retval = nsnull;
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
PRInt32 nsHTMLIFrameAccessible::GetAccNodeCharLength(nsIAccessible *aAccNode)
|
||||
{
|
||||
PRUint32 role;
|
||||
PRInt32 childCharLength;
|
||||
nsAutoString tempAccName;
|
||||
|
||||
PRInt32 rv = 0;
|
||||
role = ROLE_NOTHING;
|
||||
aAccNode->GetAccRole(&role);
|
||||
|
||||
//ROLE_TEXT
|
||||
if (ROLE_TEXT == role) {
|
||||
aAccNode->GetAccName(tempAccName);
|
||||
rv = tempAccName.Length();
|
||||
}
|
||||
|
||||
//sum up the number all accChildren's characters
|
||||
nsCOMPtr<nsIAccessible> childa;
|
||||
nsCOMPtr<nsIAccessible> child;
|
||||
|
||||
aAccNode->GetAccFirstChild(getter_AddRefs(child));
|
||||
while (child) {
|
||||
childCharLength = GetAccNodeCharLength(child);
|
||||
rv += childCharLength;
|
||||
child->GetAccNextSibling(getter_AddRefs(childa));
|
||||
child = childa;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// *_retval is zero-based index, so -1 for no index.
|
||||
// be careful, charIndex is zero-index, but length is not.
|
||||
nsresult nsHTMLIFrameAccessible::GetLinkIndexFromAccNode(nsIAccessible *aAccNode,
|
||||
PRInt32 aCharIndex,
|
||||
PRInt32 *_retval)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 role;
|
||||
nsAutoString tempAccName;
|
||||
PRInt32 charLength;
|
||||
PRInt32 links;
|
||||
|
||||
*_retval = -1;
|
||||
links = 0;
|
||||
charLength = 0;
|
||||
role = ROLE_NOTHING;
|
||||
aAccNode->GetAccRole(&role);
|
||||
|
||||
// if the beginning node is hyperlink
|
||||
if (IsHyperLink(aAccNode)) {
|
||||
charLength = GetAccNodeCharLength(aAccNode);
|
||||
if (aCharIndex < charLength) {
|
||||
*_retval = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
*_retval = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//begin to count char length
|
||||
if (ROLE_TEXT == role) {
|
||||
aAccNode->GetAccName(tempAccName);
|
||||
charLength = tempAccName.Length();
|
||||
if (aCharIndex < charLength) {
|
||||
*_retval = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
if (IsHyperLink(aAccNode)) {
|
||||
links = 1;
|
||||
}
|
||||
//exam the beginning node end
|
||||
|
||||
//getLinkIndex from accChildren
|
||||
nsCOMPtr<nsIAccessible> childa;
|
||||
nsCOMPtr<nsIAccessible> child;
|
||||
PRInt32 childCharLength;
|
||||
PRInt32 childLinks;
|
||||
|
||||
aAccNode->GetAccFirstChild(getter_AddRefs(child));
|
||||
while (child) {
|
||||
childCharLength = GetAccNodeCharLength(child);
|
||||
if (aCharIndex < charLength + childCharLength) {
|
||||
rv = GetLinkIndexFromAccNode(child, aCharIndex - charLength, _retval);
|
||||
*_retval += links;
|
||||
return rv;
|
||||
}
|
||||
charLength += childCharLength;
|
||||
childLinks = GetLinksFromAccNode(child);
|
||||
links += childLinks;
|
||||
child->GetAccNextSibling(getter_AddRefs(childa));
|
||||
child = childa;
|
||||
}
|
||||
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::AddAccessibleEventListener(nsIAccessibleEventListener *aListener)
|
||||
{
|
||||
nsCOMPtr<nsIAccessibleEventReceiver> rootReceiver(do_QueryInterface(mRootAccessible));
|
||||
NS_ENSURE_TRUE(rootReceiver, NS_OK);
|
||||
return rootReceiver->AddAccessibleEventListener(aListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::RemoveAccessibleEventListener()
|
||||
{
|
||||
nsCOMPtr<nsIAccessibleEventReceiver> rootReceiver(do_QueryInterface(mRootAccessible));
|
||||
NS_ENSURE_TRUE(rootReceiver, NS_OK);
|
||||
return rootReceiver->RemoveAccessibleEventListener();
|
||||
}
|
||||
|
||||
|
||||
//=============================//
|
||||
// nsHTMLIFrameRootAccessible //
|
||||
//=============================//
|
||||
|
||||
//-----------------------------------------------------
|
||||
// construction
|
||||
//-----------------------------------------------------
|
||||
nsHTMLIFrameRootAccessible::nsHTMLIFrameRootAccessible(nsIWeakReference* aShell):
|
||||
nsRootAccessible(aShell)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
// destruction
|
||||
//-----------------------------------------------------
|
||||
nsHTMLIFrameRootAccessible::~nsHTMLIFrameRootAccessible()
|
||||
{
|
||||
}
|
||||
|
||||
/* void addAccessibleEventListener (in nsIAccessibleEventListener aListener); */
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::AddAccessibleEventListener(nsIAccessibleEventListener *aListener)
|
||||
{
|
||||
NS_ASSERTION(aListener, "Trying to add a null listener!");
|
||||
if (!mListener) {
|
||||
mListener = aListener;
|
||||
AddContentDocListeners();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void removeAccessibleEventListener (); */
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::RemoveAccessibleEventListener()
|
||||
{
|
||||
if (mListener) {
|
||||
RemoveContentDocListeners();
|
||||
mListener = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_PANE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccName(nsAString& aAccName)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameRootAccessible::GetAccValue(nsAString& aAccValue)
|
||||
{
|
||||
return GetURL(aAccValue);
|
||||
}
|
|
@ -1,109 +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 Netscape 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/NPL/
|
||||
*
|
||||
* 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
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* 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 _nsIFrameRootAccessible_H_
|
||||
#define _nsIFrameRootAccessible_H_
|
||||
|
||||
#include "nsBaseWidgetAccessible.h"
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsAccessible.h"
|
||||
#include "nsIAccessibleDocument.h"
|
||||
#include "nsIAccessibleHyperText.h"
|
||||
#include "nsIAccessibleEventReceiver.h"
|
||||
|
||||
class nsIWebShell;
|
||||
class nsIWeakReference;
|
||||
|
||||
class nsHTMLIFrameAccessible : public nsBlockAccessible,
|
||||
public nsIAccessibleDocument,
|
||||
public nsIAccessibleHyperText,
|
||||
public nsIAccessibleEventReceiver,
|
||||
public nsDocAccessibleMixin
|
||||
{
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLEDOCUMENT
|
||||
NS_DECL_NSIACCESSIBLEHYPERTEXT
|
||||
|
||||
public:
|
||||
nsHTMLIFrameAccessible(nsIDOMNode* aNode, nsIAccessible* aRoot, nsIWeakReference* aShell, nsIDocument *doc);
|
||||
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetAccName(nsAString& aAccName);
|
||||
NS_IMETHOD GetAccValue(nsAString& AccValue);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
|
||||
NS_IMETHOD GetAccState(PRUint32 *aAccState);
|
||||
|
||||
// ----- nsIAccessibleEventReceiver -------------------
|
||||
NS_IMETHOD AddAccessibleEventListener(nsIAccessibleEventListener *aListener);
|
||||
NS_IMETHOD RemoveAccessibleEventListener();
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIAccessible> mRootAccessible;
|
||||
|
||||
//helper function for nsIAccessibleHyperText
|
||||
PRBool IsHyperLink(nsIAccessible *aAccNode);
|
||||
PRInt32 GetLinksFromAccNode(nsIAccessible *aAccNode);
|
||||
nsresult GetLinkFromAccNode(PRInt32 aIndex, nsIAccessible *aAccNode,
|
||||
nsIAccessibleHyperLink **_retval);
|
||||
PRInt32 GetAccNodeCharLength(nsIAccessible *aAccNode);
|
||||
nsresult GetLinkIndexFromAccNode(nsIAccessible *aAccNode,
|
||||
PRInt32 aCharIndex, PRInt32 *_retval);
|
||||
|
||||
};
|
||||
|
||||
class nsHTMLIFrameRootAccessible : public nsRootAccessible
|
||||
{
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
public:
|
||||
nsHTMLIFrameRootAccessible(nsIWeakReference* aShell);
|
||||
virtual ~nsHTMLIFrameRootAccessible();
|
||||
|
||||
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
|
||||
NS_IMETHOD GetAccName(nsAString& aAccName);
|
||||
NS_IMETHOD GetAccValue(nsAString& aAccValue);
|
||||
|
||||
// ----- nsIAccessibleEventReceiver -------------------
|
||||
NS_IMETHOD AddAccessibleEventListener(nsIAccessibleEventListener *aListener);
|
||||
NS_IMETHOD RemoveAccessibleEventListener();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче