From 7417717465a0cca4e446e6b3cb4d0be69909d33e Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Fri, 23 Mar 2012 10:49:55 +0900 Subject: [PATCH] Bug 736944 - make nsDocAccessible::RecreateAccessible fall into usual ContentInserted/ContentRemoved procedure, r=tbsaunde --- accessible/public/nsIAccessibilityService.h | 6 ---- .../src/base/nsAccessibilityService.cpp | 6 ++-- accessible/src/base/nsAccessibilityService.h | 6 ++-- accessible/src/base/nsDocAccessible.cpp | 24 ++++--------- .../mochitest/treeupdate/test_imagemap.html | 36 +++++++++++++++++++ 5 files changed, 49 insertions(+), 29 deletions(-) diff --git a/accessible/public/nsIAccessibilityService.h b/accessible/public/nsIAccessibilityService.h index 009f73b0ea0..a46b91dc634 100644 --- a/accessible/public/nsIAccessibilityService.h +++ b/accessible/public/nsIAccessibilityService.h @@ -162,12 +162,6 @@ public: */ virtual void PresShellDestroyed(nsIPresShell *aPresShell) = 0; - /** - * Recreate an accessible for the given content node in the presshell. - */ - virtual void RecreateAccessible(nsIPresShell* aPresShell, - nsIContent* aContent) = 0; - /** * Fire accessible event of the given type for the given target. * diff --git a/accessible/src/base/nsAccessibilityService.cpp b/accessible/src/base/nsAccessibilityService.cpp index ce736ac3009..df7f820a90b 100644 --- a/accessible/src/base/nsAccessibilityService.cpp +++ b/accessible/src/base/nsAccessibilityService.cpp @@ -676,10 +676,8 @@ nsAccessibilityService::RecreateAccessible(nsIPresShell* aPresShell, nsIContent* aContent) { nsDocAccessible* document = GetDocAccessible(aPresShell->GetDocument()); - if (document) { - document->HandleNotification - (document, &nsDocAccessible::RecreateAccessible, aContent); - } + if (document) + document->RecreateAccessible(aContent); } //////////////////////////////////////////////////////////////////////////////// diff --git a/accessible/src/base/nsAccessibilityService.h b/accessible/src/base/nsAccessibilityService.h index 8d47b0b0d4c..a3ab0ddf69f 100644 --- a/accessible/src/base/nsAccessibilityService.h +++ b/accessible/src/base/nsAccessibilityService.h @@ -173,8 +173,10 @@ public: */ virtual void PresShellActivated(nsIPresShell* aPresShell); - virtual void RecreateAccessible(nsIPresShell* aPresShell, - nsIContent* aContent); + /** + * Recreate an accessible for the given content node in the presshell. + */ + void RecreateAccessible(nsIPresShell* aPresShell, nsIContent* aContent); virtual void FireAccessibleEvent(PRUint32 aEvent, nsAccessible* aTarget); diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index a958cd290bd..ac70389f7ae 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -1467,14 +1467,8 @@ nsDocAccessible::RecreateAccessible(nsIContent* aContent) // coalescence with normal hide and show events. Note, in this case they // should be coalesced with normal show/hide events. - // Check if the node is in accessible document. - nsAccessible* container = GetContainerAccessible(aContent); - if (container) { - // Remove and reinsert. - UpdateTree(container, aContent, false); - container->UpdateChildren(); - UpdateTree(container, aContent, true); - } + ContentRemoved(aContent->GetParent(), aContent); + ContentInserted(aContent->GetParent(), aContent, aContent->GetNextSibling()); } void @@ -1717,8 +1711,7 @@ nsDocAccessible::UpdateAccessibleOnAttrChange(dom::Element* aElement, // Recreate the accessible when role is changed because we might require a // different accessible class for the new role or the accessible may expose // a different sets of interfaces (COM restriction). - HandleNotification - (this, &nsDocAccessible::RecreateAccessible, aElement); + RecreateAccessible(aElement); return true; } @@ -1729,11 +1722,9 @@ nsDocAccessible::UpdateAccessibleOnAttrChange(dom::Element* aElement, // kill use to recreate the accessible even if the attribute was used in // the wrong namespace or an element that doesn't support it. - // Recreate accessible asynchronously to allow the content to handle - // the attribute change. - mNotificationController->ScheduleNotification - (this, &nsDocAccessible::RecreateAccessible, aElement); - + // Make sure the accessible is recreated asynchronously to allow the content + // to handle the attribute change. + RecreateAccessible(aElement); return true; } @@ -1742,8 +1733,7 @@ nsDocAccessible::UpdateAccessibleOnAttrChange(dom::Element* aElement, // This affects whether the accessible supports SelectAccessible. // COM says we cannot change what interfaces are supported on-the-fly, // so invalidate this object. A new one will be created on demand. - HandleNotification - (this, &nsDocAccessible::RecreateAccessible, aElement); + RecreateAccessible(aElement); return true; } diff --git a/accessible/tests/mochitest/treeupdate/test_imagemap.html b/accessible/tests/mochitest/treeupdate/test_imagemap.html index 88a62568165..1a448d1693a 100644 --- a/accessible/tests/mochitest/treeupdate/test_imagemap.html +++ b/accessible/tests/mochitest/treeupdate/test_imagemap.html @@ -345,6 +345,41 @@ } } + function hideImageMap(aContainerID, aImageID) + { + this.container = getAccessible(aContainerID); + this.imageMap = null; + this.imageMapNode = getNode(aImageID); + + function getImageMap(aThisObj) + { + return aThisObj.imageMap; + } + + this.eventSeq = [ + new invokerChecker(EVENT_HIDE, getImageMap, this), + new invokerChecker(EVENT_REORDER, aContainerID) + ]; + + this.invoke = function hideImageMap_invoke() + { + this.imageMap = getAccessible(this.imageMapNode); + this.imageMapNode.style.display = "none"; + } + + this.finalCheck = function hideImageMap_finalCheck() + { + var accTree = + { SECTION: [ ] }; + testAccessibleTree(this.container, accTree); + } + + this.getID = function hideImageMap_getID() + { + return "display:none image"; + } + } + //gA11yEventDumpToConsole = true; var gQueue = null; @@ -359,6 +394,7 @@ gQueue.push(new restoreNameOnMap("container", "imgmap", "map")); gQueue.push(new removeMap("container", "imgmap", "map")); gQueue.push(new insertMap("container", "imgmap")); + gQueue.push(new hideImageMap("container", "imgmap")); gQueue.invoke(); // Will call SimpleTest.finish(); }