зеркало из https://github.com/mozilla/pjs.git
Bug 566298 - don't use nsIAccessible::GetNextSibling() to iterate children, r=davidb, sr=neil
This commit is contained in:
Родитель
62ca056f81
Коммит
152b7b9fe4
|
@ -943,36 +943,26 @@ getIndexInParentCB(AtkObject *aAtkObj)
|
|||
return -1;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> parent;
|
||||
accWrap->GetParent(getter_AddRefs(parent));
|
||||
nsAccessible *parent = accWrap->GetParent();
|
||||
if (!parent) {
|
||||
return -1; // No parent
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> sibling;
|
||||
parent->GetFirstChild(getter_AddRefs(sibling));
|
||||
if (!sibling) {
|
||||
return -1; // Error, parent has no children
|
||||
}
|
||||
|
||||
PRInt32 currentIndex = 0;
|
||||
|
||||
while (sibling != static_cast<nsIAccessible*>(accWrap)) {
|
||||
NS_ASSERTION(sibling, "Never ran into the same child that we started from");
|
||||
|
||||
if (!sibling) {
|
||||
return -1;
|
||||
PRInt32 childCount = parent->GetChildCount();
|
||||
for (PRInt32 idx = 0; idx < childCount; idx++) {
|
||||
nsAccessible *sibling = parent->GetChildAt(idx);
|
||||
if (sibling == accWrap) {
|
||||
return currentIndex;
|
||||
}
|
||||
|
||||
if (nsAccUtils::IsEmbeddedObject(sibling)) {
|
||||
++ currentIndex;
|
||||
++ currentIndex;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> tempAccessible;
|
||||
sibling->GetNextSibling(getter_AddRefs(tempAccessible));
|
||||
sibling.swap(tempAccessible);
|
||||
}
|
||||
|
||||
return currentIndex;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void TranslateStates(PRUint32 aState, const AtkStateMap *aStateMap,
|
||||
|
|
|
@ -1130,15 +1130,14 @@ nsARIAGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttrib
|
|||
|
||||
// Expose "table-cell-index" attribute.
|
||||
|
||||
nsCOMPtr<nsIAccessible> thisRow;
|
||||
GetParent(getter_AddRefs(thisRow));
|
||||
nsAccessible *thisRow = GetParent();
|
||||
if (nsAccUtils::Role(thisRow) != nsIAccessibleRole::ROLE_ROW)
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 colIdx = 0, colCount = 0;
|
||||
nsCOMPtr<nsIAccessible> child, nextChild;
|
||||
thisRow->GetFirstChild(getter_AddRefs(child));
|
||||
while (child) {
|
||||
PRInt32 childCount = thisRow->GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *child = thisRow->GetChildAt(childIdx);
|
||||
if (child == this)
|
||||
colIdx = colCount;
|
||||
|
||||
|
@ -1147,25 +1146,22 @@ nsARIAGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttrib
|
|||
role == nsIAccessibleRole::ROLE_ROWHEADER ||
|
||||
role == nsIAccessibleRole::ROLE_COLUMNHEADER)
|
||||
colCount++;
|
||||
|
||||
child->GetNextSibling(getter_AddRefs(nextChild));
|
||||
child.swap(nextChild);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> table;
|
||||
thisRow->GetParent(getter_AddRefs(table));
|
||||
nsAccessible *table = thisRow->GetParent();
|
||||
if (nsAccUtils::Role(table) != nsIAccessibleRole::ROLE_TABLE &&
|
||||
nsAccUtils::Role(table) != nsIAccessibleRole::ROLE_TREE_TABLE)
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 rowIdx = 0;
|
||||
table->GetFirstChild(getter_AddRefs(child));
|
||||
while (child && child != thisRow) {
|
||||
childCount = table->GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *child = table->GetChildAt(childIdx);
|
||||
if (child == thisRow)
|
||||
break;
|
||||
|
||||
if (nsAccUtils::Role(child) == nsIAccessibleRole::ROLE_ROW)
|
||||
rowIdx++;
|
||||
|
||||
child->GetNextSibling(getter_AddRefs(nextChild));
|
||||
child.swap(nextChild);
|
||||
}
|
||||
|
||||
PRInt32 idx = rowIdx * colCount + colIdx;
|
||||
|
|
|
@ -789,31 +789,29 @@ nsAccUtils::GetLiveAttrValue(PRUint32 aRule, nsAString& aValue)
|
|||
#ifdef DEBUG_A11Y
|
||||
|
||||
PRBool
|
||||
nsAccUtils::IsTextInterfaceSupportCorrect(nsIAccessible *aAccessible)
|
||||
nsAccUtils::IsTextInterfaceSupportCorrect(nsAccessible *aAccessible)
|
||||
{
|
||||
PRBool foundText = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIAccessibleDocument> accDoc = do_QueryInterface(aAccessible);
|
||||
nsCOMPtr<nsIAccessibleDocument> accDoc = do_QueryObject(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) {
|
||||
PRInt32 childCount = aAccessible->GetChildCount();
|
||||
for (PRint32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *child = GetChildAt(childIdx);
|
||||
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);
|
||||
nsCOMPtr<nsIAccessibleText> text = do_QueryObject(aAccessible);
|
||||
if (!text)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
|
|
@ -324,7 +324,7 @@ public:
|
|||
* Detect whether the given accessible object implements nsIAccessibleText,
|
||||
* when it is text or has text child node.
|
||||
*/
|
||||
static PRBool IsTextInterfaceSupportCorrect(nsIAccessible *aAccessible);
|
||||
static PRBool IsTextInterfaceSupportCorrect(nsAccessible *aAccessible);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -1803,9 +1803,8 @@ void nsDocAccessible::RefreshNodes(nsIDOMNode *aStartNode)
|
|||
// created.
|
||||
if (accessible->GetCachedFirstChild()) {
|
||||
nsCOMPtr<nsIArray> children;
|
||||
// use GetChildren() to fetch children at one time, instead of using
|
||||
// GetNextSibling(), because after we shutdown the first child,
|
||||
// mNextSibling will be set null.
|
||||
// use GetChildren() to fetch all children at once, because after shutdown
|
||||
// the child references are cleared.
|
||||
accessible->GetChildren(getter_AddRefs(children));
|
||||
PRUint32 childCount =0;
|
||||
if (children)
|
||||
|
|
|
@ -236,16 +236,14 @@ nsresult
|
|||
nsTextEquivUtils::AppendFromAccessibleChildren(nsIAccessible *aAccessible,
|
||||
nsAString *aString)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> accChild, accNextChild;
|
||||
aAccessible->GetFirstChild(getter_AddRefs(accChild));
|
||||
|
||||
nsresult rv = NS_OK_NO_NAME_CLAUSE_HANDLED;
|
||||
while (accChild) {
|
||||
rv = AppendFromAccessible(accChild, aString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
accChild->GetNextSibling(getter_AddRefs(accNextChild));
|
||||
accChild.swap(accNextChild);
|
||||
nsRefPtr<nsAccessible> accessible(do_QueryObject(aAccessible));
|
||||
PRInt32 childCount = accessible->GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *child = accessible->GetChildAt(childIdx);
|
||||
rv = AppendFromAccessible(child, aString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -390,26 +390,21 @@ __try {
|
|||
|
||||
PRUint32 currentRole = nsAccUtils::Role(xpAccessible);
|
||||
if (currentRole == nsIAccessibleRole::ROLE_OUTLINEITEM) {
|
||||
nsCOMPtr<nsIAccessible> child;
|
||||
xpAccessible->GetFirstChild(getter_AddRefs(child));
|
||||
while (child) {
|
||||
PRInt32 childCount = xpAccessible->GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *child = xpAccessible->GetChildAt(childIdx);
|
||||
currentRole = nsAccUtils::Role(child);
|
||||
if (currentRole == nsIAccessibleRole::ROLE_GROUPING) {
|
||||
nsCOMPtr<nsIAccessible> groupChild;
|
||||
child->GetFirstChild(getter_AddRefs(groupChild));
|
||||
while (groupChild) {
|
||||
PRInt32 groupChildCount = child->GetChildCount();
|
||||
for (PRInt32 groupChildIdx = 0; groupChildIdx < groupChildCount;
|
||||
groupChildIdx++) {
|
||||
nsAccessible *groupChild = child->GetChildAt(groupChildIdx);
|
||||
currentRole = nsAccUtils::Role(groupChild);
|
||||
numChildren +=
|
||||
(currentRole == nsIAccessibleRole::ROLE_OUTLINEITEM);
|
||||
nsCOMPtr<nsIAccessible> nextGroupChild;
|
||||
groupChild->GetNextSibling(getter_AddRefs(nextGroupChild));
|
||||
groupChild.swap(nextGroupChild);
|
||||
}
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIAccessible> nextChild;
|
||||
child->GetNextSibling(getter_AddRefs(nextChild));
|
||||
child.swap(nextChild);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -553,39 +553,32 @@ already_AddRefed<nsIDOMNode>
|
|||
nsXFormsSelectableAccessible::GetItemByIndex(PRInt32 *aIndex,
|
||||
nsIAccessible *aAccessible)
|
||||
{
|
||||
nsCOMPtr<nsIAccessible> accessible(aAccessible ? aAccessible : this);
|
||||
nsRefPtr<nsAccessible> accessible(do_QueryObject(aAccessible));
|
||||
if (!accessible)
|
||||
accessible = this;
|
||||
|
||||
nsCOMPtr<nsIAccessible> curAccChild;
|
||||
accessible->GetFirstChild(getter_AddRefs(curAccChild));
|
||||
PRInt32 childCount = accessible->GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
nsAccessible *child = accessible->GetChildAt(childIdx);
|
||||
|
||||
while (curAccChild) {
|
||||
nsCOMPtr<nsIAccessNode> curAccNodeChild(do_QueryInterface(curAccChild));
|
||||
if (curAccNodeChild) {
|
||||
nsCOMPtr<nsIDOMNode> curChildNode;
|
||||
curAccNodeChild->GetDOMNode(getter_AddRefs(curChildNode));
|
||||
nsCOMPtr<nsIContent> curChildContent(do_QueryInterface(curChildNode));
|
||||
if (curChildContent) {
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo = curChildContent->NodeInfo();
|
||||
if (nodeInfo->NamespaceEquals(NS_LITERAL_STRING(NS_NAMESPACE_XFORMS))) {
|
||||
if (nodeInfo->Equals(nsAccessibilityAtoms::item)) {
|
||||
if (!*aIndex) {
|
||||
nsIDOMNode *itemNode = nsnull;
|
||||
curChildNode.swap(itemNode);
|
||||
return itemNode;
|
||||
}
|
||||
--*aIndex;
|
||||
} else if (nodeInfo->Equals(nsAccessibilityAtoms::choices)) {
|
||||
nsIDOMNode *itemNode = GetItemByIndex(aIndex, curAccChild).get();
|
||||
if (itemNode)
|
||||
return itemNode;
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> childNode(child->GetDOMNode());
|
||||
nsCOMPtr<nsIContent> childContent(do_QueryInterface(childNode));
|
||||
if (!childContent)
|
||||
continue;
|
||||
|
||||
nsINodeInfo *nodeInfo = childContent->NodeInfo();
|
||||
if (nodeInfo->NamespaceEquals(NS_LITERAL_STRING(NS_NAMESPACE_XFORMS))) {
|
||||
if (nodeInfo->Equals(nsAccessibilityAtoms::item)) {
|
||||
if (!*aIndex)
|
||||
return childNode.forget();
|
||||
|
||||
--*aIndex;
|
||||
} else if (nodeInfo->Equals(nsAccessibilityAtoms::choices)) {
|
||||
nsIDOMNode *itemNode = GetItemByIndex(aIndex, child).get();
|
||||
if (itemNode)
|
||||
return itemNode;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessible> nextAccChild;
|
||||
curAccChild->GetNextSibling(getter_AddRefs(nextAccChild));
|
||||
curAccChild.swap(nextAccChild);
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
|
|
|
@ -1149,25 +1149,23 @@ nsXULListCellAccessible::GetColumnHeaderCells(nsIArray **aHeaderCells)
|
|||
NS_ENSURE_STATE(table); // we expect to be in a listbox (table)
|
||||
|
||||
// Get column header cell from XUL listhead.
|
||||
nsCOMPtr<nsIAccessible> tableAcc(do_QueryInterface(table));
|
||||
nsAccessible *list = nsnull;
|
||||
|
||||
nsCOMPtr<nsIAccessible> list, nextChild;
|
||||
tableAcc->GetFirstChild(getter_AddRefs(list));
|
||||
while (list) {
|
||||
if (nsAccUtils::Role(list) == nsIAccessibleRole::ROLE_LIST)
|
||||
nsRefPtr<nsAccessible> tableAcc(do_QueryObject(table));
|
||||
PRInt32 tableChildCount = tableAcc->GetChildCount();
|
||||
for (PRInt32 childIdx = 0; childIdx < tableChildCount; childIdx++) {
|
||||
nsAccessible *child = tableAcc->GetChildAt(childIdx);
|
||||
if (nsAccUtils::Role(child) == nsIAccessibleRole::ROLE_LIST) {
|
||||
list = child;
|
||||
break;
|
||||
|
||||
list->GetNextSibling(getter_AddRefs(nextChild));
|
||||
nextChild.swap(list);
|
||||
}
|
||||
}
|
||||
|
||||
if (list) {
|
||||
PRInt32 colIdx = -1;
|
||||
GetColumnIndex(&colIdx);
|
||||
|
||||
nsCOMPtr<nsIAccessible> headerCell;
|
||||
list->GetChildAt(colIdx, getter_AddRefs(headerCell));
|
||||
|
||||
nsIAccessible *headerCell = list->GetChildAt(colIdx);
|
||||
if (headerCell) {
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIMutableArray> headerCells =
|
||||
|
|
Загрузка…
Ссылка в новой задаче