From 7ba9ae2d81a42f1abecd806e020066bf1ca95df9 Mon Sep 17 00:00:00 2001 From: "ginn.chen@sun.com" Date: Tue, 15 May 2007 02:46:06 -0700 Subject: [PATCH] Bug 357969 container xul element which doesn't have a xbl def under a deck frame has no accessible objectpatch by nian.liu at sun.com r=surkov.alexander sr=neil --- accessible/public/nsIAccessibleProvider.idl | 23 +++++------ accessible/src/base/nsAccessibilityAtomList.h | 3 ++ .../src/base/nsAccessibilityService.cpp | 41 ++++++++++++++++--- accessible/src/base/nsAccessibilityService.h | 5 +++ accessible/src/xul/nsXULTabAccessible.cpp | 37 ----------------- accessible/src/xul/nsXULTabAccessible.h | 19 --------- content/base/src/nsGkAtomList.h | 1 + layout/xul/base/src/nsDeckFrame.cpp | 6 +++ layout/xul/base/src/nsDeckFrame.h | 2 + toolkit/content/widgets/tabbox.xml | 9 +--- 10 files changed, 63 insertions(+), 83 deletions(-) diff --git a/accessible/public/nsIAccessibleProvider.idl b/accessible/public/nsIAccessibleProvider.idl index 9e2614b5dd65..71576a040ec0 100644 --- a/accessible/public/nsIAccessibleProvider.idl +++ b/accessible/public/nsIAccessibleProvider.idl @@ -45,7 +45,7 @@ object. For that XBL binding of element should implement the interface. */ -[scriptable, uuid(18797ea7-44cc-469e-8923-bd5d1c144461)] +[scriptable, uuid(7250d0f0-732d-4981-b73e-dd5d71b16183)] interface nsIAccessibleProvider : nsISupports { /** @@ -87,21 +87,18 @@ interface nsIAccessibleProvider : nsISupports /** A combination of a tabs object and a tabpanels object */ const long XULTabBox = 0x00001022; - /** The display area for a dialog or tabbrowser interface */ - const long XULTabPanels = 0x00001023; - /** The collection of tab objects, useable in the TabBox and independant of as well */ - const long XULTabs = 0x00001024; + const long XULTabs = 0x00001023; - const long XULText = 0x00001025; - const long XULTextBox = 0x00001026; - const long XULTree = 0x00001027; - const long XULTreeColumns = 0x00001028; - const long XULTreeColumnitem = 0x00001029; - const long XULToolbar = 0x00001030; - const long XULToolbarSeparator = 0x00001031; - const long XULTooltip = 0x00001032; + const long XULText = 0x00001024; + const long XULTextBox = 0x00001025; + const long XULTree = 0x00001026; + const long XULTreeColumns = 0x00001027; + const long XULTreeColumnitem = 0x00001028; + const long XULToolbar = 0x00001029; + const long XULToolbarSeparator = 0x00001030; + const long XULTooltip = 0x00001031; /** diff --git a/accessible/src/base/nsAccessibilityAtomList.h b/accessible/src/base/nsAccessibilityAtomList.h index 4b48baee037e..8add029d65c4 100755 --- a/accessible/src/base/nsAccessibilityAtomList.h +++ b/accessible/src/base/nsAccessibilityAtomList.h @@ -71,10 +71,13 @@ ACCESSIBILITY_ATOM(headerContentLanguage, "content-language") // Alphabetical list of frame types ACCESSIBILITY_ATOM(areaFrame, "AreaFrame") ACCESSIBILITY_ATOM(blockFrame, "BlockFrame") +ACCESSIBILITY_ATOM(boxFrame, "BoxFrame") ACCESSIBILITY_ATOM(brFrame, "BRFrame") +ACCESSIBILITY_ATOM(deckFrame, "DeckFrame") ACCESSIBILITY_ATOM(inlineBlockFrame, "InlineBlockFrame") ACCESSIBILITY_ATOM(inlineFrame, "InlineFrame") ACCESSIBILITY_ATOM(objectFrame, "ObjectFrame") +ACCESSIBILITY_ATOM(scrollFrame, "ScrollFrame") ACCESSIBILITY_ATOM(textFrame, "TextFrame") ACCESSIBILITY_ATOM(tableCellFrame, "TableCellFrame") ACCESSIBILITY_ATOM(tableOuterFrame, "TableOuterFrame") diff --git a/accessible/src/base/nsAccessibilityService.cpp b/accessible/src/base/nsAccessibilityService.cpp index f190ee8879d4..1d0617905a7b 100644 --- a/accessible/src/base/nsAccessibilityService.cpp +++ b/accessible/src/base/nsAccessibilityService.cpp @@ -1268,6 +1268,10 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessible(nsIDOMNode *aNode, } } + if (!newAcc) { + GetAccessibleForDeckChildren(aNode, getter_AddRefs(newAcc)); + } + // If no accessible, see if we need to create a generic accessible because // of some property that makes this object interesting // We don't do this for , , , etc. which @@ -1372,12 +1376,12 @@ nsresult nsAccessibilityService::GetAccessibleByType(nsIDOMNode *aNode, *aAccessible = nsnull; - nsCOMPtr node(do_QueryInterface(aNode)); - if (!node) + nsCOMPtr accessibleProvider(do_QueryInterface(aNode)); + if (!accessibleProvider) return NS_OK; PRInt32 type; - nsresult rv = node->GetAccessibleType(&type); + nsresult rv = accessibleProvider->GetAccessibleType(&type); NS_ENSURE_SUCCESS(rv, rv); if (type == nsIAccessibleProvider::OuterDoc) @@ -1485,9 +1489,6 @@ nsresult nsAccessibilityService::GetAccessibleByType(nsIDOMNode *aNode, case nsIAccessibleProvider::XULTabBox: *aAccessible = new nsXULTabBoxAccessible(aNode, weakShell); break; - case nsIAccessibleProvider::XULTabPanels: - *aAccessible = new nsXULTabPanelsAccessible(aNode, weakShell); - break; case nsIAccessibleProvider::XULTabs: *aAccessible = new nsXULTabsAccessible(aNode, weakShell); break; @@ -1674,3 +1675,31 @@ NS_GetAccessibilityService(nsIAccessibilityService** aResult) return nsAccessibilityService::GetAccessibilityService(aResult); } +nsresult +nsAccessibilityService::GetAccessibleForDeckChildren(nsIDOMNode *aNode, nsIAccessible** aAccessible) +{ + nsCOMPtr weakShell; + GetShellFromNode(aNode, getter_AddRefs(weakShell)); + NS_ENSURE_TRUE(weakShell, NS_ERROR_FAILURE); + nsCOMPtr shell(do_QueryReferent(weakShell)); + NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE); + + nsIFrame* frame = nsnull; + nsIFrame* parentFrame = nsnull; + nsCOMPtr content(do_QueryInterface(aNode)); + + if (content) { + frame = shell->GetPrimaryFrameFor(content); + } + + if (frame && (frame->GetType() == nsAccessibilityAtoms::boxFrame || + frame->GetType() == nsAccessibilityAtoms::scrollFrame)) { + parentFrame = frame->GetParent(); + if (parentFrame && parentFrame->GetType() == nsAccessibilityAtoms::deckFrame) { + *aAccessible = new nsEnumRoleAccessible(aNode, weakShell, nsIAccessibleRole::ROLE_PROPERTYPAGE); + NS_ADDREF(*aAccessible); + } + } + + return NS_OK; +} diff --git a/accessible/src/base/nsAccessibilityService.h b/accessible/src/base/nsAccessibilityService.h index b15e53ab88b7..cbcd45a01481 100644 --- a/accessible/src/base/nsAccessibilityService.h +++ b/accessible/src/base/nsAccessibilityService.h @@ -83,6 +83,11 @@ private: */ nsresult GetAccessibleByType(nsIDOMNode *aNode, nsIAccessible **aAccessible); PRBool HasListener(nsIContent *aContent, nsAString& aEventType); + + /** + * Return accessible object if parent is a deck frame + */ + nsresult GetAccessibleForDeckChildren(nsIDOMNode *aNode, nsIAccessible **aAccessible); }; #endif /* __nsIAccessibilityService_h__ */ diff --git a/accessible/src/xul/nsXULTabAccessible.cpp b/accessible/src/xul/nsXULTabAccessible.cpp index 75acd0c36015..575343768cc9 100644 --- a/accessible/src/xul/nsXULTabAccessible.cpp +++ b/accessible/src/xul/nsXULTabAccessible.cpp @@ -183,43 +183,6 @@ NS_IMETHODIMP nsXULTabBoxAccessible::GetChildCount(PRInt32 *_retval) } #endif -/** - * XUL TabPanels - * XXX jgaunt -- this has to report the info for the selected child, reachable through - * the DOMNode. The TabPanels object has as its children the different - * vbox/hbox/whatevers that provide what you look at when you click on - * a tab. - * Here is how this will work: when asked about an object the tabPanels object will find - * out the selected child and create the tabPanel object using the child. That should wrap - * any XUL/HTML content in the child, since it is a simple nsAccessible basically. - * or maybe we just do that on creation. Not use the DOMnode we are given, but cache the selected - * DOMnode and then run from there. - */ - -/** Constructor */ -nsXULTabPanelsAccessible::nsXULTabPanelsAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell): -nsAccessibleWrap(aNode, aShell) -{ -} - -/** We are a Property Page */ -NS_IMETHODIMP nsXULTabPanelsAccessible::GetRole(PRUint32 *aRole) -{ - *aRole = nsIAccessibleRole::ROLE_PROPERTYPAGE; - return NS_OK; -} - -/** - * The name for the panel is the name from the tab associated with - * the panel. XXX not sure if the "panels" object should have the - * same name. - */ -NS_IMETHODIMP nsXULTabPanelsAccessible::GetName(nsAString& aName) -{ - aName.Truncate(); - return NS_OK; -} - /** * XUL Tabs - the s really stands for strip. this is a collection of tab objects */ diff --git a/accessible/src/xul/nsXULTabAccessible.h b/accessible/src/xul/nsXULTabAccessible.h index 38c07d1fa474..aa5eb2929ea2 100644 --- a/accessible/src/xul/nsXULTabAccessible.h +++ b/accessible/src/xul/nsXULTabAccessible.h @@ -72,25 +72,6 @@ public: //NS_IMETHOD GetChildCount(PRInt32 *_retval); // aaronl remove this? }; -/** - * Represents the content area associated with the tabs object (when - * used together) - */ -class nsXULTabPanelsAccessible : public nsAccessibleWrap -{ -public: - nsXULTabPanelsAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell); - NS_IMETHOD GetRole(PRUint32 *_retval); - NS_IMETHOD GetName(nsAString& _retval); - -protected: - nsresult GetAccPluginChild(nsIAccessible **_retval); - - // data members - nsCOMPtr mGParentDOMNode; - nsCOMPtr mParentDOMNode; -}; - /** merely a container of tab obejcts */ class nsXULTabsAccessible : public nsXULSelectableAccessible { diff --git a/content/base/src/nsGkAtomList.h b/content/base/src/nsGkAtomList.h index 82a3cd739d53..f4bff4145594 100755 --- a/content/base/src/nsGkAtomList.h +++ b/content/base/src/nsGkAtomList.h @@ -1361,6 +1361,7 @@ GK_ATOM(bulletFrame, "BulletFrame") GK_ATOM(columnSetFrame, "ColumnSetFrame") GK_ATOM(comboboxControlFrame, "ComboboxControlFrame") GK_ATOM(comboboxDisplayFrame, "ComboboxDisplayFrame") +GK_ATOM(deckFrame, "DeckFrame") GK_ATOM(directionalFrame, "DirectionalFrame") GK_ATOM(fieldSetFrame, "FieldSetFrame") GK_ATOM(frameSetFrame, "FrameSetFrame") diff --git a/layout/xul/base/src/nsDeckFrame.cpp b/layout/xul/base/src/nsDeckFrame.cpp index a64d9fb9558f..1fe5d5498129 100644 --- a/layout/xul/base/src/nsDeckFrame.cpp +++ b/layout/xul/base/src/nsDeckFrame.cpp @@ -80,6 +80,12 @@ nsDeckFrame::nsDeckFrame(nsIPresShell* aPresShell, SetLayoutManager(layout); } +nsIAtom* +nsDeckFrame::GetType() const +{ + return nsGkAtoms::deckFrame; +} + NS_IMETHODIMP nsDeckFrame::AttributeChanged(PRInt32 aNameSpaceID, nsIAtom* aAttribute, diff --git a/layout/xul/base/src/nsDeckFrame.h b/layout/xul/base/src/nsDeckFrame.h index 8397cb8f7181..3e3fc548d67d 100644 --- a/layout/xul/base/src/nsDeckFrame.h +++ b/layout/xul/base/src/nsDeckFrame.h @@ -74,6 +74,8 @@ public: nsIFrame* aParent, nsIFrame* aPrevInFlow); + virtual nsIAtom* GetType() const; + virtual PRBool ChildrenMustHaveWidgets() const { return PR_TRUE; } #ifdef NS_DEBUG diff --git a/toolkit/content/widgets/tabbox.xml b/toolkit/content/widgets/tabbox.xml index 6868d5bc755e..95d03468cff3 100644 --- a/toolkit/content/widgets/tabbox.xml +++ b/toolkit/content/widgets/tabbox.xml @@ -533,14 +533,7 @@ - - - - - - + null