mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 460239 - move static methods from nsAccessible and nsAccessNode to utils, r=aaronlev
This commit is contained in:
parent
75f0f837c1
commit
5919623dd2
@ -371,7 +371,7 @@ NS_IMETHODIMP nsAccessibleWrap::GetNativeInterface(void **aOutAccessible)
|
||||
*aOutAccessible = nsnull;
|
||||
|
||||
if (!mAtkObject) {
|
||||
if (!mWeakShell || !IsEmbeddedObject(this)) {
|
||||
if (!mWeakShell || !nsAccUtils::IsEmbeddedObject(this)) {
|
||||
// We don't create ATK objects for node which has been shutdown, or
|
||||
// nsIAccessible plain text leaves
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -477,7 +477,7 @@ nsAccessibleWrap::CreateMaiInterfaces(void)
|
||||
interfacesBits |= 1 << MAI_INTERFACE_HYPERLINK_IMPL;
|
||||
}
|
||||
|
||||
if (!MustPrune(this)) { // These interfaces require children
|
||||
if (!nsAccUtils::MustPrune(this)) { // These interfaces require children
|
||||
//nsIAccessibleHypertext
|
||||
nsCOMPtr<nsIAccessibleHyperText> accessInterfaceHypertext;
|
||||
QueryInterface(NS_GET_IID(nsIAccessibleHyperText),
|
||||
@ -770,7 +770,8 @@ getRoleCB(AtkObject *aAtkObj)
|
||||
}
|
||||
|
||||
#ifdef DEBUG_A11Y
|
||||
NS_ASSERTION(nsAccessible::IsTextInterfaceSupportCorrect(accWrap), "Does not support nsIAccessibleText when it should");
|
||||
NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(accWrap),
|
||||
"Does not support nsIAccessibleText when it should");
|
||||
#endif
|
||||
|
||||
if (aAtkObj->role == ATK_ROLE_INVALID) {
|
||||
@ -880,7 +881,7 @@ gint
|
||||
getChildCountCB(AtkObject *aAtkObj)
|
||||
{
|
||||
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
|
||||
if (!accWrap || nsAccessibleWrap::MustPrune(accWrap)) {
|
||||
if (!accWrap || nsAccUtils::MustPrune(accWrap)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -914,7 +915,7 @@ refChildCB(AtkObject *aAtkObj, gint aChildIndex)
|
||||
// or we should cache an array of children in each nsAccessible
|
||||
// (instead of mNextSibling on the children)
|
||||
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
|
||||
if (!accWrap || nsAccessibleWrap::MustPrune(accWrap)) {
|
||||
if (!accWrap || nsAccUtils::MustPrune(accWrap)) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
@ -980,7 +981,7 @@ getIndexInParentCB(AtkObject *aAtkObj)
|
||||
if (!sibling) {
|
||||
return -1;
|
||||
}
|
||||
if (nsAccessible::IsEmbeddedObject(sibling)) {
|
||||
if (nsAccUtils::IsEmbeddedObject(sibling)) {
|
||||
++ currentIndex;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ refAccessibleAtPointCB(AtkComponent *aComponent,
|
||||
AtkCoordType aCoordType)
|
||||
{
|
||||
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
|
||||
if (!accWrap || nsAccessibleWrap::MustPrune(accWrap))
|
||||
if (!accWrap || nsAccUtils::MustPrune(accWrap))
|
||||
return nsnull;
|
||||
|
||||
// nsIAccessible getChildAtPoint (x,y) is in screen pixels.
|
||||
|
@ -43,11 +43,13 @@
|
||||
#include "nsIAccessibleTypes.h"
|
||||
#include "nsPIAccessible.h"
|
||||
#include "nsPIAccessNode.h"
|
||||
#include "nsAccessibleEventData.h"
|
||||
|
||||
#include "nsAccessibleEventData.h"
|
||||
#include "nsHyperTextAccessible.h"
|
||||
#include "nsAccessibilityAtoms.h"
|
||||
#include "nsAccessible.h"
|
||||
#include "nsARIAMap.h"
|
||||
|
||||
#include "nsIDOMXULContainerElement.h"
|
||||
#include "nsIDOMXULSelectCntrlEl.h"
|
||||
#include "nsIDOMXULSelectCntrlItemEl.h"
|
||||
@ -175,7 +177,7 @@ nsAccUtils::SetAccAttrsForXULSelectControlItem(nsIDOMNode *aNode,
|
||||
nsAccessNode::GetAccService()->GetAccessibleFor(currNode,
|
||||
getter_AddRefs(itemAcc));
|
||||
if (!itemAcc ||
|
||||
nsAccessible::State(itemAcc) & nsIAccessibleStates::STATE_INVISIBLE) {
|
||||
State(itemAcc) & nsIAccessibleStates::STATE_INVISIBLE) {
|
||||
setSize--;
|
||||
if (index < static_cast<PRUint32>(indexOf))
|
||||
posInSet--;
|
||||
@ -217,11 +219,11 @@ nsAccUtils::SetAccAttrsForXULContainerItem(nsIDOMNode *aNode,
|
||||
getter_AddRefs(itemAcc));
|
||||
|
||||
if (itemAcc) {
|
||||
PRUint32 itemRole = nsAccessible::Role(itemAcc);
|
||||
PRUint32 itemRole = Role(itemAcc);
|
||||
if (itemRole == nsIAccessibleRole::ROLE_SEPARATOR)
|
||||
break; // We reached the beginning of our group.
|
||||
|
||||
PRUint32 itemState = nsAccessible::State(itemAcc);
|
||||
PRUint32 itemState = State(itemAcc);
|
||||
if (!(itemState & nsIAccessibleStates::STATE_INVISIBLE)) {
|
||||
setSize++;
|
||||
posInSet++;
|
||||
@ -239,11 +241,11 @@ nsAccUtils::SetAccAttrsForXULContainerItem(nsIDOMNode *aNode,
|
||||
getter_AddRefs(itemAcc));
|
||||
|
||||
if (itemAcc) {
|
||||
PRUint32 itemRole = nsAccessible::Role(itemAcc);
|
||||
PRUint32 itemRole = Role(itemAcc);
|
||||
if (itemRole == nsIAccessibleRole::ROLE_SEPARATOR)
|
||||
break; // We reached the end of our group.
|
||||
|
||||
PRUint32 itemState = nsAccessible::State(itemAcc);
|
||||
PRUint32 itemState = State(itemAcc);
|
||||
if (!(itemState & nsIAccessibleStates::STATE_INVISIBLE))
|
||||
setSize++;
|
||||
}
|
||||
@ -549,7 +551,7 @@ nsAccUtils::GetScreenCoordsForParent(nsIAccessNode *aAccessNode)
|
||||
nsRoleMapEntry*
|
||||
nsAccUtils::GetRoleMapEntry(nsIDOMNode *aNode)
|
||||
{
|
||||
nsIContent *content = nsAccessible::GetRoleContent(aNode);
|
||||
nsIContent *content = nsCoreUtils::GetRoleContent(aNode);
|
||||
nsAutoString roleString;
|
||||
if (!content || !content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::role, roleString)) {
|
||||
return nsnull;
|
||||
@ -581,3 +583,132 @@ nsAccUtils::GetRoleMapEntry(nsIDOMNode *aNode)
|
||||
// To ensure an accessible object is created
|
||||
return &nsARIAMap::gLandmarkRoleMap;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG_A11Y
|
||||
|
||||
PRBool
|
||||
nsAccUtils::IsTextInterfaceSupportCorrect(nsIAccessible *aAccessible)
|
||||
{
|
||||
PRBool foundText = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIAccessibleDocument> accDoc = do_QueryInterface(aAccessible);
|
||||
if (accDoc) {
|
||||
// Don't test for accessible docs, it makes us create accessibles too
|
||||
// early and fire mutation events before we need to
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> child, nextSibling;
|
||||
aAccessible->GetFirstChild(getter_AddRefs(child));
|
||||
while (child) {
|
||||
if (IsText(child)) {
|
||||
foundText = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
child->GetNextSibling(getter_AddRefs(nextSibling));
|
||||
child.swap(nextSibling);
|
||||
}
|
||||
|
||||
if (foundText) {
|
||||
// found text child node
|
||||
nsCOMPtr<nsIAccessibleText> text = do_QueryInterface(aAccessible);
|
||||
if (!text)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
PRInt32
|
||||
nsAccUtils::TextLength(nsIAccessible *aAccessible)
|
||||
{
|
||||
if (!IsText(aAccessible))
|
||||
return 1;
|
||||
|
||||
nsCOMPtr<nsPIAccessNode> pAccNode(do_QueryInterface(aAccessible));
|
||||
|
||||
nsIFrame *frame = pAccNode->GetFrame();
|
||||
if (frame && frame->GetType() == nsAccessibilityAtoms::textFrame) {
|
||||
// Ensure that correct text length is calculated (with non-rendered
|
||||
// whitespace chars not counted).
|
||||
nsIContent *content = frame->GetContent();
|
||||
if (content) {
|
||||
PRUint32 length;
|
||||
nsresult rv = nsHyperTextAccessible::
|
||||
ContentToRenderedOffset(frame, content->TextLength(), &length);
|
||||
return NS_SUCCEEDED(rv) ? static_cast<PRInt32>(length) : -1;
|
||||
}
|
||||
}
|
||||
|
||||
// For list bullets (or anything other accessible which would compute its own
|
||||
// text. They don't have their own frame.
|
||||
// XXX In the future, list bullets may have frame and anon content, so
|
||||
// we should be able to remove this at that point
|
||||
nsCOMPtr<nsPIAccessible> pAcc(do_QueryInterface(aAccessible));
|
||||
|
||||
nsAutoString text;
|
||||
pAcc->AppendTextTo(text, 0, PR_UINT32_MAX); // Get all the text
|
||||
return text.Length();
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsAccUtils::MustPrune(nsIAccessible *aAccessible)
|
||||
{
|
||||
PRUint32 role = nsAccUtils::Role(aAccessible);
|
||||
|
||||
return role == nsIAccessibleRole::ROLE_MENUITEM ||
|
||||
role == nsIAccessibleRole::ROLE_COMBOBOX_OPTION ||
|
||||
role == nsIAccessibleRole::ROLE_OPTION ||
|
||||
role == nsIAccessibleRole::ROLE_ENTRY ||
|
||||
role == nsIAccessibleRole::ROLE_FLAT_EQUATION ||
|
||||
role == nsIAccessibleRole::ROLE_PASSWORD_TEXT ||
|
||||
role == nsIAccessibleRole::ROLE_PUSHBUTTON ||
|
||||
role == nsIAccessibleRole::ROLE_TOGGLE_BUTTON ||
|
||||
role == nsIAccessibleRole::ROLE_GRAPHIC ||
|
||||
role == nsIAccessibleRole::ROLE_SLIDER ||
|
||||
role == nsIAccessibleRole::ROLE_PROGRESSBAR ||
|
||||
role == nsIAccessibleRole::ROLE_SEPARATOR;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsAccUtils::IsNodeRelevant(nsIDOMNode *aNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> relevantNode;
|
||||
nsAccessNode::GetAccService()->GetRelevantContentNodeFor(aNode,
|
||||
getter_AddRefs(relevantNode));
|
||||
return aNode == relevantNode;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIAccessible>
|
||||
nsAccUtils::GetMultiSelectFor(nsIDOMNode *aNode)
|
||||
{
|
||||
if (!aNode)
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
nsAccessNode::GetAccService()->GetAccessibleFor(aNode,
|
||||
getter_AddRefs(accessible));
|
||||
if (!accessible)
|
||||
return nsnull;
|
||||
|
||||
PRUint32 state = State(accessible);
|
||||
if (0 == (state & nsIAccessibleStates::STATE_SELECTABLE))
|
||||
return nsnull;
|
||||
|
||||
PRUint32 containerRole;
|
||||
while (0 == (state & nsIAccessibleStates::STATE_MULTISELECTABLE)) {
|
||||
nsIAccessible *current = accessible;
|
||||
current->GetParent(getter_AddRefs(accessible));
|
||||
if (!accessible || (NS_SUCCEEDED(accessible->GetFinalRole(&containerRole)) &&
|
||||
containerRole == nsIAccessibleRole::ROLE_PANE)) {
|
||||
return nsnull;
|
||||
}
|
||||
state = State(accessible);
|
||||
}
|
||||
|
||||
nsIAccessible *returnAccessible = nsnull;
|
||||
accessible.swap(returnAccessible);
|
||||
return returnAccessible;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@
|
||||
|
||||
#include "nsIAccessible.h"
|
||||
#include "nsIAccessNode.h"
|
||||
#include "nsIAccessibleRole.h"
|
||||
#include "nsARIAMap.h"
|
||||
|
||||
#include "nsIDOMNode.h"
|
||||
@ -210,8 +211,92 @@ public:
|
||||
* @param aNode The DOM node to get the role map entry for
|
||||
* @return A pointer to the role map entry for the ARIA role, or nsnull if none
|
||||
*/
|
||||
static nsRoleMapEntry* GetRoleMapEntry(nsIDOMNode *aNode);
|
||||
static nsRoleMapEntry* GetRoleMapEntry(nsIDOMNode *aNode);
|
||||
|
||||
/**
|
||||
* Return the role of the given accessible.
|
||||
*/
|
||||
static PRUint32 Role(nsIAccessible *aAcc)
|
||||
{
|
||||
PRUint32 role = nsIAccessibleRole::ROLE_NOTHING;
|
||||
if (aAcc)
|
||||
aAcc->GetFinalRole(&role);
|
||||
|
||||
return role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the state for the given accessible.
|
||||
*/
|
||||
static PRUint32 State(nsIAccessible *aAcc)
|
||||
{
|
||||
PRUint32 state = 0;
|
||||
if (aAcc)
|
||||
aAcc->GetFinalState(&state, nsnull);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_A11Y
|
||||
/**
|
||||
* Detect whether the given accessible object implements nsIAccessibleText,
|
||||
* when it is text or has text child node.
|
||||
*/
|
||||
static PRBool IsTextInterfaceSupportCorrect(nsIAccessible *aAccessible);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return true if the given accessible has text role.
|
||||
*/
|
||||
static PRBool IsText(nsIAccessible *aAcc)
|
||||
{
|
||||
PRUint32 role = Role(aAcc);
|
||||
return role == nsIAccessibleRole::ROLE_TEXT_LEAF ||
|
||||
role == nsIAccessibleRole::ROLE_STATICTEXT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return text length of the given accessible, return -1 on failure.
|
||||
*/
|
||||
static PRInt32 TextLength(nsIAccessible *aAccessible);
|
||||
|
||||
/**
|
||||
* Return true if the given accessible is embedded object.
|
||||
*/
|
||||
static PRBool IsEmbeddedObject(nsIAccessible *aAcc)
|
||||
{
|
||||
PRUint32 role = Role(aAcc);
|
||||
return role != nsIAccessibleRole::ROLE_TEXT_LEAF &&
|
||||
role != nsIAccessibleRole::ROLE_WHITESPACE &&
|
||||
role != nsIAccessibleRole::ROLE_STATICTEXT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given accessible hasn't children.
|
||||
*/
|
||||
static PRBool IsLeaf(nsIAccessible *aAcc)
|
||||
{
|
||||
PRInt32 numChildren;
|
||||
aAcc->GetChildCount(&numChildren);
|
||||
return numChildren > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given accessible can't have children. Used when exposing
|
||||
* to platform accessibility APIs, should the children be pruned off?
|
||||
*/
|
||||
static PRBool MustPrune(nsIAccessible *aAccessible);
|
||||
|
||||
/**
|
||||
* Return true if the given node can be accessible and attached to
|
||||
* the document's accessible tree.
|
||||
*/
|
||||
static PRBool IsNodeRelevant(nsIDOMNode *aNode);
|
||||
|
||||
/**
|
||||
* Return multiselectable parent for the given selectable accessible if any.
|
||||
*/
|
||||
static already_AddRefed<nsIAccessible> GetMultiSelectFor(nsIDOMNode *aNode);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDocumentViewer.h"
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsIDOMCSSPrimitiveValue.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
@ -55,7 +54,6 @@
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIDOMNSDocument.h"
|
||||
#include "nsIDOMNSHTMLElement.h"
|
||||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
@ -616,7 +614,8 @@ nsAccessNode::GetComputedStyleValue(const nsAString& aPseudoElt,
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl;
|
||||
GetComputedStyleDeclaration(aPseudoElt, mDOMNode, getter_AddRefs(styleDecl));
|
||||
nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mDOMNode,
|
||||
getter_AddRefs(styleDecl));
|
||||
NS_ENSURE_TRUE(styleDecl, NS_ERROR_FAILURE);
|
||||
|
||||
return styleDecl->GetPropertyValue(aPropertyName, aValue);
|
||||
@ -634,8 +633,8 @@ nsAccessNode::GetComputedStyleCSSValue(const nsAString& aPseudoElt,
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl;
|
||||
GetComputedStyleDeclaration(aPseudoElt, mDOMNode,
|
||||
getter_AddRefs(styleDecl));
|
||||
nsCoreUtils::GetComputedStyleDeclaration(aPseudoElt, mDOMNode,
|
||||
getter_AddRefs(styleDecl));
|
||||
NS_ENSURE_STATE(styleDecl);
|
||||
|
||||
nsCOMPtr<nsIDOMCSSValue> cssValue;
|
||||
@ -645,32 +644,6 @@ nsAccessNode::GetComputedStyleCSSValue(const nsAString& aPseudoElt,
|
||||
return CallQueryInterface(cssValue, aCSSValue);
|
||||
}
|
||||
|
||||
void
|
||||
nsAccessNode::GetComputedStyleDeclaration(const nsAString& aPseudoElt,
|
||||
nsIDOMNode *aNode,
|
||||
nsIDOMCSSStyleDeclaration **aCssDecl)
|
||||
{
|
||||
*aCssDecl = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> domElement = nsCoreUtils::GetDOMElementFor(aNode);
|
||||
if (!domElement)
|
||||
return;
|
||||
|
||||
// Returns number of items in style declaration
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(domElement);
|
||||
nsCOMPtr<nsIDocument> doc = content->GetDocument();
|
||||
if (!doc)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDOMViewCSS> viewCSS(do_QueryInterface(doc->GetWindow()));
|
||||
if (!viewCSS)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
||||
viewCSS->GetComputedStyle(domElement, aPseudoElt, getter_AddRefs(cssDecl));
|
||||
NS_IF_ADDREF(*aCssDecl = cssDecl);
|
||||
}
|
||||
|
||||
/***************** Hashtable of nsIAccessNode's *****************/
|
||||
|
||||
already_AddRefed<nsIAccessibleDocument>
|
||||
@ -713,7 +686,7 @@ nsAccessNode::GetDocAccessibleFor(nsIDocShellTreeItem *aContainer,
|
||||
return presShell ? GetDocAccessibleFor(presShell->GetDocument()) : nsnull;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node = GetDOMNodeForContainer(aContainer);
|
||||
nsCOMPtr<nsIDOMNode> node = nsCoreUtils::GetDOMNodeForContainer(aContainer);
|
||||
if (!node) {
|
||||
return nsnull;
|
||||
}
|
||||
@ -730,7 +703,7 @@ nsAccessNode::GetDocAccessibleFor(nsIDocShellTreeItem *aContainer,
|
||||
already_AddRefed<nsIAccessibleDocument>
|
||||
nsAccessNode::GetDocAccessibleFor(nsIDOMNode *aNode)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> eventShell = GetPresShellFor(aNode);
|
||||
nsCOMPtr<nsIPresShell> eventShell = nsCoreUtils::GetPresShellFor(aNode);
|
||||
if (eventShell) {
|
||||
return GetDocAccessibleFor(eventShell->GetDocument());
|
||||
}
|
||||
@ -743,44 +716,6 @@ nsAccessNode::GetDocAccessibleFor(nsIDOMNode *aNode)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIPresShell>
|
||||
nsAccessNode::GetPresShellFor(nsIDOMNode *aNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
aNode->GetOwnerDocument(getter_AddRefs(domDocument));
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDocument));
|
||||
if (!doc) { // This is necessary when the node is the document node
|
||||
doc = do_QueryInterface(aNode);
|
||||
}
|
||||
nsIPresShell *presShell = nsnull;
|
||||
if (doc) {
|
||||
presShell = doc->GetPrimaryShell();
|
||||
NS_IF_ADDREF(presShell);
|
||||
}
|
||||
return presShell;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMNode>
|
||||
nsAccessNode::GetDOMNodeForContainer(nsISupports *aContainer)
|
||||
{
|
||||
nsIDOMNode* node = nsnull;
|
||||
nsCOMPtr<nsIDocShell> shell = do_QueryInterface(aContainer);
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
shell->GetContentViewer(getter_AddRefs(cv));
|
||||
if (cv) {
|
||||
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
|
||||
if (docv) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
docv->GetDocument(getter_AddRefs(doc));
|
||||
if (doc) {
|
||||
CallQueryInterface(doc.get(), &node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
void
|
||||
nsAccessNode::PutCacheEntry(nsAccessNodeHashtable& aCache,
|
||||
void* aUniqueID,
|
||||
@ -821,7 +756,7 @@ nsAccessNode::ClearCache(nsAccessNodeHashtable& aCache)
|
||||
|
||||
already_AddRefed<nsIDOMNode> nsAccessNode::GetCurrentFocus()
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell = GetPresShellFor(mDOMNode);
|
||||
nsCOMPtr<nsIPresShell> shell = nsCoreUtils::GetPresShellFor(mDOMNode);
|
||||
NS_ENSURE_TRUE(shell, nsnull);
|
||||
nsCOMPtr<nsIDocument> doc = shell->GetDocument();
|
||||
NS_ENSURE_TRUE(doc, nsnull);
|
||||
|
@ -111,13 +111,6 @@ class nsAccessNode: public nsIAccessNode,
|
||||
static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsIDocShellTreeItem *aContainer, PRBool aCanCreate = PR_FALSE);
|
||||
static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsIDOMNode *aNode);
|
||||
|
||||
static already_AddRefed<nsIDOMNode> GetDOMNodeForContainer(nsISupports *aContainer);
|
||||
static already_AddRefed<nsIPresShell> GetPresShellFor(nsIDOMNode *aStartNode);
|
||||
|
||||
static void GetComputedStyleDeclaration(const nsAString& aPseudoElt,
|
||||
nsIDOMNode *aNode,
|
||||
nsIDOMCSSStyleDeclaration **aCssDecl);
|
||||
|
||||
already_AddRefed<nsRootAccessible> GetRootAccessible();
|
||||
|
||||
static nsIDOMNode *gLastFocusedNode;
|
||||
|
@ -1538,7 +1538,8 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessible(nsIDOMNode *aNode,
|
||||
// Don't create accessibles for them unless they need to fire focus events
|
||||
return NS_OK;
|
||||
}
|
||||
if (tableAccessible && nsAccessible::Role(tableAccessible) != nsIAccessibleRole::ROLE_TABLE) {
|
||||
if (tableAccessible &&
|
||||
nsAccUtils::Role(tableAccessible) != nsIAccessibleRole::ROLE_TABLE) {
|
||||
NS_ASSERTION(!roleMapEntry, "Should not be changing ARIA role, just overriding impl class role");
|
||||
// Not in table: override role (roleMap entry was null).
|
||||
roleMapEntry = &nsARIAMap::gEmptyRoleMap;
|
||||
|
@ -160,43 +160,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_ADDREF_INHERITED(nsAccessible, nsAccessNode)
|
||||
NS_IMPL_RELEASE_INHERITED(nsAccessible, nsAccessNode)
|
||||
|
||||
#ifdef DEBUG_A11Y
|
||||
/*
|
||||
* static
|
||||
* help method. to detect whether this accessible object implements
|
||||
* nsIAccessibleText, when it is text or has text child node.
|
||||
*/
|
||||
PRBool nsAccessible::IsTextInterfaceSupportCorrect(nsIAccessible *aAccessible)
|
||||
{
|
||||
PRBool foundText = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIAccessibleDocument> accDoc = do_QueryInterface(aAccessible);
|
||||
if (accDoc) {
|
||||
// Don't test for accessible docs, it makes us create accessibles too
|
||||
// early and fire mutation events before we need to
|
||||
return PR_TRUE;
|
||||
}
|
||||
nsCOMPtr<nsIAccessible> child, nextSibling;
|
||||
aAccessible->GetFirstChild(getter_AddRefs(child));
|
||||
while (child) {
|
||||
if (IsText(child)) {
|
||||
foundText = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
child->GetNextSibling(getter_AddRefs(nextSibling));
|
||||
child.swap(nextSibling);
|
||||
}
|
||||
if (foundText) {
|
||||
// found text child node
|
||||
nsCOMPtr<nsIAccessibleText> text = do_QueryInterface(aAccessible);
|
||||
if (!text) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult nsAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
// Custom-built QueryInterface() knows when we support nsIAccessibleSelectable
|
||||
@ -441,7 +404,7 @@ nsAccessible::GetKeyboardShortcut(nsAString& aAccessKey)
|
||||
if (!key && content->IsNodeOfType(nsIContent::eELEMENT)) {
|
||||
// Copy access key from label node unless it is labeled
|
||||
// via an ancestor <label>, in which case that would be redundant
|
||||
nsCOMPtr<nsIContent> labelContent(GetLabelContent(content));
|
||||
nsCOMPtr<nsIContent> labelContent(nsCoreUtils::GetLabelContent(content));
|
||||
nsCOMPtr<nsIDOMNode> labelNode = do_QueryInterface(labelContent);
|
||||
if (labelNode && !nsCoreUtils::IsAncestorOf(labelNode, mDOMNode))
|
||||
key = nsCoreUtils::GetAccessKeyFor(labelContent);
|
||||
@ -506,33 +469,6 @@ NS_IMETHODIMP nsAccessible::SetNextSibling(nsIAccessible *aNextSibling)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIContent *nsAccessible::GetRoleContent(nsIDOMNode *aDOMNode)
|
||||
{
|
||||
// Given the DOM node for an acessible, return content node that
|
||||
// we should look for ARIA properties on.
|
||||
// For non-document accessibles, this is the associated content node.
|
||||
// For doc accessibles, use the <body>/<frameset> if it's HTML.
|
||||
// For any other doc accessible , this is the document element.
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aDOMNode));
|
||||
if (!content) {
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(aDOMNode));
|
||||
if (domDoc) {
|
||||
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(aDOMNode));
|
||||
if (htmlDoc) {
|
||||
nsCOMPtr<nsIDOMHTMLElement> bodyElement;
|
||||
htmlDoc->GetBody(getter_AddRefs(bodyElement));
|
||||
content = do_QueryInterface(bodyElement);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDOMElement> docElement;
|
||||
domDoc->GetDocumentElement(getter_AddRefs(docElement));
|
||||
content = do_QueryInterface(docElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessible::Shutdown()
|
||||
{
|
||||
mNextSibling = nsnull;
|
||||
@ -1125,7 +1061,7 @@ nsAccessible::GetDeepestChildAtPoint(PRInt32 aX, PRInt32 aY,
|
||||
aY >= y && aY < y + height) {
|
||||
fallbackAnswer = this;
|
||||
}
|
||||
if (MustPrune(this)) { // Do not dig any further
|
||||
if (nsAccUtils::MustPrune(this)) { // Do not dig any further
|
||||
NS_IF_ADDREF(*aAccessible = fallbackAnswer);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1196,7 +1132,7 @@ nsAccessible::GetDeepestChildAtPoint(PRInt32 aX, PRInt32 aY,
|
||||
child->GetBounds(&childX, &childY, &childWidth, &childHeight);
|
||||
if (aX >= childX && aX < childX + childWidth &&
|
||||
aY >= childY && aY < childY + childHeight &&
|
||||
(State(child) & nsIAccessibleStates::STATE_INVISIBLE) == 0) {
|
||||
(nsAccUtils::State(child) & nsIAccessibleStates::STATE_INVISIBLE) == 0) {
|
||||
// Don't walk into offscreen or invisible items
|
||||
NS_IF_ADDREF(*aAccessible = child);
|
||||
return NS_OK;
|
||||
@ -1279,8 +1215,10 @@ void nsAccessible::GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame
|
||||
*aBoundingFrame = ancestorFrame;
|
||||
// If any other frame type, we only need to deal with the primary frame
|
||||
// Otherwise, there may be more frames attached to the same content node
|
||||
if (!IsCorrectFrameType(ancestorFrame, nsAccessibilityAtoms::inlineFrame) &&
|
||||
!IsCorrectFrameType(ancestorFrame, nsAccessibilityAtoms::textFrame))
|
||||
if (!nsCoreUtils::IsCorrectFrameType(ancestorFrame,
|
||||
nsAccessibilityAtoms::inlineFrame) &&
|
||||
!nsCoreUtils::IsCorrectFrameType(ancestorFrame,
|
||||
nsAccessibilityAtoms::textFrame))
|
||||
break;
|
||||
ancestorFrame = ancestorFrame->GetParent();
|
||||
}
|
||||
@ -1304,7 +1242,8 @@ void nsAccessible::GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame
|
||||
|
||||
nsIFrame *iterNextFrame = nsnull;
|
||||
|
||||
if (IsCorrectFrameType(iterFrame, nsAccessibilityAtoms::inlineFrame)) {
|
||||
if (nsCoreUtils::IsCorrectFrameType(iterFrame,
|
||||
nsAccessibilityAtoms::inlineFrame)) {
|
||||
// Only do deeper bounds search if we're on an inline frame
|
||||
// Inline frames can contain larger frames inside of them
|
||||
iterNextFrame = iterFrame->GetFirstChild(nsnull);
|
||||
@ -1376,58 +1315,11 @@ NS_IMETHODIMP nsAccessible::GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PR
|
||||
|
||||
// helpers
|
||||
|
||||
/**
|
||||
* Static
|
||||
* Helper method to help sub classes make sure they have the proper
|
||||
* frame when walking the frame tree to get at children and such
|
||||
*/
|
||||
PRBool nsAccessible::IsCorrectFrameType( nsIFrame* aFrame, nsIAtom* aAtom )
|
||||
{
|
||||
NS_ASSERTION(aFrame != nsnull, "aFrame is null in call to IsCorrectFrameType!");
|
||||
NS_ASSERTION(aAtom != nsnull, "aAtom is null in call to IsCorrectFrameType!");
|
||||
|
||||
return aFrame->GetType() == aAtom;
|
||||
}
|
||||
|
||||
|
||||
nsIFrame* nsAccessible::GetBoundsFrame()
|
||||
{
|
||||
return GetFrame();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIAccessible>
|
||||
nsAccessible::GetMultiSelectFor(nsIDOMNode *aNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNode, nsnull);
|
||||
nsCOMPtr<nsIAccessibilityService> accService =
|
||||
do_GetService("@mozilla.org/accessibilityService;1");
|
||||
NS_ENSURE_TRUE(accService, nsnull);
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
accService->GetAccessibleFor(aNode, getter_AddRefs(accessible));
|
||||
if (!accessible) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PRUint32 state = State(accessible);
|
||||
if (0 == (state & nsIAccessibleStates::STATE_SELECTABLE)) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PRUint32 containerRole;
|
||||
while (0 == (state & nsIAccessibleStates::STATE_MULTISELECTABLE)) {
|
||||
nsIAccessible *current = accessible;
|
||||
current->GetParent(getter_AddRefs(accessible));
|
||||
if (!accessible || (NS_SUCCEEDED(accessible->GetFinalRole(&containerRole)) &&
|
||||
containerRole == nsIAccessibleRole::ROLE_PANE)) {
|
||||
return nsnull;
|
||||
}
|
||||
state = State(accessible);
|
||||
}
|
||||
nsIAccessible *returnAccessible = nsnull;
|
||||
accessible.swap(returnAccessible);
|
||||
return returnAccessible;
|
||||
}
|
||||
|
||||
/* void removeSelection (); */
|
||||
NS_IMETHODIMP nsAccessible::SetSelected(PRBool aSelect)
|
||||
{
|
||||
@ -1436,9 +1328,10 @@ NS_IMETHODIMP nsAccessible::SetSelected(PRBool aSelect)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRUint32 state = State(this);
|
||||
PRUint32 state = nsAccUtils::State(this);
|
||||
if (state & nsIAccessibleStates::STATE_SELECTABLE) {
|
||||
nsCOMPtr<nsIAccessible> multiSelect = GetMultiSelectFor(mDOMNode);
|
||||
nsCOMPtr<nsIAccessible> multiSelect =
|
||||
nsAccUtils::GetMultiSelectFor(mDOMNode);
|
||||
if (!multiSelect) {
|
||||
return aSelect ? TakeFocus() : NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -1465,9 +1358,10 @@ NS_IMETHODIMP nsAccessible::TakeSelection()
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRUint32 state = State(this);
|
||||
PRUint32 state = nsAccUtils::State(this);
|
||||
if (state & nsIAccessibleStates::STATE_SELECTABLE) {
|
||||
nsCOMPtr<nsIAccessible> multiSelect = GetMultiSelectFor(mDOMNode);
|
||||
nsCOMPtr<nsIAccessible> multiSelect =
|
||||
nsAccUtils::GetMultiSelectFor(mDOMNode);
|
||||
if (multiSelect) {
|
||||
nsCOMPtr<nsIAccessibleSelectable> selectable = do_QueryInterface(multiSelect);
|
||||
selectable->ClearSelection();
|
||||
@ -1766,52 +1660,12 @@ nsAccessible::AppendFlatStringFromSubtreeRecurse(nsIContent *aContent,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIContent *nsAccessible::GetLabelContent(nsIContent *aForNode)
|
||||
{
|
||||
if (aForNode->IsNodeOfType(nsINode::eXUL))
|
||||
return nsCoreUtils::FindNeighbourPointingToNode(aForNode, nsAccessibilityAtoms::control,
|
||||
nsAccessibilityAtoms::label);
|
||||
|
||||
return GetHTMLLabelContent(aForNode);
|
||||
}
|
||||
|
||||
nsIContent* nsAccessible::GetHTMLLabelContent(nsIContent *aForNode)
|
||||
{
|
||||
// Get either <label for="[id]"> element which explictly points to aForNode, or
|
||||
// <label> ancestor which implicitly point to it
|
||||
nsIContent *walkUpContent = aForNode;
|
||||
|
||||
// go up tree get name of ancestor label if there is one. Don't go up farther than form element
|
||||
while ((walkUpContent = walkUpContent->GetParent()) != nsnull) {
|
||||
nsIAtom *tag = walkUpContent->Tag();
|
||||
if (tag == nsAccessibilityAtoms::label) {
|
||||
return walkUpContent; // An ancestor <label> implicitly points to us
|
||||
}
|
||||
if (tag == nsAccessibilityAtoms::form ||
|
||||
tag == nsAccessibilityAtoms::body) {
|
||||
// Reached top ancestor in form
|
||||
// There can be a label targeted at this control using the
|
||||
// for="control_id" attribute. To save computing time, only
|
||||
// look for those inside of a form element
|
||||
nsAutoString forId;
|
||||
if (!nsCoreUtils::GetID(aForNode, forId)) {
|
||||
break;
|
||||
}
|
||||
// Actually we'll be walking down the content this time, with a depth first search
|
||||
return nsCoreUtils::FindDescendantPointingToID(&forId, walkUpContent,
|
||||
nsAccessibilityAtoms::_for);
|
||||
}
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsresult nsAccessible::GetTextFromRelationID(nsIAtom *aIDProperty, nsString &aName)
|
||||
{
|
||||
// Get DHTML name from content subtree pointed to by ID attribute
|
||||
aName.Truncate();
|
||||
NS_ASSERTION(mDOMNode, "Called from shutdown accessible");
|
||||
nsCOMPtr<nsIContent> content = GetRoleContent(mDOMNode);
|
||||
nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(mDOMNode);
|
||||
if (!content)
|
||||
return NS_OK;
|
||||
|
||||
@ -1863,13 +1717,13 @@ nsresult nsAccessible::GetTextFromRelationID(nsIAtom *aIDProperty, nsString &aNa
|
||||
*/
|
||||
nsresult nsAccessible::GetHTMLName(nsAString& aLabel, PRBool aCanAggregateSubtree)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = GetRoleContent(mDOMNode);
|
||||
nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(mDOMNode);
|
||||
if (!content) {
|
||||
aLabel.SetIsVoid(PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIContent *labelContent = GetHTMLLabelContent(content);
|
||||
nsIContent *labelContent = nsCoreUtils::GetHTMLLabelContent(content);
|
||||
if (labelContent) {
|
||||
nsAutoString label;
|
||||
nsresult rv = AppendFlatStringFromSubtree(labelContent, &label);
|
||||
@ -1944,7 +1798,7 @@ nsresult nsAccessible::GetXULName(nsAString& aLabel, PRBool aCanAggregateSubtree
|
||||
}
|
||||
|
||||
// CASES #2 and #3 ------ label as a child or <label control="id" ... > </label>
|
||||
nsCOMPtr<nsIContent> content = GetRoleContent(mDOMNode);
|
||||
nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(mDOMNode);
|
||||
if (!content)
|
||||
return NS_OK;
|
||||
|
||||
@ -1999,18 +1853,6 @@ nsresult nsAccessible::GetXULName(nsAString& aLabel, PRBool aCanAggregateSubtree
|
||||
AppendFlatStringFromSubtree(content, &aLabel) : NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsAccessible::IsNodeRelevant(nsIDOMNode *aNode)
|
||||
{
|
||||
// Can this node be accessible and attached to
|
||||
// the document's accessible tree?
|
||||
nsCOMPtr<nsIAccessibilityService> accService =
|
||||
do_GetService("@mozilla.org/accessibilityService;1");
|
||||
NS_ENSURE_TRUE(accService, PR_FALSE);
|
||||
nsCOMPtr<nsIDOMNode> relevantNode;
|
||||
accService->GetRelevantContentNodeFor(aNode, getter_AddRefs(relevantNode));
|
||||
return aNode == relevantNode;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessible::FireToolkitEvent(PRUint32 aEvent, nsIAccessible *aTarget)
|
||||
{
|
||||
@ -2031,7 +1873,7 @@ nsAccessible::FireAccessibleEvent(nsIAccessibleEvent *aEvent)
|
||||
NS_ENSURE_ARG_POINTER(aEvent);
|
||||
nsCOMPtr<nsIDOMNode> eventNode;
|
||||
aEvent->GetDOMNode(getter_AddRefs(eventNode));
|
||||
NS_ENSURE_TRUE(IsNodeRelevant(eventNode), NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(nsAccUtils::IsNodeRelevant(eventNode), NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
@ -2069,22 +1911,20 @@ NS_IMETHODIMP nsAccessible::GetFinalRole(PRUint32 *aRole)
|
||||
// A listbox inside of a combo box needs a special role because of ATK mapping to menu
|
||||
nsCOMPtr<nsIAccessible> possibleCombo;
|
||||
GetParent(getter_AddRefs(possibleCombo));
|
||||
if (possibleCombo && Role(possibleCombo) == nsIAccessibleRole::ROLE_COMBOBOX) {
|
||||
if (nsAccUtils::Role(possibleCombo) == nsIAccessibleRole::ROLE_COMBOBOX) {
|
||||
*aRole = nsIAccessibleRole::ROLE_COMBOBOX_LIST;
|
||||
}
|
||||
else { // Check to see if combo owns the listbox instead
|
||||
GetAccessibleRelated(nsIAccessibleRelation::RELATION_NODE_CHILD_OF, getter_AddRefs(possibleCombo));
|
||||
if (possibleCombo && Role(possibleCombo) == nsIAccessibleRole::ROLE_COMBOBOX) {
|
||||
if (nsAccUtils::Role(possibleCombo) == nsIAccessibleRole::ROLE_COMBOBOX)
|
||||
*aRole = nsIAccessibleRole::ROLE_COMBOBOX_LIST;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (*aRole == nsIAccessibleRole::ROLE_OPTION) {
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetParent(getter_AddRefs(parent));
|
||||
if (parent && Role(parent) == nsIAccessibleRole::ROLE_COMBOBOX_LIST) {
|
||||
if (nsAccUtils::Role(parent) == nsIAccessibleRole::ROLE_COMBOBOX_LIST)
|
||||
*aRole = nsIAccessibleRole::ROLE_COMBOBOX_OPTION;
|
||||
}
|
||||
}
|
||||
|
||||
// gLandmarkRoleMap: can use role of accessible class impl
|
||||
@ -2108,7 +1948,7 @@ nsAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIContent> content = GetRoleContent(mDOMNode);
|
||||
nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(mDOMNode);
|
||||
if (!content) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -2148,7 +1988,7 @@ nsAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
|
||||
}
|
||||
|
||||
|
||||
PRUint32 role = Role(this);
|
||||
PRUint32 role = nsAccUtils::Role(this);
|
||||
if (role == nsIAccessibleRole::ROLE_CHECKBUTTON ||
|
||||
role == nsIAccessibleRole::ROLE_PUSHBUTTON ||
|
||||
role == nsIAccessibleRole::ROLE_MENUITEM ||
|
||||
@ -2185,7 +2025,7 @@ nsAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
|
||||
role == nsIAccessibleRole::ROLE_OPTION ||
|
||||
role == nsIAccessibleRole::ROLE_RADIOBUTTON ||
|
||||
role == nsIAccessibleRole::ROLE_OUTLINEITEM) &&
|
||||
0 == (State(this) & nsIAccessibleStates::STATE_INVISIBLE)) {
|
||||
0 == (nsAccUtils::State(this) & nsIAccessibleStates::STATE_INVISIBLE)) {
|
||||
|
||||
PRUint32 baseRole = role;
|
||||
if (role == nsIAccessibleRole::ROLE_CHECK_MENU_ITEM ||
|
||||
@ -2214,7 +2054,7 @@ nsAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
|
||||
|
||||
// If sibling is visible and has the same base role.
|
||||
if (siblingBaseRole == baseRole &&
|
||||
!(State(sibling) & nsIAccessibleStates::STATE_INVISIBLE)) {
|
||||
!(nsAccUtils::State(sibling) & nsIAccessibleStates::STATE_INVISIBLE)) {
|
||||
++ setSize;
|
||||
if (!foundCurrent) {
|
||||
++ positionInGroup;
|
||||
@ -2286,7 +2126,7 @@ nsAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
|
||||
{
|
||||
// Attributes set by this method will not be used to override attributes on a sub-document accessible
|
||||
// when there is a <frame>/<iframe> element that spawned the sub-document
|
||||
nsIContent *content = GetRoleContent(mDOMNode);
|
||||
nsIContent *content = nsCoreUtils::GetRoleContent(mDOMNode);
|
||||
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(content));
|
||||
NS_ENSURE_TRUE(element, NS_ERROR_UNEXPECTED);
|
||||
|
||||
@ -2319,7 +2159,7 @@ nsAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
|
||||
nsIDocument *doc = startContent->GetDocument();
|
||||
nsCOMPtr<nsIDOMNode> docNode = do_QueryInterface(doc);
|
||||
NS_ENSURE_STATE(docNode);
|
||||
nsIContent *topContent = GetRoleContent(docNode);
|
||||
nsIContent *topContent = nsCoreUtils::GetRoleContent(docNode);
|
||||
NS_ENSURE_STATE(topContent);
|
||||
nsAccUtils::SetLiveContainerAttributes(aAttributes, startContent,
|
||||
topContent);
|
||||
@ -2440,7 +2280,7 @@ nsAccessible::GetFinalState(PRUint32 *aState, PRUint32 *aExtraState)
|
||||
getter_AddRefs(tabPanel));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (tabPanel && Role(tabPanel) == nsIAccessibleRole::ROLE_PROPERTYPAGE) {
|
||||
if (nsAccUtils::Role(tabPanel) == nsIAccessibleRole::ROLE_PROPERTYPAGE) {
|
||||
nsCOMPtr<nsIAccessNode> tabPanelAccessNode(do_QueryInterface(tabPanel));
|
||||
nsCOMPtr<nsIDOMNode> tabPanelNode;
|
||||
tabPanelAccessNode->GetDOMNode(getter_AddRefs(tabPanelNode));
|
||||
@ -2519,7 +2359,8 @@ nsAccessible::GetFinalState(PRUint32 *aState, PRUint32 *aExtraState)
|
||||
if (mRoleMapEntry && mRoleMapEntry->role == nsIAccessibleRole::ROLE_ENTRY) {
|
||||
PRBool isMultiLine = content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::aria_multiline,
|
||||
nsAccessibilityAtoms::_true, eCaseMatters);
|
||||
*aExtraState |= isMultiLine ? nsIAccessibleStates::EXT_STATE_MULTI_LINE : nsIAccessibleStates::EXT_STATE_SINGLE_LINE;
|
||||
*aExtraState |= isMultiLine ? nsIAccessibleStates::EXT_STATE_MULTI_LINE :
|
||||
nsIAccessibleStates::EXT_STATE_SINGLE_LINE;
|
||||
if (0 == (*aState & nsIAccessibleStates::STATE_READONLY))
|
||||
*aExtraState |= nsIAccessibleStates::EXT_STATE_EDITABLE; // Not readonly
|
||||
else // We're readonly: make sure editable state wasn't set by impl class
|
||||
@ -2557,7 +2398,7 @@ nsresult
|
||||
nsAccessible::GetARIAState(PRUint32 *aState)
|
||||
{
|
||||
// Test for universal states first
|
||||
nsIContent *content = GetRoleContent(mDOMNode);
|
||||
nsIContent *content = nsCoreUtils::GetRoleContent(mDOMNode);
|
||||
if (!content) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -2693,7 +2534,7 @@ nsAccessible::SetCurrentValue(double aValue)
|
||||
const PRUint32 kValueCannotChange = nsIAccessibleStates::STATE_READONLY |
|
||||
nsIAccessibleStates::STATE_UNAVAILABLE;
|
||||
|
||||
if (State(this) & kValueCannotChange)
|
||||
if (nsAccUtils::State(this) & kValueCannotChange)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
double minValue = 0;
|
||||
@ -2773,7 +2614,7 @@ nsAccessible::GetNumActions(PRUint8 *aNumActions)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRUint32 actionRule = GetActionRule(State(this));
|
||||
PRUint32 actionRule = GetActionRule(nsAccUtils::State(this));
|
||||
if (actionRule == eNoAction)
|
||||
return NS_OK;
|
||||
|
||||
@ -2793,7 +2634,7 @@ nsAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRUint32 states = State(this);
|
||||
PRUint32 states = nsAccUtils::State(this);
|
||||
PRUint32 actionRule = GetActionRule(states);
|
||||
|
||||
switch (actionRule) {
|
||||
@ -2857,7 +2698,7 @@ nsAccessible::DoAction(PRUint8 aIndex)
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (GetActionRule(State(this)) != eNoAction) {
|
||||
if (GetActionRule(nsAccUtils::State(this)) != eNoAction) {
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
return DoCommand(content);
|
||||
}
|
||||
@ -2897,7 +2738,7 @@ NS_IMETHODIMP nsAccessible::GetAccessibleBelow(nsIAccessible **_retval)
|
||||
|
||||
nsIDOMNode* nsAccessible::GetAtomicRegion()
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = GetRoleContent(mDOMNode);
|
||||
nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(mDOMNode);
|
||||
nsIContent *loopContent = content;
|
||||
nsAutoString atomic;
|
||||
while (loopContent && !loopContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_atomic, atomic)) {
|
||||
@ -2920,7 +2761,7 @@ NS_IMETHODIMP nsAccessible::GetAccessibleRelated(PRUint32 aRelationType, nsIAcce
|
||||
|
||||
// Relationships are defined on the same content node
|
||||
// that the role would be defined on
|
||||
nsIContent *content = GetRoleContent(mDOMNode);
|
||||
nsIContent *content = nsCoreUtils::GetRoleContent(mDOMNode);
|
||||
if (!content) {
|
||||
return NS_ERROR_FAILURE; // Node already shut down
|
||||
}
|
||||
@ -2947,7 +2788,7 @@ NS_IMETHODIMP nsAccessible::GetAccessibleRelated(PRUint32 aRelationType, nsIAcce
|
||||
case nsIAccessibleRelation::RELATION_LABELLED_BY:
|
||||
{
|
||||
if (!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_labelledby, relatedID)) {
|
||||
relatedNode = do_QueryInterface(GetLabelContent(content));
|
||||
relatedNode = do_QueryInterface(nsCoreUtils::GetLabelContent(content));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -3264,7 +3105,7 @@ nsAccessible::GetNextWithState(nsIAccessible *aStart, PRUint32 matchState)
|
||||
}
|
||||
}
|
||||
current.swap(look);
|
||||
state = State(current);
|
||||
state = nsAccUtils::State(current);
|
||||
}
|
||||
|
||||
nsIAccessible *returnAccessible = nsnull;
|
||||
@ -3338,7 +3179,7 @@ NS_IMETHODIMP nsAccessible::AddChildToSelection(PRInt32 aIndex)
|
||||
nsCOMPtr<nsIAccessible> child;
|
||||
GetChildAt(aIndex, getter_AddRefs(child));
|
||||
|
||||
PRUint32 state = State(child);
|
||||
PRUint32 state = nsAccUtils::State(child);
|
||||
if (!(state & nsIAccessibleStates::STATE_SELECTABLE)) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -3357,7 +3198,7 @@ NS_IMETHODIMP nsAccessible::RemoveChildFromSelection(PRInt32 aIndex)
|
||||
nsCOMPtr<nsIAccessible> child;
|
||||
GetChildAt(aIndex, getter_AddRefs(child));
|
||||
|
||||
PRUint32 state = State(child);
|
||||
PRUint32 state = nsAccUtils::State(child);
|
||||
if (!(state & nsIAccessibleStates::STATE_SELECTED)) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -3377,7 +3218,7 @@ NS_IMETHODIMP nsAccessible::IsChildSelected(PRInt32 aIndex, PRBool *aIsSelected)
|
||||
nsCOMPtr<nsIAccessible> child;
|
||||
GetChildAt(aIndex, getter_AddRefs(child));
|
||||
|
||||
PRUint32 state = State(child);
|
||||
PRUint32 state = nsAccUtils::State(child);
|
||||
if (state & nsIAccessibleStates::STATE_SELECTED) {
|
||||
*aIsSelected = PR_TRUE;
|
||||
}
|
||||
@ -3482,7 +3323,7 @@ NS_IMETHODIMP
|
||||
nsAccessible::GetValid(PRBool *aValid)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aValid);
|
||||
PRUint32 state = State(this);
|
||||
PRUint32 state = nsAccUtils::State(this);
|
||||
*aValid = (0 == (state & nsIAccessibleStates::STATE_INVALID));
|
||||
// XXX In order to implement this we would need to follow every link
|
||||
// Perhaps we can get information about invalid links from the cache
|
||||
@ -3513,9 +3354,9 @@ nsresult nsAccessible::GetLinkOffset(PRInt32* aStartOffset, PRInt32* aEndOffset)
|
||||
parent->GetFirstChild(getter_AddRefs(accessible));
|
||||
|
||||
while (accessible) {
|
||||
if (IsText(accessible)) {
|
||||
characterCount += TextLength(accessible);
|
||||
}
|
||||
if (nsAccUtils::IsText(accessible))
|
||||
characterCount += nsAccUtils::TextLength(accessible);
|
||||
|
||||
else if (accessible == this) {
|
||||
*aStartOffset = characterCount;
|
||||
*aEndOffset = characterCount + 1;
|
||||
@ -3531,37 +3372,6 @@ nsresult nsAccessible::GetLinkOffset(PRInt32* aStartOffset, PRInt32* aEndOffset)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRInt32 nsAccessible::TextLength(nsIAccessible *aAccessible)
|
||||
{
|
||||
if (!IsText(aAccessible))
|
||||
return 1;
|
||||
|
||||
nsCOMPtr<nsPIAccessNode> pAccNode(do_QueryInterface(aAccessible));
|
||||
NS_ASSERTION(pAccNode, "QI to nsPIAccessNode failed");
|
||||
|
||||
nsIFrame *frame = pAccNode->GetFrame();
|
||||
if (frame && frame->GetType() == nsAccessibilityAtoms::textFrame) {
|
||||
// Ensure that correct text length is calculated (with non-rendered whitespace chars not counted)
|
||||
nsIContent *content = frame->GetContent();
|
||||
if (content) {
|
||||
PRUint32 length;
|
||||
nsresult rv = nsHyperTextAccessible::ContentToRenderedOffset(frame, content->TextLength(), &length);
|
||||
return NS_SUCCEEDED(rv) ? static_cast<PRInt32>(length) : -1;
|
||||
}
|
||||
}
|
||||
|
||||
// For list bullets (or anything other accessible which would compute its own text
|
||||
// They don't have their own frame.
|
||||
// XXX In the future, list bullets may have frame and anon content, so
|
||||
// we should be able to remove this at that point
|
||||
nsCOMPtr<nsPIAccessible> pAcc(do_QueryInterface(aAccessible));
|
||||
NS_ASSERTION(pAcc, "QI to nsPIAccessible failed");
|
||||
|
||||
nsAutoString text;
|
||||
pAcc->AppendTextTo(text, 0, PR_UINT32_MAX); // Get all the text
|
||||
return text.Length();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessible::AppendTextTo(nsAString& aText, PRUint32 aStartOffset, PRUint32 aLength)
|
||||
{
|
||||
@ -3574,7 +3384,7 @@ nsAccessible::AppendTextTo(nsAString& aText, PRUint32 aStartOffset, PRUint32 aLe
|
||||
nsresult
|
||||
nsAccessible::GetARIAName(nsAString& aName)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = GetRoleContent(mDOMNode);
|
||||
nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(mDOMNode);
|
||||
if (!content)
|
||||
return NS_OK;
|
||||
|
||||
@ -3596,7 +3406,7 @@ nsAccessible::GetARIAName(nsAString& aName)
|
||||
nsresult
|
||||
nsAccessible::GetNameInternal(nsAString& aName)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = GetRoleContent(mDOMNode);
|
||||
nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(mDOMNode);
|
||||
if (!content)
|
||||
return NS_OK;
|
||||
|
||||
@ -3622,7 +3432,7 @@ nsAccessible::GetFirstAvailableAccessible(nsIDOMNode *aStartNode, PRBool aRequir
|
||||
|
||||
while (currentNode) {
|
||||
accService->GetAccessibleInWeakShell(currentNode, mWeakShell, getter_AddRefs(accessible)); // AddRef'd
|
||||
if (accessible && (!aRequireLeaf || IsLeaf(accessible))) {
|
||||
if (accessible && (!aRequireLeaf || nsAccUtils::IsLeaf(accessible))) {
|
||||
nsIAccessible *retAccessible = accessible;
|
||||
NS_ADDREF(retAccessible);
|
||||
return retAccessible;
|
||||
@ -3732,20 +3542,3 @@ nsAccessible::GetActionRule(PRUint32 aStates)
|
||||
|
||||
return eNoAction;
|
||||
}
|
||||
|
||||
PRBool nsAccessible::MustPrune(nsIAccessible *aAccessible)
|
||||
{
|
||||
PRUint32 role = Role(aAccessible);
|
||||
return role == nsIAccessibleRole::ROLE_MENUITEM ||
|
||||
role == nsIAccessibleRole::ROLE_COMBOBOX_OPTION ||
|
||||
role == nsIAccessibleRole::ROLE_OPTION ||
|
||||
role == nsIAccessibleRole::ROLE_ENTRY ||
|
||||
role == nsIAccessibleRole::ROLE_FLAT_EQUATION ||
|
||||
role == nsIAccessibleRole::ROLE_PASSWORD_TEXT ||
|
||||
role == nsIAccessibleRole::ROLE_PUSHBUTTON ||
|
||||
role == nsIAccessibleRole::ROLE_TOGGLE_BUTTON ||
|
||||
role == nsIAccessibleRole::ROLE_GRAPHIC ||
|
||||
role == nsIAccessibleRole::ROLE_SLIDER ||
|
||||
role == nsIAccessibleRole::ROLE_PROGRESSBAR ||
|
||||
role == nsIAccessibleRole::ROLE_SEPARATOR;
|
||||
}
|
||||
|
@ -155,40 +155,12 @@ public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Helper methods
|
||||
//
|
||||
// XXX: should be moved into utility class
|
||||
|
||||
#ifdef DEBUG_A11Y
|
||||
static PRBool IsTextInterfaceSupportCorrect(nsIAccessible *aAccessible);
|
||||
#endif
|
||||
|
||||
static PRBool IsCorrectFrameType(nsIFrame* aFrame, nsIAtom* aAtom);
|
||||
static PRUint32 State(nsIAccessible *aAcc) { PRUint32 state = 0; if (aAcc) aAcc->GetFinalState(&state, nsnull); return state; }
|
||||
static PRUint32 Role(nsIAccessible *aAcc) { PRUint32 role = nsIAccessibleRole::ROLE_NOTHING; if (aAcc) aAcc->GetFinalRole(&role); return role; }
|
||||
static PRBool IsText(nsIAccessible *aAcc) { PRUint32 role = Role(aAcc); return role == nsIAccessibleRole::ROLE_TEXT_LEAF || role == nsIAccessibleRole::ROLE_STATICTEXT; }
|
||||
static PRBool IsEmbeddedObject(nsIAccessible *aAcc) { PRUint32 role = Role(aAcc); return role != nsIAccessibleRole::ROLE_TEXT_LEAF && role != nsIAccessibleRole::ROLE_WHITESPACE && role != nsIAccessibleRole::ROLE_STATICTEXT; }
|
||||
static PRInt32 TextLength(nsIAccessible *aAccessible); // Returns -1 on failure
|
||||
static PRBool IsLeaf(nsIAccessible *aAcc) { PRInt32 numChildren; aAcc->GetChildCount(&numChildren); return numChildren > 0; }
|
||||
static PRBool IsNodeRelevant(nsIDOMNode *aNode); // Is node something that could have an attached accessible
|
||||
/**
|
||||
* When exposing to platform accessibility APIs, should the children be pruned off?
|
||||
*/
|
||||
static PRBool MustPrune(nsIAccessible *aAccessible);
|
||||
|
||||
already_AddRefed<nsIAccessible> GetParent() {
|
||||
nsIAccessible *parent = nsnull;
|
||||
GetParent(&parent);
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the nsIContent* to check for ARIA attributes on -- this may not always
|
||||
* be the DOM node for the accessible. Specifically, for doc accessibles, it is not
|
||||
* the document node, but either the root element or <body> in HTML.
|
||||
* @param aDOMNode The DOM node for the accessible that may be affected by ARIA
|
||||
* @return The nsIContent which may have ARIA markup
|
||||
*/
|
||||
static nsIContent *GetRoleContent(nsIDOMNode *aDOMNode);
|
||||
|
||||
protected:
|
||||
PRBool MappedAttrState(nsIContent *aContent, PRUint32 *aStateInOut, nsStateMapEntry *aStateMapEntry);
|
||||
@ -208,9 +180,6 @@ protected:
|
||||
*/
|
||||
nsresult GetTextFromRelationID(nsIAtom *aIDProperty, nsString &aName);
|
||||
|
||||
static nsIContent *GetHTMLLabelContent(nsIContent *aForNode);
|
||||
static nsIContent *GetLabelContent(nsIContent *aForNode);
|
||||
|
||||
// Name helpers
|
||||
nsresult GetHTMLName(nsAString& _retval, PRBool aCanAggregateSubtree = PR_TRUE);
|
||||
nsresult GetXULName(nsAString& aName, PRBool aCanAggregateSubtree = PR_TRUE);
|
||||
@ -260,9 +229,6 @@ protected:
|
||||
*/
|
||||
already_AddRefed<nsIAccessible> GetFirstAvailableAccessible(nsIDOMNode *aStartNode, PRBool aRequireLeaf = PR_FALSE);
|
||||
|
||||
// Selection helpers
|
||||
static already_AddRefed<nsIAccessible> GetMultiSelectFor(nsIDOMNode *aNode);
|
||||
|
||||
// Hyperlink helpers
|
||||
virtual nsresult GetLinkOffset(PRInt32* aStartOffset, PRInt32* aEndOffset);
|
||||
|
||||
|
@ -130,7 +130,7 @@ nsLinkableAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
|
||||
if (mIsLink) {
|
||||
*aState |= nsIAccessibleStates::STATE_LINKED;
|
||||
nsCOMPtr<nsIAccessible> actionAcc = GetActionAccessible();
|
||||
if (actionAcc && (State(actionAcc) & nsIAccessibleStates::STATE_TRAVERSED))
|
||||
if (nsAccUtils::State(actionAcc) & nsIAccessibleStates::STATE_TRAVERSED)
|
||||
*aState |= nsIAccessibleStates::STATE_TRAVERSED;
|
||||
}
|
||||
|
||||
@ -275,8 +275,8 @@ nsLinkableAccessible::CacheActionContent()
|
||||
GetAccService()->GetAccessibleInWeakShell(walkUpNode, mWeakShell,
|
||||
getter_AddRefs(walkUpAcc));
|
||||
|
||||
if (walkUpAcc && Role(walkUpAcc) == nsIAccessibleRole::ROLE_LINK &&
|
||||
(State(walkUpAcc) & nsIAccessibleStates::STATE_LINKED)) {
|
||||
if (nsAccUtils::Role(walkUpAcc) == nsIAccessibleRole::ROLE_LINK &&
|
||||
nsAccUtils::State(walkUpAcc) & nsIAccessibleStates::STATE_LINKED) {
|
||||
mIsLink = PR_TRUE;
|
||||
mActionContent = walkUpContent;
|
||||
return;
|
||||
|
@ -363,7 +363,8 @@ nsCaretAccessible::GetCaretRect(nsIWidget **aOutWidget)
|
||||
lastAccessNode->GetDOMNode(getter_AddRefs(lastNodeWithCaret));
|
||||
NS_ENSURE_TRUE(lastNodeWithCaret, caretRect);
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = mRootAccessible->GetPresShellFor(lastNodeWithCaret);
|
||||
nsCOMPtr<nsIPresShell> presShell =
|
||||
nsCoreUtils::GetPresShellFor(lastNodeWithCaret);
|
||||
NS_ENSURE_TRUE(presShell, caretRect);
|
||||
|
||||
nsRefPtr<nsCaret> caret;
|
||||
@ -420,7 +421,7 @@ nsCaretAccessible::GetSelectionControllerForNode(nsIDOMNode *aNode)
|
||||
if (!aNode)
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = mRootAccessible->GetPresShellFor(aNode);
|
||||
nsCOMPtr<nsIPresShell> presShell = nsCoreUtils::GetPresShellFor(aNode);
|
||||
if (!presShell)
|
||||
return nsnull;
|
||||
|
||||
|
@ -52,7 +52,11 @@
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocumentViewer.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsPresContext.h"
|
||||
@ -60,6 +64,7 @@
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsISelection2.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
#include "nsContentCID.h"
|
||||
@ -183,6 +188,30 @@ nsCoreUtils::GetDOMElementFor(nsIDOMNode *aNode)
|
||||
return element;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsCoreUtils::GetRoleContent(nsIDOMNode *aDOMNode)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aDOMNode));
|
||||
if (!content) {
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(aDOMNode));
|
||||
if (domDoc) {
|
||||
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(aDOMNode));
|
||||
if (htmlDoc) {
|
||||
nsCOMPtr<nsIDOMHTMLElement> bodyElement;
|
||||
htmlDoc->GetBody(getter_AddRefs(bodyElement));
|
||||
content = do_QueryInterface(bodyElement);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDOMElement> docElement;
|
||||
domDoc->GetDocumentElement(getter_AddRefs(docElement));
|
||||
content = do_QueryInterface(docElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsCoreUtils::IsAncestorOf(nsIDOMNode *aPossibleAncestorNode,
|
||||
nsIDOMNode *aPossibleDescendantNode)
|
||||
@ -383,7 +412,7 @@ nsCoreUtils::GetDocShellTreeItemFor(nsIDOMNode *aNode)
|
||||
nsIFrame*
|
||||
nsCoreUtils::GetFrameFor(nsIDOMElement *aElm)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell = nsAccessNode::GetPresShellFor(aElm);
|
||||
nsCOMPtr<nsIPresShell> shell = GetPresShellFor(aElm);
|
||||
if (!shell)
|
||||
return nsnull;
|
||||
|
||||
@ -394,6 +423,61 @@ nsCoreUtils::GetFrameFor(nsIDOMElement *aElm)
|
||||
return shell->GetPrimaryFrameFor(content);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsCoreUtils::IsCorrectFrameType(nsIFrame *aFrame, nsIAtom *aAtom)
|
||||
{
|
||||
NS_ASSERTION(aFrame != nsnull,
|
||||
"aFrame is null in call to IsCorrectFrameType!");
|
||||
NS_ASSERTION(aAtom != nsnull,
|
||||
"aAtom is null in call to IsCorrectFrameType!");
|
||||
|
||||
return aFrame->GetType() == aAtom;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIPresShell>
|
||||
nsCoreUtils::GetPresShellFor(nsIDOMNode *aNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
aNode->GetOwnerDocument(getter_AddRefs(domDocument));
|
||||
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDocument));
|
||||
if (!doc) // This is necessary when the node is the document node
|
||||
doc = do_QueryInterface(aNode);
|
||||
|
||||
nsIPresShell *presShell = nsnull;
|
||||
if (doc) {
|
||||
presShell = doc->GetPrimaryShell();
|
||||
NS_IF_ADDREF(presShell);
|
||||
}
|
||||
|
||||
return presShell;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMNode>
|
||||
nsCoreUtils::GetDOMNodeForContainer(nsIDocShellTreeItem *aContainer)
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> shell = do_QueryInterface(aContainer);
|
||||
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
shell->GetContentViewer(getter_AddRefs(cv));
|
||||
|
||||
if (!cv)
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
|
||||
if (!docv)
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
docv->GetDocument(getter_AddRefs(doc));
|
||||
if (!doc)
|
||||
return nsnull;
|
||||
|
||||
nsIDOMNode* node = nsnull;
|
||||
CallQueryInterface(doc.get(), &node);
|
||||
return node;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsCoreUtils::GetID(nsIContent *aContent, nsAString& aID)
|
||||
{
|
||||
@ -574,6 +658,49 @@ nsCoreUtils::FindDescendantPointingToIDImpl(nsCString& aIdWithSpaces,
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsCoreUtils::GetLabelContent(nsIContent *aForNode)
|
||||
{
|
||||
if (aForNode->IsNodeOfType(nsINode::eXUL))
|
||||
return FindNeighbourPointingToNode(aForNode, nsAccessibilityAtoms::control,
|
||||
nsAccessibilityAtoms::label);
|
||||
|
||||
return GetHTMLLabelContent(aForNode);
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsCoreUtils::GetHTMLLabelContent(nsIContent *aForNode)
|
||||
{
|
||||
// Get either <label for="[id]"> element which explictly points to aForNode,
|
||||
// or <label> ancestor which implicitly point to it.
|
||||
nsIContent *walkUpContent = aForNode;
|
||||
|
||||
// Go up tree get name of ancestor label if there is one. Don't go up farther
|
||||
// than form element.
|
||||
while ((walkUpContent = walkUpContent->GetParent()) != nsnull) {
|
||||
nsIAtom *tag = walkUpContent->Tag();
|
||||
if (tag == nsAccessibilityAtoms::label)
|
||||
return walkUpContent; // An ancestor <label> implicitly points to us
|
||||
|
||||
if (tag == nsAccessibilityAtoms::form ||
|
||||
tag == nsAccessibilityAtoms::body) {
|
||||
// Reached top ancestor in form
|
||||
// There can be a label targeted at this control using the
|
||||
// for="control_id" attribute. To save computing time, only
|
||||
// look for those inside of a form element
|
||||
nsAutoString forId;
|
||||
if (!GetID(aForNode, forId))
|
||||
break;
|
||||
|
||||
// Actually we'll be walking down the content this time, with a depth first search
|
||||
return FindDescendantPointingToID(&forId, walkUpContent,
|
||||
nsAccessibilityAtoms::_for);
|
||||
}
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
nsCoreUtils::GetLanguageFor(nsIContent *aContent, nsIContent *aRootContent,
|
||||
nsAString& aLanguage)
|
||||
@ -586,3 +713,27 @@ nsCoreUtils::GetLanguageFor(nsIContent *aContent, nsIContent *aRootContent,
|
||||
nsAccessibilityAtoms::lang, aLanguage))
|
||||
walkUp = walkUp->GetParent();
|
||||
}
|
||||
|
||||
void
|
||||
nsCoreUtils::GetComputedStyleDeclaration(const nsAString& aPseudoElt,
|
||||
nsIDOMNode *aNode,
|
||||
nsIDOMCSSStyleDeclaration **aCssDecl)
|
||||
{
|
||||
*aCssDecl = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> domElement = GetDOMElementFor(aNode);
|
||||
if (!domElement)
|
||||
return;
|
||||
|
||||
// Returns number of items in style declaration
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(domElement);
|
||||
nsCOMPtr<nsIDocument> doc = content->GetDocument();
|
||||
if (!doc)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDOMViewCSS> viewCSS(do_QueryInterface(doc->GetWindow()));
|
||||
if (!viewCSS)
|
||||
return;
|
||||
|
||||
viewCSS->GetComputedStyle(domElement, aPseudoElt, aCssDecl);
|
||||
}
|
||||
|
@ -86,6 +86,17 @@ public:
|
||||
*/
|
||||
static already_AddRefed<nsIDOMElement> GetDOMElementFor(nsIDOMNode *aNode);
|
||||
|
||||
/**
|
||||
* Return the nsIContent* to check for ARIA attributes on -- this may not
|
||||
* always be the DOM node for the accessible. Specifically, for doc
|
||||
* accessibles, it is not the document node, but either the root element or
|
||||
* <body> in HTML. Similar with GetDOMElementFor() method.
|
||||
*
|
||||
* @param aDOMNode DOM node for the accessible that may be affected by ARIA
|
||||
* @return the nsIContent which may have ARIA markup
|
||||
*/
|
||||
static nsIContent *GetRoleContent(nsIDOMNode *aDOMNode);
|
||||
|
||||
/**
|
||||
* Is the first passed in node an ancestor of the second?
|
||||
* Note: A node is not considered to be the ancestor of itself.
|
||||
@ -172,6 +183,25 @@ public:
|
||||
*/
|
||||
static nsIFrame* GetFrameFor(nsIDOMElement *aElm);
|
||||
|
||||
/**
|
||||
* Retrun true if the type of given frame equals to the given frame type.
|
||||
*
|
||||
* @param aFrame the frame
|
||||
* @param aAtom the frame type
|
||||
*/
|
||||
static PRBool IsCorrectFrameType(nsIFrame* aFrame, nsIAtom* aAtom);
|
||||
|
||||
/**
|
||||
* Return presShell for the document containing the given DOM node.
|
||||
*/
|
||||
static already_AddRefed<nsIPresShell> GetPresShellFor(nsIDOMNode *aNode);
|
||||
|
||||
/**
|
||||
* Return document node for the given document shell tree item.
|
||||
*/
|
||||
static already_AddRefed<nsIDOMNode>
|
||||
GetDOMNodeForContainer(nsIDocShellTreeItem *aContainer);
|
||||
|
||||
/**
|
||||
* Get the ID for an element, in some types of XML this may not be the ID attribute
|
||||
* @param aContent Node to get the ID for
|
||||
@ -198,6 +228,13 @@ public:
|
||||
static void GetLanguageFor(nsIContent *aContent, nsIContent *aRootContent,
|
||||
nsAString& aLanguage);
|
||||
|
||||
/**
|
||||
* Return computed styles declaration for the given node.
|
||||
*/
|
||||
static void GetComputedStyleDeclaration(const nsAString& aPseudoElt,
|
||||
nsIDOMNode *aNode,
|
||||
nsIDOMCSSStyleDeclaration **aCssDecl);
|
||||
|
||||
/**
|
||||
* Search element in neighborhood of the given element by tag name and
|
||||
* attribute value that equals to ID attribute of the given element.
|
||||
@ -266,6 +303,18 @@ public:
|
||||
PRUint32 aAttrNum = 1,
|
||||
nsIContent *aExcludeContent = nsnull,
|
||||
nsIAtom *aTagType = nsAccessibilityAtoms::label);
|
||||
|
||||
/**
|
||||
* Return the label element for the given DOM element.
|
||||
*/
|
||||
static nsIContent *GetLabelContent(nsIContent *aForNode);
|
||||
|
||||
/**
|
||||
* Return the HTML label element for the given HTML element.
|
||||
*/
|
||||
static nsIContent *GetHTMLLabelContent(nsIContent *aForNode);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1040,7 +1040,7 @@ nsDocAccessible::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent,
|
||||
nsCOMPtr<nsIAccessible> focusedAccessible;
|
||||
GetAccService()->GetAccessibleFor(targetNode, getter_AddRefs(focusedAccessible));
|
||||
if (focusedAccessible) {
|
||||
gLastFocusedAccessiblesState = State(focusedAccessible);
|
||||
gLastFocusedAccessiblesState = nsAccUtils::State(focusedAccessible);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1078,9 +1078,8 @@ nsDocAccessible::AttributeChangedImpl(nsIContent* aContent, PRInt32 aNameSpaceID
|
||||
|
||||
nsCOMPtr<nsIDOMNode> targetNode(do_QueryInterface(aContent));
|
||||
NS_ASSERTION(targetNode, "No node for attr modified");
|
||||
if (!targetNode || !IsNodeRelevant(targetNode)) {
|
||||
if (!targetNode || !nsAccUtils::IsNodeRelevant(targetNode))
|
||||
return;
|
||||
}
|
||||
|
||||
// Since we're in synchronous code, we can store whether the current attribute
|
||||
// change is from user input or not. If the attribute change causes an asynchronous
|
||||
@ -1140,7 +1139,8 @@ nsDocAccessible::AttributeChangedImpl(nsIContent* aContent, PRInt32 aNameSpaceID
|
||||
if (aAttribute == nsAccessibilityAtoms::selected ||
|
||||
aAttribute == nsAccessibilityAtoms::aria_selected) {
|
||||
// ARIA or XUL selection
|
||||
nsCOMPtr<nsIAccessible> multiSelect = GetMultiSelectFor(targetNode);
|
||||
nsCOMPtr<nsIAccessible> multiSelect =
|
||||
nsAccUtils::GetMultiSelectFor(targetNode);
|
||||
// Multi selects use selection_add and selection_remove
|
||||
// Single select widgets just mirror event_selection for
|
||||
// whatever gets event_focus, which is done in
|
||||
@ -1211,7 +1211,7 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
|
||||
// The activedescendant universal property redirects accessible focus events
|
||||
// to the element with the id that activedescendant points to
|
||||
nsCOMPtr<nsIDOMNode> currentFocus = GetCurrentFocus();
|
||||
if (SameCOMIdentity(GetRoleContent(currentFocus), targetNode)) {
|
||||
if (SameCOMIdentity(nsCoreUtils::GetRoleContent(currentFocus), targetNode)) {
|
||||
nsRefPtr<nsRootAccessible> rootAcc = GetRootAccessible();
|
||||
if (rootAcc)
|
||||
rootAcc->FireAccessibleFocusEvent(nsnull, currentFocus, nsnull, PR_TRUE);
|
||||
@ -1245,7 +1245,8 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
|
||||
event->GetAccessible(getter_AddRefs(accessible));
|
||||
if (accessible) {
|
||||
PRBool wasMixed = (gLastFocusedAccessiblesState & nsIAccessibleStates::STATE_MIXED) != 0;
|
||||
PRBool isMixed = (State(accessible) & nsIAccessibleStates::STATE_MIXED) != 0;
|
||||
PRBool isMixed =
|
||||
(nsAccUtils::State(accessible) & nsIAccessibleStates::STATE_MIXED) != 0;
|
||||
if (wasMixed != isMixed) {
|
||||
nsCOMPtr<nsIAccessibleStateChangeEvent> event =
|
||||
new nsAccStateChangeEvent(targetNode,
|
||||
@ -1369,7 +1370,7 @@ nsDocAccessible::ParentChainChanged(nsIContent *aContent)
|
||||
void
|
||||
nsDocAccessible::FireValueChangeForTextFields(nsIAccessible *aPossibleTextFieldAccessible)
|
||||
{
|
||||
if (Role(aPossibleTextFieldAccessible) != nsIAccessibleRole::ROLE_ENTRY)
|
||||
if (nsAccUtils::Role(aPossibleTextFieldAccessible) != nsIAccessibleRole::ROLE_ENTRY)
|
||||
return;
|
||||
|
||||
// Dependent value change event for text changes in textfields
|
||||
@ -1483,7 +1484,7 @@ nsDocAccessible::CreateTextChangeEventForNode(nsIAccessible *aContainerAccessibl
|
||||
if (!nsCoreUtils::IsAncestorOf(aChangeNode, childNode)) {
|
||||
break; // We only want accessibles with DOM nodes as children of this node
|
||||
}
|
||||
length += TextLength(child);
|
||||
length += nsAccUtils::TextLength(child);
|
||||
child->GetNextSibling(getter_AddRefs(changeAccessible));
|
||||
if (!changeAccessible) {
|
||||
break;
|
||||
@ -1494,8 +1495,9 @@ nsDocAccessible::CreateTextChangeEventForNode(nsIAccessible *aContainerAccessibl
|
||||
else {
|
||||
NS_ASSERTION(!changeAccessible || changeAccessible == aAccessibleForChangeNode,
|
||||
"Hypertext is reporting a different accessible for this node");
|
||||
length = TextLength(aAccessibleForChangeNode);
|
||||
if (Role(aAccessibleForChangeNode) == nsIAccessibleRole::ROLE_WHITESPACE) { // newline
|
||||
|
||||
length = nsAccUtils::TextLength(aAccessibleForChangeNode);
|
||||
if (nsAccUtils::Role(aAccessibleForChangeNode) == nsIAccessibleRole::ROLE_WHITESPACE) { // newline
|
||||
// Don't fire event for the first html:br in an editor.
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
textAccessible->GetAssociatedEditor(getter_AddRefs(editor));
|
||||
@ -1765,7 +1767,7 @@ void nsDocAccessible::RefreshNodes(nsIDOMNode *aStartNode)
|
||||
nsCOMPtr<nsIAccessible> accessible(do_QueryInterface(accessNode));
|
||||
if (accessible) {
|
||||
// Fire menupopup end if a menu goes away
|
||||
PRUint32 role = Role(accessible);
|
||||
PRUint32 role = nsAccUtils::Role(accessible);
|
||||
if (role == nsIAccessibleRole::ROLE_MENUPOPUP) {
|
||||
nsCOMPtr<nsIDOMNode> domNode;
|
||||
accessNode->GetDOMNode(getter_AddRefs(domNode));
|
||||
|
@ -451,7 +451,9 @@ PRBool nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
|
||||
// Check for aria-activedescendant, which changes which element has focus
|
||||
nsCOMPtr<nsIDOMNode> finalFocusNode = aNode;
|
||||
nsCOMPtr<nsIAccessible> finalFocusAccessible = aAccessible;
|
||||
nsCOMPtr<nsIContent> finalFocusContent = GetRoleContent(finalFocusNode);
|
||||
nsCOMPtr<nsIContent> finalFocusContent =
|
||||
nsCoreUtils::GetRoleContent(finalFocusNode);
|
||||
|
||||
if (finalFocusContent) {
|
||||
nsAutoString id;
|
||||
if (finalFocusContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_activedescendant, id)) {
|
||||
@ -490,8 +492,8 @@ PRBool nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
|
||||
}
|
||||
}
|
||||
|
||||
gLastFocusedAccessiblesState = State(finalFocusAccessible);
|
||||
PRUint32 role = Role(finalFocusAccessible);
|
||||
gLastFocusedAccessiblesState = nsAccUtils::State(finalFocusAccessible);
|
||||
PRUint32 role = nsAccUtils::Role(finalFocusAccessible);
|
||||
if (role == nsIAccessibleRole::ROLE_MENUITEM) {
|
||||
if (!mCurrentARIAMenubar) { // Entering menus
|
||||
PRUint32 naturalRole; // The natural role is the role that this type of element normally has
|
||||
@ -528,7 +530,8 @@ PRBool nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
|
||||
nsCOMPtr<nsIContent> focusContent = do_QueryInterface(gLastFocusedNode);
|
||||
nsIFrame *focusFrame = nsnull;
|
||||
if (focusContent) {
|
||||
nsCOMPtr<nsIPresShell> shell = nsAccessNode::GetPresShellFor(gLastFocusedNode);
|
||||
nsCOMPtr<nsIPresShell> shell =
|
||||
nsCoreUtils::GetPresShellFor(gLastFocusedNode);
|
||||
focusFrame = shell->GetRealPrimaryFrameFor(focusContent);
|
||||
}
|
||||
gLastFocusedFrameType = (focusFrame && focusFrame->GetStyleVisibility()->IsVisible()) ? focusFrame->GetType() : 0;
|
||||
@ -634,7 +637,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> eventShell = GetPresShellFor(aTargetNode);
|
||||
nsCOMPtr<nsIPresShell> eventShell = nsCoreUtils::GetPresShellFor(aTargetNode);
|
||||
if (!eventShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -689,7 +692,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
|
||||
#endif
|
||||
|
||||
if (eventType.EqualsLiteral("RadioStateChange")) {
|
||||
PRUint32 state = State(accessible);
|
||||
PRUint32 state = nsAccUtils::State(accessible);
|
||||
|
||||
// radiogroup in prefWindow is exposed as a list,
|
||||
// and panebutton is exposed as XULListitem in A11y.
|
||||
@ -710,7 +713,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
|
||||
}
|
||||
|
||||
if (eventType.EqualsLiteral("CheckboxStateChange")) {
|
||||
PRUint32 state = State(accessible);
|
||||
PRUint32 state = nsAccUtils::State(accessible);
|
||||
|
||||
PRBool isEnabled = !!(state & nsIAccessibleStates::STATE_CHECKED);
|
||||
|
||||
@ -749,7 +752,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
if (treeItemAccessible && eventType.EqualsLiteral("OpenStateChange")) {
|
||||
PRUint32 state = State(accessible); // collapsed/expanded changed
|
||||
PRUint32 state = nsAccUtils::State(accessible); // collapsed/expanded changed
|
||||
PRBool isEnabled = (state & nsIAccessibleStates::STATE_EXPANDED) != 0;
|
||||
|
||||
nsCOMPtr<nsIAccessibleStateChangeEvent> accEvent =
|
||||
@ -830,7 +833,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
|
||||
}
|
||||
else if (eventType.EqualsLiteral("popupshown")) {
|
||||
// Don't fire menupopup events for combobox and autocomplete lists
|
||||
PRUint32 role = Role(accessible);
|
||||
PRUint32 role = nsAccUtils::Role(accessible);
|
||||
PRInt32 event = 0;
|
||||
if (role == nsIAccessibleRole::ROLE_MENUPOPUP) {
|
||||
event = nsIAccessibleEvent::EVENT_MENUPOPUP_START;
|
||||
@ -847,7 +850,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
|
||||
}
|
||||
}
|
||||
else if (eventType.EqualsLiteral("DOMMenuInactive")) {
|
||||
if (Role(accessible) == nsIAccessibleRole::ROLE_MENUPOPUP) {
|
||||
if (nsAccUtils::Role(accessible) == nsIAccessibleRole::ROLE_MENUPOPUP) {
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
|
||||
accessible);
|
||||
}
|
||||
@ -881,11 +884,11 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
|
||||
// It is not top level menuitem
|
||||
// Only fire focus event if it is not inside collapsed popup
|
||||
// and not a listitem of a combo box
|
||||
if (State(containerAccessible) & nsIAccessibleStates::STATE_COLLAPSED) {
|
||||
if (nsAccUtils::State(containerAccessible) & nsIAccessibleStates::STATE_COLLAPSED) {
|
||||
nsCOMPtr<nsIAccessible> containerParent;
|
||||
containerAccessible->GetParent(getter_AddRefs(containerParent));
|
||||
NS_ENSURE_TRUE(containerParent, NS_ERROR_FAILURE);
|
||||
if (Role(containerParent) != nsIAccessibleRole::ROLE_COMBOBOX) {
|
||||
if (nsAccUtils::Role(containerParent) != nsIAccessibleRole::ROLE_COMBOBOX) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
@ -1020,9 +1023,9 @@ nsRootAccessible::GetContentDocShell(nsIDocShellTreeItem *aStart)
|
||||
// don't use this one. This happens for example if it's inside
|
||||
// a background tab (tabbed browsing)
|
||||
while (accessible) {
|
||||
if (State(accessible) & nsIAccessibleStates::STATE_INVISIBLE) {
|
||||
if (nsAccUtils::State(accessible) & nsIAccessibleStates::STATE_INVISIBLE)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> ancestor;
|
||||
accessible->GetParent(getter_AddRefs(ancestor));
|
||||
if (ancestor == this) {
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "nsTextUtils.h"
|
||||
|
||||
#include "nsAccessNode.h"
|
||||
#include "nsCoreUtils.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsLangTextAttr
|
||||
@ -97,12 +96,12 @@ nsCSSTextAttr::nsCSSTextAttr(PRBool aIncludeDefAttrValue, nsIDOMElement *aElm,
|
||||
nsIDOMElement *aRootElm) :
|
||||
mIndex(-1), mIncludeDefAttrValue(aIncludeDefAttrValue)
|
||||
{
|
||||
nsAccessNode::GetComputedStyleDeclaration(EmptyString(), aElm,
|
||||
getter_AddRefs(mStyleDecl));
|
||||
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), aElm,
|
||||
getter_AddRefs(mStyleDecl));
|
||||
|
||||
if (!mIncludeDefAttrValue)
|
||||
nsAccessNode::GetComputedStyleDeclaration(EmptyString(), aRootElm,
|
||||
getter_AddRefs(mDefStyleDecl));
|
||||
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), aRootElm,
|
||||
getter_AddRefs(mDefStyleDecl));
|
||||
}
|
||||
|
||||
PRBool
|
||||
@ -112,8 +111,8 @@ nsCSSTextAttr::Equal(nsIDOMElement *aElm)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> currStyleDecl;
|
||||
nsAccessNode::GetComputedStyleDeclaration(EmptyString(), aElm,
|
||||
getter_AddRefs(currStyleDecl));
|
||||
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), aElm,
|
||||
getter_AddRefs(currStyleDecl));
|
||||
if (!currStyleDecl)
|
||||
return PR_FALSE;
|
||||
|
||||
|
@ -459,9 +459,8 @@ nsHTMLTextFieldAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
|
||||
else {
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetParent(getter_AddRefs(parent));
|
||||
if (parent && Role(parent) == nsIAccessibleRole::ROLE_AUTOCOMPLETE) {
|
||||
if (nsAccUtils::Role(parent) == nsIAccessibleRole::ROLE_AUTOCOMPLETE)
|
||||
*aState |= nsIAccessibleStates::STATE_HASPOPUP;
|
||||
}
|
||||
}
|
||||
|
||||
if (content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::readonly)) {
|
||||
@ -677,8 +676,7 @@ nsHTMLLegendAccessible::GetAccessibleRelated(PRUint32 aRelationType,
|
||||
return NS_ERROR_FAILURE; // Node already shut down
|
||||
}
|
||||
nsCOMPtr<nsIAccessible> groupboxAccessible = GetParent();
|
||||
if (groupboxAccessible &&
|
||||
Role(groupboxAccessible) == nsIAccessibleRole::ROLE_GROUPING) {
|
||||
if (nsAccUtils::Role(groupboxAccessible) == nsIAccessibleRole::ROLE_GROUPING) {
|
||||
nsCOMPtr<nsIAccessible> testLabelAccessible;
|
||||
groupboxAccessible->GetAccessibleRelated(nsIAccessibleRelation::RELATION_LABELLED_BY,
|
||||
getter_AddRefs(testLabelAccessible));
|
||||
|
@ -357,12 +357,11 @@ nsHTMLSelectListAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
|
||||
|
||||
NS_IMETHODIMP nsHTMLSelectListAccessible::GetRole(PRUint32 *aRole)
|
||||
{
|
||||
if (mParent && Role(mParent) == nsIAccessibleRole::ROLE_COMBOBOX) {
|
||||
if (nsAccUtils::Role(mParent) == nsIAccessibleRole::ROLE_COMBOBOX)
|
||||
*aRole = nsIAccessibleRole::ROLE_COMBOBOX_LIST;
|
||||
}
|
||||
else {
|
||||
else
|
||||
*aRole = nsIAccessibleRole::ROLE_LIST;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -501,12 +500,11 @@ nsHyperTextAccessibleWrap(aDOMNode, aShell)
|
||||
/** We are a ListItem */
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetRole(PRUint32 *aRole)
|
||||
{
|
||||
if (mParent && Role(mParent) == nsIAccessibleRole::ROLE_COMBOBOX_LIST) {
|
||||
if (nsAccUtils::Role(mParent) == nsIAccessibleRole::ROLE_COMBOBOX_LIST)
|
||||
*aRole = nsIAccessibleRole::ROLE_COMBOBOX_OPTION;
|
||||
}
|
||||
else {
|
||||
else
|
||||
*aRole = nsIAccessibleRole::ROLE_OPTION;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -559,7 +557,7 @@ nsHTMLSelectOptionAccessible::GetAttributesInternal(nsIPersistentProperties *aAt
|
||||
parentNode->GetLocalName(parentTagName);
|
||||
|
||||
PRInt32 level = parentTagName.LowerCaseEqualsLiteral("optgroup") ? 2 : 1;
|
||||
if (level == 1 && Role(this) != nsIAccessibleRole::ROLE_HEADING) {
|
||||
if (level == 1 && nsAccUtils::Role(this) != nsIAccessibleRole::ROLE_HEADING) {
|
||||
level = 0; // In a single level list, the level is irrelevant
|
||||
}
|
||||
|
||||
@ -847,7 +845,8 @@ void nsHTMLSelectOptionAccessible::SelectionChangedIfOption(nsIContent *aPossibl
|
||||
nsCOMPtr<nsIDOMNode> optionNode(do_QueryInterface(aPossibleOption));
|
||||
NS_ASSERTION(optionNode, "No option node for nsIContent with option tag!");
|
||||
|
||||
nsCOMPtr<nsIAccessible> multiSelect = GetMultiSelectFor(optionNode);
|
||||
nsCOMPtr<nsIAccessible> multiSelect =
|
||||
nsAccUtils::GetMultiSelectFor(optionNode);
|
||||
nsCOMPtr<nsPIAccessible> privateMultiSelect = do_QueryInterface(multiSelect);
|
||||
if (!privateMultiSelect) {
|
||||
return;
|
||||
@ -864,7 +863,7 @@ void nsHTMLSelectOptionAccessible::SelectionChangedIfOption(nsIContent *aPossibl
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
|
||||
multiSelect);
|
||||
|
||||
PRUint32 state = State(optionAccessible);
|
||||
PRUint32 state = nsAccUtils::State(optionAccessible);
|
||||
PRUint32 eventType;
|
||||
if (state & nsIAccessibleStates::STATE_SELECTED) {
|
||||
eventType = nsIAccessibleEvent::EVENT_SELECTION_ADD;
|
||||
@ -1494,7 +1493,7 @@ void nsHTMLComboboxListAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aBo
|
||||
if (!comboAccessible) {
|
||||
return;
|
||||
}
|
||||
if (0 == (State(comboAccessible) & nsIAccessibleStates::STATE_COLLAPSED)) {
|
||||
if (0 == (nsAccUtils::State(comboAccessible) & nsIAccessibleStates::STATE_COLLAPSED)) {
|
||||
nsHTMLSelectListAccessible::GetBoundsRect(aBounds, aBoundingFrame);
|
||||
return;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ nsHTMLTableCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttri
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
while (parentAcc) {
|
||||
if (Role(parentAcc) == nsIAccessibleRole::ROLE_TABLE) {
|
||||
if (nsAccUtils::Role(parentAcc) == nsIAccessibleRole::ROLE_TABLE) {
|
||||
// Table accessible must implement nsIAccessibleTable interface but if
|
||||
// it isn't happen (for example because of ARIA usage) we shouldn't fail
|
||||
// on getting other attributes.
|
||||
@ -159,7 +159,7 @@ void nsHTMLTableAccessible::CacheChildren()
|
||||
nsAccessible::CacheChildren();
|
||||
nsCOMPtr<nsIAccessible> captionAccessible;
|
||||
while (NextChild(captionAccessible)) {
|
||||
if (Role(captionAccessible) == nsIAccessibleRole::ROLE_CAPTION) {
|
||||
if (nsAccUtils::Role(captionAccessible) == nsIAccessibleRole::ROLE_CAPTION) {
|
||||
nsCOMPtr<nsIAccessible> captionParentAccessible;
|
||||
captionAccessible->GetParent(getter_AddRefs(captionParentAccessible));
|
||||
if (captionParentAccessible != this) {
|
||||
@ -270,9 +270,9 @@ nsHTMLTableAccessible::GetCaption(nsIAccessible **aCaption)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> firstChild;
|
||||
GetFirstChild(getter_AddRefs(firstChild));
|
||||
if (firstChild && Role(firstChild) == nsIAccessibleRole::ROLE_CAPTION) {
|
||||
if (nsAccUtils::Role(firstChild) == nsIAccessibleRole::ROLE_CAPTION)
|
||||
NS_ADDREF(*aCaption = firstChild);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1066,7 +1066,8 @@ NS_IMETHODIMP nsHTMLTableAccessible::IsProbablyForLayout(PRBool *aIsProbablyForL
|
||||
}
|
||||
|
||||
// Check role and role attribute
|
||||
PRBool hasNonTableRole = (Role(this) != nsIAccessibleRole::ROLE_TABLE);
|
||||
PRBool hasNonTableRole =
|
||||
(nsAccUtils::Role(this) != nsIAccessibleRole::ROLE_TABLE);
|
||||
if (hasNonTableRole) {
|
||||
RETURN_LAYOUT_ANSWER(PR_FALSE, "Has role attribute");
|
||||
}
|
||||
@ -1140,8 +1141,8 @@ NS_IMETHODIMP nsHTMLTableAccessible::IsProbablyForLayout(PRBool *aIsProbablyForL
|
||||
nodeList->Item(rowCount, getter_AddRefs(rowNode));
|
||||
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl;
|
||||
GetComputedStyleDeclaration(EmptyString(), rowNode,
|
||||
getter_AddRefs(styleDecl));
|
||||
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), rowNode,
|
||||
getter_AddRefs(styleDecl));
|
||||
NS_ENSURE_TRUE(styleDecl, NS_ERROR_FAILURE);
|
||||
|
||||
lastRowColor = color;
|
||||
|
@ -347,7 +347,8 @@ nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& aEndOffset,
|
||||
PRInt32 startOffset = aStartOffset;
|
||||
PRInt32 endOffset = aEndOffset;
|
||||
// XXX this prevents text interface usage on <input type="password">
|
||||
PRBool isPassword = (Role(this) == nsIAccessibleRole::ROLE_PASSWORD_TEXT);
|
||||
PRBool isPassword =
|
||||
(nsAccUtils::Role(this) == nsIAccessibleRole::ROLE_PASSWORD_TEXT);
|
||||
|
||||
// Clear out parameters and set up loop
|
||||
if (aText) {
|
||||
@ -389,7 +390,7 @@ nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& aEndOffset,
|
||||
continue;
|
||||
}
|
||||
nsIFrame *primaryFrame = frame;
|
||||
if (IsText(accessible)) {
|
||||
if (nsAccUtils::IsText(accessible)) {
|
||||
// We only need info up to rendered offset -- that is what we're
|
||||
// converting to content offset
|
||||
PRInt32 substringEndOffset = -1;
|
||||
@ -408,7 +409,7 @@ nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& aEndOffset,
|
||||
if (substringEndOffset < 0) {
|
||||
// XXX for non-textframe text like list bullets,
|
||||
// should go away after list bullet rewrite
|
||||
substringEndOffset = TextLength(accessible);
|
||||
substringEndOffset = nsAccUtils::TextLength(accessible);
|
||||
}
|
||||
if (startOffset < substringEndOffset) {
|
||||
// Our start is within this substring
|
||||
@ -482,7 +483,7 @@ nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& aEndOffset,
|
||||
if (aText) {
|
||||
if (frame->GetType() == nsAccessibilityAtoms::brFrame) {
|
||||
*aText += kForcedNewLineChar;
|
||||
} else if (MustPrune(this)) {
|
||||
} else if (nsAccUtils::MustPrune(this)) {
|
||||
*aText += kImaginaryEmbeddedObjectChar;
|
||||
// Expose imaginary embedded object character if the accessible
|
||||
// hans't children.
|
||||
@ -542,7 +543,7 @@ NS_IMETHODIMP nsHyperTextAccessible::GetCharacterCount(PRInt32 *aCharacterCount)
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
|
||||
while (NextChild(accessible)) {
|
||||
PRInt32 textLength = TextLength(accessible);
|
||||
PRInt32 textLength = nsAccUtils::TextLength(accessible);
|
||||
NS_ENSURE_TRUE(textLength >= 0, nsnull);
|
||||
*aCharacterCount += textLength;
|
||||
}
|
||||
@ -676,7 +677,8 @@ nsresult nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode* aNode, PRI
|
||||
// Start offset, inclusive
|
||||
// Make sure the offset lands on the embedded object character in order to indicate
|
||||
// the true inner offset is inside the subtree for that link
|
||||
addTextOffset = (TextLength(descendantAccessible) == static_cast<PRInt32>(addTextOffset)) ? 1 : 0;
|
||||
addTextOffset =
|
||||
(nsAccUtils::TextLength(descendantAccessible) == static_cast<PRInt32>(addTextOffset)) ? 1 : 0;
|
||||
}
|
||||
descendantAccessible = parentAccessible;
|
||||
}
|
||||
@ -687,14 +689,16 @@ nsresult nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode* aNode, PRI
|
||||
// came after the last accessible child's node
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
while (NextChild(accessible) && accessible != childAccessible) {
|
||||
PRInt32 textLength = TextLength(accessible);
|
||||
PRInt32 textLength = nsAccUtils::TextLength(accessible);
|
||||
NS_ENSURE_TRUE(textLength >= 0, nsnull);
|
||||
*aHyperTextOffset += textLength;
|
||||
}
|
||||
if (accessible) {
|
||||
*aHyperTextOffset += addTextOffset;
|
||||
NS_ASSERTION(accessible == childAccessible, "These should be equal whenever we exit loop and accessible != nsnull");
|
||||
if (aFinalAccessible && (NextChild(accessible) || static_cast<PRInt32>(addTextOffset) < TextLength(childAccessible))) {
|
||||
if (aFinalAccessible &&
|
||||
(NextChild(accessible) ||
|
||||
static_cast<PRInt32>(addTextOffset) < nsAccUtils::TextLength(childAccessible))) {
|
||||
// If not at end of last text node, we will return the accessible we were in
|
||||
NS_ADDREF(*aFinalAccessible = childAccessible);
|
||||
}
|
||||
@ -816,7 +820,7 @@ nsHyperTextAccessible::GetRelativeOffset(nsIPresShell *aPresShell,
|
||||
|
||||
nsresult rv;
|
||||
PRInt32 contentOffset = aFromOffset;
|
||||
if (IsText(aFromAccessible)) {
|
||||
if (nsAccUtils::IsText(aFromAccessible)) {
|
||||
nsCOMPtr<nsPIAccessNode> accessNode(do_QueryInterface(aFromAccessible));
|
||||
NS_ASSERTION(accessNode, "nsIAccessible doesn't support nsPIAccessNode");
|
||||
|
||||
@ -868,8 +872,8 @@ nsHyperTextAccessible::GetRelativeOffset(nsIPresShell *aPresShell,
|
||||
else if (aAmount == eSelectBeginLine) {
|
||||
// For line selection with needsStart, set start of line exactly to line break
|
||||
if (pos.mContentOffset == 0 && mFirstChild &&
|
||||
Role(mFirstChild) == nsIAccessibleRole::ROLE_STATICTEXT &&
|
||||
TextLength(mFirstChild) == hyperTextOffset) {
|
||||
nsAccUtils::Role(mFirstChild) == nsIAccessibleRole::ROLE_STATICTEXT &&
|
||||
nsAccUtils::TextLength(mFirstChild) == hyperTextOffset) {
|
||||
// XXX Bullet hack -- we should remove this once list bullets use anonymous content
|
||||
hyperTextOffset = 0;
|
||||
}
|
||||
@ -880,7 +884,7 @@ nsHyperTextAccessible::GetRelativeOffset(nsIPresShell *aPresShell,
|
||||
else if (aAmount == eSelectEndLine && finalAccessible) {
|
||||
// If not at very end of hypertext, we may need change the end of line offset by 1,
|
||||
// to make sure we are in the right place relative to the line ending
|
||||
if (Role(finalAccessible) == nsIAccessibleRole::ROLE_WHITESPACE) { // Landed on <br> hard line break
|
||||
if (nsAccUtils::Role(finalAccessible) == nsIAccessibleRole::ROLE_WHITESPACE) { // Landed on <br> hard line break
|
||||
// if aNeedsStart, set end of line exactly 1 character past line break
|
||||
// XXX It would be cleaner if we did not have to have the hard line break check,
|
||||
// and just got the correct results from PeekOffset() for the <br> case -- the returned offset should
|
||||
@ -1049,10 +1053,13 @@ nsresult nsHyperTextAccessible::GetTextHelper(EGetTextType aType, nsAccessibleTe
|
||||
nsCOMPtr<nsIAccessible> endAcc;
|
||||
nsIFrame *endFrame = GetPosAndText(startOffset, endOffset, nsnull, nsnull,
|
||||
nsnull, getter_AddRefs(endAcc));
|
||||
if (endAcc && Role(endAcc) == nsIAccessibleRole::ROLE_STATICTEXT) {
|
||||
if (nsAccUtils::Role(endAcc) == nsIAccessibleRole::ROLE_STATICTEXT) {
|
||||
// Static text like list bullets will ruin our forward calculation,
|
||||
// since the caret cannot be in the static text. Start just after the static text.
|
||||
startOffset = endOffset = finalStartOffset + (aBoundaryType == BOUNDARY_LINE_END) + TextLength(endAcc);
|
||||
startOffset = endOffset = finalStartOffset +
|
||||
(aBoundaryType == BOUNDARY_LINE_END) +
|
||||
nsAccUtils::TextLength(endAcc);
|
||||
|
||||
endFrame = GetPosAndText(startOffset, endOffset, nsnull, nsnull,
|
||||
nsnull, getter_AddRefs(endAcc));
|
||||
}
|
||||
@ -1235,7 +1242,7 @@ nsHyperTextAccessible::GetAttributesInternal(nsIPersistentProperties *aAttribute
|
||||
nsresult rv = nsAccessibleWrap::GetAttributesInternal(aAttributes);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(GetRoleContent(mDOMNode)));
|
||||
nsCOMPtr<nsIContent> content = nsCoreUtils::GetRoleContent(mDOMNode);
|
||||
NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED);
|
||||
nsIAtom *tag = content->Tag();
|
||||
|
||||
@ -1391,7 +1398,7 @@ nsHyperTextAccessible::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY,
|
||||
}
|
||||
frame = frame->GetNextContinuation();
|
||||
}
|
||||
PRInt32 textLength = TextLength(accessible);
|
||||
PRInt32 textLength = nsAccUtils::TextLength(accessible);
|
||||
NS_ENSURE_TRUE(textLength >= 0, NS_ERROR_FAILURE);
|
||||
offset += textLength;
|
||||
}
|
||||
@ -1412,9 +1419,8 @@ nsHyperTextAccessible::GetLinkCount(PRInt32 *aLinkCount)
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
|
||||
while (NextChild(accessible)) {
|
||||
if (IsEmbeddedObject(accessible)) {
|
||||
if (nsAccUtils::IsEmbeddedObject(accessible))
|
||||
++*aLinkCount;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1432,7 +1438,7 @@ nsHyperTextAccessible::GetLink(PRInt32 aLinkIndex, nsIAccessibleHyperLink **aLin
|
||||
PRInt32 linkIndex = aLinkIndex;
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
while (NextChild(accessible)) {
|
||||
if (IsEmbeddedObject(accessible) && linkIndex-- == 0)
|
||||
if (nsAccUtils::IsEmbeddedObject(accessible) && linkIndex-- == 0)
|
||||
return CallQueryInterface(accessible, aLink);
|
||||
}
|
||||
|
||||
@ -1454,10 +1460,10 @@ nsHyperTextAccessible::GetLinkIndex(PRInt32 aCharIndex, PRInt32 *aLinkIndex)
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
|
||||
while (NextChild(accessible) && characterCount <= aCharIndex) {
|
||||
PRUint32 role = Role(accessible);
|
||||
PRUint32 role = nsAccUtils::Role(accessible);
|
||||
if (role == nsIAccessibleRole::ROLE_TEXT_LEAF ||
|
||||
role == nsIAccessibleRole::ROLE_STATICTEXT) {
|
||||
PRInt32 textLength = TextLength(accessible);
|
||||
PRInt32 textLength = nsAccUtils::TextLength(accessible);
|
||||
NS_ENSURE_TRUE(textLength >= 0, NS_ERROR_FAILURE);
|
||||
characterCount += textLength;
|
||||
}
|
||||
|
@ -468,7 +468,8 @@ GetNativeFromGeckoAccessible(nsIAccessible *anAccessible)
|
||||
- (NSString*)role
|
||||
{
|
||||
#ifdef DEBUG_A11Y
|
||||
NS_ASSERTION(nsAccessible::IsTextInterfaceSupportCorrect(mGeckoAccessible), "Does not support nsIAccessibleText when it should");
|
||||
NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(mGeckoAccessible),
|
||||
"Does not support nsIAccessibleText when it should");
|
||||
#endif
|
||||
return AXRoles[mRole];
|
||||
}
|
||||
|
@ -108,8 +108,9 @@ class nsAccessibleWrap : public nsAccessible
|
||||
|
||||
nsCOMPtr<nsIAccessible> curParent = GetParent();
|
||||
while (curParent) {
|
||||
if (MustPrune(curParent))
|
||||
if (nsAccUtils::MustPrune(curParent))
|
||||
return PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIAccessible> newParent;
|
||||
curParent->GetParent(getter_AddRefs(newParent));
|
||||
curParent.swap(newParent);
|
||||
|
@ -103,7 +103,7 @@ nsAccessibleWrap::GetNativeType ()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
||||
|
||||
PRUint32 role = Role(this);
|
||||
PRUint32 role = nsAccUtils::Role(this);
|
||||
switch (role) {
|
||||
case nsIAccessibleRole::ROLE_PUSHBUTTON:
|
||||
case nsIAccessibleRole::ROLE_SPLITBUTTON:
|
||||
@ -229,7 +229,7 @@ PRInt32
|
||||
nsAccessibleWrap::GetUnignoredChildCount(PRBool aDeepCount)
|
||||
{
|
||||
// if we're flat, we have no children.
|
||||
if (MustPrune(this))
|
||||
if (nsAccUtils::MustPrune(this))
|
||||
return 0;
|
||||
|
||||
PRInt32 childCount = 0;
|
||||
@ -245,7 +245,7 @@ nsAccessibleWrap::GetUnignoredChildCount(PRBool aDeepCount)
|
||||
++childCount;
|
||||
|
||||
// if it's flat, we don't care to inspect its children.
|
||||
if (MustPrune(childWrap))
|
||||
if (nsAccUtils::MustPrune(childWrap))
|
||||
continue;
|
||||
|
||||
if (aDeepCount) {
|
||||
@ -276,14 +276,14 @@ nsAccessibleWrap::GetUnignoredChildren(nsTArray<nsRefPtr<nsAccessibleWrap> > &aC
|
||||
nsCOMPtr<nsIAccessible> curAcc;
|
||||
|
||||
// we're flat; there are no children.
|
||||
if (MustPrune(this))
|
||||
if (nsAccUtils::MustPrune(this))
|
||||
return;
|
||||
|
||||
while (NextChild(curAcc)) {
|
||||
nsAccessibleWrap *childWrap = static_cast<nsAccessibleWrap*>((nsIAccessible*)curAcc.get());
|
||||
if (childWrap->IsIgnored()) {
|
||||
// element is ignored, so try adding its children as substitutes, if it has any.
|
||||
if (!MustPrune(childWrap)) {
|
||||
if (!nsAccUtils::MustPrune(childWrap)) {
|
||||
nsTArray<nsRefPtr<nsAccessibleWrap> > children;
|
||||
childWrap->GetUnignoredChildren(children);
|
||||
if (!children.IsEmpty()) {
|
||||
|
@ -316,7 +316,8 @@ __try{
|
||||
return E_FAIL;
|
||||
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
||||
GetComputedStyleDeclaration(EmptyString(), mDOMNode, getter_AddRefs(cssDecl));
|
||||
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), mDOMNode,
|
||||
getter_AddRefs(cssDecl));
|
||||
NS_ENSURE_TRUE(cssDecl, E_FAIL);
|
||||
|
||||
PRUint32 length;
|
||||
@ -351,7 +352,8 @@ __try {
|
||||
return E_FAIL;
|
||||
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
||||
GetComputedStyleDeclaration(EmptyString(), mDOMNode, getter_AddRefs(cssDecl));
|
||||
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), mDOMNode,
|
||||
getter_AddRefs(cssDecl));
|
||||
NS_ENSURE_TRUE(cssDecl, E_FAIL);
|
||||
|
||||
PRUint32 index;
|
||||
|
@ -246,9 +246,8 @@ STDMETHODIMP nsAccessibleWrap::get_accChildCount( long __RPC_FAR *pcountChildren
|
||||
{
|
||||
__try {
|
||||
*pcountChildren = 0;
|
||||
if (MustPrune(this)) {
|
||||
if (nsAccUtils::MustPrune(this))
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32 numChildren;
|
||||
GetChildCount(&numChildren);
|
||||
@ -274,7 +273,7 @@ __try {
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> childAccessible;
|
||||
if (!MustPrune(this)) {
|
||||
if (!nsAccUtils::MustPrune(this)) {
|
||||
GetChildAt(varChild.lVal - 1, getter_AddRefs(childAccessible));
|
||||
if (childAccessible) {
|
||||
*ppdispChild = NativeAccessible(childAccessible);
|
||||
@ -473,7 +472,8 @@ __try {
|
||||
return E_FAIL;
|
||||
|
||||
#ifdef DEBUG_A11Y
|
||||
NS_ASSERTION(nsAccessible::IsTextInterfaceSupportCorrect(xpAccessible), "Does not support nsIAccessibleText when it should");
|
||||
NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(xpAccessible),
|
||||
"Does not support nsIAccessibleText when it should");
|
||||
#endif
|
||||
|
||||
PRUint32 xpRole = 0, msaaRole = 0;
|
||||
@ -489,9 +489,8 @@ __try {
|
||||
// We need this because ARIA has a role of "row" for both grid and treegrid
|
||||
if (xpRole == nsIAccessibleRole::ROLE_ROW) {
|
||||
nsCOMPtr<nsIAccessible> parent = GetParent();
|
||||
if (parent && Role(parent) == nsIAccessibleRole::ROLE_TREE_TABLE) {
|
||||
if (nsAccUtils::Role(parent) == nsIAccessibleRole::ROLE_TREE_TABLE)
|
||||
msaaRole = ROLE_SYSTEM_OUTLINEITEM;
|
||||
}
|
||||
}
|
||||
|
||||
// -- Try enumerated role
|
||||
@ -510,7 +509,7 @@ __try {
|
||||
return E_FAIL;
|
||||
|
||||
accessNode->GetDOMNode(getter_AddRefs(domNode));
|
||||
nsIContent *content = GetRoleContent(domNode);
|
||||
nsIContent *content = nsCoreUtils::GetRoleContent(domNode);
|
||||
if (!content)
|
||||
return E_FAIL;
|
||||
|
||||
@ -913,14 +912,12 @@ __try {
|
||||
xpAccessibleStart->GetAccessibleBelow(getter_AddRefs(xpAccessibleResult));
|
||||
break;
|
||||
case NAVDIR_FIRSTCHILD:
|
||||
if (!MustPrune(xpAccessibleStart)) {
|
||||
if (!nsAccUtils::MustPrune(xpAccessibleStart))
|
||||
xpAccessibleStart->GetFirstChild(getter_AddRefs(xpAccessibleResult));
|
||||
}
|
||||
break;
|
||||
case NAVDIR_LASTCHILD:
|
||||
if (!MustPrune(xpAccessibleStart)) {
|
||||
if (!nsAccUtils::MustPrune(xpAccessibleStart))
|
||||
xpAccessibleStart->GetLastChild(getter_AddRefs(xpAccessibleResult));
|
||||
}
|
||||
break;
|
||||
case NAVDIR_LEFT:
|
||||
xpAccessibleStart->GetAccessibleToLeft(getter_AddRefs(xpAccessibleResult));
|
||||
@ -1022,7 +1019,7 @@ __try {
|
||||
xLeft = xLeft;
|
||||
yTop = yTop;
|
||||
|
||||
if (MustPrune(this)) {
|
||||
if (nsAccUtils::MustPrune(this)) {
|
||||
xpAccessible = this;
|
||||
}
|
||||
else {
|
||||
@ -1881,7 +1878,7 @@ void nsAccessibleWrap::GetXPAccessibleFor(const VARIANT& aVarChild, nsIAccessibl
|
||||
if (aVarChild.lVal == CHILDID_SELF) {
|
||||
*aXPAccessible = static_cast<nsIAccessible*>(this);
|
||||
}
|
||||
else if (MustPrune(this)) {
|
||||
else if (nsAccUtils::MustPrune(this)) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
@ -322,7 +322,7 @@ STDMETHODIMP nsDocAccessibleWrap::get_accValue(
|
||||
if (FAILED(hr) || *pszValue || varChild.lVal != CHILDID_SELF)
|
||||
return hr;
|
||||
// If document is being used to create a widget, don't use the URL hack
|
||||
PRUint32 role = Role(this);
|
||||
PRUint32 role = nsAccUtils::Role(this);
|
||||
if (role != nsIAccessibleRole::ROLE_DOCUMENT &&
|
||||
role != nsIAccessibleRole::ROLE_APPLICATION &&
|
||||
role != nsIAccessibleRole::ROLE_DIALOG &&
|
||||
|
@ -448,7 +448,7 @@ nsXULGroupboxAccessible::GetAccessibleRelated(PRUint32 aRelationType,
|
||||
// The xul:label has an accessible object but the xul:caption does not
|
||||
nsCOMPtr<nsIAccessible> testLabelAccessible;
|
||||
while (NextChild(testLabelAccessible)) {
|
||||
if (Role(testLabelAccessible) == nsIAccessibleRole::ROLE_LABEL) {
|
||||
if (nsAccUtils::Role(testLabelAccessible) == nsIAccessibleRole::ROLE_LABEL) {
|
||||
// Ensure that it's our label
|
||||
nsCOMPtr<nsIAccessible> testGroupboxAccessible;
|
||||
testLabelAccessible->GetAccessibleRelated(nsIAccessibleRelation::RELATION_LABEL_FOR,
|
||||
|
@ -327,7 +327,7 @@ nsXULMenuitemAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
|
||||
|
||||
// Combo box listitem
|
||||
PRBool isComboboxOption =
|
||||
(Role(this) == nsIAccessibleRole::ROLE_COMBOBOX_OPTION);
|
||||
(nsAccUtils::Role(this) == nsIAccessibleRole::ROLE_COMBOBOX_OPTION);
|
||||
if (isComboboxOption) {
|
||||
// Is selected?
|
||||
PRBool isSelected = PR_FALSE;
|
||||
@ -339,10 +339,8 @@ nsXULMenuitemAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
|
||||
// Is collapsed?
|
||||
PRBool isCollapsed = PR_FALSE;
|
||||
nsCOMPtr<nsIAccessible> parentAccessible(GetParent());
|
||||
if (parentAccessible &&
|
||||
State(parentAccessible) & nsIAccessibleStates::STATE_INVISIBLE) {
|
||||
if (nsAccUtils::State(parentAccessible) & nsIAccessibleStates::STATE_INVISIBLE)
|
||||
isCollapsed = PR_TRUE;
|
||||
}
|
||||
|
||||
if (isSelected) {
|
||||
*aState |= nsIAccessibleStates::STATE_SELECTED;
|
||||
@ -353,7 +351,7 @@ nsXULMenuitemAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
|
||||
nsCOMPtr<nsIAccessible> grandParentAcc;
|
||||
parentAccessible->GetParent(getter_AddRefs(grandParentAcc));
|
||||
NS_ENSURE_TRUE(grandParentAcc, NS_ERROR_FAILURE);
|
||||
NS_ASSERTION((Role(grandParentAcc) == nsIAccessibleRole::ROLE_COMBOBOX),
|
||||
NS_ASSERTION(nsAccUtils::Role(grandParentAcc) == nsIAccessibleRole::ROLE_COMBOBOX,
|
||||
"grandparent of combobox listitem is not combobox");
|
||||
PRUint32 grandParentState, grandParentExtState;
|
||||
grandParentAcc->GetFinalState(&grandParentState, &grandParentExtState);
|
||||
@ -485,7 +483,7 @@ NS_IMETHODIMP nsXULMenuitemAccessible::GetRole(PRUint32 *aRole)
|
||||
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
GetParent(getter_AddRefs(parent));
|
||||
if (parent && Role(parent) == nsIAccessibleRole::ROLE_COMBOBOX_LIST) {
|
||||
if (nsAccUtils::Role(parent) == nsIAccessibleRole::ROLE_COMBOBOX_LIST) {
|
||||
*aRole = nsIAccessibleRole::ROLE_COMBOBOX_OPTION;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -710,7 +708,7 @@ NS_IMETHODIMP nsXULMenupopupAccessible::GetRole(PRUint32 *aRole)
|
||||
GetParent(getter_AddRefs(parent));
|
||||
if (parent) {
|
||||
// Some widgets like the search bar have several popups, owned by buttons
|
||||
PRUint32 role = Role(parent);
|
||||
PRUint32 role = nsAccUtils::Role(parent);
|
||||
if (role == nsIAccessibleRole::ROLE_COMBOBOX ||
|
||||
role == nsIAccessibleRole::ROLE_PUSHBUTTON ||
|
||||
role == nsIAccessibleRole::ROLE_AUTOCOMPLETE) {
|
||||
|
@ -883,14 +883,14 @@ NS_IMETHODIMP nsXULListitemAccessible::GetRole(PRUint32 *aRole)
|
||||
nsCOMPtr<nsIAccessible> listAcc = GetListAccessible();
|
||||
NS_ENSURE_STATE(listAcc);
|
||||
|
||||
if (Role(listAcc) == nsIAccessibleRole::ROLE_TABLE) {
|
||||
if (nsAccUtils::Role(listAcc) == nsIAccessibleRole::ROLE_TABLE) {
|
||||
*aRole = nsIAccessibleRole::ROLE_ROW;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mIsCheckbox)
|
||||
*aRole = nsIAccessibleRole::ROLE_CHECKBUTTON;
|
||||
else if (mParent && Role(mParent) == nsIAccessibleRole::ROLE_COMBOBOX_LIST)
|
||||
else if (nsAccUtils::Role(mParent) == nsIAccessibleRole::ROLE_COMBOBOX_LIST)
|
||||
*aRole = nsIAccessibleRole::ROLE_COMBOBOX_OPTION;
|
||||
else
|
||||
*aRole = nsIAccessibleRole::ROLE_RICH_OPTION;
|
||||
|
@ -181,7 +181,7 @@ nsXULTabAccessible::GetAccessibleRelated(PRUint32 aRelationType,
|
||||
// the setter 'selectedIndex' of tabbox.xml#tabs binding.
|
||||
|
||||
nsCOMPtr<nsIAccessible> tabsAcc = GetParent();
|
||||
NS_ENSURE_TRUE(tabsAcc && Role(tabsAcc) == nsIAccessibleRole::ROLE_PAGETABLIST,
|
||||
NS_ENSURE_TRUE(nsAccUtils::Role(tabsAcc) == nsIAccessibleRole::ROLE_PAGETABLIST,
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
PRInt32 tabIndex = -1;
|
||||
@ -189,7 +189,7 @@ nsXULTabAccessible::GetAccessibleRelated(PRUint32 aRelationType,
|
||||
nsCOMPtr<nsIAccessible> childAcc;
|
||||
tabsAcc->GetFirstChild(getter_AddRefs(childAcc));
|
||||
while (childAcc) {
|
||||
if (Role(childAcc) == nsIAccessibleRole::ROLE_PAGETAB)
|
||||
if (nsAccUtils::Role(childAcc) == nsIAccessibleRole::ROLE_PAGETAB)
|
||||
tabIndex++;
|
||||
|
||||
if (childAcc == this)
|
||||
@ -202,12 +202,12 @@ nsXULTabAccessible::GetAccessibleRelated(PRUint32 aRelationType,
|
||||
|
||||
nsCOMPtr<nsIAccessible> tabBoxAcc;
|
||||
tabsAcc->GetParent(getter_AddRefs(tabBoxAcc));
|
||||
NS_ENSURE_TRUE(tabBoxAcc && Role(tabBoxAcc) == nsIAccessibleRole::ROLE_PANE,
|
||||
NS_ENSURE_TRUE(nsAccUtils::Role(tabBoxAcc) == nsIAccessibleRole::ROLE_PANE,
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
tabBoxAcc->GetFirstChild(getter_AddRefs(childAcc));
|
||||
while (childAcc) {
|
||||
if (Role(childAcc) == nsIAccessibleRole::ROLE_PROPERTYPAGE) {
|
||||
if (nsAccUtils::Role(childAcc) == nsIAccessibleRole::ROLE_PROPERTYPAGE) {
|
||||
if (tabIndex == 0) {
|
||||
NS_ADDREF(*aRelatedAccessible = childAcc);
|
||||
return NS_OK;
|
||||
@ -342,7 +342,7 @@ nsXULTabpanelAccessible::GetAccessibleRelated(PRUint32 aRelationType,
|
||||
// Expose 'LABELLED_BY' relation on tabpanel accessible for tab accessible.
|
||||
nsCOMPtr<nsIAccessible> tabBoxAcc;
|
||||
GetParent(getter_AddRefs(tabBoxAcc));
|
||||
NS_ENSURE_TRUE(tabBoxAcc && Role(tabBoxAcc) == nsIAccessibleRole::ROLE_PANE,
|
||||
NS_ENSURE_TRUE(nsAccUtils::Role(tabBoxAcc) == nsIAccessibleRole::ROLE_PANE,
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
PRInt32 tabpanelIndex = -1;
|
||||
@ -352,11 +352,11 @@ nsXULTabpanelAccessible::GetAccessibleRelated(PRUint32 aRelationType,
|
||||
nsCOMPtr<nsIAccessible> childAcc;
|
||||
tabBoxAcc->GetFirstChild(getter_AddRefs(childAcc));
|
||||
while (childAcc && (!tabsAcc || !isTabpanelFound)) {
|
||||
if (Role(childAcc) == nsIAccessibleRole::ROLE_PAGETABLIST)
|
||||
if (nsAccUtils::Role(childAcc) == nsIAccessibleRole::ROLE_PAGETABLIST)
|
||||
tabsAcc = childAcc;
|
||||
|
||||
if (!isTabpanelFound &&
|
||||
Role(childAcc) == nsIAccessibleRole::ROLE_PROPERTYPAGE)
|
||||
nsAccUtils::Role(childAcc) == nsIAccessibleRole::ROLE_PROPERTYPAGE)
|
||||
tabpanelIndex++;
|
||||
|
||||
if (childAcc == this)
|
||||
@ -376,7 +376,7 @@ nsXULTabpanelAccessible::GetAccessibleRelated(PRUint32 aRelationType,
|
||||
nsCOMPtr<nsIAccessible> foundTabAcc;
|
||||
tabsAcc->GetFirstChild(getter_AddRefs(childAcc));
|
||||
while (childAcc) {
|
||||
if (Role(childAcc) == nsIAccessibleRole::ROLE_PAGETAB) {
|
||||
if (nsAccUtils::Role(childAcc) == nsIAccessibleRole::ROLE_PAGETAB) {
|
||||
if (atomID) {
|
||||
nsCOMPtr<nsIAccessNode> tabAccNode(do_QueryInterface(childAcc));
|
||||
nsCOMPtr<nsIDOMNode> tabNode;
|
||||
|
@ -90,7 +90,7 @@ nsXULTextAccessible::GetAccessibleRelated(PRUint32 aRelationType,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIContent *content = GetRoleContent(mDOMNode);
|
||||
nsIContent *content = nsCoreUtils::GetRoleContent(mDOMNode);
|
||||
if (!content)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -100,9 +100,8 @@ nsXULTextAccessible::GetAccessibleRelated(PRUint32 aRelationType,
|
||||
if (parent && parent->Tag() == nsAccessibilityAtoms::caption) {
|
||||
nsCOMPtr<nsIAccessible> parentAccessible;
|
||||
GetParent(getter_AddRefs(parentAccessible));
|
||||
if (Role(parentAccessible) == nsIAccessibleRole::ROLE_GROUPING) {
|
||||
if (nsAccUtils::Role(parentAccessible) == nsIAccessibleRole::ROLE_GROUPING)
|
||||
parentAccessible.swap(*aRelated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user