From 410cab1d6fd90dced64c29992edab7052c21edde Mon Sep 17 00:00:00 2001 From: David Bolter Date: Fri, 2 Apr 2010 09:33:55 -0400 Subject: [PATCH] Bug 551684 - No statechange event for aria-expanded on native HTML elements, is fired on ARIA widgets; r=MarcoZ,surkov --- accessible/src/base/nsDocAccessible.cpp | 38 +++++---- accessible/tests/mochitest/events/Makefile.in | 1 + .../events/test_aria_statechange.html | 85 +++++++++++++++++++ 3 files changed, 107 insertions(+), 17 deletions(-) create mode 100644 accessible/tests/mochitest/events/test_aria_statechange.html diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index ea937e33f1b8..eeec02a40dd6 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -1179,6 +1179,9 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute) if (!targetNode) return; + // Note: For universal/global ARIA states and properties we don't care if + // there is an ARIA role present or not. + if (aAttribute == nsAccessibilityAtoms::aria_required) { nsRefPtr event = new nsAccStateChangeEvent(targetNode, @@ -1209,6 +1212,24 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute) return; } + // For aria drag and drop changes we fire a generic attribute change event; + // at least until native API comes up with a more meaningful event. + if (aAttribute == nsAccessibilityAtoms::aria_grabbed || + aAttribute == nsAccessibilityAtoms::aria_dropeffect) { + FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED, + targetNode); + } + + // We treat aria-expanded as a global ARIA state for historical reasons + if (aAttribute == nsAccessibilityAtoms::aria_expanded) { + nsRefPtr event = + new nsAccStateChangeEvent(targetNode, + nsIAccessibleStates::STATE_EXPANDED, + PR_FALSE); + FireDelayedAccessibleEvent(event); + return; + } + if (!aContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::role)) { // We don't care about these other ARIA attribute changes unless there is // an ARIA role set for the element @@ -1249,15 +1270,6 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute) return; } - if (aAttribute == nsAccessibilityAtoms::aria_expanded) { - nsRefPtr event = - new nsAccStateChangeEvent(targetNode, - nsIAccessibleStates::STATE_EXPANDED, - PR_FALSE); - FireDelayedAccessibleEvent(event); - return; - } - if (aAttribute == nsAccessibilityAtoms::aria_readonly) { nsRefPtr event = new nsAccStateChangeEvent(targetNode, @@ -1290,14 +1302,6 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute) nsIAccessibilityService::NODE_SIGNIFICANT_CHANGE); return; } - - // For aria drag and drop changes we fire a generic attribute change event; - // at least until native API comes up with a more meaningful event. - if (aAttribute == nsAccessibilityAtoms::aria_grabbed || - aAttribute == nsAccessibilityAtoms::aria_dropeffect) { - FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED, - targetNode); - } } void nsDocAccessible::ContentAppended(nsIDocument *aDocument, diff --git a/accessible/tests/mochitest/events/Makefile.in b/accessible/tests/mochitest/events/Makefile.in index c95ddb5ce7f2..4cccd0b5bbb7 100644 --- a/accessible/tests/mochitest/events/Makefile.in +++ b/accessible/tests/mochitest/events/Makefile.in @@ -48,6 +48,7 @@ include $(topsrcdir)/config/rules.mk _TEST_FILES =\ focus.html \ scroll.html \ + test_aria_statechange.html \ test_attrs.html \ test_caretmove.html \ $(warning test_coalescence.html temporarily disabled) \ diff --git a/accessible/tests/mochitest/events/test_aria_statechange.html b/accessible/tests/mochitest/events/test_aria_statechange.html new file mode 100644 index 000000000000..2a8f20ae9294 --- /dev/null +++ b/accessible/tests/mochitest/events/test_aria_statechange.html @@ -0,0 +1,85 @@ + + + + ARIA state change event testing + + + + + + + + + + + + + + + + + Mozilla Bug 551684 + + +

+ +
+  
+
+ + + + + + +