From 3f261b3e05391bde656de8e6cc4c1a6652cefbf7 Mon Sep 17 00:00:00 2001 From: "ginn.chen%sun.com" Date: Tue, 10 Apr 2007 07:55:51 +0000 Subject: [PATCH] Bug 366340 List items should not have SHOWING state when they are scrolled off patch by Nian.Liu r=surkov.alexander --- .../src/html/nsHTMLSelectAccessible.cpp | 57 ++++++++++++------- accessible/src/html/nsHTMLSelectAccessible.h | 9 +++ 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/accessible/src/html/nsHTMLSelectAccessible.cpp b/accessible/src/html/nsHTMLSelectAccessible.cpp index d0cadd27d80..3a005b581ae 100644 --- a/accessible/src/html/nsHTMLSelectAccessible.cpp +++ b/accessible/src/html/nsHTMLSelectAccessible.cpp @@ -551,27 +551,14 @@ nsHTMLSelectOptionAccessible::GetAttributesInternal(nsIPersistentProperties *aAt nsIFrame* nsHTMLSelectOptionAccessible::GetBoundsFrame() { - nsCOMPtr selectContent(do_QueryInterface(mDOMNode)); - - while (selectContent && selectContent->Tag() != nsAccessibilityAtoms::select) { - selectContent = selectContent->GetParent(); - } - - nsCOMPtr selectNode(do_QueryInterface(selectContent)); - if (selectNode) { - nsCOMPtr accService(do_GetService("@mozilla.org/accessibilityService;1")); - nsCOMPtr selAcc; - accService->GetAccessibleFor(selectNode, getter_AddRefs(selAcc)); - if (selAcc) { - PRUint32 state = State(selAcc); - if (state & nsIAccessibleStates::STATE_COLLAPSED) { - nsCOMPtr presShell(GetPresShell()); - if (!presShell) { - return nsnull; - } - return presShell->GetPrimaryFrameFor(selectContent); - } + PRUint32 state; + nsCOMPtr content = GetSelectState(&state); + if (state & nsIAccessibleStates::STATE_COLLAPSED) { + nsCOMPtr presShell(GetPresShell()); + if (!presShell) { + return nsnull; } + return presShell->GetPrimaryFrameFor(content); } return nsAccessible::GetBoundsFrame(); @@ -621,6 +608,13 @@ nsHTMLSelectOptionAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) *aState |= nsIAccessibleStates::STATE_SELECTABLE | nsIAccessibleStates::STATE_FOCUSABLE; + // remove STATE_SHOWING if parent is STATE_COLLAPSED + PRUint32 state; + GetSelectState(&state); + if (state & nsIAccessibleStates::STATE_COLLAPSED) { + *aState |= nsIAccessibleStates::STATE_OFFSCREEN; + } + return NS_OK; } @@ -787,6 +781,29 @@ void nsHTMLSelectOptionAccessible::SelectionChangedIfOption(nsIContent *aPossibl privateMultiSelect->FireToolkitEvent(eventType, optionAccessible, nsnull); } +nsIContent* nsHTMLSelectOptionAccessible::GetSelectState(PRUint32* aState) +{ + nsCOMPtr content(do_QueryInterface(mDOMNode)); + while (content && content->Tag() != nsAccessibilityAtoms::select) { + content = content->GetParent(); + } + + nsCOMPtr selectNode(do_QueryInterface(content)); + if (selectNode) { + nsCOMPtr accService = GetAccService(); + if (accService) { + nsCOMPtr selAcc; + accService->GetAccessibleFor(selectNode, getter_AddRefs(selAcc)); + if (selAcc) { + PRUint32 dummy; + selAcc->GetFinalState(aState, &dummy); + return content; + } + } + } + return nsnull; +} + /** ----- nsHTMLSelectOptGroupAccessible ----- */ /** Default Constructor */ diff --git a/accessible/src/html/nsHTMLSelectAccessible.h b/accessible/src/html/nsHTMLSelectAccessible.h index f88a1caa540..4027d2348af 100644 --- a/accessible/src/html/nsHTMLSelectAccessible.h +++ b/accessible/src/html/nsHTMLSelectAccessible.h @@ -169,6 +169,15 @@ public: nsIFrame* GetBoundsFrame(); static nsresult GetFocusedOptionNode(nsIDOMNode *aListNode, nsIDOMNode **aFocusedOptionNode); static void SelectionChangedIfOption(nsIContent *aPossibleOption); + +private: + + /** + * Get Select element's accessible state + * @param aState, Select element state + * @return Select element content, returns null if not avaliable + */ + nsIContent* GetSelectState(PRUint32* aState); }; /*