Bug 646368 - don't check whether children are cached while tree is traversed, r=davidb

This commit is contained in:
Alexander Surkov 2011-04-07 14:17:54 +09:00
Родитель 5b590fcff7
Коммит a49527ed08
3 изменённых файлов: 26 добавлений и 20 удалений

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

@ -474,6 +474,9 @@ nsAccessible::GetFirstChild(nsIAccessible **aFirstChild)
NS_ENSURE_ARG_POINTER(aFirstChild);
*aFirstChild = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
PRInt32 childCount = GetChildCount();
NS_ENSURE_TRUE(childCount != -1, NS_ERROR_FAILURE);
@ -490,6 +493,9 @@ nsAccessible::GetLastChild(nsIAccessible **aLastChild)
NS_ENSURE_ARG_POINTER(aLastChild);
*aLastChild = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
PRInt32 childCount = GetChildCount();
NS_ENSURE_TRUE(childCount != -1, NS_ERROR_FAILURE);
@ -503,6 +509,9 @@ nsAccessible::GetChildAt(PRInt32 aChildIndex, nsIAccessible **aChild)
NS_ENSURE_ARG_POINTER(aChild);
*aChild = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
PRInt32 childCount = GetChildCount();
NS_ENSURE_TRUE(childCount != -1, NS_ERROR_FAILURE);
@ -526,6 +535,9 @@ nsAccessible::GetChildren(nsIArray **aOutChildren)
NS_ENSURE_ARG_POINTER(aOutChildren);
*aOutChildren = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
PRInt32 childCount = GetChildCount();
NS_ENSURE_TRUE(childCount != -1, NS_ERROR_FAILURE);
@ -555,6 +567,9 @@ nsAccessible::GetChildCount(PRInt32 *aChildCount)
{
NS_ENSURE_ARG_POINTER(aChildCount);
if (IsDefunct())
return NS_ERROR_FAILURE;
*aChildCount = GetChildCount();
return *aChildCount != -1 ? NS_OK : NS_ERROR_FAILURE;
}
@ -2812,9 +2827,6 @@ nsAccessible::RemoveChild(nsAccessible* aChild)
nsAccessible*
nsAccessible::GetChildAt(PRUint32 aIndex)
{
if (EnsureChildren())
return nsnull;
nsAccessible *child = mChildren.SafeElementAt(aIndex, nsnull);
if (!child)
return nsnull;
@ -2831,14 +2843,13 @@ nsAccessible::GetChildAt(PRUint32 aIndex)
PRInt32
nsAccessible::GetChildCount()
{
return EnsureChildren() ? -1 : mChildren.Length();
return mChildren.Length();
}
PRInt32
nsAccessible::GetIndexOf(nsAccessible* aChild)
{
return EnsureChildren() || (aChild->mParent != this) ?
-1 : aChild->GetIndexInParent();
return (aChild->mParent != this) ? -1 : aChild->GetIndexInParent();
}
PRInt32
@ -2850,9 +2861,6 @@ nsAccessible::GetIndexInParent() const
PRInt32
nsAccessible::GetEmbeddedChildCount()
{
if (EnsureChildren())
return -1;
if (IsChildrenFlag(eMixedChildren)) {
if (!mEmbeddedObjCollector)
mEmbeddedObjCollector = new EmbeddedObjCollector(this);
@ -2865,9 +2873,6 @@ nsAccessible::GetEmbeddedChildCount()
nsAccessible*
nsAccessible::GetEmbeddedChildAt(PRUint32 aIndex)
{
if (EnsureChildren())
return nsnull;
if (IsChildrenFlag(eMixedChildren)) {
if (!mEmbeddedObjCollector)
mEmbeddedObjCollector = new EmbeddedObjCollector(this);
@ -2881,9 +2886,6 @@ nsAccessible::GetEmbeddedChildAt(PRUint32 aIndex)
PRInt32
nsAccessible::GetIndexOfEmbeddedChild(nsAccessible* aChild)
{
if (EnsureChildren())
return -1;
if (IsChildrenFlag(eMixedChildren)) {
if (!mEmbeddedObjCollector)
mEmbeddedObjCollector = new EmbeddedObjCollector(this);

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

@ -1468,15 +1468,20 @@ nsDocAccessible::NotifyOfCachingEnd(nsAccessible* aAccessible)
// invalidation list.
for (PRUint32 idx = 0; idx < mInvalidationList.Length(); idx++) {
nsIContent* content = mInvalidationList[idx];
if (!HasAccessible(content)) {
// Make sure we keep children updated. While we're inside of caching
// loop then we must exist it with cached children.
nsAccessible* accessible = GetAccessible(content);
if (!accessible) {
nsAccessible* container = GetContainerAccessible(content);
NS_ASSERTION(container,
"Got a referenced element that is not in document!");
if (container)
if (container) {
container->UpdateChildren();
accessible = GetAccessible(content);
}
}
// Make sure the subtree is created.
if (accessible)
CacheChildrenInSubtree(accessible);
}
mInvalidationList.Clear();

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

@ -2212,7 +2212,6 @@ nsHyperTextAccessible::GetChildOffset(PRUint32 aChildIndex,
PRUint32 lastOffset = mOffsets.IsEmpty() ?
0 : mOffsets[mOffsets.Length() - 1];
EnsureChildren();
while (mOffsets.Length() < aChildIndex) {
nsAccessible* child = mChildren[mOffsets.Length()];
lastOffset += nsAccUtils::TextLength(child);