Commit 0a0a25f9 authored by Evan.Yan@Sun.COM's avatar Evan.Yan@Sun.COM
Browse files

bug 386161 - no focus event when arrowing down in xul tree table

r=surkov.alexander
parent b3af247d
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -40,6 +40,10 @@
#include "nsIAccessibilityService.h"
#include "nsIAccessNode.h"
#include "nsIServiceManager.h"
#ifdef MOZ_XUL
#include "nsIDOMXULMultSelectCntrlEl.h"
#include "nsXULTreeAccessible.h"
#endif

NS_IMPL_ISUPPORTS1(nsAccEvent, nsIAccessibleEvent)

@@ -125,6 +129,37 @@ nsAccEvent::GetAccessibleByNode()

  nsIAccessible *accessible = nsnull;
  accService->GetAccessibleFor(mDOMNode, &accessible);
#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.
  nsAutoString localName;
  mDOMNode->GetLocalName(localName);
  if (localName.EqualsLiteral("tree")) {
    nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelect =
      do_QueryInterface(mDOMNode);
    if (multiSelect) {
      PRInt32 treeIndex = -1;
      multiSelect->GetCurrentIndex(&treeIndex);
      if (treeIndex >= 0) {
        nsCOMPtr<nsIAccessibleTreeCache> treeCache(do_QueryInterface(accessible));
        NS_IF_RELEASE(accessible);
        nsCOMPtr<nsIAccessible> treeItemAccessible;
        if (!treeCache ||
            NS_FAILED(treeCache->GetCachedTreeitemAccessible(
                      treeIndex,
                      nsnull,
                      getter_AddRefs(treeItemAccessible))) ||
                      !treeItemAccessible) {
          return nsnull;
        }
        NS_IF_ADDREF(accessible = treeItemAccessible);
      }
    }
  }
#endif

  return accessible;
}