Bug 646369 - UpdateTree should rely on accessible tree walker rather than DOM tree traversal, r=davidb

This commit is contained in:
Alexander Surkov
2011-04-07 14:17:29 +09:00
parent 6a536fa574
commit 0547d84f89
8 changed files with 216 additions and 107 deletions

View File

@@ -157,11 +157,12 @@ NotificationController::ScheduleContentInsertion(nsAccessible* aContainer,
if (mTreeConstructedState == eTreeConstructionPending)
return;
nsRefPtr<ContentInsertion> insertion =
new ContentInsertion(mDocument, aContainer, aStartChildNode, aEndChildNode);
if (insertion && mContentInsertions.AppendElement(insertion))
nsRefPtr<ContentInsertion> insertion = new ContentInsertion(mDocument,
aContainer);
if (insertion && insertion->InitChildList(aStartChildNode, aEndChildNode) &&
mContentInsertions.AppendElement(insertion)) {
ScheduleProcessing();
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -681,15 +682,31 @@ NotificationController::TextEnumerator(nsCOMPtrHashKey<nsIContent>* aEntry,
// NotificationController: content inserted notification
NotificationController::ContentInsertion::
ContentInsertion(nsDocAccessible* aDocument, nsAccessible* aContainer,
nsIContent* aStartChildNode, nsIContent* aEndChildNode) :
ContentInsertion(nsDocAccessible* aDocument, nsAccessible* aContainer) :
mDocument(aDocument), mContainer(aContainer)
{
}
bool
NotificationController::ContentInsertion::
InitChildList(nsIContent* aStartChildNode, nsIContent* aEndChildNode)
{
bool haveToUpdate = false;
nsIContent* node = aStartChildNode;
while (node != aEndChildNode) {
mInsertedContent.AppendElement(node);
// Notification triggers for content insertion even if no content was
// actually inserted, check if the given content has a frame to discard
// this case early.
if (node->GetPrimaryFrame()) {
if (mInsertedContent.AppendElement(node))
haveToUpdate = true;
}
node = node->GetNextSibling();
}
return haveToUpdate;
}
NS_IMPL_CYCLE_COLLECTION_CLASS(NotificationController::ContentInsertion)