From aa23104e9cb69a209b768b600d5dbbfc4890d1ec Mon Sep 17 00:00:00 2001 From: "aaronleventhal@moonset.net" Date: Thu, 19 Apr 2007 10:49:13 -0700 Subject: [PATCH] Checking bug 255088 again, but this time without leak. Original patch was r=surkov --- accessible/src/base/nsDocAccessible.cpp | 41 +++++++++++++++---------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index 12eeda9b6339..17d2c84c61c8 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -909,17 +909,36 @@ nsDocAccessible::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, return; // Document has been shut down } - if (aNameSpaceID == kNameSpaceID_WAIProperties) { - ARIAAttributeChanged(aContent, aAttribute); - return; - } - nsCOMPtr targetNode(do_QueryInterface(aContent)); NS_ASSERTION(targetNode, "No node for attr modified"); if (!targetNode) { return; } + // Universal boolean properties that don't require a role. + if (aAttribute == nsAccessibilityAtoms::disabled) { + // Fire the state change whether disabled attribute is + // set for XUL, HTML or ARIA namespace. + // Checking the namespace would not seem to gain us anything, because + // disabled really is going to mean the same thing in any namespace. + nsCOMPtr enabledChangeEvent = + new nsAccStateChangeEvent(targetNode, + nsIAccessibleStates::EXT_STATE_ENABLED, + PR_TRUE); + FireDelayedAccessibleEvent(enabledChangeEvent); + nsCOMPtr sensitiveChangeEvent = + new nsAccStateChangeEvent(targetNode, + nsIAccessibleStates::EXT_STATE_SENSITIVE, + PR_TRUE); + FireDelayedAccessibleEvent(sensitiveChangeEvent); + return; + } + + if (aNameSpaceID == kNameSpaceID_WAIProperties) { + ARIAAttributeChanged(aContent, aAttribute); + return; + } + if (aNameSpaceID == kNameSpaceID_XHTML2_Unofficial || aNameSpaceID == kNameSpaceID_XHTML) { if (aAttribute == nsAccessibilityAtoms::role) @@ -978,16 +997,6 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute) if (!targetNode) return; - // Universal boolean properties that don't require a role. - if (aAttribute == nsAccessibilityAtoms::disabled) { - nsCOMPtr event = - new nsAccStateChangeEvent(targetNode, - nsIAccessibleStates::EXT_STATE_ENABLED, - PR_TRUE); - FireDelayedAccessibleEvent(event); - return; - } - if (aAttribute == nsAccessibilityAtoms::required) { nsCOMPtr event = new nsAccStateChangeEvent(targetNode, @@ -1010,7 +1019,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 currentFocus = GetCurrentFocus(); - if (SameCOMIdentity(currentFocus, aContent)) { + if (currentFocus == targetNode) { nsRefPtr rootAcc = GetRootAccessible(); if (rootAcc) rootAcc->FireAccessibleFocusEvent(nsnull, currentFocus, nsnull, PR_TRUE);