From 9488e18b957ff3a5a70fbd466c02da6a1cf28e3b Mon Sep 17 00:00:00 2001 From: James Kitchener Date: Thu, 4 Oct 2012 23:34:56 +0900 Subject: [PATCH] Bug 768461 - Add Accessible::HasNumericValue() method r=tbsaunde --- accessible/src/generic/Accessible-inl.h | 9 ++++ accessible/src/generic/Accessible.cpp | 4 +- accessible/src/generic/Accessible.h | 42 +++++++++++-------- .../src/generic/FormControlAccessible.h | 1 + accessible/src/xul/XULSliderAccessible.cpp | 1 + 5 files changed, 37 insertions(+), 20 deletions(-) diff --git a/accessible/src/generic/Accessible-inl.h b/accessible/src/generic/Accessible-inl.h index ba2fb32aec9..03b86b64c99 100644 --- a/accessible/src/generic/Accessible-inl.h +++ b/accessible/src/generic/Accessible-inl.h @@ -28,4 +28,13 @@ Accessible::ARIARole() return ARIATransformRole(mRoleMapEntry->role); } +inline bool +Accessible::HasNumericValue() const +{ + if (mFlags & eHasNumericValue) + return true; + + return mRoleMapEntry && mRoleMapEntry->valueRule != eNoValue; +} + #endif diff --git a/accessible/src/generic/Accessible.cpp b/accessible/src/generic/Accessible.cpp index 5dba7eed848..d429c1bd187 100644 --- a/accessible/src/generic/Accessible.cpp +++ b/accessible/src/generic/Accessible.cpp @@ -139,12 +139,12 @@ Accessible::QueryInterface(REFNSIID aIID, void** aInstancePtr) } if (aIID.Equals(NS_GET_IID(nsIAccessibleValue))) { - if (mRoleMapEntry && mRoleMapEntry->valueRule != eNoValue) { + if (HasNumericValue()) { *aInstancePtr = static_cast(this); NS_ADDREF_THIS(); return NS_OK; } - } + } if (aIID.Equals(NS_GET_IID(nsIAccessibleHyperLink))) { if (IsLink()) { diff --git a/accessible/src/generic/Accessible.h b/accessible/src/generic/Accessible.h index 47387b82140..ff33114f6bc 100644 --- a/accessible/src/generic/Accessible.h +++ b/accessible/src/generic/Accessible.h @@ -701,6 +701,11 @@ public: */ bool IsPrimaryForNode() const { return !(mFlags & eSharedNode); } + /** + * Return true if the accessible has a numeric value. + */ + bool HasNumericValue() const; + protected: ////////////////////////////////////////////////////////////////////////////// @@ -751,7 +756,8 @@ protected: enum StateFlags { eIsDefunct = 1 << 2, // accessible is defunct eIsNotInDocument = 1 << 3, // accessible is not in document - eSharedNode = 1 << 4 // accessible shares DOM node from another accessible + eSharedNode = 1 << 4, // accessible shares DOM node from another accessible + eHasNumericValue = 1 << 5 // accessible has a numeric value }; /** @@ -759,23 +765,23 @@ protected: * @note keep these flags in sync with ChildrenFlags and StateFlags */ enum AccessibleTypes { - eApplicationAccessible = 1 << 5, - eAutoCompleteAccessible = 1 << 6, - eAutoCompletePopupAccessible = 1 << 7, - eComboboxAccessible = 1 << 8, - eDocAccessible = 1 << 9, - eHyperTextAccessible = 1 << 10, - eHTMLFileInputAccessible = 1 << 11, - eHTMLListItemAccessible = 1 << 12, - eImageAccessible = 1 << 13, - eImageMapAccessible = 1 << 14, - eListControlAccessible = 1 << 15, - eMenuButtonAccessible = 1 << 16, - eMenuPopupAccessible = 1 << 17, - eRootAccessible = 1 << 18, - eTextLeafAccessible = 1 << 19, - eXULDeckAccessible = 1 << 20, - eXULTreeAccessible = 1 << 21 + eApplicationAccessible = 1 << 6, + eAutoCompleteAccessible = 1 << 7, + eAutoCompletePopupAccessible = 1 << 8, + eComboboxAccessible = 1 << 9, + eDocAccessible = 1 << 10, + eHyperTextAccessible = 1 << 11, + eHTMLFileInputAccessible = 1 << 12, + eHTMLListItemAccessible = 1 << 13, + eImageAccessible = 1 << 14, + eImageMapAccessible = 1 << 15, + eListControlAccessible = 1 << 16, + eMenuButtonAccessible = 1 << 17, + eMenuPopupAccessible = 1 << 18, + eRootAccessible = 1 << 19, + eTextLeafAccessible = 1 << 20, + eXULDeckAccessible = 1 << 21, + eXULTreeAccessible = 1 << 22 }; ////////////////////////////////////////////////////////////////////////////// diff --git a/accessible/src/generic/FormControlAccessible.h b/accessible/src/generic/FormControlAccessible.h index ecfaae340ac..2aa518710ca 100644 --- a/accessible/src/generic/FormControlAccessible.h +++ b/accessible/src/generic/FormControlAccessible.h @@ -21,6 +21,7 @@ public: ProgressMeterAccessible(nsIContent* aContent, DocAccessible* aDoc) : LeafAccessible(aContent, aDoc) { + mFlags = mFlags | eHasNumericValue; } NS_DECL_ISUPPORTS_INHERITED diff --git a/accessible/src/xul/XULSliderAccessible.cpp b/accessible/src/xul/XULSliderAccessible.cpp index 0cda22b807a..390de243dc4 100644 --- a/accessible/src/xul/XULSliderAccessible.cpp +++ b/accessible/src/xul/XULSliderAccessible.cpp @@ -21,6 +21,7 @@ XULSliderAccessible:: XULSliderAccessible(nsIContent* aContent, DocAccessible* aDoc) : AccessibleWrap(aContent, aDoc) { + mFlags = mFlags | eHasNumericValue; } // nsISupports