bug 672507 - merge nsIAccessNode and nsIAccessible r=davidb, surkov

This commit is contained in:
Trevor Saunders 2012-01-10 11:43:27 -05:00
Родитель a219017d6d
Коммит 1e850e97c8
24 изменённых файлов: 270 добавлений и 353 удалений

Просмотреть файл

@ -61,7 +61,6 @@ XPIDLSRCS = \
nsIAccessibleDocument.idl \ nsIAccessibleDocument.idl \
nsIAccessibleProvider.idl \ nsIAccessibleProvider.idl \
nsIAccessibleSelectable.idl \ nsIAccessibleSelectable.idl \
nsIAccessNode.idl \
nsIAccessibleCursorable.idl \ nsIAccessibleCursorable.idl \
nsIAccessibleEvent.idl \ nsIAccessibleEvent.idl \
nsIAccessibleEditableText.idl \ nsIAccessibleEditableText.idl \

Просмотреть файл

@ -117,7 +117,7 @@ cpp_quote("//")
cpp_quote("//") cpp_quote("//")
cpp_quote("// get_localInterface(/* [out] */ void **localInterface);") cpp_quote("// get_localInterface(/* [out] */ void **localInterface);")
cpp_quote("// ---------------------------------------------------------------------------------------------------=") cpp_quote("// ---------------------------------------------------------------------------------------------------=")
cpp_quote("// Only available in Gecko's process - casts to an XPCOM nsIAccessNode interface pointer") cpp_quote("// Only available in Gecko's process - casts to an XPCOM nsAccessNode object pointer")
cpp_quote("//") cpp_quote("//")
cpp_quote("//") cpp_quote("//")
cpp_quote("// get_language(/* [out] */ BSTR *htmlText);") cpp_quote("// get_language(/* [out] */ BSTR *htmlText);")

Просмотреть файл

@ -1,126 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 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
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Original Author: Aaron Leventhal (aaronl@netscape.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 MPL, 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 MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIDOMNode;
interface nsIAccessibleDocument;
interface nsIDOMCSSPrimitiveValue;
/**
* An interface used by in-process accessibility clients
* to get style, window, markup and other information about
* a DOM node. When accessibility is active in Gecko,
* every DOM node can have one nsIAccessNode for each
* pres shell the DOM node is rendered in.
* The nsIAccessNode implementations are instantiated lazily.
* The nsIAccessNode tree for a given dom window
* has a one to one relationship to the DOM tree.
* If the DOM node for this access node is "accessible",
* then a QueryInterface to nsIAccessible will succeed.
*/
[scriptable, uuid(08bb2c50-1b30-11e1-bddb-0800200c9a66)]
interface nsIAccessNode : nsISupports
{
/**
* The DOM node this nsIAccessNode is associated with.
*/
readonly attribute nsIDOMNode DOMNode;
/**
* The document accessible that this access node resides in.
*/
readonly attribute nsIAccessibleDocument document;
/**
* The root document accessible that this access node resides in.
*/
readonly attribute nsIAccessibleDocument rootDocument;
/**
* The innerHTML for the DOM node
* This is a text string of all the markup inside the DOM
* node, not including the start and end tag for the node.
*/
readonly attribute DOMString innerHTML;
/**
* Makes an object visible on screen.
*
* @param scrollType - defines where the object should be placed on
* the screen (see nsIAccessibleScrollType for
* available constants).
*/
void scrollTo(in unsigned long aScrollType);
/**
* Moves the top left of an object to a specified location.
*
* @param coordinateType - specifies whether the coordinates are relative to
* the screen or the parent object (for available
* constants refer to nsIAccessibleCoordinateType)
* @param aX - defines the x coordinate
* @param aY - defines the y coordinate
*/
void scrollToPoint(in unsigned long aCoordinateType, in long aX, in long aY);
/**
* Retrieve the computed style value for this DOM node, if it is a DOM element.
* Note: the meanings of width, height and other size measurements depend
* on the version of CSS being used. Therefore, for bounds information,
* it is better to use nsIAccessible::accGetBounds.
* @param pseudoElt The pseudo element to retrieve style for, or NULL
* for general computed style information for this node.
* @param propertyName Retrieve the computed style value for this property name,
* for example "border-bottom".
*/
DOMString getComputedStyleValue(in DOMString pseudoElt, in DOMString propertyName);
/**
* The method is similar to getComputedStyleValue() excepting that this one
* returns nsIDOMCSSPrimitiveValue.
*/
nsIDOMCSSPrimitiveValue getComputedStyleCSSValue(in DOMString pseudoElt,
in DOMString propertyName);
/**
* The language for the current DOM node, e.g. en, de, etc.
*/
readonly attribute DOMString language;
};

Просмотреть файл

@ -43,7 +43,10 @@
#include "nsIArray.idl" #include "nsIArray.idl"
interface nsIPersistentProperties; interface nsIPersistentProperties;
interface nsIDOMCSSPrimitiveValue;
interface nsIDOMDOMStringList; interface nsIDOMDOMStringList;
interface nsIDOMNode;
interface nsIAccessibleDocument;
interface nsIAccessibleRelation; interface nsIAccessibleRelation;
/** /**
@ -100,6 +103,53 @@ interface nsIAccessible : nsISupports
*/ */
readonly attribute long indexInParent; readonly attribute long indexInParent;
/**
* The innerHTML for the HTML element associated with this accessible if applicable.
* This is a text string of all the markup inside the DOM
* node, not including the start and end tag for the node.
*/
readonly attribute DOMString innerHTML;
/**
* Retrieve the computed style value for this DOM node, if it is a DOM element.
* Note: the meanings of width, height and other size measurements depend
* on the version of CSS being used. Therefore, for bounds information,
* it is better to use nsIAccessible::accGetBounds.
*
* @param pseudoElt [in] The pseudo element to retrieve style for, or NULL
* for general computed style information for this node.
* @param propertyName [in] Retrieve the computed style value for this property name,
* for example "border-bottom".
*/
DOMString getComputedStyleValue(in DOMString pseudoElt, in DOMString propertyName);
/**
* The method is similar to getComputedStyleValue() excepting that this one
* returns nsIDOMCSSPrimitiveValue.
*/
nsIDOMCSSPrimitiveValue getComputedStyleCSSValue(in DOMString pseudoElt,
in DOMString propertyName);
/**
* The DOM node this nsIAccessible is associated with.
*/
readonly attribute nsIDOMNode DOMNode;
/**
* The document accessible that this access node resides in.
*/
readonly attribute nsIAccessibleDocument document;
/**
* The root document accessible that this access node resides in.
*/
readonly attribute nsIAccessibleDocument rootDocument;
/**
* The language for the current DOM node, e.g. en, de, etc.
*/
readonly attribute DOMString language;
/** /**
* Accessible name -- the main text equivalent for this node. The name is * Accessible name -- the main text equivalent for this node. The name is
* specified by ARIA or by native markup. Example of ARIA markup is * specified by ARIA or by native markup. Example of ARIA markup is
@ -285,6 +335,26 @@ interface nsIAccessible : nsISupports
*/ */
void doAction(in PRUint8 index); void doAction(in PRUint8 index);
/**
* Makes an object visible on screen.
*
* @param scrollType - defines where the object should be placed on
* the screen (see nsIAccessibleScrollType for
* available constants).
*/
void scrollTo(in unsigned long aScrollType);
/**
* Moves the top left of an object to a specified location.
*
* @param coordinateType [in] - specifies whether the coordinates are relative to
* the screen or the parent object (for available
* constants refer to nsIAccessibleCoordinateType)
* @param x [in] - defines the x coordinate
* @param y [in] - defines the y coordinate
*/
void scrollToPoint(in unsigned long coordinateType, in long x, in long y);
/** /**
* Get a pointer to accessibility interface for this node, which is specific * Get a pointer to accessibility interface for this node, which is specific
* to the OS/accessibility toolkit we're running on. * to the OS/accessibility toolkit we're running on.

Просмотреть файл

@ -39,7 +39,6 @@
#include "nsISupports.idl" #include "nsISupports.idl"
interface nsIAccessible; interface nsIAccessible;
interface nsIAccessNode;
interface nsIDOMDocument; interface nsIDOMDocument;
interface nsIDOMNode; interface nsIDOMNode;
interface nsIDOMWindow; interface nsIDOMWindow;
@ -50,10 +49,9 @@ interface nsIDOMWindow;
* When accessibility is turned on in Gecko, * When accessibility is turned on in Gecko,
* there is an nsIAccessibleDocument for each document * there is an nsIAccessibleDocument for each document
* whether it is XUL, HTML or whatever. * whether it is XUL, HTML or whatever.
* You can QueryInterface to nsIAccessibleDocument from * You can QueryInterface to nsIAccessibleDocument from the nsIAccessible for
* the nsIAccessible or nsIAccessNode for the root node * the root node of a document. You can also get one from
* of a document. You can also get one from * nsIAccessible::GetAccessibleDocument() or
* nsIAccessNode::GetAccessibleDocument() or
* nsIAccessibleEvent::GetAccessibleDocument() * nsIAccessibleEvent::GetAccessibleDocument()
*/ */
[scriptable, uuid(451242bd-8a0c-4198-ae88-c053609a4e5d)] [scriptable, uuid(451242bd-8a0c-4198-ae88-c053609a4e5d)]

Просмотреть файл

@ -43,14 +43,12 @@ interface nsIAccessible;
interface nsIWeakReference; interface nsIWeakReference;
interface nsIPresShell; interface nsIPresShell;
interface nsIDOMWindow; interface nsIDOMWindow;
interface nsIAccessNode;
interface nsIDOMDOMStringList; interface nsIDOMDOMStringList;
interface nsIAccessiblePivot; interface nsIAccessiblePivot;
/** /**
* An interface for in-process accessibility clients * An interface for in-process accessibility clients
* wishing to get an nsIAccessible or nsIAccessNode for * wishing to get an nsIAccessible for a given DOM node.
* a given DOM node.
* More documentation at: * More documentation at:
* http://www.mozilla.org/projects/ui/accessibility * http://www.mozilla.org/projects/ui/accessibility
*/ */

Просмотреть файл

@ -40,7 +40,6 @@
#define nsAccUtils_h_ #define nsAccUtils_h_
#include "nsIAccessible.h" #include "nsIAccessible.h"
#include "nsIAccessNode.h"
#include "nsIAccessibleRole.h" #include "nsIAccessibleRole.h"
#include "nsIAccessibleText.h" #include "nsIAccessibleText.h"
#include "nsIAccessibleTable.h" #include "nsIAccessibleTable.h"

Просмотреть файл

@ -36,37 +36,27 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "nsDocAccessible.h" #include "nsAccessNode.h"
#include "nsIAccessible.h"
#include "nsAccCache.h"
#include "nsAccUtils.h"
#include "nsCoreUtils.h"
#include "nsHashtable.h"
#include "nsAccessibilityService.h" #include "nsAccessibilityService.h"
#include "nsAccUtils.h"
#include "nsApplicationAccessibleWrap.h" #include "nsApplicationAccessibleWrap.h"
#include "nsCoreUtils.h"
#include "nsRootAccessible.h"
#include "nsIDocShell.h" #include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeItem.h"
#include "nsIDocument.h"
#include "nsIDOMCSSPrimitiveValue.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsPIDOMWindow.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIFrame.h" #include "nsIFrame.h"
#include "nsIPrefService.h" #include "nsIInterfaceRequestorUtils.h"
#include "nsIObserverService.h"
#include "nsIPrefBranch.h" #include "nsIPrefBranch.h"
#include "nsPresContext.h" #include "nsIPrefService.h"
#include "nsIPresShell.h" #include "nsIPresShell.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsIStringBundle.h" #include "nsIStringBundle.h"
#include "nsRootAccessible.h"
#include "nsFocusManager.h" #include "nsFocusManager.h"
#include "nsIObserverService.h" #include "nsPresContext.h"
#include "mozilla/Services.h" #include "mozilla/Services.h"
/* For documentation of the accessibility architecture, /* For documentation of the accessibility architecture,
@ -89,9 +79,7 @@ nsApplicationAccessible *nsAccessNode::gApplicationAccessible = nsnull;
NS_IMPL_CYCLE_COLLECTION_1(nsAccessNode, mContent) NS_IMPL_CYCLE_COLLECTION_1(nsAccessNode, mContent)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsAccessNode) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsAccessNode)
NS_INTERFACE_MAP_ENTRY(nsIAccessNode)
NS_INTERFACE_MAP_ENTRY(nsAccessNode) NS_INTERFACE_MAP_ENTRY(nsAccessNode)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessNode)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsAccessNode) NS_IMPL_CYCLE_COLLECTING_ADDREF(nsAccessNode)
@ -287,128 +275,30 @@ nsAccessNode::IsPrimaryForNode() const
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsIAccessNode void
NS_IMETHODIMP
nsAccessNode::GetDOMNode(nsIDOMNode **aDOMNode)
{
NS_ENSURE_ARG_POINTER(aDOMNode);
*aDOMNode = nsnull;
nsINode *node = GetNode();
if (node)
CallQueryInterface(node, aDOMNode);
return NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetDocument(nsIAccessibleDocument **aDocument)
{
NS_ENSURE_ARG_POINTER(aDocument);
NS_IF_ADDREF(*aDocument = GetDocAccessible());
return NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetRootDocument(nsIAccessibleDocument **aRootDocument)
{
NS_ENSURE_ARG_POINTER(aRootDocument);
nsRootAccessible* rootDocument = RootAccessible();
NS_IF_ADDREF(*aRootDocument = rootDocument);
return NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetInnerHTML(nsAString& aInnerHTML)
{
aInnerHTML.Truncate();
nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(mContent);
NS_ENSURE_TRUE(htmlElement, NS_ERROR_NULL_POINTER);
return htmlElement->GetInnerHTML(aInnerHTML);
}
NS_IMETHODIMP
nsAccessNode::ScrollTo(PRUint32 aScrollType) nsAccessNode::ScrollTo(PRUint32 aScrollType)
{ {
if (IsDefunct()) if (IsDefunct())
return NS_ERROR_FAILURE; return;
nsCOMPtr<nsIPresShell> shell(GetPresShell()); nsCOMPtr<nsIPresShell> shell(GetPresShell());
NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE); if (!shell)
return;
nsIFrame *frame = GetFrame(); nsIFrame *frame = GetFrame();
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE); if (!frame)
return;
nsCOMPtr<nsIContent> content = frame->GetContent(); nsIContent* content = frame->GetContent();
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE); if (!content)
return;
PRInt16 vPercent, hPercent; PRInt16 vPercent, hPercent;
nsCoreUtils::ConvertScrollTypeToPercents(aScrollType, &vPercent, &hPercent); nsCoreUtils::ConvertScrollTypeToPercents(aScrollType, &vPercent, &hPercent);
return shell->ScrollContentIntoView(content, vPercent, hPercent, shell->ScrollContentIntoView(content, vPercent, hPercent,
nsIPresShell::SCROLL_OVERFLOW_HIDDEN); nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
} }
NS_IMETHODIMP
nsAccessNode::ScrollToPoint(PRUint32 aCoordinateType, PRInt32 aX, PRInt32 aY)
{
nsIFrame *frame = GetFrame();
if (!frame)
return NS_ERROR_FAILURE;
nsIntPoint coords;
nsresult rv = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordinateType,
this, &coords);
NS_ENSURE_SUCCESS(rv, rv);
nsIFrame *parentFrame = frame;
while ((parentFrame = parentFrame->GetParent()))
nsCoreUtils::ScrollFrameToPoint(parentFrame, frame, coords);
return NS_OK;
}
NS_IMETHODIMP
nsAccessNode::GetComputedStyleValue(const nsAString& aPseudoElt,
const nsAString& aPropertyName,
nsAString& aValue)
{
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mContent);
NS_ENSURE_TRUE(styleDecl, NS_ERROR_FAILURE);
return styleDecl->GetPropertyValue(aPropertyName, aValue);
}
NS_IMETHODIMP
nsAccessNode::GetComputedStyleCSSValue(const nsAString& aPseudoElt,
const nsAString& aPropertyName,
nsIDOMCSSPrimitiveValue **aCSSValue)
{
NS_ENSURE_ARG_POINTER(aCSSValue);
*aCSSValue = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mContent);
NS_ENSURE_STATE(styleDecl);
nsCOMPtr<nsIDOMCSSValue> cssValue;
styleDecl->GetPropertyCSSValue(aPropertyName, getter_AddRefs(cssValue));
NS_ENSURE_TRUE(cssValue, NS_ERROR_FAILURE);
return CallQueryInterface(cssValue, aCSSValue);
}
// nsAccessNode public // nsAccessNode public
already_AddRefed<nsINode> already_AddRefed<nsINode>
nsAccessNode::GetCurrentFocus() nsAccessNode::GetCurrentFocus()
@ -443,20 +333,18 @@ nsAccessNode::GetCurrentFocus()
return focusedNode; return focusedNode;
} }
NS_IMETHODIMP void
nsAccessNode::GetLanguage(nsAString& aLanguage) nsAccessNode::GetLanguage(nsAString& aLanguage)
{ {
aLanguage.Truncate(); aLanguage.Truncate();
if (IsDefunct()) if (IsDefunct())
return NS_ERROR_FAILURE; return;
nsCoreUtils::GetLanguageFor(mContent, nsnull, aLanguage); nsCoreUtils::GetLanguageFor(mContent, nsnull, aLanguage);
if (aLanguage.IsEmpty()) { // Nothing found, so use document's language if (aLanguage.IsEmpty()) { // Nothing found, so use document's language
mContent->OwnerDoc()->GetHeaderData(nsGkAtoms::headerContentLanguage, mContent->OwnerDoc()->GetHeaderData(nsGkAtoms::headerContentLanguage,
aLanguage); aLanguage);
} }
return NS_OK;
} }

Просмотреть файл

@ -43,7 +43,6 @@
#ifndef _nsAccessNode_H_ #ifndef _nsAccessNode_H_
#define _nsAccessNode_H_ #define _nsAccessNode_H_
#include "nsIAccessNode.h"
#include "nsIAccessibleTypes.h" #include "nsIAccessibleTypes.h"
#include "a11yGeneric.h" #include "a11yGeneric.h"
@ -68,15 +67,7 @@ class nsIDocShellTreeItem;
#define ACCESSIBLE_BUNDLE_URL "chrome://global-platform/locale/accessible.properties" #define ACCESSIBLE_BUNDLE_URL "chrome://global-platform/locale/accessible.properties"
#define PLATFORM_KEYS_BUNDLE_URL "chrome://global-platform/locale/platformKeys.properties" #define PLATFORM_KEYS_BUNDLE_URL "chrome://global-platform/locale/platformKeys.properties"
#define NS_ACCESSNODE_IMPL_CID \ class nsAccessNode: public nsISupports
{ /* 2b07e3d7-00b3-4379-aa0b-ea22e2c8ffda */ \
0x2b07e3d7, \
0x00b3, \
0x4379, \
{ 0xaa, 0x0b, 0xea, 0x22, 0xe2, 0xc8, 0xff, 0xda } \
}
class nsAccessNode: public nsIAccessNode
{ {
public: public:
@ -84,10 +75,7 @@ public:
virtual ~nsAccessNode(); virtual ~nsAccessNode();
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsAccessNode, nsIAccessNode) NS_DECL_CYCLE_COLLECTION_CLASS(nsAccessNode)
NS_DECL_NSIACCESSNODE
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSNODE_IMPL_CID)
static void InitXPAccessibility(); static void InitXPAccessibility();
static void ShutdownXPAccessibility(); static void ShutdownXPAccessibility();
@ -134,18 +122,6 @@ public:
* Return frame for the given access node object. * Return frame for the given access node object.
*/ */
virtual nsIFrame* GetFrame() const; virtual nsIFrame* GetFrame() const;
/**
* Return DOM node associated with this accessible.
*/
already_AddRefed<nsIDOMNode> GetDOMNode() const
{
nsIDOMNode *DOMNode = nsnull;
if (GetNode())
CallQueryInterface(GetNode(), &DOMNode);
return DOMNode;
}
/** /**
* Return DOM node associated with the accessible. * Return DOM node associated with the accessible.
*/ */
@ -195,6 +171,18 @@ public:
*/ */
virtual bool IsPrimaryForNode() const; virtual bool IsPrimaryForNode() const;
/**
* Return the string bundle
*/
static nsIStringBundle* GetStringBundle()
{ return gStringBundle; }
/**
* Interface methods on nsIAccessible shared with ISimpleDOM.
*/
void GetLanguage(nsAString& aLocale);
void ScrollTo(PRUint32 aType);
protected: protected:
nsPresContext* GetPresContext(); nsPresContext* GetPresContext();
@ -221,8 +209,5 @@ private:
static nsApplicationAccessible *gApplicationAccessible; static nsApplicationAccessible *gApplicationAccessible;
}; };
NS_DEFINE_STATIC_IID_ACCESSOR(nsAccessNode,
NS_ACCESSNODE_IMPL_CID)
#endif #endif

Просмотреть файл

@ -52,11 +52,14 @@
#include "nsAccessibilityService.h" #include "nsAccessibilityService.h"
#include "nsAccTreeWalker.h" #include "nsAccTreeWalker.h"
#include "nsIAccessibleRelation.h" #include "nsIAccessibleRelation.h"
#include "nsRootAccessible.h"
#include "nsTextEquivUtils.h" #include "nsTextEquivUtils.h"
#include "Relation.h" #include "Relation.h"
#include "Role.h" #include "Role.h"
#include "States.h" #include "States.h"
#include "nsIDOMCSSValue.h"
#include "nsIDOMCSSPrimitiveValue.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDOMDocumentXBL.h" #include "nsIDOMDocumentXBL.h"
@ -229,6 +232,92 @@ nsAccessible::SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry)
mRoleMapEntry = aRoleMapEntry; mRoleMapEntry = aRoleMapEntry;
} }
NS_IMETHODIMP
nsAccessible::GetComputedStyleValue(const nsAString& aPseudoElt,
const nsAString& aPropertyName,
nsAString& aValue)
{
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mContent);
NS_ENSURE_TRUE(styleDecl, NS_ERROR_FAILURE);
return styleDecl->GetPropertyValue(aPropertyName, aValue);
}
NS_IMETHODIMP
nsAccessible::GetComputedStyleCSSValue(const nsAString& aPseudoElt,
const nsAString& aPropertyName,
nsIDOMCSSPrimitiveValue **aCSSValue) {
NS_ENSURE_ARG_POINTER(aCSSValue);
*aCSSValue = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mContent);
NS_ENSURE_STATE(styleDecl);
nsCOMPtr<nsIDOMCSSValue> cssValue;
styleDecl->GetPropertyCSSValue(aPropertyName, getter_AddRefs(cssValue));
NS_ENSURE_TRUE(cssValue, NS_ERROR_FAILURE);
return CallQueryInterface(cssValue, aCSSValue);
}
NS_IMETHODIMP
nsAccessible::GetDocument(nsIAccessibleDocument **aDocument)
{
NS_ENSURE_ARG_POINTER(aDocument);
NS_IF_ADDREF(*aDocument = GetDocAccessible());
return NS_OK;
}
NS_IMETHODIMP
nsAccessible::GetDOMNode(nsIDOMNode **aDOMNode)
{
NS_ENSURE_ARG_POINTER(aDOMNode);
*aDOMNode = nsnull;
nsINode *node = GetNode();
if (node)
CallQueryInterface(node, aDOMNode);
return NS_OK;
}
NS_IMETHODIMP
nsAccessible::GetRootDocument(nsIAccessibleDocument **aRootDocument)
{
NS_ENSURE_ARG_POINTER(aRootDocument);
nsRootAccessible* rootDocument = RootAccessible();
NS_IF_ADDREF(*aRootDocument = rootDocument);
return NS_OK;
}
NS_IMETHODIMP
nsAccessible::GetInnerHTML(nsAString& aInnerHTML)
{
aInnerHTML.Truncate();
nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(mContent);
NS_ENSURE_TRUE(htmlElement, NS_ERROR_NULL_POINTER);
return htmlElement->GetInnerHTML(aInnerHTML);
}
NS_IMETHODIMP
nsAccessible::GetLanguage(nsAString& aLanguage)
{
nsAccessNode::GetLanguage(aLanguage);
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsAccessible::GetName(nsAString& aName) nsAccessible::GetName(nsAString& aName)
{ {
@ -2176,6 +2265,32 @@ nsAccessible::DispatchClickEvent(nsIContent *aContent, PRUint32 aActionIndex)
nsCoreUtils::DispatchMouseEvent(NS_MOUSE_BUTTON_UP, presShell, aContent); nsCoreUtils::DispatchMouseEvent(NS_MOUSE_BUTTON_UP, presShell, aContent);
} }
NS_IMETHODIMP
nsAccessible::ScrollTo(PRUint32 aHow)
{
nsAccessNode::ScrollTo(aHow);
return NS_OK;
}
NS_IMETHODIMP
nsAccessible::ScrollToPoint(PRUint32 aCoordinateType, PRInt32 aX, PRInt32 aY)
{
nsIFrame *frame = GetFrame();
if (!frame)
return NS_ERROR_FAILURE;
nsIntPoint coords;
nsresult rv = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordinateType,
this, &coords);
NS_ENSURE_SUCCESS(rv, rv);
nsIFrame *parentFrame = frame;
while ((parentFrame = parentFrame->GetParent()))
nsCoreUtils::ScrollFrameToPoint(parentFrame, frame, coords);
return NS_OK;
}
// nsIAccessibleSelectable // nsIAccessibleSelectable
NS_IMETHODIMP nsAccessible::GetSelectedChildren(nsIArray **aSelectedAccessibles) NS_IMETHODIMP nsAccessible::GetSelectedChildren(nsIArray **aSelectedAccessibles)
{ {

Просмотреть файл

@ -116,6 +116,9 @@ public:
NS_DECL_NSIACCESSIBLEVALUE NS_DECL_NSIACCESSIBLEVALUE
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLE_IMPL_IID) NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLE_IMPL_IID)
using nsAccessNode::ScrollTo;
using nsAccessNode::GetLanguage;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// nsAccessNode // nsAccessNode
@ -129,6 +132,17 @@ public:
*/ */
virtual void Description(nsString& aDescription); virtual void Description(nsString& aDescription);
/**
* Return DOM node associated with this accessible.
*/
inline already_AddRefed<nsIDOMNode> DOMNode() const
{
nsIDOMNode *DOMNode = nsnull;
if (GetNode())
CallQueryInterface(GetNode(), &DOMNode);
return DOMNode;
}
/** /**
* Returns the accessible name specified by ARIA. * Returns the accessible name specified by ARIA.
*/ */

Просмотреть файл

@ -421,7 +421,7 @@ nsApplicationAccessible::GetSiblingAtOffset(PRInt32 aOffset,
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsIAccessNode and nsAccessNode // nsIAccessible
NS_IMETHODIMP NS_IMETHODIMP
nsApplicationAccessible::GetDOMNode(nsIDOMNode **aDOMNode) nsApplicationAccessible::GetDOMNode(nsIDOMNode **aDOMNode)

Просмотреть файл

@ -69,7 +69,7 @@ public:
// nsISupports // nsISupports
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
// nsIAccessNode // nsIAccessible
NS_SCRIPTABLE NS_IMETHOD GetDOMNode(nsIDOMNode** aDOMNode); NS_SCRIPTABLE NS_IMETHOD GetDOMNode(nsIDOMNode** aDOMNode);
NS_SCRIPTABLE NS_IMETHOD GetDocument(nsIAccessibleDocument** aDocument); NS_SCRIPTABLE NS_IMETHOD GetDocument(nsIAccessibleDocument** aDocument);
NS_SCRIPTABLE NS_IMETHOD GetRootDocument(nsIAccessibleDocument** aRootDocument); NS_SCRIPTABLE NS_IMETHOD GetRootDocument(nsIAccessibleDocument** aRootDocument);
@ -83,8 +83,6 @@ public:
const nsAString& aPropertyName, const nsAString& aPropertyName,
nsIDOMCSSPrimitiveValue** aValue NS_OUTPARAM); nsIDOMCSSPrimitiveValue** aValue NS_OUTPARAM);
NS_SCRIPTABLE NS_IMETHOD GetLanguage(nsAString& aLanguage); NS_SCRIPTABLE NS_IMETHOD GetLanguage(nsAString& aLanguage);
// nsIAccessible
NS_IMETHOD GetParent(nsIAccessible **aParent); NS_IMETHOD GetParent(nsIAccessible **aParent);
NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling); NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling);
NS_IMETHOD GetPreviousSibling(nsIAccessible **aPreviousSibling); NS_IMETHOD GetPreviousSibling(nsIAccessible **aPreviousSibling);

Просмотреть файл

@ -191,7 +191,7 @@ public:
/** /**
* Scrolls the given frame to the point, used for implememntation of * Scrolls the given frame to the point, used for implememntation of
* nsIAccessNode::scrollToPoint and nsIAccessibleText::scrollSubstringToPoint. * nsIAccessible::scrollToPoint and nsIAccessibleText::scrollSubstringToPoint.
* *
* @param aScrollableFrame the scrollable frame * @param aScrollableFrame the scrollable frame
* @param aFrame the frame to scroll * @param aFrame the frame to scroll

Просмотреть файл

@ -1148,7 +1148,7 @@ nsHyperTextAccessible::GetTextAttributes(bool aIncludeDefAttrs,
// Compute spelling attributes on text accessible only. // Compute spelling attributes on text accessible only.
nsIFrame *offsetFrame = accAtOffset->GetFrame(); nsIFrame *offsetFrame = accAtOffset->GetFrame();
if (offsetFrame && offsetFrame->GetType() == nsGkAtoms::textFrame) { if (offsetFrame && offsetFrame->GetType() == nsGkAtoms::textFrame) {
nsCOMPtr<nsIDOMNode> node = accAtOffset->GetDOMNode(); nsCOMPtr<nsIDOMNode> node = accAtOffset->DOMNode();
PRInt32 nodeOffset = 0; PRInt32 nodeOffset = 0;
nsresult rv = RenderedToContentOffset(offsetFrame, offsetInAcc, nsresult rv = RenderedToContentOffset(offsetFrame, offsetInAcc,
@ -2255,10 +2255,8 @@ nsHyperTextAccessible::GetDOMPointByFrameOffset(nsIFrame *aFrame,
if (!aFrame) { if (!aFrame) {
// If the given frame is null then set offset after the DOM node of the // If the given frame is null then set offset after the DOM node of the
// given accessible. // given accessible.
nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(aAccessible));
nsCOMPtr<nsIDOMNode> DOMNode; nsCOMPtr<nsIDOMNode> DOMNode;
accessNode->GetDOMNode(getter_AddRefs(DOMNode)); aAccessible->GetDOMNode(getter_AddRefs(DOMNode));
nsCOMPtr<nsIContent> content(do_QueryInterface(DOMNode)); nsCOMPtr<nsIContent> content(do_QueryInterface(DOMNode));
NS_ENSURE_STATE(content); NS_ENSURE_STATE(content);

Просмотреть файл

@ -155,7 +155,7 @@ CAccessibleComponent::GetARGBValueFromCSSProperty(const nsAString& aPropName,
__try { __try {
*aColorValue = 0; *aColorValue = 0;
nsCOMPtr<nsIAccessNode> acc(do_QueryObject(this)); nsRefPtr<nsAccessible> acc(do_QueryObject(this));
if (!acc) if (!acc)
return E_FAIL; return E_FAIL;

Просмотреть файл

@ -404,8 +404,7 @@ __try {
aScrollTopLeft ? nsIAccessibleScrollType::SCROLL_TYPE_TOP_LEFT : aScrollTopLeft ? nsIAccessibleScrollType::SCROLL_TYPE_TOP_LEFT :
nsIAccessibleScrollType::SCROLL_TYPE_BOTTOM_RIGHT; nsIAccessibleScrollType::SCROLL_TYPE_BOTTOM_RIGHT;
nsresult rv = ScrollTo(scrollType); ScrollTo(scrollType);
if (NS_SUCCEEDED(rv))
return S_OK; return S_OK;
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { } } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
@ -562,10 +561,7 @@ __try {
*aLanguage = NULL; *aLanguage = NULL;
nsAutoString language; nsAutoString language;
if (NS_FAILED(GetLanguage(language))) { GetLanguage(language)
return E_FAIL;
}
if (language.IsEmpty()) if (language.IsEmpty())
return S_FALSE; return S_FALSE;
@ -583,7 +579,7 @@ nsAccessNodeWrap::get_localInterface(
/* [out] */ void __RPC_FAR *__RPC_FAR *localInterface) /* [out] */ void __RPC_FAR *__RPC_FAR *localInterface)
{ {
__try { __try {
*localInterface = static_cast<nsIAccessNode*>(this); *localInterface = static_cast<nsAccessNode*>(this);
NS_ADDREF_THIS(); NS_ADDREF_THIS();
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { } } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return S_OK; return S_OK;

Просмотреть файл

@ -662,17 +662,10 @@ nsXULToolbarButtonAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
bool bool
nsXULToolbarButtonAccessible::IsSeparator(nsAccessible *aAccessible) nsXULToolbarButtonAccessible::IsSeparator(nsAccessible *aAccessible)
{ {
nsCOMPtr<nsIDOMNode> domNode; nsIContent* content = aAccessible->GetContent();
aAccessible->GetDOMNode(getter_AddRefs(domNode)); return content && ((content->Tag() == nsGkAtoms::toolbarseparator) ||
nsCOMPtr<nsIContent> contentDomNode(do_QueryInterface(domNode)); (content->Tag() == nsGkAtoms::toolbarspacer) ||
(content->Tag() == nsGkAtoms::toolbarspring)); }
if (!contentDomNode)
return false;
return (contentDomNode->Tag() == nsGkAtoms::toolbarseparator) ||
(contentDomNode->Tag() == nsGkAtoms::toolbarspacer) ||
(contentDomNode->Tag() == nsGkAtoms::toolbarspring);
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -153,9 +153,9 @@ nsXULTabAccessible::RelationByType(PRUint32 aType)
if (!tabsElm) if (!tabsElm)
return rel; return rel;
nsCOMPtr<nsIDOMNode> DOMNode(GetDOMNode()); nsCOMPtr<nsIDOMNode> domNode(DOMNode());
nsCOMPtr<nsIDOMNode> tabpanelNode; nsCOMPtr<nsIDOMNode> tabpanelNode;
tabsElm->GetRelatedElement(DOMNode, getter_AddRefs(tabpanelNode)); tabsElm->GetRelatedElement(domNode, getter_AddRefs(tabpanelNode));
if (!tabpanelNode) if (!tabpanelNode)
return rel; return rel;
@ -255,9 +255,9 @@ nsXULTabpanelAccessible::RelationByType(PRUint32 aType)
if (!tabpanelsElm) if (!tabpanelsElm)
return rel; return rel;
nsCOMPtr<nsIDOMNode> DOMNode(GetDOMNode()); nsCOMPtr<nsIDOMNode> domNode(DOMNode());
nsCOMPtr<nsIDOMNode> tabNode; nsCOMPtr<nsIDOMNode> tabNode;
tabpanelsElm->GetRelatedElement(DOMNode, getter_AddRefs(tabNode)); tabpanelsElm->GetRelatedElement(domNode, getter_AddRefs(tabNode));
if (!tabNode) if (!tabNode)
return rel; return rel;

Просмотреть файл

@ -18,7 +18,6 @@ const nsIAccessibleCoordinateType = Components.interfaces.nsIAccessibleCoordinat
const nsIAccessibleRelation = Components.interfaces.nsIAccessibleRelation; const nsIAccessibleRelation = Components.interfaces.nsIAccessibleRelation;
const nsIAccessNode = Components.interfaces.nsIAccessNode;
const nsIAccessible = Components.interfaces.nsIAccessible; const nsIAccessible = Components.interfaces.nsIAccessible;
const nsIAccessibleDocument = Components.interfaces.nsIAccessibleDocument; const nsIAccessibleDocument = Components.interfaces.nsIAccessibleDocument;
@ -121,10 +120,8 @@ function getNode(aAccOrNodeOrID)
if (aAccOrNodeOrID instanceof nsIDOMNode) if (aAccOrNodeOrID instanceof nsIDOMNode)
return aAccOrNodeOrID; return aAccOrNodeOrID;
if (aAccOrNodeOrID instanceof nsIAccessible) { if (aAccOrNodeOrID instanceof nsIAccessible)
aAccOrNodeOrID.QueryInterface(nsIAccessNode);
return aAccOrNodeOrID.DOMNode; return aAccOrNodeOrID.DOMNode;
}
node = document.getElementById(aAccOrNodeOrID); node = document.getElementById(aAccOrNodeOrID);
if (!node) { if (!node) {
@ -167,7 +164,6 @@ function getAccessible(aAccOrElmOrID, aInterfaces, aElmObj, aDoNotFailIf)
var elm = null; var elm = null;
if (aAccOrElmOrID instanceof nsIAccessible) { if (aAccOrElmOrID instanceof nsIAccessible) {
aAccOrElmOrID.QueryInterface(nsIAccessNode);
elm = aAccOrElmOrID.DOMNode; elm = aAccOrElmOrID.DOMNode;
} else if (aAccOrElmOrID instanceof nsIDOMNode) { } else if (aAccOrElmOrID instanceof nsIDOMNode) {
@ -199,8 +195,6 @@ function getAccessible(aAccOrElmOrID, aInterfaces, aElmObj, aDoNotFailIf)
} }
} }
acc.QueryInterface(nsIAccessNode);
if (!aInterfaces) if (!aInterfaces)
return acc; return acc;
@ -257,8 +251,7 @@ function getContainerAccessible(aAccOrElmOrID)
*/ */
function getRootAccessible(aAccOrElmOrID) function getRootAccessible(aAccOrElmOrID)
{ {
var acc = getAccessible(aAccOrElmOrID ? aAccOrElmOrID : document, var acc = getAccessible(aAccOrElmOrID ? aAccOrElmOrID : document);
[nsIAccessNode]);
return acc ? acc.rootDocument.QueryInterface(nsIAccessible) : null; return acc ? acc.rootDocument.QueryInterface(nsIAccessible) : null;
} }
@ -267,11 +260,10 @@ function getRootAccessible(aAccOrElmOrID)
*/ */
function getTabDocAccessible(aAccOrElmOrID) function getTabDocAccessible(aAccOrElmOrID)
{ {
var acc = getAccessible(aAccOrElmOrID ? aAccOrElmOrID : document, var acc = getAccessible(aAccOrElmOrID ? aAccOrElmOrID : document);
[nsIAccessNode]);
var docAcc = acc.document.QueryInterface(nsIAccessible); var docAcc = acc.document.QueryInterface(nsIAccessible);
var containerDocAcc = docAcc.parent.QueryInterface(nsIAccessNode).document; var containerDocAcc = docAcc.parent.document;
// Test is running is stand-alone mode. // Test is running is stand-alone mode.
if (acc.rootDocument == containerDocAcc) if (acc.rootDocument == containerDocAcc)
@ -584,7 +576,7 @@ function getTextFromClipboard()
function prettyName(aIdentifier) function prettyName(aIdentifier)
{ {
if (aIdentifier instanceof nsIAccessible) { if (aIdentifier instanceof nsIAccessible) {
var acc = getAccessible(aIdentifier, [nsIAccessNode]); var acc = getAccessible(aIdentifier);
var msg = "[" + getNodePrettyName(acc.DOMNode); var msg = "[" + getNodePrettyName(acc.DOMNode);
try { try {
msg += ", role: " + roleToString(acc.role); msg += ", role: " + roleToString(acc.role);

Просмотреть файл

@ -91,7 +91,7 @@
var item = menu.getChildAt(idx); var item = menu.getChildAt(idx);
if (hasState(item, STATE_FOCUSED)) if (hasState(item, STATE_FOCUSED))
return getAccessible(item, [nsIAccessNode]); return getAccessible(item);
} }
return null; return null;
} }

Просмотреть файл

@ -60,7 +60,7 @@
{ {
this.containerNode = getNode(aContainerID); this.containerNode = getNode(aContainerID);
this.container = getAccessible(this.containerNode, nsIAccessibleHyperText); this.container = getAccessible(this.containerNode, nsIAccessibleHyperText);
this.text = this.container.firstChild.QueryInterface(nsIAccessNode); this.text = this.container.firstChild;
this.textNode = this.text.DOMNode; this.textNode = this.text.DOMNode;
this.textLen = this.textNode.data.length; this.textLen = this.textNode.data.length;

Просмотреть файл

@ -15,7 +15,7 @@
function doTest() function doTest()
{ {
var elmObj = {}; var elmObj = {};
var acc = getAccessible("span", [nsIAccessNode], elmObj); var acc = getAccessible("span", null, elmObj);
computedStyle = document.defaultView.getComputedStyle(elmObj.value, ""); computedStyle = document.defaultView.getComputedStyle(elmObj.value, "");
// html:span element // html:span element
@ -23,7 +23,7 @@
"Wrong color for element with ID 'span'"); "Wrong color for element with ID 'span'");
// text child of html:span element // text child of html:span element
acc = getAccessible(acc.firstChild, [nsIAccessNode]); acc = getAccessible(acc.firstChild);
is(acc.getComputedStyleValue("", "color"), computedStyle.color, is(acc.getComputedStyleValue("", "color"), computedStyle.color,
"Wrong color for text child of element with ID 'span'"); "Wrong color for text child of element with ID 'span'");

Просмотреть файл

@ -64,8 +64,8 @@
this.preinvoke = function rootContentRemoved_preinvoke() this.preinvoke = function rootContentRemoved_preinvoke()
{ {
// Set up target for hide event before we invoke. // Set up target for hide event before we invoke.
var text = getAccessible(getAccessible(getDocNode(aID)).firstChild, var text =
[nsIAccessNode]).DOMNode; getAccessible(getAccessible(getDocNode(aID)).firstChild).DOMNode;
this.eventSeq[0].target = text; this.eventSeq[0].target = text;
} }