From ce83452872f90f795f92a1af1462ea151aeea7b5 Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Tue, 16 Aug 2011 19:28:31 +0900 Subject: [PATCH] Bug 386821 - need better solution for firing delayed event against xul tree, r=tbsaunde --- accessible/src/base/AccEvent.cpp | 33 +---- accessible/src/base/nsRootAccessible.cpp | 8 +- accessible/tests/mochitest/events/Makefile.in | 1 + .../mochitest/events/test_focus_tree.xul | 120 ++++++++++++++++++ 4 files changed, 127 insertions(+), 35 deletions(-) create mode 100644 accessible/tests/mochitest/events/test_focus_tree.xul diff --git a/accessible/src/base/AccEvent.cpp b/accessible/src/base/AccEvent.cpp index e9ef4d01dec9..fa9f3704561e 100644 --- a/accessible/src/base/AccEvent.cpp +++ b/accessible/src/base/AccEvent.cpp @@ -136,39 +136,10 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AccEvent, Release) //////////////////////////////////////////////////////////////////////////////// // AccEvent protected methods -nsAccessible * +nsAccessible* AccEvent::GetAccessibleForNode() const { - if (!mNode) - return nsnull; - - nsAccessible *accessible = GetAccService()->GetAccessible(mNode); - -#ifdef MOZ_XUL - // hack for xul tree table. We need a better way for firing delayed event - // against xul tree table. see bug 386821. - // There will be problem if some day we want to fire delayed event against - // the xul tree itself or an unselected treeitem. - nsCOMPtr content(do_QueryInterface(mNode)); - if (content && content->NodeInfo()->Equals(nsAccessibilityAtoms::tree, - kNameSpaceID_XUL)) { - - nsCOMPtr multiSelect = - do_QueryInterface(mNode); - - if (multiSelect) { - PRInt32 treeIndex = -1; - multiSelect->GetCurrentIndex(&treeIndex); - if (treeIndex >= 0) { - nsRefPtr treeAcc = do_QueryObject(accessible); - if (treeAcc) - return treeAcc->GetTreeItemAccessible(treeIndex); - } - } - } -#endif - - return accessible; + return mNode ? GetAccService()->GetAccessible(mNode) : nsnull; } void diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index 8c022db77b2b..e993dfc4e4f1 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -393,10 +393,10 @@ nsRootAccessible::FireAccessibleFocusEvent(nsAccessible* aFocusAccessible, // Coalesce focus events from the same document, because DOM focus event might // be fired for the document node and then for the focused DOM element. - focusDocument->FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_FOCUS, - focusNode, - AccEvent::eCoalesceFromSameDocument, - aIsFromUserInput); + nsRefPtr focusEvent = + new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, focusAccessible, + aIsFromUserInput, AccEvent::eCoalesceFromSameDocument); + focusDocument->FireDelayedAccessibleEvent(focusEvent); } void diff --git a/accessible/tests/mochitest/events/Makefile.in b/accessible/tests/mochitest/events/Makefile.in index 1c099e789eaf..91326d4c399c 100644 --- a/accessible/tests/mochitest/events/Makefile.in +++ b/accessible/tests/mochitest/events/Makefile.in @@ -66,6 +66,7 @@ _TEST_FILES =\ test_focus.html \ test_focus.xul \ test_focus_name.html \ + test_focus_tree.xul \ test_focusdoc.html \ test_menu.xul \ test_mutation.html \ diff --git a/accessible/tests/mochitest/events/test_focus_tree.xul b/accessible/tests/mochitest/events/test_focus_tree.xul new file mode 100644 index 000000000000..ef979520c508 --- /dev/null +++ b/accessible/tests/mochitest/events/test_focus_tree.xul @@ -0,0 +1,120 @@ + + + + + + + + + + + + Mozilla Bug 386821 +
+

+ +
+      
+ + + + + + + + + + +
+ +
+