author | Trevor Saunders <trev.saunders@gmail.com> |
Sun, 10 Apr 2011 08:38:06 +0900 | |
changeset 67790 | f15bfa1cb14b56e067e1cfcf2f2eb75a6b27691d |
parent 67789 | a8449b5e644016c651b590fa9ca5b569bc3c52d5 |
child 67791 | 56d25b561e19d465520d6d369d80b66b194df30c |
push id | 19428 |
push user | eakhgari@mozilla.com |
push date | Sun, 10 Apr 2011 19:11:44 +0000 |
treeherder | mozilla-central@6eaee284fdb9 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | surkov |
bugs | 634218 |
milestone | 2.2a1pre |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/accessible/src/atk/nsAccessibleWrap.cpp +++ b/accessible/src/atk/nsAccessibleWrap.cpp @@ -47,16 +47,17 @@ #include "nsDocAccessibleWrap.h" #include "nsIAccessibleValue.h" #include "nsString.h" #include "nsAutoPtr.h" #include "prprf.h" #include "nsRoleMap.h" #include "nsRelUtils.h" #include "nsStateMap.h" +#include "States.h" #include "nsMaiInterfaceComponent.h" #include "nsMaiInterfaceAction.h" #include "nsMaiInterfaceText.h" #include "nsMaiInterfaceEditableText.h" #include "nsMaiInterfaceSelection.h" #include "nsMaiInterfaceValue.h" #include "nsMaiInterfaceHypertext.h" @@ -791,27 +792,25 @@ ConvertToAtkAttributeSet(nsIPersistentPr objAttr->value = g_strdup(NS_ConvertUTF16toUTF8(value).get()); objAttributeSet = g_slist_prepend(objAttributeSet, objAttr); } //libspi will free it return objAttributeSet; } -AtkAttributeSet * -GetAttributeSet(nsIAccessible* aAccessible) +AtkAttributeSet* +GetAttributeSet(nsAccessible* aAccessible) { nsCOMPtr<nsIPersistentProperties> attributes; aAccessible->GetAttributes(getter_AddRefs(attributes)); if (attributes) { // Deal with attributes that we only need to expose in ATK - PRUint32 state; - aAccessible->GetState(&state, nsnull); - if (state & nsIAccessibleStates::STATE_HASPOPUP) { + if (aAccessible->State() & states::HASPOPUP) { // There is no ATK state for haspopup, must use object attribute to expose the same info nsAutoString oldValueUnused; attributes->SetStringProperty(NS_LITERAL_CSTRING("haspopup"), NS_LITERAL_STRING("true"), oldValueUnused); } return ConvertToAtkAttributeSet(attributes); } @@ -900,60 +899,52 @@ getIndexInParentCB(AtkObject *aAtkObj) nsAccessible *parent = accWrap->GetParent(); if (!parent) { return -1; // No parent } return parent->GetIndexOfEmbeddedChild(accWrap); } -static void TranslateStates(PRUint32 aState, const AtkStateMap *aStateMap, - AtkStateSet *aStateSet) +static void +TranslateStates(PRUint64 aState, AtkStateSet* aStateSet) { - NS_ASSERTION(aStateSet, "Can't pass in null state set"); // Convert every state to an entry in AtkStateMap PRUint32 stateIndex = 0; - PRUint32 bitMask = 1; - while (aStateMap[stateIndex].stateMapEntryType != kNoSuchState) { - if (aStateMap[stateIndex].atkState) { // There's potentially an ATK state for this + PRUint64 bitMask = 1; + while (gAtkStateMap[stateIndex].stateMapEntryType != kNoSuchState) { + if (gAtkStateMap[stateIndex].atkState) { // There's potentially an ATK state for this PRBool isStateOn = (aState & bitMask) != 0; - if (aStateMap[stateIndex].stateMapEntryType == kMapOpposite) { + if (gAtkStateMap[stateIndex].stateMapEntryType == kMapOpposite) { isStateOn = !isStateOn; } if (isStateOn) { - atk_state_set_add_state(aStateSet, aStateMap[stateIndex].atkState); + atk_state_set_add_state(aStateSet, gAtkStateMap[stateIndex].atkState); } } - // Map extended state bitMask <<= 1; ++ stateIndex; } } AtkStateSet * refStateSetCB(AtkObject *aAtkObj) { AtkStateSet *state_set = nsnull; state_set = ATK_OBJECT_CLASS(parent_class)->ref_state_set(aAtkObj); nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj); if (!accWrap) { - TranslateStates(nsIAccessibleStates::EXT_STATE_DEFUNCT, - gAtkStateMapExt, state_set); + TranslateStates(states::DEFUNCT, state_set); return state_set; } // Map states - PRUint32 accState = 0, accExtState = 0; - nsresult rv = accWrap->GetState(&accState, &accExtState); - NS_ENSURE_SUCCESS(rv, state_set); - - TranslateStates(accState, gAtkStateMap, state_set); - TranslateStates(accExtState, gAtkStateMapExt, state_set); + TranslateStates(accWrap->State(), state_set); return state_set; } AtkRelationSet * refRelationSetCB(AtkObject *aAtkObj) { AtkRelationSet *relation_set = nsnull; @@ -1081,19 +1072,17 @@ nsAccessibleWrap::FirePlatformEvent(AccE case nsIAccessibleEvent::EVENT_FOCUS: { MAI_LOG_DEBUG(("\n\nReceived: EVENT_FOCUS\n")); nsRootAccessible* rootAccWrap = accWrap->RootAccessible(); if (rootAccWrap && rootAccWrap->mActivated) { atk_focus_tracker_notify(atkObj); // Fire state change event for focus nsRefPtr<AccEvent> stateChangeEvent = - new AccStateChangeEvent(accessible, - nsIAccessibleStates::STATE_FOCUSED, - PR_FALSE, PR_TRUE); + new AccStateChangeEvent(accessible, states::FOCUSED, PR_TRUE); return FireAtkStateChangeEvent(stateChangeEvent, atkObj); } } break; case nsIAccessibleEvent::EVENT_VALUE_CHANGE: { MAI_LOG_DEBUG(("\n\nReceived: EVENT_VALUE_CHANGE\n")); nsCOMPtr<nsIAccessibleValue> value(do_QueryObject(accessible)); @@ -1332,36 +1321,32 @@ nsresult nsAccessibleWrap::FireAtkStateChangeEvent(AccEvent* aEvent, AtkObject *aObject) { MAI_LOG_DEBUG(("\n\nReceived: EVENT_STATE_CHANGE\n")); AccStateChangeEvent* event = downcast_accEvent(aEvent); NS_ENSURE_TRUE(event, NS_ERROR_FAILURE); - PRUint32 state = event->GetState(); - PRBool isExtra = event->IsExtraState(); PRBool isEnabled = event->IsStateEnabled(); - - PRInt32 stateIndex = AtkStateMap::GetStateIndexFor(state); + PRInt32 stateIndex = AtkStateMap::GetStateIndexFor(event->GetState()); if (stateIndex >= 0) { - const AtkStateMap *atkStateMap = isExtra ? gAtkStateMapExt : gAtkStateMap; - NS_ASSERTION(atkStateMap[stateIndex].stateMapEntryType != kNoSuchState, + NS_ASSERTION(gAtkStateMap[stateIndex].stateMapEntryType != kNoSuchState, "No such state"); - if (atkStateMap[stateIndex].atkState != kNone) { - NS_ASSERTION(atkStateMap[stateIndex].stateMapEntryType != kNoStateChange, + if (gAtkStateMap[stateIndex].atkState != kNone) { + NS_ASSERTION(gAtkStateMap[stateIndex].stateMapEntryType != kNoStateChange, "State changes should not fired for this state"); - if (atkStateMap[stateIndex].stateMapEntryType == kMapOpposite) + if (gAtkStateMap[stateIndex].stateMapEntryType == kMapOpposite) isEnabled = !isEnabled; // Fire state change for first state if there is one to map atk_object_notify_state_change(aObject, - atkStateMap[stateIndex].atkState, + gAtkStateMap[stateIndex].atkState, isEnabled); } } return NS_OK; } nsresult
--- a/accessible/src/atk/nsStateMap.h +++ b/accessible/src/atk/nsStateMap.h @@ -75,90 +75,71 @@ enum EStateMapEntryType { }; const AtkStateType kNone = ATK_STATE_INVALID; struct AtkStateMap { AtkStateType atkState; EStateMapEntryType stateMapEntryType; - static PRInt32 GetStateIndexFor(PRUint32 aState) + static PRInt32 GetStateIndexFor(PRUint64 aState) { PRInt32 stateIndex = -1; while (aState > 0) { ++ stateIndex; aState >>= 1; } return stateIndex; // Returns -1 if not mapped } }; // Map array from cross platform roles to ATK roles -static const AtkStateMap gAtkStateMap[] = { // Cross Platform States - { kNone, kMapOpposite }, // nsIAccessibleStates::STATE_UNAVAILABLE = 0x00000001 - { ATK_STATE_SELECTED, kMapDirectly }, // nsIAccessibleStates::STATE_SELECTED = 0x00000002 - { ATK_STATE_FOCUSED, kMapDirectly }, // nsIAccessibleStates::STATE_FOCUSED = 0x00000004 - { ATK_STATE_PRESSED, kMapDirectly }, // nsIAccessibleStates::STATE_PRESSED = 0x00000008 - { ATK_STATE_CHECKED, kMapDirectly }, // nsIAccessibleStates::STATE_CHECKED = 0x00000010 - { ATK_STATE_INDETERMINATE, kMapDirectly }, // nsIAccessibleStates::STATE_MIXED = 0x00000020 - { kNone, kMapDirectly }, // nsIAccessibleStates::STATE_READONLY = 0x00000040 - { kNone, kMapDirectly }, // nsIAccessibleStates::STATE_HOTTRACKED = 0x00000080 - { ATK_STATE_DEFAULT, kMapDirectly }, // nsIAccessibleStates::STATE_DEFAULT = 0x00000100 - { ATK_STATE_EXPANDED, kMapDirectly }, // nsIAccessibleStates::STATE_EXPANDED = 0x00000200 - { kNone, kNoStateChange }, // nsIAccessibleStates::STATE_COLLAPSED = 0x00000400 - { ATK_STATE_BUSY, kMapDirectly }, // nsIAccessibleStates::STATE_BUSY = 0x00000800 - { kNone, kMapDirectly }, // nsIAccessibleStates::STATE_FLOATING = 0x00001000 - { kNone, kMapDirectly }, // nsIAccessibleStates::STATE_CHECKABLE = 0x00002000 - { ATK_STATE_ANIMATED, kMapDirectly }, // nsIAccessibleStates::STATE_ANIMATED = 0x00004000 - { ATK_STATE_VISIBLE, kMapOpposite }, // nsIAccessibleStates::STATE_INVISIBLE = 0x00008000 - { ATK_STATE_SHOWING, kMapOpposite }, // nsIAccessibleStates::STATE_OFFSCREEN = 0x00010000 - { ATK_STATE_RESIZABLE, kMapDirectly }, // nsIAccessibleStates::STATE_SIZEABLE = 0x00020000 - { kNone, kMapDirectly }, // nsIAccessibleStates::STATE_MOVEABLE = 0x00040000 - { kNone, kMapDirectly }, // nsIAccessibleStates::STATE_SELFVOICING = 0x00080000 - { ATK_STATE_FOCUSABLE, kMapDirectly }, // nsIAccessibleStates::STATE_FOCUSABLE = 0x00100000 - { ATK_STATE_SELECTABLE, kMapDirectly }, // nsIAccessibleStates::STATE_SELECTABLE = 0x00200000 - { kNone, kMapDirectly }, // nsIAccessibleStates::STATE_LINKED = 0x00400000 - { ATK_STATE_VISITED, kMapDirectly }, // nsIAccessibleStates::STATE_TRAVERSED = 0x00800000 - { ATK_STATE_MULTISELECTABLE, kMapDirectly }, // nsIAccessibleStates::STATE_MULTISELECTABLE = 0x01000000 - { kNone, kMapDirectly }, // nsIAccessibleStates::STATE_EXTSELECTABLE = 0x02000000 - { ATK_STATE_REQUIRED, kMapDirectly }, // nsIAccessibleStates::STATE_REQUIRED = 0x04000000 - { kNone, kMapDirectly }, // nsIAccessibleStates::STATE_ALERT_MEDIUM = 0x08000000 - { ATK_STATE_INVALID_ENTRY, kMapDirectly }, // nsIAccessibleStates::STATE_INVALID = 0x10000000 - { kNone, kMapDirectly }, // nsIAccessibleStates::STATE_PROTECTED = 0x20000000 - { kNone, kMapDirectly }, // nsIAccessibleStates::STATE_HASPOPUP = 0x40000000 - { kNone, kNoSuchState }, // = 0x80000000 +static const AtkStateMap gAtkStateMap[] = { // Cross Platform States + { kNone, kMapOpposite }, // states::UNAVAILABLE = 1 << 0 + { ATK_STATE_SELECTED, kMapDirectly }, // states::SELECTED = 1 << 1 + { ATK_STATE_FOCUSED, kMapDirectly }, // states::FOCUSED = 1 << 2 + { ATK_STATE_PRESSED, kMapDirectly }, // states::PRESSED = 1 << 3 + { ATK_STATE_CHECKED, kMapDirectly }, // states::CHECKED = 1 << 4 + { ATK_STATE_INDETERMINATE, kMapDirectly }, // states::MIXED = 1 << 5 + { kNone, kMapDirectly }, // states::READONLY = 1 << 6 + { kNone, kMapDirectly }, // states::HOTTRACKED = 1 << 7 + { ATK_STATE_DEFAULT, kMapDirectly }, // states::DEFAULT = 1 << 8 + { ATK_STATE_EXPANDED, kMapDirectly }, // states::EXPANDED = 1 << 9 + { kNone, kNoStateChange }, // states::COLLAPSED = 1 << 10 + { ATK_STATE_BUSY, kMapDirectly }, // states::BUSY = 1 << 11 + { kNone, kMapDirectly }, // states::FLOATING = 1 << 12 + { kNone, kMapDirectly }, // states::CHECKABLE = 1 << 13 + { ATK_STATE_ANIMATED, kMapDirectly }, // states::ANIMATED = 1 << 14 + { ATK_STATE_VISIBLE, kMapOpposite }, // states::INVISIBLE = 1 << 15 + { ATK_STATE_SHOWING, kMapOpposite }, // states::OFFSCREEN = 1 << 16 + { ATK_STATE_RESIZABLE, kMapDirectly }, // states::SIZEABLE = 1 << 17 + { kNone, kMapDirectly }, // states::MOVEABLE = 1 << 18 + { kNone, kMapDirectly }, // states::SELFVOICING = 1 << 19 + { ATK_STATE_FOCUSABLE, kMapDirectly }, // states::FOCUSABLE = 1 << 20 + { ATK_STATE_SELECTABLE, kMapDirectly }, // states::SELECTABLE = 1 << 21 + { kNone, kMapDirectly }, // states::LINKED = 1 << 22 + { ATK_STATE_VISITED, kMapDirectly }, // states::TRAVERSED = 1 << 23 + { ATK_STATE_MULTISELECTABLE, kMapDirectly }, // states::MULTISELECTABLE = 1 << 24 + { kNone, kMapDirectly }, // states::EXTSELECTABLE = 1 << 25 + { ATK_STATE_REQUIRED, kMapDirectly }, // states::STATE_REQUIRED = 1 << 26 + { kNone, kMapDirectly }, // states::ALERT_MEDIUM = 1 << 27 + { ATK_STATE_INVALID_ENTRY, kMapDirectly }, // states::INVALID = 1 << 28 + { kNone, kMapDirectly }, // states::PROTECTED = 1 << 29 + { kNone, kMapDirectly }, // states::HASPOPUP = 1 << 30 + { ATK_STATE_SUPPORTS_AUTOCOMPLETION, kMapDirectly }, // states::SUPPORTS_AUTOCOMPLETION = 1 << 31 + { ATK_STATE_DEFUNCT, kMapDirectly }, // states::DEFUNCT = 1 << 32 + { ATK_STATE_SELECTABLE_TEXT, kMapDirectly }, // states::SELECTABLE_TEXT = 1 << 33 + { ATK_STATE_EDITABLE, kMapDirectly }, // states::EDITABLE = 1 << 34 + { ATK_STATE_ACTIVE, kMapDirectly }, // states::ACTIVE = 1 << 35 + { ATK_STATE_MODAL, kMapDirectly }, // states::MODAL = 1 << 36 + { ATK_STATE_MULTI_LINE, kMapDirectly }, // states::MULTI_LINE = 1 << 37 + { ATK_STATE_HORIZONTAL, kMapDirectly }, // states::HORIZONTAL = 1 << 38 + { ATK_STATE_OPAQUE, kMapDirectly }, // states::OPAQUE = 1 << 39 + { ATK_STATE_SINGLE_LINE, kMapDirectly }, // states::SINGLE_LINE = 1 << 40 + { ATK_STATE_TRANSIENT, kMapDirectly }, // states::TRANSIENT = 1 << 41 + { ATK_STATE_VERTICAL, kMapDirectly }, // states::VERTICAL = 1 << 42 + { ATK_STATE_STALE, kMapDirectly }, // states::STALE = 1 << 43 + { ATK_STATE_ENABLED, kMapDirectly }, // states::ENABLED = 1 << 44 + { ATK_STATE_SENSITIVE, kMapDirectly }, // states::SENSITIVE = 1 << 45 + { ATK_STATE_EXPANDABLE, kMapDirectly }, // states::EXPANDABLE = 1 << 46 + { kNone, kNoSuchState }, // = 1 << 47 }; - -static const AtkStateMap gAtkStateMapExt[] = { // Cross Platform States - { ATK_STATE_SUPPORTS_AUTOCOMPLETION, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_SUPPORTS_AUTOCOMPLETION = 0x00000001 - { ATK_STATE_DEFUNCT, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_DEFUNCT = 0x00000002 - { ATK_STATE_SELECTABLE_TEXT, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_SELECTABLE_TEXT = 0x00000004 - { ATK_STATE_EDITABLE, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_EDITABLE = 0x00000008 - { ATK_STATE_ACTIVE, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_ACTIVE = 0x00000010 - { ATK_STATE_MODAL, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_MODAL = 0x00000020 - { ATK_STATE_MULTI_LINE, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_MULTI_LINE = 0x00000040 - { ATK_STATE_HORIZONTAL, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_HORIZONTAL = 0x00000080 - { ATK_STATE_OPAQUE, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_OPAQUE = 0x00000100 - { ATK_STATE_SINGLE_LINE, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_SINGLE_LINE = 0x00000200 - { ATK_STATE_TRANSIENT, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_TRANSIENT = 0x00000400 - { ATK_STATE_VERTICAL, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_VERTICAL = 0x00000800 - { ATK_STATE_STALE, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_STALE = 0x00001000 - { ATK_STATE_ENABLED, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_ENABLED = 0x00002000 - { ATK_STATE_SENSITIVE, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_SENSITIVE = 0x00004000 - { ATK_STATE_EXPANDABLE, kMapDirectly }, // nsIAccessibleStates::EXT_STATE_EXPANDABLE = 0x00008000 - { kNone, kNoSuchState }, // = 0x00010000 - { kNone, kNoSuchState }, // = 0x00020000 - { kNone, kNoSuchState }, // = 0x00040000 - { kNone, kNoSuchState }, // = 0x00080000 - { kNone, kNoSuchState }, // = 0x00100000 - { kNone, kNoSuchState }, // = 0x00200000 - { kNone, kNoSuchState }, // = 0x00400000 - { kNone, kNoSuchState }, // = 0x00800000 - { kNone, kNoSuchState }, // = 0x01000000 - { kNone, kNoSuchState }, // = 0x02000000 - { kNone, kNoSuchState }, // = 0x04000000 - { kNone, kNoSuchState }, // = 0x08000000 - { kNone, kNoSuchState }, // = 0x10000000 - { kNone, kNoSuchState }, // = 0x20000000 - { kNone, kNoSuchState }, // = 0x40000000 - { kNone, kNoSuchState }, // = 0x80000000 -};
--- a/accessible/src/base/AccEvent.cpp +++ b/accessible/src/base/AccEvent.cpp @@ -216,49 +216,40 @@ AccEvent::CaptureIsFromUserInput(EIsFrom //////////////////////////////////////////////////////////////////////////////// // AccStateChangeEvent //////////////////////////////////////////////////////////////////////////////// // Note: we pass in eAllowDupes to the base class because we don't currently // support correct state change coalescence (XXX Bug 569356). Also we need to // decide how to coalesce events created via accessible (instead of node). AccStateChangeEvent:: - AccStateChangeEvent(nsAccessible* aAccessible, - PRUint32 aState, PRBool aIsExtraState, + AccStateChangeEvent(nsAccessible* aAccessible, PRUint64 aState, PRBool aIsEnabled, EIsFromUserInput aIsFromUserInput): AccEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE, aAccessible, aIsFromUserInput, eAllowDupes), - mState(aState), mIsExtraState(aIsExtraState), mIsEnabled(aIsEnabled) + mState(aState), mIsEnabled(aIsEnabled) { } AccStateChangeEvent:: - AccStateChangeEvent(nsINode* aNode, PRUint32 aState, PRBool aIsExtraState, - PRBool aIsEnabled): + AccStateChangeEvent(nsINode* aNode, PRUint64 aState, PRBool aIsEnabled): AccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aNode), - mState(aState), mIsExtraState(aIsExtraState), mIsEnabled(aIsEnabled) + mState(aState), mIsEnabled(aIsEnabled) { } AccStateChangeEvent:: - AccStateChangeEvent(nsINode* aNode, PRUint32 aState, PRBool aIsExtraState) : - AccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aNode), - mState(aState), mIsExtraState(aIsExtraState) + AccStateChangeEvent(nsINode* aNode, PRUint64 aState) : + AccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aNode), mState(aState) { // Use GetAccessibleForNode() because we do not want to store an accessible // since it leads to problems with delayed events in the case when // an accessible gets reorder event before delayed event is processed. nsAccessible *accessible = GetAccessibleForNode(); - if (accessible) { - PRUint32 state = 0, extraState = 0; - accessible->GetState(&state, mIsExtraState ? &extraState : nsnull); - mIsEnabled = ((mIsExtraState ? extraState : state) & mState) != 0; - } else { - mIsEnabled = PR_FALSE; - } + mIsEnabled = accessible && ((accessible->State() & mState) != 0); } already_AddRefed<nsAccEvent> AccStateChangeEvent::CreateXPCOMObject() { nsAccEvent* event = new nsAccStateChangeEvent(this); NS_IF_ADDREF(event); return event;
--- a/accessible/src/base/AccEvent.h +++ b/accessible/src/base/AccEvent.h @@ -163,43 +163,39 @@ protected: /** * Accessible state change event. */ class AccStateChangeEvent: public AccEvent { public: - AccStateChangeEvent(nsAccessible* aAccessible, - PRUint32 aState, PRBool aIsExtraState, + AccStateChangeEvent(nsAccessible* aAccessible, PRUint64 aState, PRBool aIsEnabled, EIsFromUserInput aIsFromUserInput = eAutoDetect); - AccStateChangeEvent(nsINode* aNode, PRUint32 aState, PRBool aIsExtraState, - PRBool aIsEnabled); + AccStateChangeEvent(nsINode* aNode, PRUint64 aState, PRBool aIsEnabled); - AccStateChangeEvent(nsINode* aNode, PRUint32 aState, PRBool aIsExtraState); + AccStateChangeEvent(nsINode* aNode, PRUint64 aState); // AccEvent virtual already_AddRefed<nsAccEvent> CreateXPCOMObject(); static const EventGroup kEventGroup = eStateChangeEvent; virtual unsigned int GetEventGroups() const { return AccEvent::GetEventGroups() | (1U << eStateChangeEvent); } // AccStateChangeEvent - PRUint32 GetState() const { return mState; } - PRBool IsExtraState() const { return mIsExtraState; } + PRUint64 GetState() const { return mState; } PRBool IsStateEnabled() const { return mIsEnabled; } private: - PRUint32 mState; - PRBool mIsExtraState; + PRUint64 mState; PRBool mIsEnabled; }; /** * Accessible text change event. */ class AccTextChangeEvent: public AccEvent
--- a/accessible/src/base/AccGroupInfo.cpp +++ b/accessible/src/base/AccGroupInfo.cpp @@ -32,16 +32,18 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "AccGroupInfo.h" +#include "States.h" + AccGroupInfo::AccGroupInfo(nsAccessible* aItem, PRUint32 aRole) : mPosInSet(0), mSetSize(0), mParent(nsnull) { MOZ_COUNT_CTOR(AccGroupInfo); nsAccessible* parent = aItem->GetParent(); if (!parent) return; @@ -54,18 +56,17 @@ AccGroupInfo::AccGroupInfo(nsAccessible* nsAccessible* sibling = parent->GetChildAt(idx); PRUint32 siblingRole = sibling->Role(); // If the sibling is separator then the group is ended. if (siblingRole == nsIAccessibleRole::ROLE_SEPARATOR) break; // If sibling is not visible and hasn't the same base role. - if (BaseRole(siblingRole) != aRole || - nsAccUtils::State(sibling) & nsIAccessibleStates::STATE_INVISIBLE) + if (BaseRole(siblingRole) != aRole || sibling->State() & states::INVISIBLE) continue; // Check if it's hierarchical flatten structure, i.e. if the sibling // level is lesser than this one then group is ended, if the sibling level // is greater than this one then the group is split by some child elements // (group will be continued). PRInt32 siblingLevel = nsAccUtils::GetARIAOrDefaultLevel(sibling); if (siblingLevel < level) { @@ -98,18 +99,17 @@ AccGroupInfo::AccGroupInfo(nsAccessible* PRUint32 siblingRole = sibling->Role(); // If the sibling is separator then the group is ended. if (siblingRole == nsIAccessibleRole::ROLE_SEPARATOR) break; // If sibling is visible and has the same base role - if (BaseRole(siblingRole) != aRole || - nsAccUtils::State(sibling) & nsIAccessibleStates::STATE_INVISIBLE) + if (BaseRole(siblingRole) != aRole || sibling->State() & states::INVISIBLE) continue; // and check if it's hierarchical flatten structure. PRInt32 siblingLevel = nsAccUtils::GetARIAOrDefaultLevel(sibling); if (siblingLevel < level) break; // Skip subset.
new file mode 100644 --- /dev/null +++ b/accessible/src/base/States.h @@ -0,0 +1,309 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:expandtab:shiftwidth=2:tabstop=2: */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Trevor Saunders + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Trevor Saunders <trev.saunders@gmail.com> (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef _states_h_ +#define _states_h_ + +#include <prtypes.h> + +namespace states { + + /** + * The object is disabled, opposite to enabled and sensitive. + */ + const PRUint64 UNAVAILABLE = ((PRUint64) 0x1) << 0; + + /** + * The object is selected. + */ + const PRUint64 SELECTED = ((PRUint64) 0x1) << 1; + + /** + * The object has the keyboard focus. + */ + const PRUint64 FOCUSED = ((PRUint64) 0x1) << 2; + + /** + * The object is pressed. + */ + const PRUint64 PRESSED = ((PRUint64) 0x1) << 3; + + /** + * The checkable object is checked, applied to check box controls, + * @see CHECKABLE and MIXED states. + */ + const PRUint64 CHECKED = ((PRUint64) 0x1) << 4; + + /** + * Indicates that the state of a three-state check box or tool bar button is + * undetermined. The check box is neither checked or unchecked, and is + * in the third or mixed state. + */ + const PRUint64 MIXED = ((PRUint64) 0x1) << 5; + + /** + * The object is designated read-only, so it can't be edited. + */ + const PRUint64 READONLY = ((PRUint64) 0x1) << 6; + + /** + * The object is hot-tracked by the mouse, which means that its appearance + * has changed to indicate that the mouse pointer is located over it. + * + * This is currently unused. + */ + const PRUint64 HOTTRACKED = ((PRUint64) 0x1) << 7; + + /** + * This object is the default button in a window. + */ + const PRUint64 DEFAULT = ((PRUint64) 0x1) << 8; + + /** + * The expandable object's children are displayed, the opposite of collapsed, + * applied to trees, list and other controls. + * @see COLLAPSED state + */ + const PRUint64 EXPANDED = ((PRUint64) 0x1) << 9; + + /** + * The expandable object's children are not displayed, the opposite of + * expanded, applied to tree lists and other controls, + * @see EXPANDED state. + */ + const PRUint64 COLLAPSED = ((PRUint64) 0x1) << 10; + + /** + * The control or document can not accept input at this time. + */ + const PRUint64 BUSY = ((PRUint64) 0x1) << 11; + + /** + * The object is out of normal flow, may be outside of boundaries of its + * parent. + */ + const PRUint64 FLOATING = ((PRUint64) 0x1) << 12; + + /** + * The object can be checked. + */ + const PRUint64 CHECKABLE = ((PRUint64) 0x1) << 13; + + /** + * This object is a graphic which is rapidly changing appearance. + */ + const PRUint64 ANIMATED = ((PRUint64) 0x1) << 14; + + /** + * The object is programmatically hidden. + * So user action like scrolling or switching tabs won't make this visible. + */ + const PRUint64 INVISIBLE = ((PRUint64) 0x1) << 15; + + /** + * The object is scrolled off screen. + * User action such as scrolling or changing tab may make the object + * visible. + */ + const PRUint64 OFFSCREEN = ((PRUint64) 0x1) << 16; + + /** + * The object can be resized. + */ + const PRUint64 SIZEABLE = ((PRUint64) 0x1) << 17; + + /** + * The object can be moved to a different position. + */ + const PRUint64 MOVEABLE = ((PRUint64) 0x1) << 18; + + /** + * The object describes itself with speech. + * Other speech related assistive technology may want to avoid speaking + * information about this object, because the object is already doing this. + */ + const PRUint64 SELFVOICING = ((PRUint64) 0x1) << 19; + + /** + * The object can have the focus and become focused. + */ + const PRUint64 FOCUSABLE = ((PRUint64) 0x1) << 20; + + /** + * The object can be selected. + */ + const PRUint64 SELECTABLE = ((PRUint64) 0x1) << 21; + + /** + * This object is a link. + */ + const PRUint64 LINKED = ((PRUint64) 0x1) << 22; + + /** + * This is used for links that have been traversed + * i.e. the linked page has been visited. + */ + const PRUint64 TRAVERSED = ((PRUint64) 0x1) << 23; + + /** + * Supports multiple selection. + */ + const PRUint64 MULTISELECTABLE = ((PRUint64) 0x1) << 24; + + /** + * Supports extended selection. + * All objects supporting this are also multipselectable. + * This only makes sense for msaa see bug 635690. + */ + const PRUint64 EXTSELECTABLE = ((PRUint64) 0x1) << 25; + + /** + * The user is required to interact with this object. + */ + const PRUint64 REQUIRED = ((PRUint64) 0x1) << 26; + + /** + * The object is an alert, notifying the user of something important. + */ + const PRUint64 ALERT = ((PRUint64) 0x1) << 27; + + /** + * Used for text fields containing invalid values. + */ + const PRUint64 INVALID = ((PRUint64) 0x1) << 28; + + /** + * The controls value can not be obtained, and is returned as a set of "*"s. + */ + const PRUint64 PROTECTED = ((PRUint64) 0x1) << 29; + + /** + * The object can be invoked to show a pop up menu or window. + */ + const PRUint64 HASPOPUP = ((PRUint64) 0x1) << 30; + + /** + * The editable area has some kind of autocompletion. + */ + const PRUint64 SUPPORTS_AUTOCOMPLETION = ((PRUint64) 0x1) << 31; + + /** + * The object is no longer available to be queried. + */ + const PRUint64 DEFUNCT = ((PRUint64) 0x1) << 32; + + /** + * The text is selectable, the object must implement the text interface. + */ + const PRUint64 SELECTABLE_TEXT = ((PRUint64) 0x1) << 33; + + /** + * The text in this object can be edited. + */ + const PRUint64 EDITABLE = ((PRUint64) 0x1) << 34; + + /** + * This window is currently the active window. + */ + const PRUint64 ACTIVE = ((PRUint64) 0x1) << 35; + + /** + * Indicates that the object is modal. Modal objects have the behavior + * that something must be done with the object before the user can + * interact with an object in a different window. + */ + const PRUint64 MODAL = ((PRUint64) 0x1) << 36; + + /** + * Edit control that can take multiple lines. + */ + const PRUint64 MULTI_LINE = ((PRUint64) 0x1) << 37; + + /** + * Uses horizontal layout. + */ + const PRUint64 HORIZONTAL = ((PRUint64) 0x1) << 38; + + /** + * Indicates this object paints every pixel within its rectangular region. + */ + const PRUint64 OPAQUE1 = ((PRUint64) 0x1) << 39; + + /** + * This text object can only contain 1 line of text. + */ + const PRUint64 SINGLE_LINE = ((PRUint64) 0x1) << 40; + + /** + * The parent object manages descendants, and this object may only exist + * while it is visible or has focus. + * For example the focused cell of a table or the current element of a list box may have this state. + */ + const PRUint64 TRANSIENT = ((PRUint64) 0x1) << 41; + + /** + * Uses vertical layout. + * Especially used for sliders and scrollbars. + */ + const PRUint64 VERTICAL = ((PRUint64) 0x1) << 42; + + /** + * Object not dead, but not up-to-date either. + */ + const PRUint64 STALE = ((PRUint64) 0x1) << 43; + + /** + * A widget that is not unavailable. + */ + const PRUint64 ENABLED = ((PRUint64) 0x1) << 44; + + /** + * Same as ENABLED state for now see bug 636158 + */ + const PRUint64 SENSITIVE = ((PRUint64) 0x1) << 45; + + /** + * The object is expandable, provides a UI to expand/collapse its children + * @see EXPANDED and COLLAPSED states. + */ + const PRUint64 EXPANDABLE = ((PRUint64) 0x1) << 46; +} + +#endif +
--- a/accessible/src/base/filters.cpp +++ b/accessible/src/base/filters.cpp @@ -34,27 +34,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "filters.h" #include "nsAccessible.h" #include "nsAccUtils.h" +#include "States.h" bool filters::GetSelected(nsAccessible* aAccessible) { - return nsAccUtils::State(aAccessible) & nsIAccessibleStates::STATE_SELECTED; + return aAccessible->State() & states::SELECTED; } bool filters::GetSelectable(nsAccessible* aAccessible) { - return nsAccUtils::State(aAccessible) & nsIAccessibleStates::STATE_SELECTABLE; + return aAccessible->State() & states::SELECTABLE; } bool filters::GetRow(nsAccessible* aAccessible) { return aAccessible->Role() == nsIAccessibleRole::ROLE_ROW; }
--- a/accessible/src/base/nsARIAGridAccessible.cpp +++ b/accessible/src/base/nsARIAGridAccessible.cpp @@ -35,16 +35,17 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsARIAGridAccessible.h" #include "AccIterator.h" #include "nsAccUtils.h" +#include "States.h" #include "nsIMutableArray.h" #include "nsComponentManagerUtils.h" //////////////////////////////////////////////////////////////////////////////// // nsARIAGridAccessible //////////////////////////////////////////////////////////////////////////////// @@ -1104,43 +1105,37 @@ nsARIAGridCellAccessible::IsSelected(PRB *aIsSelected = PR_TRUE; return NS_OK; } //////////////////////////////////////////////////////////////////////////////// // nsAccessible -nsresult -nsARIAGridCellAccessible::GetARIAState(PRUint32 *aState, PRUint32 *aExtraState) +void +nsARIAGridCellAccessible::ApplyARIAState(PRUint64* aState) { - nsresult rv = nsHyperTextAccessibleWrap::GetARIAState(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + nsHyperTextAccessibleWrap::ApplyARIAState(aState); // Return if the gridcell has aria-selected="true". - if (*aState & nsIAccessibleStates::STATE_SELECTED) - return NS_OK; + if (*aState & states::SELECTED) + return; // Check aria-selected="true" on the row. nsAccessible* row = GetParent(); if (!row || row->Role() != nsIAccessibleRole::ROLE_ROW) - return NS_OK; + return; nsIContent *rowContent = row->GetContent(); if (nsAccUtils::HasDefinedARIAToken(rowContent, nsAccessibilityAtoms::aria_selected) && !rowContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::aria_selected, - nsAccessibilityAtoms::_false, eCaseMatters)) { - - *aState |= nsIAccessibleStates::STATE_SELECTABLE | - nsIAccessibleStates::STATE_SELECTED; - } - - return NS_OK; + nsAccessibilityAtoms::_false, eCaseMatters)) + *aState |= states::SELECTABLE | states::SELECTED; } nsresult nsARIAGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes) { if (IsDefunct()) return NS_ERROR_FAILURE;
--- a/accessible/src/base/nsARIAGridAccessible.h +++ b/accessible/src/base/nsARIAGridAccessible.h @@ -114,13 +114,13 @@ public: // nsISupports NS_DECL_ISUPPORTS_INHERITED // nsIAccessibleTableCell NS_DECL_NSIACCESSIBLETABLECELL // nsAccessible - virtual nsresult GetARIAState(PRUint32 *aState, PRUint32 *aExtraState); + virtual void ApplyARIAState(PRUint64* aState); virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes); }; #endif
--- a/accessible/src/base/nsARIAMap.cpp +++ b/accessible/src/base/nsARIAMap.cpp @@ -35,17 +35,17 @@ * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsARIAMap.h" #include "nsIAccessibleRole.h" -#include "nsIAccessibleStates.h" +#include "States.h" #include "nsAccessibilityAtoms.h" #include "nsIContent.h" /** * This list of WAI-defined roles are currently hardcoded. * Eventually we will most likely be loading an RDF resource that contains this information * Using RDF will also allow for role extensibility. See bug 280138. @@ -91,17 +91,17 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] }, { "article", nsIAccessibleRole::ROLE_DOCUMENT, kUseMapRole, eNoValue, eNoAction, eNoLiveAttr, - nsIAccessibleStates::STATE_READONLY + states::READONLY }, { "button", nsIAccessibleRole::ROLE_PUSHBUTTON, kUseMapRole, eNoValue, eClickAction, eNoLiveAttr, @@ -132,17 +132,17 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] }, { "combobox", nsIAccessibleRole::ROLE_COMBOBOX, kUseMapRole, eHasValueMinMax, eOpenCloseAction, eNoLiveAttr, - nsIAccessibleStates::STATE_COLLAPSED | nsIAccessibleStates::STATE_HASPOPUP, + states::COLLAPSED | states::HASPOPUP, eARIAAutoComplete, eARIAReadonly }, { "dialog", nsIAccessibleRole::ROLE_DIALOG, kUseMapRole, eNoValue, @@ -161,26 +161,26 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] }, { "document", nsIAccessibleRole::ROLE_DOCUMENT, kUseMapRole, eNoValue, eNoAction, eNoLiveAttr, - nsIAccessibleStates::STATE_READONLY + states::READONLY }, { "grid", nsIAccessibleRole::ROLE_TABLE, kUseMapRole, eNoValue, eNoAction, eNoLiveAttr, - nsIAccessibleStates::STATE_FOCUSABLE, + states::FOCUSABLE, eARIAMultiSelectable, eARIAReadonly }, { "gridcell", nsIAccessibleRole::ROLE_GRID_CELL, kUseMapRole, eNoValue, @@ -228,26 +228,26 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] }, { "link", nsIAccessibleRole::ROLE_LINK, kUseMapRole, eNoValue, eJumpAction, eNoLiveAttr, - nsIAccessibleStates::STATE_LINKED + states::LINKED }, { "list", nsIAccessibleRole::ROLE_LIST, kUseMapRole, eNoValue, eNoAction, eNoLiveAttr, - nsIAccessibleStates::STATE_READONLY, + states::READONLY, eARIAMultiSelectable }, { "listbox", nsIAccessibleRole::ROLE_LISTBOX, kUseMapRole, eNoValue, eNoAction, @@ -258,17 +258,17 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] }, { "listitem", nsIAccessibleRole::ROLE_LISTITEM, kUseMapRole, eNoValue, eNoAction, // XXX: should depend on state, parent accessible eNoLiveAttr, - nsIAccessibleStates::STATE_READONLY, + states::READONLY, eARIASelectable, eARIACheckedMixed }, { "log", nsIAccessibleRole::ROLE_NOTHING, kUseNativeRole, eNoValue, @@ -365,17 +365,17 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] }, { "progressbar", nsIAccessibleRole::ROLE_PROGRESSBAR, kUseMapRole, eHasValueMinMax, eNoAction, eNoLiveAttr, - nsIAccessibleStates::STATE_READONLY + states::READONLY }, { "radio", nsIAccessibleRole::ROLE_RADIOBUTTON, kUseMapRole, eNoValue, eSelectAction, eNoLiveAttr, @@ -595,96 +595,85 @@ nsRoleMapEntry nsARIAMap::gEmptyRoleMap }; nsStateMapEntry nsARIAMap::gWAIStateMap[] = { // eARIANone nsStateMapEntry(), // eARIAAutoComplete nsStateMapEntry(&nsAccessibilityAtoms::aria_autocomplete, - "inline", 0, nsIAccessibleStates::EXT_STATE_SUPPORTS_AUTOCOMPLETION, - "list", nsIAccessibleStates::STATE_HASPOPUP, nsIAccessibleStates::EXT_STATE_SUPPORTS_AUTOCOMPLETION, - "both", nsIAccessibleStates::STATE_HASPOPUP, nsIAccessibleStates::EXT_STATE_SUPPORTS_AUTOCOMPLETION), + "inline", states::SUPPORTS_AUTOCOMPLETION, + "list", states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION, + "both", states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION), // eARIABusy nsStateMapEntry(&nsAccessibilityAtoms::aria_busy, - "true", nsIAccessibleStates::STATE_BUSY, 0, - "error", nsIAccessibleStates::STATE_INVALID, 0), + "true", states::BUSY, + "error", states::INVALID), // eARIACheckableBool nsStateMapEntry(&nsAccessibilityAtoms::aria_checked, kBoolType, - nsIAccessibleStates::STATE_CHECKABLE, - nsIAccessibleStates::STATE_CHECKED, 0, - 0, 0, PR_TRUE), + states::CHECKABLE, states::CHECKED, 0, PR_TRUE), // eARIACheckableMixed nsStateMapEntry(&nsAccessibilityAtoms::aria_checked, kMixedType, - nsIAccessibleStates::STATE_CHECKABLE, - nsIAccessibleStates::STATE_CHECKED, 0, - 0, 0, PR_TRUE), + states::CHECKABLE, states::CHECKED, 0, PR_TRUE), // eARIACheckedMixed nsStateMapEntry(&nsAccessibilityAtoms::aria_checked, kMixedType, - nsIAccessibleStates::STATE_CHECKABLE, - nsIAccessibleStates::STATE_CHECKED, 0), + states::CHECKABLE, states::CHECKED, 0), // eARIADisabled - nsStateMapEntry(&nsAccessibilityAtoms::aria_disabled, kBoolType, 0, - nsIAccessibleStates::STATE_UNAVAILABLE, 0), + nsStateMapEntry(&nsAccessibilityAtoms::aria_disabled, kBoolType, + 0, states::UNAVAILABLE), // eARIAExpanded - nsStateMapEntry(&nsAccessibilityAtoms::aria_expanded, kBoolType, 0, - nsIAccessibleStates::STATE_EXPANDED, 0, - nsIAccessibleStates::STATE_COLLAPSED, 0), + nsStateMapEntry(&nsAccessibilityAtoms::aria_expanded, kBoolType, + 0, states::EXPANDED, states::COLLAPSED), // eARIAHasPopup - nsStateMapEntry(&nsAccessibilityAtoms::aria_haspopup, kBoolType, 0, - nsIAccessibleStates::STATE_HASPOPUP, 0), + nsStateMapEntry(&nsAccessibilityAtoms::aria_haspopup, kBoolType, + 0, states::HASPOPUP), // eARIAInvalid - nsStateMapEntry(&nsAccessibilityAtoms::aria_invalid, kBoolType, 0, - nsIAccessibleStates::STATE_INVALID, 0), + nsStateMapEntry(&nsAccessibilityAtoms::aria_invalid, kBoolType, + 0, states::INVALID), // eARIAMultiline - nsStateMapEntry(&nsAccessibilityAtoms::aria_multiline, kBoolType, 0, - 0, nsIAccessibleStates::EXT_STATE_MULTI_LINE, - 0, nsIAccessibleStates::EXT_STATE_SINGLE_LINE, PR_TRUE), + nsStateMapEntry(&nsAccessibilityAtoms::aria_multiline, kBoolType, + 0, states::MULTI_LINE, states::SINGLE_LINE, PR_TRUE), // eARIAMultiSelectable - nsStateMapEntry(&nsAccessibilityAtoms::aria_multiselectable, kBoolType, 0, - nsIAccessibleStates::STATE_MULTISELECTABLE | nsIAccessibleStates::STATE_EXTSELECTABLE, 0), + nsStateMapEntry(&nsAccessibilityAtoms::aria_multiselectable, kBoolType, + 0, states::MULTISELECTABLE | states::EXTSELECTABLE), // eARIAOrientation nsStateMapEntry(&nsAccessibilityAtoms::aria_orientation, eUseFirstState, - "vertical", 0, nsIAccessibleStates::EXT_STATE_VERTICAL, - "horizontal", 0, nsIAccessibleStates::EXT_STATE_HORIZONTAL), + "vertical", states::VERTICAL, + "horizontal", states::HORIZONTAL), // eARIAPressed nsStateMapEntry(&nsAccessibilityAtoms::aria_pressed, kMixedType, - nsIAccessibleStates::STATE_CHECKABLE, - nsIAccessibleStates::STATE_PRESSED, 0), + states::CHECKABLE, states::PRESSED), // eARIAReadonly - nsStateMapEntry(&nsAccessibilityAtoms::aria_readonly, kBoolType, 0, - nsIAccessibleStates::STATE_READONLY, 0), + nsStateMapEntry(&nsAccessibilityAtoms::aria_readonly, kBoolType, + 0, states::READONLY), // eARIAReadonlyOrEditable - nsStateMapEntry(&nsAccessibilityAtoms::aria_readonly, kBoolType, 0, - nsIAccessibleStates::STATE_READONLY, 0, - 0, nsIAccessibleStates::EXT_STATE_EDITABLE, PR_TRUE), + nsStateMapEntry(&nsAccessibilityAtoms::aria_readonly, kBoolType, + 0, states::READONLY, states::EDITABLE, PR_TRUE), // eARIARequired - nsStateMapEntry(&nsAccessibilityAtoms::aria_required, kBoolType, 0, - nsIAccessibleStates::STATE_REQUIRED, 0), + nsStateMapEntry(&nsAccessibilityAtoms::aria_required, kBoolType, + 0, states::REQUIRED), // eARIASelectable nsStateMapEntry(&nsAccessibilityAtoms::aria_selected, kBoolType, - nsIAccessibleStates::STATE_SELECTABLE, - nsIAccessibleStates::STATE_SELECTED, 0, - 0, 0, PR_TRUE) + states::SELECTABLE, states::SELECTED, 0, PR_TRUE) }; /** * Universal (Global) states: * The following state rules are applied to any accessible element, * whether there is an ARIA role or not: */ eStateMapEntryID nsARIAMap::gWAIUnivStateMap[] = { @@ -747,93 +736,76 @@ PRUint32 nsARIAMap::gWAIUnivAttrMapLengt // nsStateMapEntry nsStateMapEntry::nsStateMapEntry() : mAttributeName(nsnull), mIsToken(PR_FALSE), mPermanentState(0), mValue1(nsnull), mState1(0), - mExtraState1(0), mValue2(nsnull), mState2(0), - mExtraState2(0), mValue3(nsnull), mState3(0), - mExtraState3(0), mDefaultState(0), - mDefaultExtraState(0), mDefinedIfAbsent(PR_FALSE) {} -nsStateMapEntry::nsStateMapEntry(nsIAtom **aAttrName, eStateValueType aType, - PRUint32 aPermanentState, - PRUint32 aTrueState, PRUint32 aTrueExtraState, - PRUint32 aFalseState, PRUint32 aFalseExtraState, +nsStateMapEntry::nsStateMapEntry(nsIAtom** aAttrName, eStateValueType aType, + PRUint64 aPermanentState, + PRUint64 aTrueState, + PRUint64 aFalseState, PRBool aDefinedIfAbsent) : mAttributeName(aAttrName), mIsToken(PR_TRUE), mPermanentState(aPermanentState), mValue1("false"), mState1(aFalseState), - mExtraState1(aFalseExtraState), mValue2(nsnull), mState2(0), - mExtraState2(0), mValue3(nsnull), mState3(0), - mExtraState3(0), mDefaultState(aTrueState), - mDefaultExtraState(aTrueExtraState), mDefinedIfAbsent(aDefinedIfAbsent) { if (aType == kMixedType) { mValue2 = "mixed"; - mState2 = nsIAccessibleStates::STATE_MIXED; + mState2 = states::MIXED; } } -nsStateMapEntry::nsStateMapEntry(nsIAtom **aAttrName, - const char *aValue1, - PRUint32 aState1, PRUint32 aExtraState1, - const char *aValue2, - PRUint32 aState2, PRUint32 aExtraState2, - const char *aValue3, - PRUint32 aState3, PRUint32 aExtraState3) : +nsStateMapEntry::nsStateMapEntry(nsIAtom** aAttrName, + const char* aValue1, PRUint64 aState1, + const char* aValue2, PRUint64 aState2, + const char* aValue3, PRUint64 aState3) : mAttributeName(aAttrName), mIsToken(PR_FALSE), mPermanentState(0), - mValue1(aValue1), mState1(aState1), mExtraState1(aExtraState1), - mValue2(aValue2), mState2(aState2), mExtraState2(aExtraState2), - mValue3(aValue3), mState3(aState3), mExtraState3(aExtraState3), - mDefaultState(0), mDefaultExtraState(0), mDefinedIfAbsent(PR_FALSE) + mValue1(aValue1), mState1(aState1), + mValue2(aValue2), mState2(aState2), + mValue3(aValue3), mState3(aState3), + mDefaultState(0), mDefinedIfAbsent(PR_FALSE) { } -nsStateMapEntry::nsStateMapEntry(nsIAtom **aAttrName, +nsStateMapEntry::nsStateMapEntry(nsIAtom** aAttrName, EDefaultStateRule aDefaultStateRule, - const char *aValue1, - PRUint32 aState1, PRUint32 aExtraState1, - const char *aValue2, - PRUint32 aState2, PRUint32 aExtraState2, - const char *aValue3, - PRUint32 aState3, PRUint32 aExtraState3) : + const char* aValue1, PRUint64 aState1, + const char* aValue2, PRUint64 aState2, + const char* aValue3, PRUint64 aState3) : mAttributeName(aAttrName), mIsToken(PR_TRUE), mPermanentState(0), - mValue1(aValue1), mState1(aState1), mExtraState1(aExtraState1), - mValue2(aValue2), mState2(aState2), mExtraState2(aExtraState2), - mValue3(aValue3), mState3(aState3), mExtraState3(aExtraState3), - mDefaultState(0), mDefaultExtraState(0), mDefinedIfAbsent(PR_TRUE) + mValue1(aValue1), mState1(aState1), + mValue2(aValue2), mState2(aState2), + mValue3(aValue3), mState3(aState3), + mDefaultState(0), mDefinedIfAbsent(PR_TRUE) { - if (aDefaultStateRule == eUseFirstState) { + if (aDefaultStateRule == eUseFirstState) mDefaultState = aState1; - mDefaultExtraState = aExtraState1; - } } PRBool -nsStateMapEntry::MapToStates(nsIContent *aContent, - PRUint32 *aState, PRUint32 *aExtraState, +nsStateMapEntry::MapToStates(nsIContent* aContent, PRUint64* aState, eStateMapEntryID aStateMapEntryID) { // Return true if we should continue. if (aStateMapEntryID == eARIANone) return PR_FALSE; const nsStateMapEntry& entry = nsARIAMap::gWAIStateMap[aStateMapEntryID]; @@ -841,19 +813,16 @@ nsStateMapEntry::MapToStates(nsIContent // If attribute is considered as defined when it's absent then let's act // attribute value is "false" supposedly. PRBool hasAttr = aContent->HasAttr(kNameSpaceID_None, *entry.mAttributeName); if (entry.mDefinedIfAbsent && !hasAttr) { if (entry.mPermanentState) *aState |= entry.mPermanentState; if (entry.mState1) *aState |= entry.mState1; - if (aExtraState && entry.mExtraState1) - *aExtraState |= entry.mExtraState1; - return PR_TRUE; } // We only have attribute state mappings for NMTOKEN (and boolean) based // ARIA attributes. According to spec, a value of "undefined" is to be // treated equivalent to "", or the absence of the attribute. We bail out // for this case here. // Note: If this method happens to be called with a non-token based @@ -882,45 +851,34 @@ nsStateMapEntry::MapToStates(nsIContent // states. PRBool applyDefaultStates = PR_TRUE; if (entry.mValue1) { if (attrValue.EqualsASCII(entry.mValue1)) { applyDefaultStates = PR_FALSE; if (entry.mState1) *aState |= entry.mState1; - - if (aExtraState && entry.mExtraState1) - *aExtraState |= entry.mExtraState1; - } else if (entry.mValue2) { if (attrValue.EqualsASCII(entry.mValue2)) { applyDefaultStates = PR_FALSE; if (entry.mState2) *aState |= entry.mState2; - if (aExtraState && entry.mExtraState2) - *aExtraState |= entry.mExtraState2; - } else if (entry.mValue3) { if (attrValue.EqualsASCII(entry.mValue3)) { applyDefaultStates = PR_FALSE; if (entry.mState3) *aState |= entry.mState3; - if (aExtraState && entry.mExtraState3) - *aExtraState |= entry.mExtraState3; } } } } if (applyDefaultStates) { if (entry.mDefaultState) *aState |= entry.mDefaultState; - if (entry.mDefaultExtraState && aExtraState) - *aExtraState |= entry.mDefaultExtraState; } return PR_TRUE; }
--- a/accessible/src/base/nsARIAMap.h +++ b/accessible/src/base/nsARIAMap.h @@ -194,81 +194,72 @@ public: /** * Used to create stub. */ nsStateMapEntry(); /** * Used for ARIA attributes having boolean or mixed values. */ - nsStateMapEntry(nsIAtom **aAttrName, eStateValueType aType, - PRUint32 aPermanentState, - PRUint32 aTrueState, PRUint32 aTrueExtraState, - PRUint32 aFalseState = 0, PRUint32 aFalseExtraState = 0, + nsStateMapEntry(nsIAtom** aAttrName, eStateValueType aType, + PRUint64 aPermanentState, + PRUint64 aTrueState, + PRUint64 aFalseState = 0, PRBool aDefinedIfAbsent = PR_FALSE); /** * Used for ARIA attributes having enumerated values. */ - nsStateMapEntry(nsIAtom **aAttrName, - const char *aValue1, PRUint32 aState1, PRUint32 aExtraState1, - const char *aValue2, PRUint32 aState2, PRUint32 aExtraState2, - const char *aValue3 = 0, PRUint32 aState3 = 0, - PRUint32 aExtraState3 = 0); + nsStateMapEntry(nsIAtom** aAttrName, + const char* aValue1, PRUint64 aState1, + const char* aValue2, PRUint64 aState2, + const char* aValue3 = 0, PRUint64 aState3 = 0); /** * Used for ARIA attributes having enumerated values, and where a default * attribute state should be assumed when not supplied by the author. */ - nsStateMapEntry(nsIAtom **aAttrName, - EDefaultStateRule aDefaultStateRule, - const char *aValue1, PRUint32 aState1, PRUint32 aExtraState1, - const char *aValue2, PRUint32 aState2, PRUint32 aExtraState2, - const char *aValue3 = 0, PRUint32 aState3 = 0, - PRUint32 aExtraState3 = 0); + nsStateMapEntry(nsIAtom** aAttrName, EDefaultStateRule aDefaultStateRule, + const char* aValue1, PRUint64 aState1, + const char* aValue2, PRUint64 aState2, + const char* aValue3 = 0, PRUint64 aState3 = 0); /** * Maps ARIA state map pointed by state map entry ID to accessible states. * * @param aContent [in] node of the accessible * @param aState [in/out] accessible states - * @param aExtraState [in/out] accessible extra states * @param aStateMapEntryID [in] state map entry ID * @return true if state map entry ID is valid */ - static PRBool MapToStates(nsIContent *aContent, - PRUint32 *aState, PRUint32 *aExtraState, + static PRBool MapToStates(nsIContent* aContent, PRUint64* aState, eStateMapEntryID aStateMapEntryID); private: // ARIA attribute name nsIAtom** mAttributeName; // Indicates if attribute is token (can be undefined) PRBool mIsToken; // State applied always if attribute is defined - PRUint32 mPermanentState; + PRUint64 mPermanentState; // States applied if attribute value is matched to the stored value const char* mValue1; - PRUint32 mState1; - PRUint32 mExtraState1; + PRUint64 mState1; const char* mValue2; - PRUint32 mState2; - PRUint32 mExtraState2; + PRUint64 mState2; const char* mValue3; - PRUint32 mState3; - PRUint32 mExtraState3; + PRUint64 mState3; // States applied if no stored values above are matched - PRUint32 mDefaultState; - PRUint32 mDefaultExtraState; + PRUint64 mDefaultState; // Permanent and false states are applied if attribute is absent PRBool mDefinedIfAbsent; }; //////////////////////////////////////////////////////////////////////////////// // Role map entry @@ -293,17 +284,17 @@ struct nsRoleMapEntry // Action mapping rule, how to expose nsIAccessible action EActionRule actionRule; // 'live' and 'container-live' object attributes mapping rule: how to expose // these object attributes if ARIA 'live' attribute is missed. ELiveAttrRule liveAttRule; // Automatic state mapping rule: always include in nsIAccessibleStates - PRUint32 state; // or kNoReqStates if no nsIAccessibleStates are automatic for this role. + PRUint64 state; // or kNoReqStates if no nsIAccessibleStates are automatic for this role. // ARIA properties supported for this role // (in other words, the aria-foo attribute to nsIAccessibleStates mapping rules) // Currently you cannot have unlimited mappings, because // a variable sized array would not allow the use of // C++'s struct initialization feature. eStateMapEntryID attributeMap1; eStateMapEntryID attributeMap2;
--- a/accessible/src/base/nsAccDocManager.cpp +++ b/accessible/src/base/nsAccDocManager.cpp @@ -38,16 +38,17 @@ #include "nsAccDocManager.h" #include "nsAccessibilityService.h" #include "nsAccUtils.h" #include "nsApplicationAccessible.h" #include "nsOuterDocAccessible.h" #include "nsRootAccessibleWrap.h" +#include "States.h" #include "nsCURILoader.h" #include "nsDocShellLoadTypes.h" #include "nsIChannel.h" #include "nsIContentViewer.h" #include "nsIDOMDocument.h" #include "nsIEventListenerManager.h" #include "nsIDOMEventTarget.h" @@ -216,18 +217,17 @@ nsAccDocManager::OnStateChange(nsIWebPro // Mark the document accessible as loading, if it stays alive then we'll mark // it as loaded when we receive proper notification. docAcc->MarkAsLoading(); // Fire state busy change event. Use delayed event since we don't care // actually if event isn't delivered when the document goes away like a shot. nsRefPtr<AccEvent> stateEvent = - new AccStateChangeEvent(document, nsIAccessibleStates::STATE_BUSY, - PR_FALSE, PR_TRUE); + new AccStateChangeEvent(document, states::BUSY, PR_TRUE); docAcc->FireDelayedAccessibleEvent(stateEvent); return NS_OK; } NS_IMETHODIMP nsAccDocManager::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, @@ -351,18 +351,17 @@ nsAccDocManager::HandleDOMDocumentLoad(n // Fire complete/load stopped if the load event type is given. if (aLoadEventType) { nsRefPtr<AccEvent> loadEvent = new AccEvent(aLoadEventType, aDocument); docAcc->FireDelayedAccessibleEvent(loadEvent); } // Fire busy state change event. nsRefPtr<AccEvent> stateEvent = - new AccStateChangeEvent(aDocument, nsIAccessibleStates::STATE_BUSY, - PR_FALSE, PR_FALSE); + new AccStateChangeEvent(aDocument, states::BUSY, PR_FALSE); docAcc->FireDelayedAccessibleEvent(stateEvent); } PRBool nsAccDocManager::IsEventTargetDocument(nsIDocument *aDocument) const { nsCOMPtr<nsISupports> container = aDocument->GetContainer(); nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem =
--- a/accessible/src/base/nsAccDocManager.h +++ b/accessible/src/base/nsAccDocManager.h @@ -365,17 +365,17 @@ private: if (type == nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED) { \ strEventType.AssignLiteral("load stopped"); \ } else if (type == nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE) { \ strEventType.AssignLiteral("load complete"); \ } else if (type == nsIAccessibleEvent::EVENT_DOCUMENT_RELOAD) { \ strEventType.AssignLiteral("reload"); \ } else if (type == nsIAccessibleEvent::EVENT_STATE_CHANGE) { \ AccStateChangeEvent* event = downcast_accEvent(aEvent); \ - if (event->GetState() == nsIAccessibleStates::STATE_BUSY) { \ + if (event->GetState() == states::BUSY) { \ strEventType.AssignLiteral("busy "); \ if (event->IsStateEnabled()) \ strEventType.AppendLiteral("true"); \ else \ strEventType.AppendLiteral("false"); \ } \ }
--- a/accessible/src/base/nsAccUtils.cpp +++ b/accessible/src/base/nsAccUtils.cpp @@ -34,17 +34,17 @@ * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsCoreUtils.h" #include "nsAccUtils.h" -#include "nsIAccessibleStates.h" +#include "States.h" #include "nsIAccessibleTypes.h" #include "nsAccessibilityService.h" #include "nsAccessibilityAtoms.h" #include "nsARIAMap.h" #include "nsDocAccessible.h" #include "nsHyperTextAccessible.h" #include "nsHTMLTableAccessible.h" @@ -157,18 +157,17 @@ nsAccUtils::GetPositionAndSizeForXULSele for (PRUint32 index = 0; index < itemsCount; index++) { nsCOMPtr<nsIDOMXULSelectControlItemElement> currItem; control->GetItemAtIndex(index, getter_AddRefs(currItem)); nsCOMPtr<nsINode> currNode(do_QueryInterface(currItem)); nsAccessible* itemAcc = GetAccService()->GetAccessible(currNode); - if (!itemAcc || - State(itemAcc) & nsIAccessibleStates::STATE_INVISIBLE) { + if (!itemAcc || itemAcc->State() & states::INVISIBLE) { (*aSetSize)--; if (index < static_cast<PRUint32>(indexOf)) (*aPosInSet)--; } } (*aPosInSet)++; // group position is 1-index based. } @@ -204,18 +203,17 @@ nsAccUtils::GetPositionAndSizeForXULCont nsAccessible* itemAcc = GetAccService()->GetAccessible(itemNode); if (itemAcc) { PRUint32 itemRole = Role(itemAcc); if (itemRole == nsIAccessibleRole::ROLE_SEPARATOR) break; // We reached the beginning of our group. - PRUint32 itemState = State(itemAcc); - if (!(itemState & nsIAccessibleStates::STATE_INVISIBLE)) { + if (!(itemAcc->State() & states::INVISIBLE)) { (*aSetSize)++; (*aPosInSet)++; } } } for (PRInt32 index = indexOf + 1; index < static_cast<PRInt32>(itemsCount); index++) { @@ -225,18 +223,17 @@ nsAccUtils::GetPositionAndSizeForXULCont nsAccessible* itemAcc = GetAccService()->GetAccessible(itemNode); if (itemAcc) { PRUint32 itemRole = Role(itemAcc); if (itemRole == nsIAccessibleRole::ROLE_SEPARATOR) break; // We reached the end of our group. - PRUint32 itemState = State(itemAcc); - if (!(itemState & nsIAccessibleStates::STATE_INVISIBLE)) + if (!(itemAcc->State() & states::INVISIBLE)) (*aSetSize)++; } } } PRInt32 nsAccUtils::GetLevelForXULContainerItem(nsIContent *aContent) { @@ -344,42 +341,44 @@ nsAccUtils::GetAncestorWithRole(nsAccess return parent; if (parent == document) break; } return nsnull; } -nsAccessible * -nsAccUtils::GetSelectableContainer(nsAccessible *aAccessible, PRUint32 aState) +nsAccessible* +nsAccUtils::GetSelectableContainer(nsAccessible* aAccessible, PRUint64 aState) { if (!aAccessible) return nsnull; - if (!(aState & nsIAccessibleStates::STATE_SELECTABLE)) + if (!(aState & states::SELECTABLE)) return nsnull; nsAccessible* parent = aAccessible; while ((parent = parent->GetParent()) && !parent->IsSelect()) { if (Role(parent) == nsIAccessibleRole::ROLE_PANE) return nsnull; } return parent; } -nsAccessible * -nsAccUtils::GetMultiSelectableContainer(nsINode *aNode) +nsAccessible* +nsAccUtils::GetMultiSelectableContainer(nsINode* aNode) { - nsAccessible *accessible = GetAccService()->GetAccessible(aNode); - nsAccessible *container = GetSelectableContainer(accessible, - State(accessible)); + nsAccessible* accessible = GetAccService()->GetAccessible(aNode); + if (accessible) { + nsAccessible* container = GetSelectableContainer(accessible, + accessible->State()); + if (container && container->State() & states::MULTISELECTABLE) + return container; + } - if (State(container) & nsIAccessibleStates::STATE_MULTISELECTABLE) - return container; return nsnull; } PRBool nsAccUtils::IsARIASelected(nsAccessible *aAccessible) { return aAccessible->GetContent()-> AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::aria_selected,
--- a/accessible/src/base/nsAccUtils.h +++ b/accessible/src/base/nsAccUtils.h @@ -194,18 +194,18 @@ public: PRUint32 aRole); /** * Return single or multi selectable container for the given item. * * @param aAccessible [in] the item accessible * @param aState [in] the state of the item accessible */ - static nsAccessible *GetSelectableContainer(nsAccessible *aAccessible, - PRUint32 aState); + static nsAccessible* GetSelectableContainer(nsAccessible* aAccessible, + PRUint64 aState); /** * Return multi selectable container for the given item. */ static nsAccessible *GetMultiSelectableContainer(nsINode *aNode); /** * Return true if the DOM node of given accessible has aria-selected="true" @@ -286,41 +286,16 @@ public: PRUint32 role = nsIAccessibleRole::ROLE_NOTHING; if (aAcc) aAcc->GetRole(&role); return role; } /** - * Return the state for the given accessible. - */ - static PRUint32 State(nsIAccessible *aAcc) - { - PRUint32 state = 0; - if (aAcc) - aAcc->GetState(&state, nsnull); - - return state; - } - - /** - * Return the extended state for the given accessible. - */ - static PRUint32 ExtendedState(nsIAccessible *aAcc) - { - PRUint32 state = 0; - PRUint32 extstate = 0; - if (aAcc) - aAcc->GetState(&state, &extstate); - - return extstate; - } - - /** * Get the ARIA attribute characteristics for a given ARIA attribute. * * @param aAtom ARIA attribute * @return A bitflag representing the attribute characteristics * (see nsARIAMap.h for possible bit masks, prefixed "ARIA_") */ static PRUint8 GetAttributeCharacteristics(nsIAtom* aAtom); @@ -365,16 +340,36 @@ public: { PRUint32 role = Role(aAcc); return role != nsIAccessibleRole::ROLE_TEXT_LEAF && role != nsIAccessibleRole::ROLE_WHITESPACE && role != nsIAccessibleRole::ROLE_STATICTEXT; } /** + * Transform nsIAccessibleStates constants to internal state constant. + */ + static inline PRUint64 To64State(PRUint32 aState1, PRUint32 aState2) + { + return static_cast<PRUint64>(aState1) + + (static_cast<PRUint64>(aState2) << 31); + } + + /** + * Transform internal state constant to nsIAccessibleStates constants. + */ + static inline void To32States(PRUint64 aState64, + PRUint32* aState1, PRUint32* aState2) + { + *aState1 = aState64 & 0x7fffffff; + if (aState2) + *aState2 = static_cast<PRUint32>(aState64 >> 31); + } + + /** * Return true if the given accessible can't have children. Used when exposing * to platform accessibility APIs, should the children be pruned off? */ static PRBool MustPrune(nsIAccessible *aAccessible); /** * Search hint enum constants. Used by GetHeaderCellsFor() method. */
--- a/accessible/src/base/nsAccessibilityService.cpp +++ b/accessible/src/base/nsAccessibilityService.cpp @@ -50,16 +50,17 @@ #include "nsHTMLImageMapAccessible.h" #include "nsHTMLLinkAccessible.h" #include "nsHTMLSelectAccessible.h" #include "nsHTMLTableAccessibleWrap.h" #include "nsHTMLTextAccessible.h" #include "nsHyperTextAccessibleWrap.h" #include "nsIAccessibilityService.h" #include "nsIAccessibleProvider.h" +#include "States.h" #include "nsIDOMDocument.h" #include "nsIDOMHTMLAreaElement.h" #include "nsIDOMHTMLLegendElement.h" #include "nsIDOMHTMLObjectElement.h" #include "nsIDOMHTMLOptGroupElement.h" #include "nsIDOMHTMLOptionElement.h" #include "nsIDOMXULElement.h" @@ -625,123 +626,124 @@ nsAccessibilityService::GetStringRole(PR return NS_OK; } CopyUTF8toUTF16(kRoleNames[aRole], aString); return NS_OK; } NS_IMETHODIMP -nsAccessibilityService::GetStringStates(PRUint32 aStates, PRUint32 aExtraStates, +nsAccessibilityService::GetStringStates(PRUint32 aState, PRUint32 aExtraState, nsIDOMDOMStringList **aStringStates) { nsAccessibleDOMStringList *stringStates = new nsAccessibleDOMStringList(); NS_ENSURE_TRUE(stringStates, NS_ERROR_OUT_OF_MEMORY); - //states - if (aStates & nsIAccessibleStates::STATE_UNAVAILABLE) + PRUint64 state = nsAccUtils::To64State(aState, aExtraState); + + // states + if (state & states::UNAVAILABLE) stringStates->Add(NS_LITERAL_STRING("unavailable")); - if (aStates & nsIAccessibleStates::STATE_SELECTED) + if (state & states::SELECTED) stringStates->Add(NS_LITERAL_STRING("selected")); - if (aStates & nsIAccessibleStates::STATE_FOCUSED) + if (state & states::FOCUSED) stringStates->Add(NS_LITERAL_STRING("focused")); - if (aStates & nsIAccessibleStates::STATE_PRESSED) + if (state & states::PRESSED) stringStates->Add(NS_LITERAL_STRING("pressed")); - if (aStates & nsIAccessibleStates::STATE_CHECKED) + if (state & states::CHECKED) stringStates->Add(NS_LITERAL_STRING("checked")); - if (aStates & nsIAccessibleStates::STATE_MIXED) + if (state & states::MIXED) stringStates->Add(NS_LITERAL_STRING("mixed")); - if (aStates & nsIAccessibleStates::STATE_READONLY) + if (state & states::READONLY) stringStates->Add(NS_LITERAL_STRING("readonly")); - if (aStates & nsIAccessibleStates::STATE_HOTTRACKED) + if (state & states::HOTTRACKED) stringStates->Add(NS_LITERAL_STRING("hottracked")); - if (aStates & nsIAccessibleStates::STATE_DEFAULT) + if (state & states::DEFAULT) stringStates->Add(NS_LITERAL_STRING("default")); - if (aStates & nsIAccessibleStates::STATE_EXPANDED) + if (state & states::EXPANDED) stringStates->Add(NS_LITERAL_STRING("expanded")); - if (aStates & nsIAccessibleStates::STATE_COLLAPSED) + if (state & states::COLLAPSED) stringStates->Add(NS_LITERAL_STRING("collapsed")); - if (aStates & nsIAccessibleStates::STATE_BUSY) + if (state & states::BUSY) stringStates->Add(NS_LITERAL_STRING("busy")); - if (aStates & nsIAccessibleStates::STATE_FLOATING) + if (state & states::FLOATING) stringStates->Add(NS_LITERAL_STRING("floating")); - if (aStates & nsIAccessibleStates::STATE_ANIMATED) + if (state & states::ANIMATED) stringStates->Add(NS_LITERAL_STRING("animated")); - if (aStates & nsIAccessibleStates::STATE_INVISIBLE) + if (state & states::INVISIBLE) stringStates->Add(NS_LITERAL_STRING("invisible")); - if (aStates & nsIAccessibleStates::STATE_OFFSCREEN) + if (state & states::OFFSCREEN) stringStates->Add(NS_LITERAL_STRING("offscreen")); - if (aStates & nsIAccessibleStates::STATE_SIZEABLE) + if (state & states::SIZEABLE) stringStates->Add(NS_LITERAL_STRING("sizeable")); - if (aStates & nsIAccessibleStates::STATE_MOVEABLE) + if (state & states::MOVEABLE) stringStates->Add(NS_LITERAL_STRING("moveable")); - if (aStates & nsIAccessibleStates::STATE_SELFVOICING) + if (state & states::SELFVOICING) stringStates->Add(NS_LITERAL_STRING("selfvoicing")); - if (aStates & nsIAccessibleStates::STATE_FOCUSABLE) + if (state & states::FOCUSABLE) stringStates->Add(NS_LITERAL_STRING("focusable")); - if (aStates & nsIAccessibleStates::STATE_SELECTABLE) + if (state & states::SELECTABLE) stringStates->Add(NS_LITERAL_STRING("selectable")); - if (aStates & nsIAccessibleStates::STATE_LINKED) + if (state & states::LINKED) stringStates->Add(NS_LITERAL_STRING("linked")); - if (aStates & nsIAccessibleStates::STATE_TRAVERSED) + if (state & states::TRAVERSED) stringStates->Add(NS_LITERAL_STRING("traversed")); - if (aStates & nsIAccessibleStates::STATE_MULTISELECTABLE) + if (state & states::MULTISELECTABLE) stringStates->Add(NS_LITERAL_STRING("multiselectable")); - if (aStates & nsIAccessibleStates::STATE_EXTSELECTABLE) + if (state & states::EXTSELECTABLE) stringStates->Add(NS_LITERAL_STRING("extselectable")); - if (aStates & nsIAccessibleStates::STATE_PROTECTED) + if (state & states::PROTECTED) stringStates->Add(NS_LITERAL_STRING("protected")); - if (aStates & nsIAccessibleStates::STATE_HASPOPUP) + if (state & states::HASPOPUP) stringStates->Add(NS_LITERAL_STRING("haspopup")); - if (aStates & nsIAccessibleStates::STATE_REQUIRED) + if (state & states::REQUIRED) stringStates->Add(NS_LITERAL_STRING("required")); - if (aStates & nsIAccessibleStates::STATE_IMPORTANT) - stringStates->Add(NS_LITERAL_STRING("important")); - if (aStates & nsIAccessibleStates::STATE_INVALID) + if (state & states::ALERT) + stringStates->Add(NS_LITERAL_STRING("alert")); + if (state & states::INVALID) stringStates->Add(NS_LITERAL_STRING("invalid")); - if (aStates & nsIAccessibleStates::STATE_CHECKABLE) + if (state & states::CHECKABLE) stringStates->Add(NS_LITERAL_STRING("checkable")); - //extraStates - if (aExtraStates & nsIAccessibleStates::EXT_STATE_SUPPORTS_AUTOCOMPLETION) + // extraStates + if (state & states::SUPPORTS_AUTOCOMPLETION) stringStates->Add(NS_LITERAL_STRING("autocompletion")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_DEFUNCT) + if (state & states::DEFUNCT) stringStates->Add(NS_LITERAL_STRING("defunct")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_SELECTABLE_TEXT) + if (state & states::SELECTABLE_TEXT) stringStates->Add(NS_LITERAL_STRING("selectable text")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_EDITABLE) + if (state & states::EDITABLE) stringStates->Add(NS_LITERAL_STRING("editable")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_ACTIVE) + if (state & states::ACTIVE) stringStates->Add(NS_LITERAL_STRING("active")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_MODAL) + if (state & states::MODAL) stringStates->Add(NS_LITERAL_STRING("modal")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_MULTI_LINE) + if (state & states::MULTI_LINE) stringStates->Add(NS_LITERAL_STRING("multi line")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_HORIZONTAL) + if (state & states::HORIZONTAL) stringStates->Add(NS_LITERAL_STRING("horizontal")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_OPAQUE) + if (state & states::OPAQUE1) stringStates->Add(NS_LITERAL_STRING("opaque")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_SINGLE_LINE) + if (state & states::SINGLE_LINE) stringStates->Add(NS_LITERAL_STRING("single line")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_TRANSIENT) + if (state & states::TRANSIENT) stringStates->Add(NS_LITERAL_STRING("transient")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_VERTICAL) + if (state & states::VERTICAL) stringStates->Add(NS_LITERAL_STRING("vertical")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_STALE) + if (state & states::STALE) stringStates->Add(NS_LITERAL_STRING("stale")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_ENABLED) + if (state & states::ENABLED) stringStates->Add(NS_LITERAL_STRING("enabled")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_SENSITIVE) + if (state & states::SENSITIVE) stringStates->Add(NS_LITERAL_STRING("sensitive")); - if (aExtraStates & nsIAccessibleStates::EXT_STATE_EXPANDABLE) + if (state & states::EXPANDABLE) stringStates->Add(NS_LITERAL_STRING("expandable")); //unknown states PRUint32 stringStatesLength = 0; - stringStates->GetLength(&stringStatesLength); if (!stringStatesLength) stringStates->Add(NS_LITERAL_STRING("unknown")); NS_ADDREF(*aStringStates = stringStates); return NS_OK; }
--- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -47,16 +47,17 @@ #include "nsDocAccessible.h" #include "nsEventShell.h" #include "nsAccEvent.h" #include "nsAccessibilityService.h" #include "nsAccTreeWalker.h" #include "nsRelUtils.h" #include "nsTextEquivUtils.h" +#include "States.h" #include "nsIDOMElement.h" #include "nsIDOMDocument.h" #include "nsIDOMDocumentXBL.h" #include "nsIDOMDocumentTraversal.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLFormElement.h" #include "nsIDOMNodeFilter.h" @@ -607,22 +608,23 @@ nsresult nsAccessible::GetFullKeyName(co getter_Copies(separator)))) { return NS_ERROR_FAILURE; } aStringOut = modifierName + separator + aKeyName; return NS_OK; } -PRBool nsAccessible::IsVisible(PRBool *aIsOffscreen) +PRBool +nsAccessible::IsVisible(PRBool* aIsOffscreen) { - // We need to know if at least a kMinPixels around the object is visible - // Otherwise it will be marked nsIAccessibleStates::STATE_OFFSCREEN - // The STATE_INVISIBLE flag is for elements which are programmatically hidden - + // We need to know if at least a kMinPixels around the object is visible, + // otherwise it will be marked states::OFFSCREEN. The states::INVISIBLE flag + // is for elements which are programmatically hidden. + *aIsOffscreen = PR_TRUE; if (IsDefunct()) return PR_FALSE; const PRUint16 kMinPixels = 12; // Set up the variables we need, return false if we can't get at them all nsCOMPtr<nsIPresShell> shell(GetPresShell()); if (!shell) @@ -685,85 +687,77 @@ PRBool nsAccessible::IsVisible(PRBool *a nsIView* view = frameWithView->GetViewExternal(); PRBool isVisible = CheckVisibilityInParentChain(doc, view); if (isVisible && rectVisibility == nsRectVisibility_kVisible) { *aIsOffscreen = PR_FALSE; } return isVisible; } -nsresult -nsAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsAccessible::NativeState() { - *aState = 0; - - if (IsDefunct()) { - if (aExtraState) - *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - - return NS_OK_DEFUNCT_OBJECT; - } - - if (aExtraState) - *aExtraState = 0; - + if (IsDefunct()) + return states::DEFUNCT; + + PRUint64 state = 0; nsEventStates intrinsicState = mContent->IntrinsicState(); if (intrinsicState.HasState(NS_EVENT_STATE_INVALID)) - *aState |= nsIAccessibleStates::STATE_INVALID; + state |= states::INVALID; if (intrinsicState.HasState(NS_EVENT_STATE_REQUIRED)) - *aState |= nsIAccessibleStates::STATE_REQUIRED; + state |= states::REQUIRED; PRBool disabled = mContent->IsHTML() ? (intrinsicState.HasState(NS_EVENT_STATE_DISABLED)) : (mContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::disabled, nsAccessibilityAtoms::_true, eCaseMatters)); // Set unavailable state based on disabled state, otherwise set focus states if (disabled) { - *aState |= nsIAccessibleStates::STATE_UNAVAILABLE; + state |= states::UNAVAILABLE; } else if (mContent->IsElement()) { nsIFrame *frame = GetFrame(); if (frame && frame->IsFocusable()) { - *aState |= nsIAccessibleStates::STATE_FOCUSABLE; + state |= states::FOCUSABLE; } if (gLastFocusedNode == mContent) { - *aState |= nsIAccessibleStates::STATE_FOCUSED; + state |= states::FOCUSED; } } - // Check if nsIAccessibleStates::STATE_INVISIBLE and - // STATE_OFFSCREEN flags should be turned on for this object. + // Check if states::INVISIBLE and + // states::OFFSCREEN flags should be turned on for this object. PRBool isOffscreen; if (!IsVisible(&isOffscreen)) { - *aState |= nsIAccessibleStates::STATE_INVISIBLE; + state |= states::INVISIBLE; } if (isOffscreen) { - *aState |= nsIAccessibleStates::STATE_OFFSCREEN; + state |= states::OFFSCREEN; } nsIFrame *frame = GetFrame(); if (frame && (frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) - *aState |= nsIAccessibleStates::STATE_FLOATING; + state |= states::FLOATING; // Check if a XUL element has the popup attribute (an attached popup menu). if (mContent->IsXUL()) if (mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::popup)) - *aState |= nsIAccessibleStates::STATE_HASPOPUP; + state |= states::HASPOPUP; // Add 'linked' state for simple xlink. if (nsCoreUtils::IsXLink(mContent)) - *aState |= nsIAccessibleStates::STATE_LINKED; - - return NS_OK; + state |= states::LINKED; + + return state; } /* readonly attribute boolean focusedChild; */ NS_IMETHODIMP nsAccessible::GetFocusedChild(nsIAccessible **aFocusedChild) { nsAccessible *focusedChild = nsnull; if (gLastFocusedNode == mContent) { @@ -838,17 +832,17 @@ nsAccessible::GetChildAtPoint(PRInt32 aX PRInt32 childCount = GetChildCount(); for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) { nsAccessible *child = GetChildAt(childIdx); PRInt32 childX, childY, childWidth, childHeight; child->GetBounds(&childX, &childY, &childWidth, &childHeight); if (aX >= childX && aX < childX + childWidth && aY >= childY && aY < childY + childHeight && - (nsAccUtils::State(child) & nsIAccessibleStates::STATE_INVISIBLE) == 0) { + (child->State() & states::INVISIBLE) == 0) { if (aWhichChild == eDeepestChild) return child->GetChildAtPoint(aX, aY, eDeepestChild); return child; } } @@ -1048,18 +1042,17 @@ nsIFrame* nsAccessible::GetBoundsFrame() /* void removeSelection (); */ NS_IMETHODIMP nsAccessible::SetSelected(PRBool aSelect) { // Add or remove selection if (IsDefunct()) return NS_ERROR_FAILURE; - PRUint32 state = nsAccUtils::State(this); - if (state & nsIAccessibleStates::STATE_SELECTABLE) { + if (State() & states::SELECTABLE) { nsCOMPtr<nsIAccessible> multiSelect = nsAccUtils::GetMultiSelectableContainer(mContent); if (!multiSelect) { return aSelect ? TakeFocus() : NS_ERROR_FAILURE; } if (mRoleMapEntry) { if (aSelect) { @@ -1077,18 +1070,17 @@ NS_IMETHODIMP nsAccessible::SetSelected( /* void takeSelection (); */ NS_IMETHODIMP nsAccessible::TakeSelection() { // Select only this item if (IsDefunct()) return NS_ERROR_FAILURE; - PRUint32 state = nsAccUtils::State(this); - if (state & nsIAccessibleStates::STATE_SELECTABLE) { + if (State() & states::SELECTABLE) { nsCOMPtr<nsIAccessible> multiSelect = nsAccUtils::GetMultiSelectableContainer(mContent); if (multiSelect) { nsCOMPtr<nsIAccessibleSelectable> selectable = do_QueryInterface(multiSelect); selectable->ClearSelection(); } return SetSelected(PR_TRUE); } @@ -1326,17 +1318,17 @@ nsAccessible::GetAttributes(nsIPersisten // We test for the value interface because we don't want to expose traditional get_accValue() // information such as URL's on links and documents, or text in an input nsAutoString valuetext; GetValue(valuetext); attributes->SetStringProperty(NS_LITERAL_CSTRING("valuetext"), valuetext, oldValueUnused); } // Expose checkable object attribute if the accessible has checkable state - if (nsAccUtils::State(this) & nsIAccessibleStates::STATE_CHECKABLE) + if (State() & states::CHECKABLE) nsAccUtils::SetAccAttr(attributes, nsAccessibilityAtoms::checkable, NS_LITERAL_STRING("true")); // Group attributes (level/setsize/posinset) PRInt32 level = 0, posInSet = 0, setSize = 0; rv = GroupPosition(&level, &setSize, &posInSet); if (NS_SUCCEEDED(rv)) nsAccUtils::SetAccGroupAttrs(attributes, level, setSize, posInSet); @@ -1492,17 +1484,17 @@ nsAccessible::GroupPosition(PRInt32 *aGr aGroupLevel); nsCoreUtils::GetUIntAttr(mContent, nsAccessibilityAtoms::aria_posinset, aPositionInGroup); nsCoreUtils::GetUIntAttr(mContent, nsAccessibilityAtoms::aria_setsize, aSimilarItemsInGroup); // If ARIA is missed and the accessible is visible then calculate group // position from hierarchy. - if (nsAccUtils::State(this) & nsIAccessibleStates::STATE_INVISIBLE) + if (State() & states::INVISIBLE) return NS_OK; // Calculate group level if ARIA is missed. if (*aGroupLevel == 0) { PRInt32 level = GetLevelInternal(); if (level != 0) *aGroupLevel = level; } @@ -1519,176 +1511,176 @@ nsAccessible::GroupPosition(PRInt32 *aGr *aSimilarItemsInGroup = setSize; } } return NS_OK; } NS_IMETHODIMP -nsAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) +nsAccessible::GetState(PRUint32* aState, PRUint32* aExtraState) { NS_ENSURE_ARG_POINTER(aState); - nsresult rv = GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + nsAccUtils::To32States(State(), aState, aExtraState); + return NS_OK; +} + +PRUint64 +nsAccessible::State() +{ + PRUint64 state = NativeState(); + if (state & states::DEFUNCT) + return state; // Apply ARIA states to be sure accessible states will be overriden. - GetARIAState(aState, aExtraState); + ApplyARIAState(&state); if (mRoleMapEntry && mRoleMapEntry->role == nsIAccessibleRole::ROLE_PAGETAB) { - if (*aState & nsIAccessibleStates::STATE_FOCUSED) { - *aState |= nsIAccessibleStates::STATE_SELECTED; + if (state & states::FOCUSED) { + state |= states::SELECTED; } else { // Expose 'selected' state on ARIA tab if the focus is on internal element // of related tabpanel. nsCOMPtr<nsIAccessible> tabPanel = nsRelUtils:: GetRelatedAccessible(this, nsIAccessibleRelation::RELATION_LABEL_FOR); if (nsAccUtils::Role(tabPanel) == nsIAccessibleRole::ROLE_PROPERTYPAGE) { nsRefPtr<nsAccessible> tabPanelAcc(do_QueryObject(tabPanel)); nsINode *tabPanelNode = tabPanelAcc->GetNode(); if (nsCoreUtils::IsAncestorOf(tabPanelNode, gLastFocusedNode)) - *aState |= nsIAccessibleStates::STATE_SELECTED; + state |= states::SELECTED; } } } - const PRUint32 kExpandCollapseStates = - nsIAccessibleStates::STATE_COLLAPSED | nsIAccessibleStates::STATE_EXPANDED; - if ((*aState & kExpandCollapseStates) == kExpandCollapseStates) { + const PRUint32 kExpandCollapseStates = states::COLLAPSED | states::EXPANDED; + if ((state & kExpandCollapseStates) == kExpandCollapseStates) { // Cannot be both expanded and collapsed -- this happens in ARIA expanded // combobox because of limitation of nsARIAMap. // XXX: Perhaps we will be able to make this less hacky if we support // extended states in nsARIAMap, e.g. derive COLLAPSED from // EXPANDABLE && !EXPANDED. - *aState &= ~nsIAccessibleStates::STATE_COLLAPSED; + state &= ~states::COLLAPSED; } - // Set additional states which presence depends on another states. - if (!aExtraState) - return NS_OK; - - if (!(*aState & nsIAccessibleStates::STATE_UNAVAILABLE)) { - *aExtraState |= nsIAccessibleStates::EXT_STATE_ENABLED | - nsIAccessibleStates::EXT_STATE_SENSITIVE; + if (!(state & states::UNAVAILABLE)) { + state |= states::ENABLED | states::SENSITIVE; } - if ((*aState & nsIAccessibleStates::STATE_COLLAPSED) || - (*aState & nsIAccessibleStates::STATE_EXPANDED)) - *aExtraState |= nsIAccessibleStates::EXT_STATE_EXPANDABLE; + if ((state & states::COLLAPSED) || (state & states::EXPANDED)) + state |= states::EXPANDABLE; if (mRoleMapEntry) { // If an object has an ancestor with the activedescendant property // pointing at it, we mark it as ACTIVE even if it's not currently focused. // This allows screen reader virtual buffer modes to know which descendant // is the current one that would get focus if the user navigates to the container widget. nsAutoString id; if (nsCoreUtils::GetID(mContent, id)) { nsIContent *ancestorContent = mContent; nsAutoString activeID; while ((ancestorContent = ancestorContent->GetParent()) != nsnull) { if (ancestorContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_activedescendant, activeID)) { if (id == activeID) { - *aExtraState |= nsIAccessibleStates::EXT_STATE_ACTIVE; + state |= states::ACTIVE; } break; } } } } // For some reasons DOM node may have not a frame. We tract such accessibles // as invisible. nsIFrame *frame = GetFrame(); if (!frame) - return NS_OK; + return state; const nsStyleDisplay* display = frame->GetStyleDisplay(); if (display && display->mOpacity == 1.0f && - !(*aState & nsIAccessibleStates::STATE_INVISIBLE)) { - *aExtraState |= nsIAccessibleStates::EXT_STATE_OPAQUE; + !(state & states::INVISIBLE)) { + state |= states::OPAQUE1; } const nsStyleXUL *xulStyle = frame->GetStyleXUL(); if (xulStyle) { // In XUL all boxes are either vertical or horizontal if (xulStyle->mBoxOrient == NS_STYLE_BOX_ORIENT_VERTICAL) { - *aExtraState |= nsIAccessibleStates::EXT_STATE_VERTICAL; + state |= states::VERTICAL; } else { - *aExtraState |= nsIAccessibleStates::EXT_STATE_HORIZONTAL; + state |= states::HORIZONTAL; } } // If we are editable, force readonly bit off - if (*aExtraState & nsIAccessibleStates::EXT_STATE_EDITABLE) - *aState &= ~nsIAccessibleStates::STATE_READONLY; + if (state & states::EDITABLE) + state &= ~states::READONLY; - return NS_OK; + return state; } -nsresult -nsAccessible::GetARIAState(PRUint32 *aState, PRUint32 *aExtraState) +void +nsAccessible::ApplyARIAState(PRUint64* aState) { // Test for universal states first PRUint32 index = 0; - while (nsStateMapEntry::MapToStates(mContent, aState, aExtraState, + while (nsStateMapEntry::MapToStates(mContent, aState, nsARIAMap::gWAIUnivStateMap[index])) { ++ index; } if (mRoleMapEntry) { // We only force the readonly bit off if we have a real mapping for the aria // role. This preserves the ability for screen readers to use readonly // (primarily on the document) as the hint for creating a virtual buffer. if (mRoleMapEntry->role != nsIAccessibleRole::ROLE_NOTHING) - *aState &= ~nsIAccessibleStates::STATE_READONLY; + *aState &= ~states::READONLY; if (mContent->HasAttr(kNameSpaceID_None, mContent->GetIDAttributeName())) { // If has a role & ID and aria-activedescendant on the container, assume focusable nsIContent *ancestorContent = mContent; while ((ancestorContent = ancestorContent->GetParent()) != nsnull) { if (ancestorContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::aria_activedescendant)) { // ancestor has activedescendant property, this content could be active - *aState |= nsIAccessibleStates::STATE_FOCUSABLE; + *aState |= states::FOCUSABLE; break; } } } } - if (*aState & nsIAccessibleStates::STATE_FOCUSABLE) { + if (*aState & states::FOCUSABLE) { // Special case: aria-disabled propagates from ancestors down to any focusable descendant nsIContent *ancestorContent = mContent; while ((ancestorContent = ancestorContent->GetParent()) != nsnull) { if (ancestorContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::aria_disabled, nsAccessibilityAtoms::_true, eCaseMatters)) { // ancestor has aria-disabled property, this is disabled - *aState |= nsIAccessibleStates::STATE_UNAVAILABLE; + *aState |= states::UNAVAILABLE; break; } } } if (!mRoleMapEntry) - return NS_OK; + return; // Note: the readonly bitflag will be overridden later if content is editable *aState |= mRoleMapEntry->state; - if (nsStateMapEntry::MapToStates(mContent, aState, aExtraState, + if (nsStateMapEntry::MapToStates(mContent, aState, mRoleMapEntry->attributeMap1) && - nsStateMapEntry::MapToStates(mContent, aState, aExtraState, + nsStateMapEntry::MapToStates(mContent, aState, mRoleMapEntry->attributeMap2)) { - nsStateMapEntry::MapToStates(mContent, aState, aExtraState, + nsStateMapEntry::MapToStates(mContent, aState, mRoleMapEntry->attributeMap3); } - return NS_OK; } // Not implemented by this class /* DOMString getValue (); */ NS_IMETHODIMP nsAccessible::GetValue(nsAString& aValue) { @@ -1757,20 +1749,19 @@ NS_IMETHODIMP nsAccessible::SetCurrentValue(double aValue) { if (IsDefunct()) return NS_ERROR_FAILURE; if (!mRoleMapEntry || mRoleMapEntry->valueRule == eNoValue) return NS_OK_NO_ARIA_VALUE; - const PRUint32 kValueCannotChange = nsIAccessibleStates::STATE_READONLY | - nsIAccessibleStates::STATE_UNAVAILABLE; - - if (nsAccUtils::State(this) & kValueCannotChange) + const PRUint32 kValueCannotChange = states::READONLY | states::UNAVAILABLE; + + if (State() & kValueCannotChange) return NS_ERROR_FAILURE; double minValue = 0; if (NS_SUCCEEDED(GetMinimumValue(&minValue)) && aValue < minValue) return NS_ERROR_INVALID_ARG; double maxValue = 0; if (NS_SUCCEEDED(GetMaximumValue(&maxValue)) && aValue > maxValue) @@ -1874,17 +1865,17 @@ NS_IMETHODIMP nsAccessible::GetNumActions(PRUint8 *aNumActions) { NS_ENSURE_ARG_POINTER(aNumActions); *aNumActions = 0; if (IsDefunct()) return NS_ERROR_FAILURE; - PRUint32 actionRule = GetActionRule(nsAccUtils::State(this)); + PRUint32 actionRule = GetActionRule(State()); if (actionRule == eNoAction) return NS_OK; *aNumActions = 1; return NS_OK; } /* DOMString getAccActionName (in PRUint8 index); */ @@ -1894,43 +1885,43 @@ nsAccessible::GetActionName(PRUint8 aInd aName.Truncate(); if (aIndex != 0) return NS_ERROR_INVALID_ARG; if (IsDefunct()) return NS_ERROR_FAILURE; - PRUint32 states = nsAccUtils::State(this); + PRUint64 states = State(); PRUint32 actionRule = GetActionRule(states); switch (actionRule) { case eActivateAction: aName.AssignLiteral("activate"); return NS_OK; case eClickAction: aName.AssignLiteral("click"); return NS_OK; case eCheckUncheckAction: - if (states & nsIAccessibleStates::STATE_CHECKED) + if (states & states::CHECKED) aName.AssignLiteral("uncheck"); - else if (states & nsIAccessibleStates::STATE_MIXED) + else if (states & states::MIXED) aName.AssignLiteral("cycle"); else aName.AssignLiteral("check"); return NS_OK; case eJumpAction: aName.AssignLiteral("jump"); return NS_OK; case eOpenCloseAction: - if (states & nsIAccessibleStates::STATE_COLLAPSED) + if (states & states::COLLAPSED) aName.AssignLiteral("open"); else aName.AssignLiteral("close"); return NS_OK; case eSelectAction: aName.AssignLiteral("select"); return NS_OK; @@ -1939,17 +1930,17 @@ nsAccessible::GetActionName(PRUint8 aInd aName.AssignLiteral("switch"); return NS_OK; case eSortAction: aName.AssignLiteral("sort"); return NS_OK; case eExpandAction: - if (states & nsIAccessibleStates::STATE_COLLAPSED) + if (states & states::COLLAPSED) aName.AssignLiteral("expand"); else aName.AssignLiteral("collapse"); return NS_OK; } return NS_ERROR_INVALID_ARG; } @@ -1971,17 +1962,17 @@ NS_IMETHODIMP nsAccessible::DoAction(PRUint8 aIndex) { if (aIndex != 0) return NS_ERROR_INVALID_ARG; if (IsDefunct()) return NS_ERROR_FAILURE; - if (GetActionRule(nsAccUtils::State(this)) != eNoAction) { + if (GetActionRule(State()) != eNoAction) { DoCommand(); return NS_OK; } return NS_ERROR_INVALID_ARG; } /* DOMString getHelp (); */ @@ -2797,20 +2788,20 @@ nsAccessible::InsertChildAt(PRUint32 aIn } PRBool nsAccessible::RemoveChild(nsAccessible* aChild) { if (!aChild) return PR_FALSE; - PRInt32 index = aChild->mIndexInParent; - if (aChild->mParent != this || index == -1) + if (aChild->mParent != this || aChild->mIndexInParent == -1) return PR_FALSE; + PRUint32 index = static_cast<PRUint32>(aChild->mIndexInParent); if (index >= mChildren.Length() || mChildren[index] != aChild) { NS_ERROR("Child is bound to parent but parent hasn't this child at its index!"); aChild->UnbindFromParent(); return PR_FALSE; } for (PRUint32 idx = index + 1; idx < mChildren.Length(); idx++) { NS_ASSERTION(mChildren[idx]->mIndexInParent == idx, "Accessible child index doesn't match"); @@ -2925,18 +2916,17 @@ nsAccessible::EndOffset() return hyperText ? (hyperText->GetChildOffset(this) + 1) : 0; } bool nsAccessible::IsValid() { NS_PRECONDITION(IsHyperLink(), "IsValid is called on not hyper link!"); - PRUint32 state = nsAccUtils::State(this); - return (0 == (state & nsIAccessibleStates::STATE_INVALID)); + return (0 == (State() & states::INVALID)); // XXX In order to implement this we would need to follow every link // Perhaps we can get information about invalid links from the cache // In the mean time authors can use role="link" aria-invalid="true" // to force it for links they internally know to be invalid } bool nsAccessible::IsSelected() @@ -3049,17 +3039,17 @@ nsAccessible::IsItemSelected(PRUint32 aI { PRUint32 index = 0; AccIterator iter(this, filters::GetSelectable, AccIterator::eTreeNav); nsAccessible* selected = nsnull; while ((selected = iter.GetNext()) && index < aIndex) index++; return selected && - nsAccUtils::State(selected) & nsIAccessibleStates::STATE_SELECTED; + selected->State() & states::SELECTED; } bool nsAccessible::AddItemToSelection(PRUint32 aIndex) { PRUint32 index = 0; AccIterator iter(this, filters::GetSelectable, AccIterator::eTreeNav); nsAccessible* selected = nsnull; @@ -3316,19 +3306,19 @@ nsAccessible::GetAttrValue(nsIAtom *aPro double value = attrValue.ToDouble(&error); if (NS_SUCCEEDED(error)) *aValue = value; return NS_OK; } PRUint32 -nsAccessible::GetActionRule(PRUint32 aStates) +nsAccessible::GetActionRule(PRUint64 aStates) { - if (aStates & nsIAccessibleStates::STATE_UNAVAILABLE) + if (aStates & states::UNAVAILABLE) return eNoAction; // Check if it's simple xlink. if (nsCoreUtils::IsXLink(mContent)) return eJumpAction; // Return "click" action on elements that have an attached popup menu. if (mContent->IsXUL())
--- a/accessible/src/base/nsAccessible.h +++ b/accessible/src/base/nsAccessible.h @@ -125,19 +125,18 @@ public: nsresult GetARIAName(nsAString& aName); /** * Maps ARIA state attributes to state of accessible. Note the given state * argument should hold states for accessible before you pass it into this * method. * * @param [in/out] where to fill the states into. - * @param [in/out] where to fill the extra states into */ - virtual nsresult GetARIAState(PRUint32 *aState, PRUint32 *aExtraState); + virtual void ApplyARIAState(PRUint64* aState); /** * Returns the accessible name provided by native markup. It doesn't take * into account ARIA markup used to specify the name. * * @param aName [out] the accessible name * * @return NS_OK_EMPTY_NAME points empty name was specified by native markup @@ -171,22 +170,25 @@ public: /** * Returns enumerated accessible role from native markup (see constants in * nsIAccessibleRole). Doesn't take into account ARIA roles. */ virtual PRUint32 NativeRole(); /** - * Return the state of accessible that doesn't take into account ARIA states. - * Use nsIAccessible::state to get all states for accessible. If - * second argument is omitted then second bit field of accessible state won't - * be calculated. + * Return all states of accessible (including ARIA states). */ - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 State(); + + /** + * Return the states of accessible, not taking into account ARIA states. + * Use State() to get complete set of states. + */ + virtual PRUint64 NativeState(); /** * Returns attributes for accessible without explicitly setted ARIA * attributes. */ virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes); /** @@ -615,17 +617,17 @@ protected: nsresult GetAttrValue(nsIAtom *aAriaProperty, double *aValue); /** * Return the action rule based on ARIA enum constants EActionRule * (see nsARIAMap.h). Used by GetNumActions() and GetActionName(). * * @param aStates [in] states of the accessible */ - PRUint32 GetActionRule(PRUint32 aStates); + PRUint32 GetActionRule(PRUint64 aStates); /** * Return group info. */ AccGroupInfo* GetGroupInfo(); /** * Fires platform accessible event. It's notification method only. It does
--- a/accessible/src/base/nsApplicationAccessible.cpp +++ b/accessible/src/base/nsApplicationAccessible.cpp @@ -37,16 +37,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsApplicationAccessible.h" +#include "States.h" #include "nsAccessibilityService.h" #include "nsAccUtils.h" #include "nsIComponentManager.h" #include "nsIDOMDocument.h" #include "nsIDOMWindow.h" #include "nsIWindowMediator.h" #include "nsServiceManagerUtils.h" @@ -135,22 +136,20 @@ nsApplicationAccessible::GetDescription( NS_IMETHODIMP nsApplicationAccessible::GetKeyboardShortcut(nsAString &aKeyboardShortcut) { aKeyboardShortcut.Truncate(); return NS_OK; } -NS_IMETHODIMP -nsApplicationAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsApplicationAccessible::State() { - NS_ENSURE_ARG_POINTER(aState); - GetStateInternal(aState, aExtraState); - return NS_OK; + return NativeState(); } NS_IMETHODIMP nsApplicationAccessible::GetAttributes(nsIPersistentProperties **aAttributes) { NS_ENSURE_ARG_POINTER(aAttributes); *aAttributes = nsnull; return NS_OK; @@ -357,45 +356,31 @@ bool nsApplicationAccessible::IsPrimaryForNode() const { return false; } //////////////////////////////////////////////////////////////////////////////// // nsAccessible public methods -nsresult -nsApplicationAccessible::GetARIAState(PRUint32 *aState, PRUint32 *aExtraState) +void +nsApplicationAccessible::ApplyARIAState(PRUint64* aState) { - return NS_OK; } PRUint32 nsApplicationAccessible::NativeRole() { return nsIAccessibleRole::ROLE_APP_ROOT; } -nsresult -nsApplicationAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsApplicationAccessible::NativeState() { - *aState = 0; - - if (IsDefunct()) { - if (aExtraState) - *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - - return NS_OK_DEFUNCT_OBJECT; - } - - if (aExtraState) - *aExtraState = 0; - - return NS_OK; + return IsDefunct() ? states::DEFUNCT : 0; } void nsApplicationAccessible::InvalidateChildren() { // Do nothing because application children are kept updated by AppendChild() // and RemoveChild() method calls. }
--- a/accessible/src/base/nsApplicationAccessible.h +++ b/accessible/src/base/nsApplicationAccessible.h @@ -89,17 +89,16 @@ public: // nsIAccessible NS_IMETHOD GetParent(nsIAccessible **aParent); NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling); NS_IMETHOD GetPreviousSibling(nsIAccessible **aPreviousSibling); NS_IMETHOD GetName(nsAString &aName); NS_IMETHOD GetValue(nsAString &aValue); NS_IMETHOD GetDescription(nsAString &aDescription); NS_IMETHOD GetKeyboardShortcut(nsAString &aKeyboardShortcut); - NS_IMETHOD GetState(PRUint32 *aState , PRUint32 *aExtraState ); NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes); NS_IMETHOD GroupPosition(PRInt32 *aGroupLevel, PRInt32 *aSimilarItemsInGroup, PRInt32 *aPositionInGroup); NS_IMETHOD GetRelationByType(PRUint32 aRelationType, nsIAccessibleRelation **aRelation); NS_IMETHOD GetRelationsCount(PRUint32 *aRelationsCount); NS_IMETHOD GetRelation(PRUint32 aIndex, nsIAccessibleRelation **aRelation); NS_IMETHOD GetRelations(nsIArray **aRelations); @@ -118,19 +117,20 @@ public: // nsAccessNode virtual PRBool IsDefunct(); virtual PRBool Init(); virtual void Shutdown(); virtual bool IsPrimaryForNode() const; // nsAccessible - virtual nsresult GetARIAState(PRUint32 *aState, PRUint32 *aExtraState); + virtual void ApplyARIAState(PRUint64* aState); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 State(); + virtual PRUint64 NativeState(); virtual nsAccessible* GetChildAtPoint(PRInt32 aX, PRInt32 aY, EWhichChildAtPoint aWhichChild); virtual void InvalidateChildren(); protected: // nsAccessible
--- a/accessible/src/base/nsBaseWidgetAccessible.cpp +++ b/accessible/src/base/nsBaseWidgetAccessible.cpp @@ -34,16 +34,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsBaseWidgetAccessible.h" +#include "States.h" #include "nsAccessibilityAtoms.h" #include "nsAccessibilityService.h" #include "nsAccUtils.h" #include "nsCoreUtils.h" #include "nsHyperTextAccessibleWrap.h" #include "nsIDOMNSHTMLElement.h" #include "nsGUIEvent.h" @@ -108,30 +109,28 @@ nsLinkableAccessible::TakeFocus() { nsAccessible *actionAcc = GetActionAccessible(); if (actionAcc) return actionAcc->TakeFocus(); return nsAccessibleWrap::TakeFocus(); } -nsresult -nsLinkableAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsLinkableAccessible::NativeState() { - nsresult rv = nsAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); - + PRUint64 states = nsAccessibleWrap::NativeState(); if (mIsLink) { - *aState |= nsIAccessibleStates::STATE_LINKED; - nsAccessible *actionAcc = GetActionAccessible(); - if (nsAccUtils::State(actionAcc) & nsIAccessibleStates::STATE_TRAVERSED) - *aState |= nsIAccessibleStates::STATE_TRAVERSED; + states |= states::LINKED; + nsAccessible* actionAcc = GetActionAccessible(); + if (actionAcc->State() & states::TRAVERSED) + states |= states::TRAVERSED; } - return NS_OK; + return states; } NS_IMETHODIMP nsLinkableAccessible::GetValue(nsAString& aValue) { aValue.Truncate(); nsAccessible::GetValue(aValue); @@ -255,17 +254,17 @@ nsLinkableAccessible::BindToParent(nsAcc return; } while ((walkUpContent = walkUpContent->GetParent())) { nsAccessible* walkUpAcc = GetAccService()->GetAccessibleInWeakShell(walkUpContent, mWeakShell); if (walkUpAcc && walkUpAcc->Role() == nsIAccessibleRole::ROLE_LINK && - nsAccUtils::State(walkUpAcc) & nsIAccessibleStates::STATE_LINKED) { + walkUpAcc->State() & states::LINKED) { mIsLink = PR_TRUE; mActionContent = walkUpContent; return; } isOnclick = nsCoreUtils::HasClickListener(walkUpContent); if (isOnclick) { mActionContent = walkUpContent;
--- a/accessible/src/base/nsBaseWidgetAccessible.h +++ b/accessible/src/base/nsBaseWidgetAccessible.h @@ -94,17 +94,17 @@ public: NS_IMETHOD GetValue(nsAString& _retval); NS_IMETHOD TakeFocus(); NS_IMETHOD GetKeyboardShortcut(nsAString& _retval); // nsAccessNode virtual void Shutdown(); // nsAccessible - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); // HyperLinkAccessible virtual already_AddRefed<nsIURI> GetAnchorURI(PRUint32 aAnchorIndex); protected: // nsAccessible virtual void BindToParent(nsAccessible* aParent, PRUint32 aIndexInParent);
--- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -31,16 +31,17 @@ * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ +#include "States.h" #include "nsAccCache.h" #include "nsAccessibilityAtoms.h" #include "nsAccessibilityService.h" #include "nsAccTreeWalker.h" #include "nsAccUtils.h" #include "nsRootAccessible.h" #include "nsTextEquivUtils.h" @@ -78,17 +79,17 @@ #include "nsIXULDocument.h" #endif namespace dom = mozilla::dom; //////////////////////////////////////////////////////////////////////////////// // Static member initialization -PRUint32 nsDocAccessible::gLastFocusedAccessiblesState = 0; +PRUint64 nsDocAccessible::gLastFocusedAccessiblesState = 0; static nsIAtom** kRelationAttrs[] = { &nsAccessibilityAtoms::aria_labelledby, &nsAccessibilityAtoms::aria_describedby, &nsAccessibilityAtoms::aria_owns, &nsAccessibilityAtoms::aria_controls, &nsAccessibilityAtoms::aria_flowto, @@ -285,92 +286,75 @@ nsDocAccessible::GetDescription(nsAStrin description); aDescription = description; } return NS_OK; } // nsAccessible public method -nsresult -nsDocAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsDocAccessible::NativeState() { - *aState = 0; - - if (IsDefunct()) { - if (aExtraState) - *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - return NS_OK_DEFUNCT_OBJECT; - } + if (IsDefunct()) + return states::DEFUNCT; - if (aExtraState) { - // The root content of the document might be removed so that mContent is - // out of date. - *aExtraState = (mContent->GetCurrentDoc() == mDocument) ? - 0 : nsIAccessibleStates::EXT_STATE_STALE; - } + // The root content of the document might be removed so that mContent is + // out of date. + PRUint64 state = (mContent->GetCurrentDoc() == mDocument) ? + 0 : states::STALE; #ifdef MOZ_XUL nsCOMPtr<nsIXULDocument> xulDoc(do_QueryInterface(mDocument)); if (!xulDoc) #endif { // XXX Need to invent better check to see if doc is focusable, // which it should be if it is scrollable. A XUL document could be focusable. // See bug 376803. - *aState |= nsIAccessibleStates::STATE_FOCUSABLE; + state |= states::FOCUSABLE; if (gLastFocusedNode == mDocument) - *aState |= nsIAccessibleStates::STATE_FOCUSED; + state |= states::FOCUSED; } // Expose state busy until the document is loaded or tree is constructed. if (!mIsLoaded || !mNotificationController->IsTreeConstructed()) { - *aState |= nsIAccessibleStates::STATE_BUSY; - if (aExtraState) { - *aExtraState |= nsIAccessibleStates::EXT_STATE_STALE; - } + state |= states::BUSY | states::STALE; } nsIFrame* frame = GetFrame(); while (frame != nsnull && !frame->HasView()) { frame = frame->GetParent(); } if (frame == nsnull || !CheckVisibilityInParentChain(mDocument, frame->GetViewExternal())) { - *aState |= nsIAccessibleStates::STATE_INVISIBLE | - nsIAccessibleStates::STATE_OFFSCREEN; + state |= states::INVISIBLE | states::OFFSCREEN; } nsCOMPtr<nsIEditor> editor; GetAssociatedEditor(getter_AddRefs(editor)); - if (!editor) { - *aState |= nsIAccessibleStates::STATE_READONLY; - } - else if (aExtraState) { - *aExtraState |= nsIAccessibleStates::EXT_STATE_EDITABLE; - } + state |= editor ? states::EDITABLE : states::READONLY; - return NS_OK; + return state; } // nsAccessible public method -nsresult -nsDocAccessible::GetARIAState(PRUint32 *aState, PRUint32 *aExtraState) +void +nsDocAccessible::ApplyARIAState(PRUint64* aState) { // Combine with states from outer doc - NS_ENSURE_ARG_POINTER(aState); - nsresult rv = nsAccessible::GetARIAState(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + // + nsAccessible::ApplyARIAState(aState); - if (mParent) // Allow iframe/frame etc. to have final state override via ARIA - return mParent->GetARIAState(aState, aExtraState); + // Allow iframe/frame etc. to have final state override via ARIA + if (mParent) + mParent->ApplyARIAState(aState); - return rv; } NS_IMETHODIMP nsDocAccessible::GetAttributes(nsIPersistentProperties **aAttributes) { nsAccessible::GetAttributes(aAttributes); if (mParent) { mParent->GetAttributes(aAttributes); // Add parent attributes (override inner) @@ -392,19 +376,18 @@ NS_IMETHODIMP nsDocAccessible::GetFocuse return NS_OK; } NS_IMETHODIMP nsDocAccessible::TakeFocus() { if (IsDefunct()) return NS_ERROR_FAILURE; - PRUint32 state; - GetStateInternal(&state, nsnull); - if (0 == (state & nsIAccessibleStates::STATE_FOCUSABLE)) { + PRUint64 state = NativeState(); + if (0 == (state & states::FOCUSABLE)) { return NS_ERROR_FAILURE; // Not focusable } // Focus the document. nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID); NS_ENSURE_STATE(fm); nsCOMPtr<nsIDOMElement> newFocus; @@ -910,18 +893,17 @@ NS_IMETHODIMP nsDocAccessible::Observe(n const PRUnichar *aData) { if (!nsCRT::strcmp(aTopic,"obs_documentCreated")) { // State editable will now be set, readonly is now clear // Normally we only fire delayed events created from the node, not an // accessible object. See the AccStateChangeEvent constructor for details // about this exceptional case. nsRefPtr<AccEvent> event = - new AccStateChangeEvent(this, nsIAccessibleStates::EXT_STATE_EDITABLE, - PR_TRUE, PR_TRUE); + new AccStateChangeEvent(this, states::EDITABLE, PR_TRUE); FireDelayedAccessibleEvent(event); } return NS_OK; } //////////////////////////////////////////////////////////////////////////////// // nsIDocumentObserver @@ -992,17 +974,17 @@ nsDocAccessible::AttributeChanged(nsIDoc // dependent IDs cache when its accessible is created. if (aModType == nsIDOMMutationEvent::MODIFICATION || aModType == nsIDOMMutationEvent::ADDITION) { AddDependentIDsFor(accessible, aAttribute); } // If it was the focused node, cache the new state. if (aElement == gLastFocusedNode) - gLastFocusedAccessiblesState = nsAccUtils::State(accessible); + gLastFocusedAccessiblesState = accessible->State(); } // nsDocAccessible protected member void nsDocAccessible::AttributeChangedImpl(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute) { // Fire accessible event after short timer, because we need to wait for // DOM attribute & resulting layout to actually change. Otherwise, @@ -1028,26 +1010,22 @@ nsDocAccessible::AttributeChangedImpl(ns // Note. Checking the XUL or HTML namespace would not seem to gain us // anything, because disabled attribute really is going to mean the same // thing in any namespace. // Note. We use the attribute instead of the disabled state bit because // ARIA's aria-disabled does not affect the disabled state bit. nsRefPtr<AccEvent> enabledChangeEvent = - new AccStateChangeEvent(aContent, - nsIAccessibleStates::EXT_STATE_ENABLED, - PR_TRUE); + new AccStateChangeEvent(aContent, states::ENABLED); FireDelayedAccessibleEvent(enabledChangeEvent); nsRefPtr<AccEvent> sensitiveChangeEvent = - new AccStateChangeEvent(aContent, - nsIAccessibleStates::EXT_STATE_SENSITIVE, - PR_TRUE); + new AccStateChangeEvent(aContent, states::SENSITIVE); FireDelayedAccessibleEvent(sensitiveChangeEvent); return; } // Check for namespaced ARIA attribute if (aNameSpaceID == kNameSpaceID_None) { // Check for hyphenated aria-foo property? @@ -1095,43 +1073,39 @@ nsDocAccessible::AttributeChangedImpl(ns FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_SELECTION_ADD, aContent); } } if (aAttribute == nsAccessibilityAtoms::contenteditable) { nsRefPtr<AccEvent> editableChangeEvent = - new AccStateChangeEvent(aContent, - nsIAccessibleStates::EXT_STATE_EDITABLE, - PR_TRUE); + new AccStateChangeEvent(aContent, states::EDITABLE); FireDelayedAccessibleEvent(editableChangeEvent); return; } } // nsDocAccessible protected member void nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute) { // Note: For universal/global ARIA states and properties we don't care if // there is an ARIA role present or not. if (aAttribute == nsAccessibilityAtoms::aria_required) { nsRefPtr<AccEvent> event = - new AccStateChangeEvent(aContent, nsIAccessibleStates::STATE_REQUIRED, - PR_FALSE); + new AccStateChangeEvent(aContent, states::REQUIRED); FireDelayedAccessibleEvent(event); return; } if (aAttribute == nsAccessibilityAtoms::aria_invalid) { nsRefPtr<AccEvent> event = - new AccStateChangeEvent(aContent, nsIAccessibleStates::STATE_INVALID, - PR_FALSE); + new AccStateChangeEvent(aContent, states::INVALID); FireDelayedAccessibleEvent(event); return; } if (aAttribute == nsAccessibilityAtoms::aria_activedescendant) { // The activedescendant universal property redirects accessible focus events // to the element with the id that activedescendant points to nsCOMPtr<nsINode> focusedNode = GetCurrentFocus(); @@ -1152,64 +1126,60 @@ nsDocAccessible::ARIAAttributeChanged(ns aAttribute == nsAccessibilityAtoms::aria_hidden) { FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED, aContent); } // We treat aria-expanded as a global ARIA state for historical reasons if (aAttribute == nsAccessibilityAtoms::aria_expanded) { nsRefPtr<AccEvent> event = - new AccStateChangeEvent(aContent, nsIAccessibleStates::STATE_EXPANDED, - PR_FALSE); + new AccStateChangeEvent(aContent, states::EXPANDED); FireDelayedAccessibleEvent(event); return; } if (!aContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::role)) { // We don't care about these other ARIA attribute changes unless there is // an ARIA role set for the element // XXX: we should check the role map to see if the changed property is // relevant for that particular role. return; } // The following ARIA attributes only take affect when dynamic content role is present if (aAttribute == nsAccessibilityAtoms::aria_checked || aAttribute == nsAccessibilityAtoms::aria_pressed) { const PRUint32 kState = (aAttribute == nsAccessibilityAtoms::aria_checked) ? - nsIAccessibleStates::STATE_CHECKED : - nsIAccessibleStates::STATE_PRESSED; + states::CHECKED : states::PRESSED; nsRefPtr<AccEvent> event = - new AccStateChangeEvent(aContent, kState, PR_FALSE); + new AccStateChangeEvent(aContent, kState); FireDelayedAccessibleEvent(event); if (aContent == gLastFocusedNode) { // State changes for MIXED state currently only supported for focused item, because // otherwise we would need access to the old attribute value in this listener. // This is because we don't know if the previous value of aria-checked or aria-pressed was "mixed" // without caching that info. nsAccessible *accessible = event->GetAccessible(); if (accessible) { - PRBool wasMixed = (gLastFocusedAccessiblesState & nsIAccessibleStates::STATE_MIXED) != 0; + PRBool wasMixed = (gLastFocusedAccessiblesState & states::MIXED) != 0; PRBool isMixed = - (nsAccUtils::State(accessible) & nsIAccessibleStates::STATE_MIXED) != 0; + (accessible->State() & states::MIXED) != 0; if (wasMixed != isMixed) { nsRefPtr<AccEvent> event = - new AccStateChangeEvent(aContent, nsIAccessibleStates::STATE_MIXED, - PR_FALSE, isMixed); + new AccStateChangeEvent(aContent, states::MIXED, isMixed); FireDelayedAccessibleEvent(event); } } } return; } if (aAttribute == nsAccessibilityAtoms::aria_readonly) { nsRefPtr<AccEvent> event = - new AccStateChangeEvent(aContent, nsIAccessibleStates::STATE_READONLY, - PR_FALSE); + new AccStateChangeEvent(aContent, states::READONLY); FireDelayedAccessibleEvent(event); return; } // Fire value change event whenever aria-valuetext is changed, or // when aria-valuenow is changed and aria-valuetext is empty if (aAttribute == nsAccessibilityAtoms::aria_valuetext || (aAttribute == nsAccessibilityAtoms::aria_valuenow && @@ -1236,18 +1206,17 @@ void nsDocAccessible::ContentStateChange nsEventStates aStateMask) { if (aStateMask.HasState(NS_EVENT_STATE_CHECKED)) { nsHTMLSelectOptionAccessible::SelectionChangedIfOption(aContent); } if (aStateMask.HasState(NS_EVENT_STATE_INVALID)) { nsRefPtr<AccEvent> event = - new AccStateChangeEvent(aContent, nsIAccessibleStates::STATE_INVALID, - PR_FALSE, PR_TRUE); + new AccStateChangeEvent(aContent, states::INVALID, PR_TRUE); FireDelayedAccessibleEvent(event); } } void nsDocAccessible::DocumentStatesChanged(nsIDocument* aDocument, nsEventStates aStateMask) { }
--- a/accessible/src/base/nsDocAccessible.h +++ b/accessible/src/base/nsDocAccessible.h @@ -110,18 +110,18 @@ public: virtual void Shutdown(); virtual nsIFrame* GetFrame() const; virtual PRBool IsDefunct(); virtual nsINode* GetNode() const { return mDocument; } virtual nsIDocument* GetDocumentNode() const { return mDocument; } // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); - virtual nsresult GetARIAState(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); + virtual void ApplyARIAState(PRUint64* aState); virtual void SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry); #ifdef DEBUG_ACCDOCMGR virtual nsresult HandleAccEvent(AccEvent* aAccEvent); #endif // nsIAccessibleText @@ -496,17 +496,17 @@ protected: protected: /** * Specifies if the document was loaded, used for error pages only. */ PRPackedBool mIsLoaded; - static PRUint32 gLastFocusedAccessiblesState; + static PRUint64 gLastFocusedAccessiblesState; nsTArray<nsRefPtr<nsDocAccessible> > mChildDocuments; /** * A storage class for pairing content with one of its relation attributes. */ class AttrRelProvider {
--- a/accessible/src/base/nsOuterDocAccessible.cpp +++ b/accessible/src/base/nsOuterDocAccessible.cpp @@ -33,16 +33,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsOuterDocAccessible.h" +#include "States.h" #include "nsAccUtils.h" #include "nsDocAccessible.h" //////////////////////////////////////////////////////////////////////////////// // nsOuterDocAccessible //////////////////////////////////////////////////////////////////////////////// nsOuterDocAccessible:: @@ -61,24 +62,20 @@ NS_IMPL_ISUPPORTS_INHERITED0(nsOuterDocA // nsAccessible public (DON'T add methods here) PRUint32 nsOuterDocAccessible::NativeRole() { return nsIAccessibleRole::ROLE_INTERNAL_FRAME; } -nsresult -nsOuterDocAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsOuterDocAccessible::NativeState() { - nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); - - *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; - return NS_OK; + return nsAccessible::NativeState() & ~states::FOCUSABLE; } nsAccessible* nsOuterDocAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY, EWhichChildAtPoint aWhichChild) { PRInt32 docX = 0, docY = 0, docWidth = 0, docHeight = 0; nsresult rv = GetBounds(&docX, &docY, &docWidth, &docHeight);
--- a/accessible/src/base/nsOuterDocAccessible.h +++ b/accessible/src/base/nsOuterDocAccessible.h @@ -63,17 +63,17 @@ public: NS_IMETHOD GetActionDescription(PRUint8 aIndex, nsAString& aDescription); NS_IMETHOD DoAction(PRUint8 aIndex); // nsAccessNode virtual void Shutdown(); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes); virtual nsAccessible* GetChildAtPoint(PRInt32 aX, PRInt32 aY, EWhichChildAtPoint aWhichChild); virtual void InvalidateChildren(); virtual PRBool AppendChild(nsAccessible *aAccessible); virtual PRBool RemoveChild(nsAccessible *aAccessible);
--- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -30,16 +30,17 @@ * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ +#include "States.h" #include "nsAccessibilityService.h" #include "nsApplicationAccessibleWrap.h" #include "nsAccUtils.h" #include "nsCoreUtils.h" #include "nsRelUtils.h" #include "mozilla/dom/Element.h" #include "nsHTMLSelectAccessible.h" @@ -180,56 +181,52 @@ PRUint32 nsRootAccessible::GetChromeFlag return 0; } PRUint32 chromeFlags; xulWin->GetChromeFlags(&chromeFlags); return chromeFlags; } #endif -nsresult -nsRootAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsRootAccessible::NativeState() { - nsresult rv = nsDocAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 states = nsDocAccessibleWrap::NativeState(); #ifdef MOZ_XUL PRUint32 chromeFlags = GetChromeFlags(); if (chromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) { - *aState |= nsIAccessibleStates::STATE_SIZEABLE; + states |= states::SIZEABLE; } if (chromeFlags & nsIWebBrowserChrome::CHROME_TITLEBAR) { // If it has a titlebar it's movable // XXX unless it's minimized or maximized, but not sure // how to detect that - *aState |= nsIAccessibleStates::STATE_MOVEABLE; + states |= states::MOVEABLE; } #endif - if (!aExtraState) - return NS_OK; - nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID); if (fm) { nsCOMPtr<nsIDOMWindow> rootWindow; GetWindow(getter_AddRefs(rootWindow)); nsCOMPtr<nsIDOMWindow> activeWindow; fm->GetActiveWindow(getter_AddRefs(activeWindow)); if (activeWindow == rootWindow) - *aExtraState |= nsIAccessibleStates::EXT_STATE_ACTIVE; + states |= states::ACTIVE; } #ifdef MOZ_XUL if (GetChromeFlags() & nsIWebBrowserChrome::CHROME_MODAL) { - *aExtraState |= nsIAccessibleStates::EXT_STATE_MODAL; + states |= states::MODAL; } #endif - return NS_OK; + return states; } const char* const docEvents[] = { #ifdef DEBUG_DRAGDROPSTART // Capture mouse over events and fire fake DRAGDROPSTART event to simplify // debugging a11y objects with event viewers "mouseover", #endif @@ -360,17 +357,17 @@ nsRootAccessible::FireAccessibleFocusEve // aForceEvent == PR_TRUE nsINode* focusNode = focusAccessible->GetNode(); if (gLastFocusedNode == focusNode && !aForceEvent) return; nsDocAccessible* focusDocument = focusAccessible->GetDocAccessible(); NS_ASSERTION(focusDocument, "No document while accessible is in document?!"); - gLastFocusedAccessiblesState = nsAccUtils::State(focusAccessible); + gLastFocusedAccessiblesState = focusAccessible->State(); // Fire menu start/end events for ARIA menus. if (focusAccessible->ARIARole() == nsIAccessibleRole::ROLE_MENUITEM) { // The focus is inside a menu. if (!mCurrentARIAMenubar) { // Entering ARIA menu. Fire menu start event. nsAccessible* menuBarAccessible = nsAccUtils::GetAncestorWithRole(focusAccessible, @@ -554,44 +551,41 @@ nsRootAccessible::ProcessDOMEvent(nsIDOM HandleTreeInvalidatedEvent(aDOMEvent, treeAcc); return; } } } #endif if (eventType.EqualsLiteral("RadioStateChange")) { - PRUint32 state = nsAccUtils::State(accessible); + PRUint64 state = accessible->State(); // radiogroup in prefWindow is exposed as a list, // and panebutton is exposed as XULListitem in A11y. // nsXULListitemAccessible::GetStateInternal uses STATE_SELECTED in this case, - // so we need to check nsIAccessibleStates::STATE_SELECTED also. - PRBool isEnabled = (state & (nsIAccessibleStates::STATE_CHECKED | - nsIAccessibleStates::STATE_SELECTED)) != 0; + // so we need to check states::SELECTED also. + PRBool isEnabled = (state & (states::CHECKED | states::SELECTED)) != 0; nsRefPtr<AccEvent> accEvent = - new AccStateChangeEvent(accessible, nsIAccessibleStates::STATE_CHECKED, - PR_FALSE, isEnabled); + new AccStateChangeEvent(accessible, states::CHECKED, isEnabled); nsEventShell::FireEvent(accEvent); if (isEnabled) FireAccessibleFocusEvent(accessible, origTargetContent); return; } if (eventType.EqualsLiteral("CheckboxStateChange")) { - PRUint32 state = nsAccUtils::State(accessible); + PRUint64 state = accessible->State(); - PRBool isEnabled = !!(state & nsIAccessibleStates::STATE_CHECKED); + PRBool isEnabled = !!(state & states::CHECKED); nsRefPtr<AccEvent> accEvent = - new AccStateChangeEvent(accessible, nsIAccessibleStates::STATE_CHECKED, - PR_FALSE, isEnabled); + new AccStateChangeEvent(accessible, states::CHECKED, isEnabled); nsEventShell::FireEvent(accEvent); return; } nsAccessible *treeItemAccessible = nsnull; #ifdef MOZ_XUL // If it's a tree element, need the currently selected item @@ -610,22 +604,21 @@ nsRootAccessible::ProcessDOMEvent(nsIDOM } } } } #endif #ifdef MOZ_XUL if (treeItemAccessible && eventType.EqualsLiteral("OpenStateChange")) { - PRUint32 state = nsAccUtils::State(accessible); // collapsed/expanded changed - PRBool isEnabled = (state & nsIAccessibleStates::STATE_EXPANDED) != 0; + PRUint64 state = accessible->State(); + PRBool isEnabled = (state & states::EXPANDED) != 0; nsRefPtr<AccEvent> accEvent = - new AccStateChangeEvent(accessible, nsIAccessibleStates::STATE_EXPANDED, - PR_FALSE, isEnabled); + new AccStateChangeEvent(accessible, states::EXPANDED, isEnabled); nsEventShell::FireEvent(accEvent); return; } if (treeItemAccessible && eventType.EqualsLiteral("select")) { // If multiselect tree, we should fire selectionadd or selection removed if (gLastFocusedNode == targetNode) { nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSel = @@ -719,17 +712,17 @@ nsRootAccessible::ProcessDOMEvent(nsIDOM return; } else { nsAccessible *containerAccessible = accessible->GetParent(); if (!containerAccessible) return; // It is not top level menuitem // Only fire focus event if it is not inside collapsed popup // and not a listitem of a combo box - if (nsAccUtils::State(containerAccessible) & nsIAccessibleStates::STATE_COLLAPSED) { + if (containerAccessible->State() & states::COLLAPSED) { nsAccessible *containerParent = containerAccessible->GetParent(); if (!containerParent) return; if (containerParent->Role() != nsIAccessibleRole::ROLE_COMBOBOX) { return; } } } @@ -812,17 +805,17 @@ nsRootAccessible::GetContentDocShell(nsI if (!accDoc) return nsnull; // If ancestor chain of accessibles is not completely visible, // don't use this one. This happens for example if it's inside // a background tab (tabbed browsing) nsAccessible *parent = accDoc->GetParent(); while (parent) { - if (nsAccUtils::State(parent) & nsIAccessibleStates::STATE_INVISIBLE) + if (parent->State() & states::INVISIBLE) return nsnull; if (parent == this) break; // Don't check past original root accessible we started with parent = parent->GetParent(); } @@ -900,19 +893,17 @@ nsRootAccessible::HandlePopupShownEvent( nsAccessible* combobox = aAccessible->GetParent(); if (!combobox) return; PRUint32 comboboxRole = combobox->Role(); if (comboboxRole == nsIAccessibleRole::ROLE_COMBOBOX || comboboxRole == nsIAccessibleRole::ROLE_AUTOCOMPLETE) { nsRefPtr<AccEvent> event = - new AccStateChangeEvent(combobox, - nsIAccessibleStates::STATE_EXPANDED, - PR_FALSE, PR_TRUE); + new AccStateChangeEvent(combobox, states::EXPANDED, PR_TRUE); if (event) nsEventShell::FireEvent(event); } } } void nsRootAccessible::HandlePopupHidingEvent(nsINode* aNode, @@ -938,19 +929,17 @@ nsRootAccessible::HandlePopupHidingEvent nsAccessible* combobox = aAccessible->GetParent(); if (!combobox) return; PRUint32 comboboxRole = combobox->Role(); if (comboboxRole == nsIAccessibleRole::ROLE_COMBOBOX || comboboxRole == nsIAccessibleRole::ROLE_AUTOCOMPLETE) { nsRefPtr<AccEvent> event = - new AccStateChangeEvent(combobox, - nsIAccessibleStates::STATE_EXPANDED, - PR_FALSE, PR_FALSE); + new AccStateChangeEvent(combobox, states::EXPANDED, PR_FALSE); if (event) nsEventShell::FireEvent(event); } } #ifdef MOZ_XUL void nsRootAccessible::HandleTreeRowCountChangedEvent(nsIDOMEvent* aEvent,
--- a/accessible/src/base/nsRootAccessible.h +++ b/accessible/src/base/nsRootAccessible.h @@ -80,17 +80,17 @@ public: // nsIDOMEventListener NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent); // nsAccessNode virtual void Shutdown(); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); // nsRootAccessible NS_DECLARE_STATIC_IID_ACCESSOR(NS_ROOTACCESSIBLE_IMPL_CID) /** * Fire an accessible focus event for the focused accessible and attach a new * selection listener to real focused element, if necessary. *
--- a/accessible/src/html/nsHTMLFormControlAccessible.cpp +++ b/accessible/src/html/nsHTMLFormControlAccessible.cpp @@ -33,16 +33,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsHTMLFormControlAccessible.h" +#include "States.h" #include "nsAccessibilityAtoms.h" #include "nsAccUtils.h" #include "nsRelUtils.h" #include "nsTextEquivUtils.h" #include "nsIDOMDocument.h" #include "nsIDOMHTMLInputElement.h" #include "nsIDOMNSHTMLElement.h" @@ -80,23 +81,21 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible:: *_retval = 1; return NS_OK; } NS_IMETHODIMP nsHTMLCheckboxAccessible::GetActionName(PRUint8 aIndex, nsAString& aName) { if (aIndex == eAction_Click) { // 0 is the magic value for default action // cycle, check or uncheck - PRUint32 state; - nsresult rv = GetStateInternal(&state, nsnull); - NS_ENSURE_SUCCESS(rv, rv); + PRUint64 state = NativeState(); - if (state & nsIAccessibleStates::STATE_CHECKED) + if (state & states::CHECKED) aName.AssignLiteral("uncheck"); - else if (state & nsIAccessibleStates::STATE_MIXED) + else if (state & states::MIXED) aName.AssignLiteral("cycle"); else aName.AssignLiteral("check"); return NS_OK; } return NS_ERROR_INVALID_ARG; } @@ -106,75 +105,70 @@ nsHTMLCheckboxAccessible::DoAction(PRUin { if (aIndex != 0) return NS_ERROR_INVALID_ARG; DoCommand(); return NS_OK; } -nsresult -nsHTMLCheckboxAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsHTMLCheckboxAccessible::NativeState() { - nsresult rv = nsFormControlAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsFormControlAccessible::NativeState(); - *aState |= nsIAccessibleStates::STATE_CHECKABLE; - - PRBool state = PR_FALSE; // Radio buttons and check boxes can be checked or mixed + state |= states::CHECKABLE; + PRBool checkState = PR_FALSE; // Radio buttons and check boxes can be checked or mixed nsCOMPtr<nsIDOMHTMLInputElement> htmlCheckboxElement = do_QueryInterface(mContent); if (htmlCheckboxElement) { - htmlCheckboxElement->GetIndeterminate(&state); + htmlCheckboxElement->GetIndeterminate(&checkState); - if (state) { - *aState |= nsIAccessibleStates::STATE_MIXED; + if (checkState) { + state |= states::MIXED; } else { // indeterminate can't be checked at the same time. - htmlCheckboxElement->GetChecked(&state); + htmlCheckboxElement->GetChecked(&checkState); - if (state) - *aState |= nsIAccessibleStates::STATE_CHECKED; + if (checkState) + state |= states::CHECKED; } } - return NS_OK; + return state; } //////////////////////////////////////////////////////////////////////////////// // nsHTMLRadioButtonAccessible //////////////////////////////////////////////////////////////////////////////// nsHTMLRadioButtonAccessible:: nsHTMLRadioButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell) : nsRadioButtonAccessible(aContent, aShell) { } -nsresult -nsHTMLRadioButtonAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsHTMLRadioButtonAccessible::NativeState() { - nsresult rv = nsAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsAccessibleWrap::NativeState(); - *aState |= nsIAccessibleStates::STATE_CHECKABLE; + state |= states::CHECKABLE; PRBool checked = PR_FALSE; // Radio buttons and check boxes can be checked nsCOMPtr<nsIDOMHTMLInputElement> htmlRadioElement = do_QueryInterface(mContent); if (htmlRadioElement) htmlRadioElement->GetChecked(&checked); if (checked) - *aState |= nsIAccessibleStates::STATE_CHECKED; + state |= states::CHECKED; - return NS_OK; + return state; } void nsHTMLRadioButtonAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet, PRInt32 *aSetSize) { nsAutoString nsURI; mContent->NodeInfo()->GetNamespaceURI(nsURI); @@ -261,29 +255,26 @@ nsHTMLButtonAccessible::DoAction(PRUint8 { if (aIndex != eAction_Click) return NS_ERROR_INVALID_ARG; DoCommand(); return NS_OK; } -nsresult -nsHTMLButtonAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsHTMLButtonAccessible::NativeState() { - nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsHyperTextAccessibleWrap::NativeState(); if (mContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type, nsAccessibilityAtoms::submit, eIgnoreCase)) - *aState |= nsIAccessibleStates::STATE_DEFAULT; + state |= states::DEFAULT; - return NS_OK; + return state; } PRUint32 nsHTMLButtonAccessible::NativeRole() { return nsIAccessibleRole::ROLE_PUSHBUTTON; } @@ -358,31 +349,28 @@ nsHTML4ButtonAccessible::DoAction(PRUint } PRUint32 nsHTML4ButtonAccessible::NativeRole() { return nsIAccessibleRole::ROLE_PUSHBUTTON; } -nsresult -nsHTML4ButtonAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsHTML4ButtonAccessible::NativeState() { - nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsHyperTextAccessibleWrap::NativeState(); - *aState |= nsIAccessibleStates::STATE_FOCUSABLE; + state |= states::FOCUSABLE; if (mContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type, nsAccessibilityAtoms::submit, eIgnoreCase)) - *aState |= nsIAccessibleStates::STATE_DEFAULT; + state |= states::DEFAULT; - return NS_OK; + return state; } //////////////////////////////////////////////////////////////////////////////// // nsHTMLTextFieldAccessible //////////////////////////////////////////////////////////////////////////////// nsHTMLTextFieldAccessible:: @@ -429,87 +417,76 @@ nsHTMLTextFieldAccessible::GetNameIntern // text inputs and textareas might have useful placeholder text mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::placeholder, aName); return NS_OK; } NS_IMETHODIMP nsHTMLTextFieldAccessible::GetValue(nsAString& _retval) { - PRUint32 state; - nsresult rv = GetStateInternal(&state, nsnull); - NS_ENSURE_SUCCESS(rv, rv); - - if (state & nsIAccessibleStates::STATE_PROTECTED) // Don't return password text! + if (NativeState() & states::PROTECTED) // Don't return password text! return NS_ERROR_FAILURE; nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mContent)); if (textArea) { return textArea->GetValue(_retval); } nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mContent)); if (inputElement) { return inputElement->GetValue(_retval); } return NS_ERROR_FAILURE; } -nsresult -nsHTMLTextFieldAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsHTMLTextFieldAccessible::NativeState() { - nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsHyperTextAccessibleWrap::NativeState(); // can be focusable, focused, protected. readonly, unavailable, selected if (mContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type, nsAccessibilityAtoms::password, eIgnoreCase)) { - *aState |= nsIAccessibleStates::STATE_PROTECTED; + state |= states::PROTECTED; } else { nsAccessible* parent = GetParent(); if (parent && parent->Role() == nsIAccessibleRole::ROLE_AUTOCOMPLETE) - *aState |= nsIAccessibleStates::STATE_HASPOPUP; + state |= states::HASPOPUP; } if (mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::readonly)) { - *aState |= nsIAccessibleStates::STATE_READONLY; + state |= states::READONLY; } - if (!aExtraState) - return NS_OK; - nsCOMPtr<nsIDOMHTMLInputElement> htmlInput(do_QueryInterface(mContent)); // Is it an <input> or a <textarea> ? if (htmlInput) { - *aExtraState |= nsIAccessibleStates::EXT_STATE_SINGLE_LINE; + state |= states::SINGLE_LINE; } else { - *aExtraState |= nsIAccessibleStates::EXT_STATE_MULTI_LINE; + state |= states::MULTI_LINE; } - if (!(*aExtraState & nsIAccessibleStates::EXT_STATE_EDITABLE)) - return NS_OK; + if (!(state & states::EDITABLE)) + return state; nsCOMPtr<nsIContent> bindingContent = mContent->GetBindingParent(); if (bindingContent && bindingContent->NodeInfo()->Equals(nsAccessibilityAtoms::textbox, kNameSpaceID_XUL)) { if (bindingContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type, nsAccessibilityAtoms::autocomplete, eIgnoreCase)) { // If parent is XUL textbox and value of @type attribute is "autocomplete", // then this accessible supports autocompletion. - *aExtraState |= nsIAccessibleStates::EXT_STATE_SUPPORTS_AUTOCOMPLETION; + state |= states::SUPPORTS_AUTOCOMPLETION; } - } else if (gIsFormFillEnabled && htmlInput && - !(*aState & nsIAccessibleStates::STATE_PROTECTED)) { + } else if (gIsFormFillEnabled && htmlInput && !(state & states::PROTECTED)) { // Check to see if autocompletion is allowed on this input. We don't expose // it for password fields even though the entire password can be remembered // for a page if the user asks it to be. However, the kind of autocomplete // we're talking here is based on what the user types, where a popup of // possible choices comes up. nsAutoString autocomplete; mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::autocomplete, autocomplete); @@ -519,21 +496,21 @@ nsHTMLTextFieldAccessible::GetStateInter htmlInput->GetForm(getter_AddRefs(form)); nsCOMPtr<nsIContent> formContent(do_QueryInterface(form)); if (formContent) { formContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::autocomplete, autocomplete); } if (!formContent || !autocomplete.LowerCaseEqualsLiteral("off")) - *aExtraState |= nsIAccessibleStates::EXT_STATE_SUPPORTS_AUTOCOMPLETION; + state |= states::SUPPORTS_AUTOCOMPLETION; } } - return NS_OK; + return state; } NS_IMETHODIMP nsHTMLTextFieldAccessible::GetNumActions(PRUint8 *_retval) { *_retval = 1; return NS_OK;; }
--- a/accessible/src/html/nsHTMLFormControlAccessible.h +++ b/accessible/src/html/nsHTMLFormControlAccessible.h @@ -55,31 +55,31 @@ public: // nsIAccessible NS_IMETHOD GetNumActions(PRUint8 *_retval); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD DoAction(PRUint8 index); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Accessible for HTML input@type="radio" element. */ class nsHTMLRadioButtonAccessible : public nsRadioButtonAccessible { public: nsHTMLRadioButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsAccessible - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet, PRInt32 *aSetSize); }; /** * Accessible for HTML input@type="button", @type="submit", @type="image" * elements. @@ -95,17 +95,17 @@ public: // nsIAccessible NS_IMETHOD GetNumActions(PRUint8 *_retval); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD DoAction(PRUint8 index); // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Accessible for HTML button element. */ class nsHTML4ButtonAccessible : public nsHyperTextAccessibleWrap { @@ -117,17 +117,17 @@ public: // nsIAccessible NS_IMETHOD GetNumActions(PRUint8 *_retval); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD DoAction(PRUint8 index); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Accessible for HTML input@type="text" element. */ class nsHTMLTextFieldAccessible : public nsHyperTextAccessibleWrap { @@ -146,17 +146,17 @@ public: NS_IMETHOD DoAction(PRUint8 index); // nsIAccessibleEditableText NS_IMETHOD GetAssociatedEditor(nsIEditor **aEditor); // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Accessible for HTML fieldset element. */ class nsHTMLGroupboxAccessible : public nsHyperTextAccessibleWrap {
--- a/accessible/src/html/nsHTMLImageAccessible.cpp +++ b/accessible/src/html/nsHTMLImageAccessible.cpp @@ -33,16 +33,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsHTMLImageAccessible.h" +#include "States.h" #include "nsAccessibilityAtoms.h" #include "nsAccUtils.h" #include "imgIContainer.h" #include "imgIRequest.h" #include "nsIDocument.h" #include "nsIImageLoadingContent.h" #include "nsILink.h" @@ -63,44 +64,43 @@ nsHTMLImageAccessible:: } NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLImageAccessible, nsAccessible, nsIAccessibleImage) //////////////////////////////////////////////////////////////////////////////// // nsAccessible public -nsresult -nsHTMLImageAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsHTMLImageAccessible::NativeState() { // The state is a bitfield, get our inherited state, then logically OR it with - // STATE_ANIMATED if this is an animated image. + // states::ANIMATED if this is an animated image. - nsresult rv = nsLinkableAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsLinkableAccessible::NativeState(); nsCOMPtr<nsIImageLoadingContent> content(do_QueryInterface(mContent)); nsCOMPtr<imgIRequest> imageRequest; if (content) content->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST, getter_AddRefs(imageRequest)); nsCOMPtr<imgIContainer> imgContainer; if (imageRequest) imageRequest->GetImage(getter_AddRefs(imgContainer)); if (imgContainer) { PRBool animated; imgContainer->GetAnimated(&animated); if (animated) - *aState |= nsIAccessibleStates::STATE_ANIMATED; + state |= states::ANIMATED; } - return NS_OK; + return state; } nsresult nsHTMLImageAccessible::GetNameInternal(nsAString& aName) { PRBool hasAltAttrib = mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::alt, aName); if (!aName.IsEmpty())
--- a/accessible/src/html/nsHTMLImageAccessible.h +++ b/accessible/src/html/nsHTMLImageAccessible.h @@ -62,17 +62,17 @@ public: NS_IMETHOD DoAction(PRUint8 index); // nsIAccessibleImage NS_DECL_NSIACCESSIBLEIMAGE // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes); private: /** * Determine if this image accessible has a longdesc attribute. * * @returns true if the longdesc attribute is present. */
--- a/accessible/src/html/nsHTMLImageMapAccessible.cpp +++ b/accessible/src/html/nsHTMLImageMapAccessible.cpp @@ -228,27 +228,27 @@ nsHTMLAreaAccessible::GetBounds(PRInt32 *aY += orgRectPixels.y; return NS_OK; } //////////////////////////////////////////////////////////////////////////////// // nsHTMLAreaAccessible: nsAccessible public -nsresult -nsHTMLAreaAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsHTMLAreaAccessible::NativeState() { // Bypass the link states specialization for non links. if (mRoleMapEntry && mRoleMapEntry->role != nsIAccessibleRole::ROLE_NOTHING && mRoleMapEntry->role != nsIAccessibleRole::ROLE_LINK) { - return nsAccessible::GetStateInternal(aState,aExtraState); + return nsAccessible::NativeState(); } - return nsHTMLLinkAccessible::GetStateInternal(aState, aExtraState); + return nsHTMLLinkAccessible::NativeState(); } nsAccessible* nsHTMLAreaAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY, EWhichChildAtPoint aWhichChild) { // Don't walk into area accessibles. return this;
--- a/accessible/src/html/nsHTMLImageMapAccessible.h +++ b/accessible/src/html/nsHTMLImageMapAccessible.h @@ -88,17 +88,17 @@ public: // nsIAccessible NS_IMETHOD GetDescription(nsAString& aDescription); NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height); // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual nsAccessible* GetChildAtPoint(PRInt32 aX, PRInt32 aY, EWhichChildAtPoint aWhichChild); // HyperLinkAccessible virtual PRUint32 StartOffset(); virtual PRUint32 EndOffset(); protected:
--- a/accessible/src/html/nsHTMLLinkAccessible.cpp +++ b/accessible/src/html/nsHTMLLinkAccessible.cpp @@ -34,16 +34,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsHTMLLinkAccessible.h" +#include "States.h" #include "nsCoreUtils.h" #include "nsIEventStateManager.h" //////////////////////////////////////////////////////////////////////////////// // nsHTMLLinkAccessible //////////////////////////////////////////////////////////////////////////////// @@ -61,50 +62,48 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLLinkA // nsIAccessible PRUint32 nsHTMLLinkAccessible::NativeRole() { return nsIAccessibleRole::ROLE_LINK; } -nsresult -nsHTMLLinkAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsHTMLLinkAccessible::NativeState() { - nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 states = nsHyperTextAccessibleWrap::NativeState(); - *aState &= ~nsIAccessibleStates::STATE_READONLY; + states &= ~states::READONLY; if (mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::name)) { // This is how we indicate it is a named anchor // In other words, this anchor can be selected as a location :) // There is no other better state to use to indicate this. - *aState |= nsIAccessibleStates::STATE_SELECTABLE; + states |= states::SELECTABLE; } nsEventStates state = mContent->IntrinsicState(); if (state.HasAtLeastOneOfStates(NS_EVENT_STATE_VISITED | NS_EVENT_STATE_UNVISITED)) { - *aState |= nsIAccessibleStates::STATE_LINKED; + states |= states::LINKED; if (state.HasState(NS_EVENT_STATE_VISITED)) - *aState |= nsIAccessibleStates::STATE_TRAVERSED; + states |= states::TRAVERSED; - return NS_OK; + return states; } // This is a either named anchor (a link with also a name attribute) or // it doesn't have any attributes. Check if 'click' event handler is // registered, otherwise bail out. if (nsCoreUtils::HasClickListener(mContent)) - *aState |= nsIAccessibleStates::STATE_LINKED; + states |= states::LINKED; - return NS_OK; + return states; } NS_IMETHODIMP nsHTMLLinkAccessible::GetValue(nsAString& aValue) { aValue.Truncate(); nsresult rv = nsHyperTextAccessible::GetValue(aValue);
--- a/accessible/src/html/nsHTMLLinkAccessible.h +++ b/accessible/src/html/nsHTMLLinkAccessible.h @@ -53,17 +53,17 @@ public: NS_IMETHOD GetValue(nsAString& aValue); NS_IMETHOD GetNumActions(PRUint8 *aNumActions); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD DoAction(PRUint8 aIndex); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); // HyperLinkAccessible virtual bool IsHyperLink(); virtual already_AddRefed<nsIURI> GetAnchorURI(PRUint32 aAnchorIndex); protected: enum { eAction_Jump = 0 };
--- a/accessible/src/html/nsHTMLSelectAccessible.cpp +++ b/accessible/src/html/nsHTMLSelectAccessible.cpp @@ -39,16 +39,17 @@ #include "nsHTMLSelectAccessible.h" #include "nsAccessibilityService.h" #include "nsAccUtils.h" #include "nsDocAccessible.h" #include "nsEventShell.h" #include "nsIAccessibleEvent.h" #include "nsTextEquivUtils.h" +#include "States.h" #include "nsCOMPtr.h" #include "nsIFrame.h" #include "nsIComboboxControlFrame.h" #include "nsIDocument.h" #include "nsIDOMHTMLInputElement.h" #include "nsIDOMHTMLOptGroupElement.h" #include "nsIDOMHTMLSelectElement.h" @@ -64,41 +65,37 @@ nsHTMLSelectListAccessible:: nsHTMLSelectListAccessible(nsIContent *aContent, nsIWeakReference *aShell) : nsAccessibleWrap(aContent, aShell) { } //////////////////////////////////////////////////////////////////////////////// // nsHTMLSelectListAccessible: nsAccessible public -nsresult -nsHTMLSelectListAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsHTMLSelectListAccessible::NativeState() { - nsresult rv = nsAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsAccessibleWrap::NativeState(); // As a nsHTMLSelectListAccessible we can have the following states: - // nsIAccessibleStates::STATE_MULTISELECTABLE - // nsIAccessibleStates::STATE_EXTSELECTABLE + // states::MULTISELECTABLE, states::EXTSELECTABLE - if (*aState & nsIAccessibleStates::STATE_FOCUSED) { + if (state & states::FOCUSED) { // Treat first focusable option node as actual focus, in order // to avoid confusing JAWS, which needs focus on the option nsCOMPtr<nsIContent> focusedOption = nsHTMLSelectOptionAccessible::GetFocusedOption(mContent); if (focusedOption) { // Clear focused state since it is on option - *aState &= ~nsIAccessibleStates::STATE_FOCUSED; + state &= ~states::FOCUSED; } } if (mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::multiple)) - *aState |= nsIAccessibleStates::STATE_MULTISELECTABLE | - nsIAccessibleStates::STATE_EXTSELECTABLE; + state |= states::MULTISELECTABLE | states::EXTSELECTABLE; - return NS_OK; + return state; } PRUint32 nsHTMLSelectListAccessible::NativeRole() { if (mParent && mParent->Role() == nsIAccessibleRole::ROLE_COMBOBOX) return nsIAccessibleRole::ROLE_COMBOBOX_LIST; @@ -224,116 +221,103 @@ nsHTMLSelectOptionAccessible::GetNameInt } return NS_OK; } // nsAccessible protected nsIFrame* nsHTMLSelectOptionAccessible::GetBoundsFrame() { - PRUint32 state = 0; - nsCOMPtr<nsIContent> content = GetSelectState(&state); - if (state & nsIAccessibleStates::STATE_COLLAPSED) { + PRUint64 state = 0; + nsIContent* content = GetSelectState(&state); + if (state & states::COLLAPSED) { if (content) { return content->GetPrimaryFrame(); } return nsnull; } return nsAccessible::GetBoundsFrame(); } -/** - * As a nsHTMLSelectOptionAccessible we can have the following states: - * STATE_SELECTABLE - * STATE_SELECTED - * STATE_FOCUSED - * STATE_FOCUSABLE - * STATE_OFFSCREEN - */ -nsresult -nsHTMLSelectOptionAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsHTMLSelectOptionAccessible::NativeState() { + // As a nsHTMLSelectOptionAccessible we can have the following states: + // SELECTABLE, SELECTED, FOCUSED, FOCUSABLE, OFFSCREEN // Upcall to nsAccessible, but skip nsHyperTextAccessible impl - // because we don't want EXT_STATE_EDITABLE or EXT_STATE_SELECTABLE_TEXT - nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + // because we don't want EDITABLE or SELECTABLE_TEXT + PRUint64 state = nsAccessible::NativeState(); - PRUint32 selectState = 0, selectExtState = 0; - nsCOMPtr<nsIContent> selectContent = GetSelectState(&selectState, - &selectExtState); - if (selectState & nsIAccessibleStates::STATE_INVISIBLE) { - return NS_OK; - } + PRUint64 selectState = 0; + nsIContent* selectContent = GetSelectState(&selectState); + if (selectState & states::INVISIBLE) + return state; NS_ENSURE_TRUE(selectContent, NS_ERROR_FAILURE); // Is disabled? - if (0 == (*aState & nsIAccessibleStates::STATE_UNAVAILABLE)) { - *aState |= (nsIAccessibleStates::STATE_FOCUSABLE | - nsIAccessibleStates::STATE_SELECTABLE); + if (0 == (state & states::UNAVAILABLE)) { + state |= (states::FOCUSABLE | states::SELECTABLE); // When the list is focused but no option is actually focused, // Firefox draws a focus ring around the first non-disabled option. - // We need to indicated STATE_FOCUSED in that case, because it + // We need to indicate states::FOCUSED in that case, because it // prevents JAWS from ignoring the list // GetFocusedOption() ensures that an option node is // returned in this case, as long as some focusable option exists // in the listbox nsCOMPtr<nsIContent> focusedOption = GetFocusedOption(selectContent); if (focusedOption == mContent) - *aState |= nsIAccessibleStates::STATE_FOCUSED; + state |= states::FOCUSED; } // Are we selected? PRBool isSelected = PR_FALSE; nsCOMPtr<nsIDOMHTMLOptionElement> option(do_QueryInterface(mContent)); if (option) { option->GetSelected(&isSelected); - if ( isSelected ) - *aState |= nsIAccessibleStates::STATE_SELECTED; + if (isSelected) + state |= states::SELECTED; + } - if (selectState & nsIAccessibleStates::STATE_OFFSCREEN) { - *aState |= nsIAccessibleStates::STATE_OFFSCREEN; + if (selectState & states::OFFSCREEN) { + state |= states::OFFSCREEN; } - else if (selectState & nsIAccessibleStates::STATE_COLLAPSED) { - // <select> is COLLAPSED: add STATE_OFFSCREEN, if not the currently + else if (selectState & states::COLLAPSED) { + // <select> is COLLAPSED: add OFFSCREEN, if not the currently // visible option if (!isSelected) { - *aState |= nsIAccessibleStates::STATE_OFFSCREEN; + state |= states::OFFSCREEN; } else { // Clear offscreen and invisible for currently showing option - *aState &= ~nsIAccessibleStates::STATE_OFFSCREEN; - *aState &= ~nsIAccessibleStates::STATE_INVISIBLE; - if (aExtraState) { - *aExtraState |= selectExtState & nsIAccessibleStates::EXT_STATE_OPAQUE; - } + state &= ~(states::OFFSCREEN | states::INVISIBLE); + state |= selectState & states::OPAQUE1; } } else { // XXX list frames are weird, don't rely on nsAccessible's general // visibility implementation unless they get reimplemented in layout - *aState &= ~nsIAccessibleStates::STATE_OFFSCREEN; - // <select> is not collapsed: compare bounds to calculate STATE_OFFSCREEN + state &= ~states::OFFSCREEN; + // <select> is not collapsed: compare bounds to calculate OFFSCREEN nsAccessible* listAcc = GetParent(); if (listAcc) { PRInt32 optionX, optionY, optionWidth, optionHeight; PRInt32 listX, listY, listWidth, listHeight; GetBounds(&optionX, &optionY, &optionWidth, &optionHeight); listAcc->GetBounds(&listX, &listY, &listWidth, &listHeight); if (optionY < listY || optionY + optionHeight > listY + listHeight) { - *aState |= nsIAccessibleStates::STATE_OFFSCREEN; + state |= states::OFFSCREEN; } } } - return NS_OK; + return state; } PRInt32 nsHTMLSelectOptionAccessible::GetLevelInternal() { nsIContent *parentContent = mContent->GetParent(); PRInt32 level = @@ -548,51 +532,48 @@ nsHTMLSelectOptionAccessible::SelectionC nsRefPtr<AccEvent> selWithinEvent = new AccEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN, multiSelect); if (!selWithinEvent) return; option->GetDocAccessible()->FireDelayedAccessibleEvent(selWithinEvent); - PRUint32 state = nsAccUtils::State(option); + PRUint64 state = option->State(); PRUint32 eventType; - if (state & nsIAccessibleStates::STATE_SELECTED) { + if (state & states::SELECTED) { eventType = nsIAccessibleEvent::EVENT_SELECTION_ADD; } else { eventType = nsIAccessibleEvent::EVENT_SELECTION_REMOVE; } nsRefPtr<AccEvent> selAddRemoveEvent = new AccEvent(eventType, option); if (selAddRemoveEvent) option->GetDocAccessible()->FireDelayedAccessibleEvent(selAddRemoveEvent); } //////////////////////////////////////////////////////////////////////////////// // nsHTMLSelectOptionAccessible: private methods -nsIContent* nsHTMLSelectOptionAccessible::GetSelectState(PRUint32* aState, - PRUint32* aExtraState) +nsIContent* +nsHTMLSelectOptionAccessible::GetSelectState(PRUint64* aState) { *aState = 0; - if (aExtraState) - *aExtraState = 0; - nsIContent *content = mContent; while (content && content->Tag() != nsAccessibilityAtoms::select) { content = content->GetParent(); } if (content) { nsAccessible* selAcc = GetAccService()->GetAccessible(content); if (selAcc) { - selAcc->GetState(aState, aExtraState); + *aState = selAcc->State(); return content; } } return nsnull; } //////////////////////////////////////////////////////////////////////////////// @@ -607,28 +588,24 @@ nsHTMLSelectOptGroupAccessible:: } PRUint32 nsHTMLSelectOptGroupAccessible::NativeRole() { return nsIAccessibleRole::ROLE_HEADING; } -nsresult -nsHTMLSelectOptGroupAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsHTMLSelectOptGroupAccessible::NativeState() { - nsresult rv = nsHTMLSelectOptionAccessible::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsHTMLSelectOptionAccessible::NativeState(); - *aState &= ~(nsIAccessibleStates::STATE_FOCUSABLE | - nsIAccessibleStates::STATE_SELECTABLE); + state &= ~(states::FOCUSABLE | states::SELECTABLE); - return NS_OK; + return state; } NS_IMETHODIMP nsHTMLSelectOptGroupAccessible::DoAction(PRUint8 index) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP nsHTMLSelectOptGroupAccessible::GetActionName(PRUint8 aIndex, nsAString& aName) @@ -721,45 +698,38 @@ nsHTMLComboboxAccessible::Shutdown() if (mListAccessible) { mListAccessible->Shutdown(); mListAccessible = nsnull; } } /** - * As a nsHTMLComboboxAccessible we can have the following states: - * STATE_FOCUSED - * STATE_FOCUSABLE - * STATE_HASPOPUP - * STATE_EXPANDED - * STATE_COLLAPSED */ -nsresult -nsHTMLComboboxAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsHTMLComboboxAccessible::NativeState() { + // As a nsHTMLComboboxAccessible we can have the following states: + // FOCUSED, FOCUSABLE, HASPOPUP, EXPANDED, COLLAPSED // Get focus status from base class - nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsAccessible::NativeState(); nsIFrame *frame = GetBoundsFrame(); nsIComboboxControlFrame *comboFrame = do_QueryFrame(frame); if (comboFrame && comboFrame->IsDroppedDown()) { - *aState |= nsIAccessibleStates::STATE_EXPANDED; + state |= states::EXPANDED; } else { - *aState &= ~nsIAccessibleStates::STATE_FOCUSED; // Focus is on an option - *aState |= nsIAccessibleStates::STATE_COLLAPSED; + state &= ~states::FOCUSED; // Focus is on an option + state |= states::COLLAPSED; } - *aState |= nsIAccessibleStates::STATE_HASPOPUP | - nsIAccessibleStates::STATE_FOCUSABLE; + state |= states::HASPOPUP | states::FOCUSABLE; - return NS_OK; + return state; } NS_IMETHODIMP nsHTMLComboboxAccessible::GetDescription(nsAString& aDescription) { aDescription.Truncate(); // First check to see if combo box itself has a description, perhaps through // tooltip (title attribute) or via aria-describedby nsAccessible::GetDescription(aDescription); @@ -889,54 +859,47 @@ bool nsHTMLComboboxListAccessible::IsPrimaryForNode() const { return false; } //////////////////////////////////////////////////////////////////////////////// // nsHTMLComboboxAccessible: nsAccessible -/** - * As a nsHTMLComboboxListAccessible we can have the following states: - * STATE_FOCUSED - * STATE_FOCUSABLE - * STATE_INVISIBLE - * STATE_FLOATING - */ -nsresult -nsHTMLComboboxListAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsHTMLComboboxListAccessible::NativeState() { + // As a nsHTMLComboboxListAccessible we can have the following states: + // FOCUSED, FOCUSABLE, FLOATING, INVISIBLE // Get focus status from base class - nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsAccessible::NativeState(); nsIFrame *boundsFrame = GetBoundsFrame(); nsIComboboxControlFrame* comboFrame = do_QueryFrame(boundsFrame); if (comboFrame && comboFrame->IsDroppedDown()) - *aState |= nsIAccessibleStates::STATE_FLOATING; + state |= states::FLOATING; else - *aState |= nsIAccessibleStates::STATE_INVISIBLE; + state |= states::INVISIBLE; - return NS_OK; + return state; } /** * Gets the bounds for the areaFrame. * Walks the Frame tree and checks for proper frames. */ void nsHTMLComboboxListAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame) { *aBoundingFrame = nsnull; nsAccessible* comboAcc = GetParent(); if (!comboAcc) return; - if (0 == (nsAccUtils::State(comboAcc) & nsIAccessibleStates::STATE_COLLAPSED)) { + if (0 == (comboAcc->State() & states::COLLAPSED)) { nsHTMLSelectListAccessible::GetBoundsRect(aBounds, aBoundingFrame); return; } // Get the first option. nsIContent* content = mContent->GetChildAt(0); if (!content) { return;
--- a/accessible/src/html/nsHTMLSelectAccessible.h +++ b/accessible/src/html/nsHTMLSelectAccessible.h @@ -69,17 +69,17 @@ class nsHTMLSelectListAccessible : publi { public: nsHTMLSelectListAccessible(nsIContent *aContent, nsIWeakReference *aShell); virtual ~nsHTMLSelectListAccessible() {} // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); // SelectAccessible virtual bool IsSelect(); virtual bool SelectAll(); virtual bool UnselectAll(); protected: @@ -109,17 +109,17 @@ public: NS_IMETHOD DoAction(PRUint8 index); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD GetNumActions(PRUint8 *_retval); NS_IMETHOD SetSelected(PRBool aSelect); // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual PRInt32 GetLevelInternal(); virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet, PRInt32 *aSetSize); /** * Return focused option if any. */ @@ -131,20 +131,19 @@ protected: // nsAccessible virtual nsIFrame* GetBoundsFrame(); private: /** * Get Select element's accessible state * @param aState, Select element state - * @param aExtraState, Select element extra state * @return Select element content, returns null if not avaliable */ - nsIContent* GetSelectState(PRUint32* aState, PRUint32* aExtraState = nsnull); + nsIContent* GetSelectState(PRUint64* aState); }; /* * Opt Groups inside the select, contained within the list */ class nsHTMLSelectOptGroupAccessible : public nsHTMLSelectOptionAccessible { public: @@ -154,17 +153,17 @@ public: // nsIAccessible NS_IMETHOD DoAction(PRUint8 index); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD GetNumActions(PRUint8 *_retval); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); protected: // nsAccessible virtual void CacheChildren(); }; /** ------------------------------------------------------ */ /** Finally, the Combobox widgets */ @@ -190,17 +189,17 @@ public: NS_IMETHOD GetNumActions(PRUint8 *aNumActions); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); // nsAccessNode virtual void Shutdown(); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual void InvalidateChildren(); protected: // nsAccessible virtual void CacheChildren(); // nsHTMLComboboxAccessible @@ -227,13 +226,13 @@ public: nsIWeakReference* aShell); virtual ~nsHTMLComboboxListAccessible() {} // nsAccessNode virtual nsIFrame* GetFrame() const; virtual bool IsPrimaryForNode() const; // nsAccessible - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame); }; #endif
--- a/accessible/src/html/nsHTMLTableAccessible.cpp +++ b/accessible/src/html/nsHTMLTableAccessible.cpp @@ -34,16 +34,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsHTMLTableAccessible.h" +#include "States.h" #include "nsAccessibilityService.h" #include "nsAccTreeWalker.h" #include "nsAccUtils.h" #include "nsDocAccessible.h" #include "nsRelUtils.h" #include "nsTextEquivUtils.h" #include "nsIDOMElement.h" @@ -87,35 +88,33 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLTable // nsHTMLTableCellAccessible: nsAccessible implementation PRUint32 nsHTMLTableCellAccessible::NativeRole() { return nsIAccessibleRole::ROLE_CELL; } -nsresult -nsHTMLTableCellAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsHTMLTableCellAccessible::NativeState() { - nsresult rv= nsHyperTextAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsHyperTextAccessibleWrap::NativeState(); nsIFrame *frame = mContent->GetPrimaryFrame(); NS_ASSERTION(frame, "No frame for valid cell accessible!"); if (frame) { - *aState |= nsIAccessibleStates::STATE_SELECTABLE; + state |= states::SELECTABLE; PRBool isSelected = PR_FALSE; frame->GetSelected(&isSelected); if (isSelected) - *aState |= nsIAccessibleStates::STATE_SELECTED; + state |= states::SELECTED; } - return NS_OK; + return state; } nsresult nsHTMLTableCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes) { if (IsDefunct()) return NS_ERROR_FAILURE; @@ -451,24 +450,20 @@ nsHTMLTableAccessible::CacheChildren() } PRUint32 nsHTMLTableAccessible::NativeRole() { return nsIAccessibleRole::ROLE_TABLE; } -nsresult -nsHTMLTableAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsHTMLTableAccessible::NativeState() { - nsresult rv= nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); - - *aState |= nsIAccessibleStates::STATE_READONLY; - return NS_OK; + return nsAccessible::NativeState() | states::READONLY; } nsresult nsHTMLTableAccessible::GetNameInternal(nsAString& aName) { nsAccessible::GetNameInternal(aName); if (aName.IsEmpty()) @@ -1362,19 +1357,18 @@ nsHTMLTableAccessible::IsProbablyForLayo *aIsProbablyForLayout = PR_FALSE; if (IsDefunct()) return NS_ERROR_FAILURE; nsDocAccessible *docAccessible = GetDocAccessible(); if (docAccessible) { - PRUint32 state, extState; - docAccessible->GetState(&state, &extState); - if (extState & nsIAccessibleStates::EXT_STATE_EDITABLE) { // Need to see all elements while document is being edited + PRUint64 docState = docAccessible->State(); + if (docState & states::EDITABLE) { // Need to see all elements while document is being edited RETURN_LAYOUT_ANSWER(PR_FALSE, "In editable document"); } } // Check to see if an ARIA role overrides the role from native markup, // but for which we still expose table semantics (treegrid, for example). PRBool hasNonTableRole = (Role() != nsIAccessibleRole::ROLE_TABLE); if (hasNonTableRole) {
--- a/accessible/src/html/nsHTMLTableAccessible.h +++ b/accessible/src/html/nsHTMLTableAccessible.h @@ -57,17 +57,17 @@ public: // nsISupports NS_DECL_ISUPPORTS_INHERITED // nsIAccessibleTableCell NS_DECL_NSIACCESSIBLETABLECELL // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes); protected: /** * Return host table accessible. */ already_AddRefed<nsIAccessibleTable> GetTableAccessible(); @@ -133,17 +133,17 @@ public: // nsIAccessible NS_IMETHOD GetDescription(nsAString& aDescription); NS_IMETHOD GetRelationByType(PRUint32 aRelationType, nsIAccessibleRelation **aRelation); // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes); // nsHTMLTableAccessible /** * Retun cell element at the given row and column index. */ nsresult GetCellAt(PRInt32 aRowIndex, PRInt32 aColIndex,
--- a/accessible/src/html/nsHTMLTextAccessible.cpp +++ b/accessible/src/html/nsHTMLTextAccessible.cpp @@ -38,16 +38,17 @@ * ***** END LICENSE BLOCK ***** */ #include "nsHTMLTextAccessible.h" #include "nsDocAccessible.h" #include "nsAccUtils.h" #include "nsRelUtils.h" #include "nsTextEquivUtils.h" +#include "States.h" #include "nsIFrame.h" #include "nsPresContext.h" #include "nsBlockFrame.h" #include "nsISelection.h" #include "nsISelectionController.h" #include "nsComponentManagerUtils.h" @@ -79,32 +80,30 @@ nsHTMLTextAccessible::NativeRole() // after accessible is shutdown/DEFUNCT if (frame && frame->IsGeneratedContentFrame()) { return nsIAccessibleRole::ROLE_STATICTEXT; } return nsTextAccessible::NativeRole(); } -nsresult -nsHTMLTextAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsHTMLTextAccessible::NativeState() { - nsresult rv = nsTextAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsTextAccessible::NativeState(); nsDocAccessible *docAccessible = GetDocAccessible(); if (docAccessible) { - PRUint32 state, extState; - docAccessible->GetState(&state, &extState); - if (0 == (extState & nsIAccessibleStates::EXT_STATE_EDITABLE)) { - *aState |= nsIAccessibleStates::STATE_READONLY; // Links not focusable in editor + PRUint64 docState = docAccessible->State(); + if (0 == (docState & states::EDITABLE)) { + state |= states::READONLY; // Links not focusable in editor } } - return NS_OK; + return state; } nsresult nsHTMLTextAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes) { if (NativeRole() == nsIAccessibleRole::ROLE_STATICTEXT) { nsAutoString oldValueUnused; aAttributes->SetStringProperty(NS_LITERAL_CSTRING("auto-generated"), @@ -143,33 +142,20 @@ nsHTMLBRAccessible:: } PRUint32 nsHTMLBRAccessible::NativeRole() { return nsIAccessibleRole::ROLE_WHITESPACE; } -nsresult -nsHTMLBRAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsHTMLBRAccessible::NativeState() { - *aState = 0; - - if (IsDefunct()) { - if (aExtraState) - *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - - return NS_OK_DEFUNCT_OBJECT; - } - - *aState = nsIAccessibleStates::STATE_READONLY; - if (aExtraState) - *aExtraState = 0; - - return NS_OK; + return IsDefunct() ? states::DEFUNCT : states::READONLY; } nsresult nsHTMLBRAccessible::GetNameInternal(nsAString& aName) { aName = static_cast<PRUnichar>('\n'); // Newline char return NS_OK; } @@ -277,25 +263,20 @@ nsHTMLLIAccessible::Shutdown() } PRUint32 nsHTMLLIAccessible::NativeRole() { return nsIAccessibleRole::ROLE_LISTITEM; } -nsresult -nsHTMLLIAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsHTMLLIAccessible::NativeState() { - nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); - - *aState |= nsIAccessibleStates::STATE_READONLY; - return NS_OK; + return nsHyperTextAccessibleWrap::NativeState() | states::READONLY; } NS_IMETHODIMP nsHTMLLIAccessible::GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height) { nsresult rv = nsAccessibleWrap::GetBounds(x, y, width, height); if (NS_FAILED(rv) || !mBullet) return rv; @@ -392,25 +373,24 @@ nsHTMLListBulletAccessible::GetName(nsAS } PRUint32 nsHTMLListBulletAccessible::NativeRole() { return nsIAccessibleRole::ROLE_STATICTEXT; } -nsresult -nsHTMLListBulletAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsHTMLListBulletAccessible::NativeState() { - nsresult rv = nsLeafAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsLeafAccessible::NativeState(); - *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; - *aState |= nsIAccessibleStates::STATE_READONLY; - return NS_OK; + state &= ~states::FOCUSABLE; + state |= states::READONLY; + return state; } void nsHTMLListBulletAccessible::AppendTextTo(nsAString& aText, PRUint32 aStartOffset, PRUint32 aLength) { nsAutoString bulletText; nsBlockFrame* blockFrame = do_QueryFrame(mContent->GetPrimaryFrame()); @@ -434,19 +414,14 @@ nsHTMLListAccessible:: NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLListAccessible, nsHyperTextAccessible) PRUint32 nsHTMLListAccessible::NativeRole() { return nsIAccessibleRole::ROLE_LIST; } -nsresult -nsHTMLListAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsHTMLListAccessible::NativeState() { - nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); - - *aState |= nsIAccessibleStates::STATE_READONLY; - return NS_OK; + return nsHyperTextAccessibleWrap::NativeState() | states::READONLY; }
--- a/accessible/src/html/nsHTMLTextAccessible.h +++ b/accessible/src/html/nsHTMLTextAccessible.h @@ -56,17 +56,17 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIAccessible NS_IMETHOD GetName(nsAString& aName); // nsAccessible virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Used for HTML hr element. */ class nsHTMLHRAccessible : public nsLeafAccessible { public: @@ -82,17 +82,17 @@ public: class nsHTMLBRAccessible : public nsLeafAccessible { public: nsHTMLBRAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Used for HTML label element. */ class nsHTMLLabelAccessible : public nsHyperTextAccessibleWrap { public: @@ -135,17 +135,17 @@ public: // nsIAccessible NS_IMETHOD GetName(nsAString& aName); // nsAccessNode virtual bool IsPrimaryForNode() const; // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual void AppendTextTo(nsAString& aText, PRUint32 aStartOffset = 0, PRUint32 aLength = PR_UINT32_MAX); }; /** * Used for HTML list (like HTML ul). */ class nsHTMLListAccessible : public nsHyperTextAccessibleWrap @@ -153,17 +153,17 @@ class nsHTMLListAccessible : public nsHy public: nsHTMLListAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsISupports NS_DECL_ISUPPORTS_INHERITED // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Used for HTML list item (e.g. HTML li). */ class nsHTMLLIAccessible : public nsHyperTextAccessibleWrap { public: @@ -175,17 +175,17 @@ public: // nsAccessNode virtual void Shutdown(); // nsIAccessible NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); // nsHTMLLIAccessible void UpdateBullet(bool aHasBullet); protected: // nsAccessible virtual void CacheChildren();
--- a/accessible/src/html/nsHyperTextAccessible.cpp +++ b/accessible/src/html/nsHyperTextAccessible.cpp @@ -34,16 +34,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsHyperTextAccessible.h" +#include "States.h" #include "nsAccessibilityAtoms.h" #include "nsAccessibilityService.h" #include "nsAccUtils.h" #include "nsTextAttrs.h" #include "nsIClipboard.h" #include "nsContentCID.h" #include "nsIDOMAbstractView.h" @@ -168,42 +169,38 @@ nsHyperTextAccessible::NativeRole() // An html:input @type="file" is the only input that is exposed as a // blockframe. It must be exposed as ROLE_TEXT_CONTAINER for JAWS. return nsIAccessibleRole::ROLE_PARAGRAPH; } return nsIAccessibleRole::ROLE_TEXT_CONTAINER; // In ATK this works } -nsresult -nsHyperTextAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsHyperTextAccessible::NativeState() { - nsresult rv = nsAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); - - if (!aExtraState) - return NS_OK; + PRUint64 states = nsAccessibleWrap::NativeState(); nsCOMPtr<nsIEditor> editor; GetAssociatedEditor(getter_AddRefs(editor)); if (editor) { PRUint32 flags; editor->GetFlags(&flags); if (0 == (flags & nsIPlaintextEditor::eEditorReadonlyMask)) { - *aExtraState |= nsIAccessibleStates::EXT_STATE_EDITABLE; + states |= states::EDITABLE; } } else if (mContent->Tag() == nsAccessibilityAtoms::article) { // We want <article> to behave like a document in terms of readonly state. - *aState |= nsIAccessibleStates::STATE_READONLY; + states |= states::READONLY; } if (GetChildCount() > 0) - *aExtraState |= nsIAccessibleStates::EXT_STATE_SELECTABLE_TEXT; + states |= states::SELECTABLE_TEXT; - return NS_OK; + return states; } // Substring must be entirely within the same text node nsIntRect nsHyperTextAccessible::GetBoundsForString(nsIFrame *aFrame, PRUint32 aStartRenderedOffset, PRUint32 aEndRenderedOffset) { nsIntRect screenRect; NS_ENSURE_TRUE(aFrame, screenRect);
--- a/accessible/src/html/nsHyperTextAccessible.h +++ b/accessible/src/html/nsHyperTextAccessible.h @@ -82,17 +82,17 @@ public: NS_DECL_NSIACCESSIBLEHYPERTEXT NS_DECL_NSIACCESSIBLEEDITABLETEXT NS_DECLARE_STATIC_IID_ACCESSOR(NS_HYPERTEXTACCESSIBLE_IMPL_CID) // nsAccessible virtual PRInt32 GetLevelInternal(); virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual void InvalidateChildren(); virtual PRBool RemoveChild(nsAccessible* aAccessible); // nsHyperTextAccessible (static helper method) // Convert content offset to rendered text offset static nsresult ContentToRenderedOffset(nsIFrame *aFrame, PRInt32 aContentOffset,
--- a/accessible/src/mac/mozAccessible.mm +++ b/accessible/src/mac/mozAccessible.mm @@ -543,39 +543,33 @@ GetNativeFromGeckoAccessible(nsIAccessib return [NSString stringWithFormat:@"(%p) %@", self, [self role]]; NS_OBJC_END_TRY_ABORT_BLOCK_NIL; } - (BOOL)isFocused { - PRUint32 state = 0; - mGeckoAccessible->GetState (&state, nsnull); - return (state & nsIAccessibleStates::STATE_FOCUSED) != 0; + return (mGeckoAccessible->State() & states::FOCUSED) != 0; } - (BOOL)canBeFocused { - PRUint32 state = 0; - mGeckoAccessible->GetState (&state, nsnull); - return (state & nsIAccessibleStates::STATE_FOCUSABLE) != 0; + return mGeckoAccessible->State() & states::FOCUSABLE; } - (BOOL)focus { nsresult rv = mGeckoAccessible->TakeFocus(); return NS_SUCCEEDED(rv); } - (BOOL)isEnabled { - PRUint32 state = 0; - mGeckoAccessible->GetState (&state, nsnull); - return (state & nsIAccessibleStates::STATE_UNAVAILABLE) == 0; + return (mGeckoAccessible->State() & states::UNAVAILABLE) == 0; } // The root accessible calls this when the focused node was // changed to us. - (void)didReceiveFocus { NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
--- a/accessible/src/mac/mozActionElements.mm +++ b/accessible/src/mac/mozActionElements.mm @@ -152,22 +152,21 @@ enum CheckboxValue { return nil; NS_OBJC_END_TRY_ABORT_BLOCK_NIL; } - (int)isChecked { - PRUint32 state = 0; - mGeckoAccessible->GetStateInternal(&state, nsnull); + PRUint64 state = mGeckoAccessible->NativeState(); // check if we're checked or in a mixed state - if (state & nsIAccessibleStates::STATE_CHECKED) { - return (state & nsIAccessibleStates::STATE_MIXED) ? kMixed : kChecked; + if (state & states::CHECKED) { + return (state & states::MIXED) ? kMixed : kChecked; } return kUnchecked; } - (id)value { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
--- a/accessible/src/mac/mozTextAccessible.mm +++ b/accessible/src/mac/mozTextAccessible.mm @@ -133,21 +133,18 @@ extern const NSString *kTopLevelUIElemen - (BOOL)isReadOnly { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN; if ([[self role] isEqualToString:NSAccessibilityStaticTextRole]) return YES; - if (mGeckoEditableTextAccessible) { - PRUint32 state = 0; - mGeckoAccessible->GetState(&state, nsnull); - return (state & nsIAccessibleStates::STATE_READONLY) == 0; - } + if (mGeckoEditableTextAccessible) + return (mGeckoEditableTextAccessible->State() & states::READONLY) == 0; return NO; NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO); } - (void)setText:(NSString*)newString {
--- a/accessible/src/mac/nsAccessibleWrap.h +++ b/accessible/src/mac/nsAccessibleWrap.h @@ -79,19 +79,17 @@ class nsAccessibleWrap : public nsAccess // ignored means that the accessible might still have children, but is not displayed // to the user. it also has no native accessible object represented for it. PRBool IsIgnored(); PRInt32 GetUnignoredChildCount(PRBool aDeepCount); PRBool HasPopup () { - PRUint32 state = 0; - GetStateInternal(&state, nsnull); - return (state & nsIAccessibleStates::STATE_HASPOPUP); + return (NativeState() & states::HASPOPUP); } // return this accessible's all children, adhering to "flat" accessibles by not returning their children. void GetUnignoredChildren(nsTArray<nsRefPtr<nsAccessibleWrap> > &aChildrenArray); virtual already_AddRefed<nsIAccessible> GetUnignoredParent(); protected:
--- a/accessible/src/msaa/CAccessibleComponent.cpp +++ b/accessible/src/msaa/CAccessibleComponent.cpp @@ -37,22 +37,19 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "CAccessibleComponent.h" #include "AccessibleComponent_i.c" -#include "nsIAccessNode.h" -#include "nsIAccessible.h" -#include "nsIAccessibleStates.h" -#include "nsAccessNodeWrap.h" +#include "nsAccessible.h" +#include "States.h" -#include "nsCOMPtr.h" #include "nsString.h" #include "nsIDOMCSSPrimitiveValue.h" #include "nsIDOMNSRGBAColor.h" enum { IA2AlphaShift = 24, IA2RedShift = 16, @@ -80,31 +77,27 @@ CAccessibleComponent::QueryInterface(REF STDMETHODIMP CAccessibleComponent::get_locationInParent(long *aX, long *aY) { __try { *aX = 0; *aY = 0; - nsCOMPtr<nsIAccessible> acc(do_QueryObject(this)); + nsRefPtr<nsAccessible> acc(do_QueryObject(this)); if (!acc) return E_FAIL; // If the object is not on any screen the returned position is (0,0). - PRUint32 states = 0; - nsresult rv = acc->GetState(&states, nsnull); - if (NS_FAILED(rv)) - return GetHRESULT(rv); - - if (states & nsIAccessibleStates::STATE_INVISIBLE) + PRUint64 state = acc->State(); + if (state & states::INVISIBLE) return S_OK; PRInt32 x = 0, y = 0, width = 0, height = 0; - rv = acc->GetBounds(&x, &y, &width, &height); + nsresult rv = acc->GetBounds(&x, &y, &width, &height); if (NS_FAILED(rv)) return GetHRESULT(rv); nsCOMPtr<nsIAccessible> parentAcc; rv = acc->GetParent(getter_AddRefs(parentAcc)); if (NS_FAILED(rv)) return GetHRESULT(rv);
--- a/accessible/src/msaa/nsAccessibleWrap.cpp +++ b/accessible/src/msaa/nsAccessibleWrap.cpp @@ -38,16 +38,17 @@ #include "nsAccessibleWrap.h" #include "nsAccessibilityAtoms.h" #include "nsAccUtils.h" #include "nsCoreUtils.h" #include "nsRelUtils.h" #include "nsWinUtils.h" +#include "States.h" #include "nsIAccessibleDocument.h" #include "nsIAccessibleEvent.h" #include "nsIAccessibleWin32Object.h" #include "Accessible2_i.c" #include "AccessibleStates.h" @@ -430,21 +431,27 @@ STDMETHODIMP nsAccessibleWrap::get_accSt VariantInit(pvarState); pvarState->vt = VT_I4; pvarState->lVal = 0; nsAccessible *xpAccessible = GetXPAccessibleFor(varChild); if (!xpAccessible) return E_FAIL; - PRUint32 state = 0; - if (NS_FAILED(xpAccessible->GetState(&state, nsnull))) - return E_FAIL; + // MSAA only has 31 states and the lowest 31 bits of our state bit mask + // are the same states as MSAA. + // Note: we map the following Gecko states to different MSAA states: + // REQUIRED -> ALERT_LOW + // ALERT -> ALERT_MEDIUM + // INVALID -> ALERT_HIGH + // CHECKABLE -> MARQUEED - pvarState->lVal = state; + PRUint32 msaaState = 0; + nsAccUtils::To32States(xpAccessible->State(), &msaaState, nsnull); + pvarState->lVal = msaaState; } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { } return S_OK; } STDMETHODIMP nsAccessibleWrap::get_accHelp( /* [optional][in] */ VARIANT varChild, /* [retval][out] */ BSTR __RPC_FAR *pszHelp) @@ -1238,57 +1245,54 @@ nsAccessibleWrap::get_groupPosition(long STDMETHODIMP nsAccessibleWrap::get_states(AccessibleStates *aStates) { __try { *aStates = 0; // XXX: bug 344674 should come with better approach that we have here. - PRUint32 states = 0, extraStates = 0; - nsresult rv = GetState(&states, &extraStates); - if (NS_FAILED(rv)) - return GetHRESULT(rv); + PRUint64 state = State(); - if (states & nsIAccessibleStates::STATE_INVALID) + if (state & states::INVALID) *aStates |= IA2_STATE_INVALID_ENTRY; - if (states & nsIAccessibleStates::STATE_REQUIRED) + if (state & states::REQUIRED) *aStates |= IA2_STATE_REQUIRED; // The following IA2 states are not supported by Gecko // IA2_STATE_ARMED // IA2_STATE_MANAGES_DESCENDANTS // IA2_STATE_ICONIFIED // IA2_STATE_INVALID // This is not a state, it is the absence of a state - if (extraStates & nsIAccessibleStates::EXT_STATE_ACTIVE) + if (state & states::ACTIVE) *aStates |= IA2_STATE_ACTIVE; - if (extraStates & nsIAccessibleStates::EXT_STATE_DEFUNCT) + if (state & states::DEFUNCT) *aStates |= IA2_STATE_DEFUNCT; - if (extraStates & nsIAccessibleStates::EXT_STATE_EDITABLE) + if (state & states::EDITABLE) *aStates |= IA2_STATE_EDITABLE; - if (extraStates & nsIAccessibleStates::EXT_STATE_HORIZONTAL) + if (state & states::HORIZONTAL) *aStates |= IA2_STATE_HORIZONTAL; - if (extraStates & nsIAccessibleStates::EXT_STATE_MODAL) + if (state & states::MODAL) *aStates |= IA2_STATE_MODAL; - if (extraStates & nsIAccessibleStates::EXT_STATE_MULTI_LINE) + if (state & states::MULTI_LINE) *aStates |= IA2_STATE_MULTI_LINE; - if (extraStates & nsIAccessibleStates::EXT_STATE_OPAQUE) + if (state & states::OPAQUE1) *aStates |= IA2_STATE_OPAQUE; - if (extraStates & nsIAccessibleStates::EXT_STATE_SELECTABLE_TEXT) + if (state & states::SELECTABLE_TEXT) *aStates |= IA2_STATE_SELECTABLE_TEXT; - if (extraStates & nsIAccessibleStates::EXT_STATE_SINGLE_LINE) + if (state & states::SINGLE_LINE) *aStates |= IA2_STATE_SINGLE_LINE; - if (extraStates & nsIAccessibleStates::EXT_STATE_STALE) + if (state & states::STALE) *aStates |= IA2_STATE_STALE; - if (extraStates & nsIAccessibleStates::EXT_STATE_SUPPORTS_AUTOCOMPLETION) + if (state & states::SUPPORTS_AUTOCOMPLETION) *aStates |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; - if (extraStates & nsIAccessibleStates::EXT_STATE_TRANSIENT) + if (state & states::TRANSIENT) *aStates |= IA2_STATE_TRANSIENT; - if (extraStates & nsIAccessibleStates::EXT_STATE_VERTICAL) + if (state & states::VERTICAL) *aStates |= IA2_STATE_VERTICAL; return S_OK; } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { } return E_FAIL; }
--- a/accessible/src/msaa/nsHTMLWin32ObjectAccessible.cpp +++ b/accessible/src/msaa/nsHTMLWin32ObjectAccessible.cpp @@ -33,16 +33,18 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsHTMLWin32ObjectAccessible.h" +#include "States.h" + //////////////////////////////////////////////////////////////////////////////// // nsHTMLWin32ObjectOwnerAccessible //////////////////////////////////////////////////////////////////////////////// nsHTMLWin32ObjectOwnerAccessible:: nsHTMLWin32ObjectOwnerAccessible(nsIContent *aContent, nsIWeakReference *aShell, void *aHwnd) : nsAccessibleWrap(aContent, aShell), mHwnd(aHwnd) @@ -65,30 +67,25 @@ nsHTMLWin32ObjectOwnerAccessible::Shutdo // nsHTMLWin32ObjectOwnerAccessible: nsAccessible implementation PRUint32 nsHTMLWin32ObjectOwnerAccessible::NativeRole() { return nsIAccessibleRole::ROLE_EMBEDDED_OBJECT; } -nsresult -nsHTMLWin32ObjectOwnerAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsHTMLWin32ObjectOwnerAccessible::NativeState() { - nsresult rv = nsAccessibleWrap::GetStateInternal(aState, aExtraState); - if (rv == NS_OK_DEFUNCT_OBJECT) - return rv; - // XXX: No HWND means this is windowless plugin which is not accessible in // the meantime. - if (!mHwnd) - *aState = nsIAccessibleStates::STATE_UNAVAILABLE; + if (mHwnd) + return nsAccessibleWrap::NativeState(); - return rv; + return IsDefunct() ? states::DEFUNCT : states::UNAVAILABLE; } //////////////////////////////////////////////////////////////////////////////// // nsHTMLWin32ObjectOwnerAccessible: nsAccessible protected implementation void nsHTMLWin32ObjectOwnerAccessible::CacheChildren() {
--- a/accessible/src/msaa/nsHTMLWin32ObjectAccessible.h +++ b/accessible/src/msaa/nsHTMLWin32ObjectAccessible.h @@ -57,17 +57,17 @@ public: nsIWeakReference *aShell, void *aHwnd); virtual ~nsHTMLWin32ObjectOwnerAccessible() {} // nsAccessNode virtual void Shutdown(); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); protected: // nsAccessible virtual void CacheChildren(); void* mHwnd; nsRefPtr<nsAccessible> mNativeAccessible;
--- a/accessible/src/xforms/nsXFormsAccessible.cpp +++ b/accessible/src/xforms/nsXFormsAccessible.cpp @@ -33,16 +33,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsXFormsAccessible.h" +#include "States.h" #include "nsAccessibilityService.h" #include "nsAccUtils.h" #include "nsTextEquivUtils.h" #include "nscore.h" #include "nsServiceManagerUtils.h" #include "nsIDOMElement.h" #include "nsIDOMNodeList.h" @@ -144,68 +145,58 @@ nsXFormsAccessible::CacheSelectChildren( NS_IMETHODIMP nsXFormsAccessible::GetValue(nsAString& aValue) { NS_ENSURE_TRUE(sXFormsService, NS_ERROR_FAILURE); nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); return sXFormsService->GetValue(DOMNode, aValue); } -nsresult -nsXFormsAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsXFormsAccessible::NativeState() { - NS_ENSURE_ARG_POINTER(aState); - *aState = 0; - if (IsDefunct()) { - if (aExtraState) - *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; + if (IsDefunct()) + return states::DEFUNCT; - return NS_OK_DEFUNCT_OBJECT; - } - - if (aExtraState) - *aExtraState = 0; - - NS_ENSURE_TRUE(sXFormsService, NS_ERROR_FAILURE); + NS_ENSURE_TRUE(sXFormsService, 0); nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); PRBool isRelevant = PR_FALSE; nsresult rv = sXFormsService->IsRelevant(DOMNode, &isRelevant); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, 0); PRBool isReadonly = PR_FALSE; rv = sXFormsService->IsReadonly(DOMNode, &isReadonly); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, 0); PRBool isRequired = PR_FALSE; rv = sXFormsService->IsRequired(DOMNode, &isRequired); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, 0); PRBool isValid = PR_FALSE; rv = sXFormsService->IsValid(DOMNode, &isValid); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, 0); - rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + PRUint64 states = nsHyperTextAccessibleWrap::NativeState(); if (!isRelevant) - *aState |= nsIAccessibleStates::STATE_UNAVAILABLE; + states |= states::UNAVAILABLE; if (isReadonly) - *aState |= nsIAccessibleStates::STATE_READONLY; + states |= states::READONLY; if (isRequired) - *aState |= nsIAccessibleStates::STATE_REQUIRED; + states |= states::REQUIRED; if (!isValid) - *aState |= nsIAccessibleStates::STATE_INVALID; + states |= states::INVALID; - return NS_OK; + return states; } nsresult nsXFormsAccessible::GetNameInternal(nsAString& aName) { // search the xforms:label element return GetBoundChildElementValue(NS_LITERAL_STRING("label"), aName); } @@ -262,55 +253,47 @@ nsXFormsContainerAccessible::GetAllowsAn //////////////////////////////////////////////////////////////////////////////// nsXFormsEditableAccessible:: nsXFormsEditableAccessible(nsIContent *aContent, nsIWeakReference *aShell) : nsXFormsAccessible(aContent, aShell) { } -nsresult -nsXFormsEditableAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXFormsEditableAccessible::NativeState() { - NS_ENSURE_ARG_POINTER(aState); - - nsresult rv = nsXFormsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); - - if (!aExtraState) - return NS_OK; + PRUint64 state = nsXFormsAccessible::NativeState(); nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); PRBool isReadonly = PR_FALSE; - rv = sXFormsService->IsReadonly(DOMNode, &isReadonly); - NS_ENSURE_SUCCESS(rv, rv); + nsresult rv = sXFormsService->IsReadonly(DOMNode, &isReadonly); + NS_ENSURE_SUCCESS(rv, state); if (!isReadonly) { PRBool isRelevant = PR_FALSE; rv = sXFormsService->IsRelevant(DOMNode, &isRelevant); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, state); if (isRelevant) { - *aExtraState |= nsIAccessibleStates::EXT_STATE_EDITABLE | - nsIAccessibleStates::EXT_STATE_SELECTABLE_TEXT; + state |= states::EDITABLE | states::SELECTABLE_TEXT; } } nsCOMPtr<nsIEditor> editor; GetAssociatedEditor(getter_AddRefs(editor)); - NS_ENSURE_TRUE(editor, NS_ERROR_FAILURE); + NS_ENSURE_TRUE(editor, state); PRUint32 flags; editor->GetFlags(&flags); if (flags & nsIPlaintextEditor::eEditorSingleLineMask) - *aExtraState |= nsIAccessibleStates::EXT_STATE_SINGLE_LINE; + state |= states::SINGLE_LINE; else - *aExtraState |= nsIAccessibleStates::EXT_STATE_MULTI_LINE; + state |= states::MULTI_LINE; - return NS_OK; + return state; } NS_IMETHODIMP nsXFormsEditableAccessible::GetAssociatedEditor(nsIEditor **aEditor) { nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); return sXFormsService->GetEditor(DOMNode, aEditor); } @@ -430,17 +413,16 @@ nsXFormsSelectableAccessible::AddItemToS bool nsXFormsSelectableAccessible::RemoveItemFromSelection(PRUint32 aIndex) { nsCOMPtr<nsIDOMNode> itemDOMNode(do_QueryInterface(GetItemByIndex(&aIndex))); if (!itemDOMNode) return false; - nsresult rv; nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); if (mIsSelect1Element) { nsCOMPtr<nsIDOMNode> selItemDOMNode; sXFormsService->GetSelectedItemForSelect1(DOMNode, getter_AddRefs(selItemDOMNode)); if (selItemDOMNode == itemDOMNode) sXFormsService->SetSelectedItemForSelect1(DOMNode, nsnull); @@ -485,17 +467,16 @@ nsXFormsSelectableAccessible::GetSelecte bool nsXFormsSelectableAccessible::IsItemSelected(PRUint32 aIndex) { nsCOMPtr<nsIDOMNode> itemDOMNode(do_QueryInterface(GetItemByIndex(&aIndex))); if (!itemDOMNode) return false; - nsresult rv; nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); if (mIsSelect1Element) { nsCOMPtr<nsIDOMNode> selItemDOMNode; sXFormsService->GetSelectedItemForSelect1(DOMNode, getter_AddRefs(selItemDOMNode)); return selItemDOMNode == itemDOMNode; }
--- a/accessible/src/xforms/nsXFormsAccessible.h +++ b/accessible/src/xforms/nsXFormsAccessible.h @@ -82,17 +82,17 @@ public: // nsAccessible // Returns value of child xforms 'label' element. virtual nsresult GetNameInternal(nsAString& aName); // Returns state of xforms element taking into account state of instance node // that it is bound to. - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); // Denies accessible nodes in anonymous content of xforms element by // always returning PR_FALSE value. virtual PRBool GetAllowsAnonChildAccessibles(); protected: // Returns value of first child xforms element by tagname that is bound to // instance node. @@ -144,17 +144,17 @@ class nsXFormsEditableAccessible : publi { public: nsXFormsEditableAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsIAccessibleEditableText NS_IMETHOD GetAssociatedEditor(nsIEditor **aEditor); // nsAccessible - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * The class is base for accessible objects for XForms select and XForms * select1 elements. */ class nsXFormsSelectableAccessible : public nsXFormsEditableAccessible
--- a/accessible/src/xforms/nsXFormsFormControlsAccessible.cpp +++ b/accessible/src/xforms/nsXFormsFormControlsAccessible.cpp @@ -33,16 +33,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsXFormsFormControlsAccessible.h" +#include "States.h" #include "nsTextEquivUtils.h" //////////////////////////////////////////////////////////////////////////////// // nsXFormsLabelAccessible //////////////////////////////////////////////////////////////////////////////// nsXFormsLabelAccessible:: nsXFormsLabelAccessible(nsIContent *aContent, nsIWeakReference *aShell) : @@ -204,32 +205,30 @@ nsXFormsInputBooleanAccessible:: } PRUint32 nsXFormsInputBooleanAccessible::NativeRole() { return nsIAccessibleRole::ROLE_CHECKBUTTON; } -nsresult -nsXFormsInputBooleanAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXFormsInputBooleanAccessible::NativeState() { - nsresult rv = nsXFormsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsXFormsAccessible::NativeState(); nsAutoString value; nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); - rv = sXFormsService->GetValue(DOMNode, value); - NS_ENSURE_SUCCESS(rv, rv); + nsresult rv = sXFormsService->GetValue(DOMNode, value); + NS_ENSURE_SUCCESS(rv, state); if (value.EqualsLiteral("true")) - *aState |= nsIAccessibleStates::STATE_CHECKED; + state |= states::CHECKED; - return NS_OK; + return state; } NS_IMETHODIMP nsXFormsInputBooleanAccessible::GetNumActions(PRUint8 *aCount) { NS_ENSURE_ARG_POINTER(aCount); *aCount = 1; @@ -294,25 +293,20 @@ nsXFormsSecretAccessible:: } PRUint32 nsXFormsSecretAccessible::NativeRole() { return nsIAccessibleRole::ROLE_PASSWORD_TEXT; } -nsresult -nsXFormsSecretAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXFormsSecretAccessible::NativeState() { - nsresult rv = nsXFormsInputAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); - - *aState |= nsIAccessibleStates::STATE_PROTECTED; - return NS_OK; + return nsXFormsInputAccessible::NativeState() | states::PROTECTED; } NS_IMETHODIMP nsXFormsSecretAccessible::GetValue(nsAString& aValue) { return NS_ERROR_FAILURE; } @@ -328,32 +322,30 @@ nsXFormsRangeAccessible:: } PRUint32 nsXFormsRangeAccessible::NativeRole() { return nsIAccessibleRole::ROLE_SLIDER; } -nsresult -nsXFormsRangeAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXFormsRangeAccessible::NativeState() { - nsresult rv = nsXFormsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsXFormsAccessible::NativeState(); PRUint32 isInRange = nsIXFormsUtilityService::STATE_NOT_A_RANGE; nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); - rv = sXFormsService->IsInRange(DOMNode, &isInRange); - NS_ENSURE_SUCCESS(rv, rv); + nsresult rv = sXFormsService->IsInRange(DOMNode, &isInRange); + NS_ENSURE_SUCCESS(rv, state); if (isInRange == nsIXFormsUtilityService::STATE_OUT_OF_RANGE) - *aState |= nsIAccessibleStates::STATE_INVALID; + state |= states::INVALID; - return NS_OK; + return state; } NS_IMETHODIMP nsXFormsRangeAccessible::GetMaximumValue(double *aMaximumValue) { NS_ENSURE_ARG_POINTER(aMaximumValue); nsAutoString value; @@ -417,33 +409,30 @@ nsXFormsRangeAccessible::GetCurrentValue //////////////////////////////////////////////////////////////////////////////// nsXFormsSelectAccessible:: nsXFormsSelectAccessible(nsIContent *aContent, nsIWeakReference *aShell) : nsXFormsContainerAccessible(aContent, aShell) { } -nsresult -nsXFormsSelectAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXFormsSelectAccessible::NativeState() { - nsresult rv = nsXFormsContainerAccessible::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsXFormsContainerAccessible::NativeState(); PRUint32 isInRange = nsIXFormsUtilityService::STATE_NOT_A_RANGE; nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); - rv = sXFormsService->IsInRange(DOMNode, &isInRange); - NS_ENSURE_SUCCESS(rv, rv); + nsresult rv = sXFormsService->IsInRange(DOMNode, &isInRange); + NS_ENSURE_SUCCESS(rv, state); if (isInRange == nsIXFormsUtilityService::STATE_OUT_OF_RANGE) - *aState |= nsIAccessibleStates::STATE_INVALID; + state |= states::INVALID; - return NS_OK; + return state; } //////////////////////////////////////////////////////////////////////////////// // nsXFormsChoicesAccessible //////////////////////////////////////////////////////////////////////////////// nsXFormsChoicesAccessible:: @@ -506,28 +495,25 @@ nsXFormsItemCheckgroupAccessible:: } PRUint32 nsXFormsItemCheckgroupAccessible::NativeRole() { return nsIAccessibleRole::ROLE_CHECKBUTTON; } -nsresult -nsXFormsItemCheckgroupAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXFormsItemCheckgroupAccessible::NativeState() { - nsresult rv = nsXFormsSelectableItemAccessible::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsXFormsSelectableItemAccessible::NativeState(); if (IsItemSelected()) - *aState |= nsIAccessibleStates::STATE_CHECKED; + state |= states::CHECKED; - return NS_OK; + return state; } NS_IMETHODIMP nsXFormsItemCheckgroupAccessible::GetActionName(PRUint8 aIndex, nsAString& aName) { if (aIndex != eAction_Click) return NS_ERROR_INVALID_ARG; @@ -551,28 +537,25 @@ nsXFormsItemRadiogroupAccessible:: } PRUint32 nsXFormsItemRadiogroupAccessible::NativeRole() { return nsIAccessibleRole::ROLE_RADIOBUTTON; } -nsresult -nsXFormsItemRadiogroupAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXFormsItemRadiogroupAccessible::NativeState() { - nsresult rv = nsXFormsSelectableItemAccessible::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsXFormsSelectableItemAccessible::NativeState(); if (IsItemSelected()) - *aState |= nsIAccessibleStates::STATE_CHECKED; + state |= states::CHECKED; - return NS_OK; + return state; } NS_IMETHODIMP nsXFormsItemRadiogroupAccessible::GetActionName(PRUint8 aIndex, nsAString& aName) { if (aIndex != eAction_Click) return NS_ERROR_INVALID_ARG; @@ -592,37 +575,32 @@ nsXFormsSelectComboboxAccessible:: } PRUint32 nsXFormsSelectComboboxAccessible::NativeRole() { return nsIAccessibleRole::ROLE_COMBOBOX; } -nsresult -nsXFormsSelectComboboxAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXFormsSelectComboboxAccessible::NativeState() { - nsresult rv = nsXFormsSelectableAccessible::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsXFormsSelectableAccessible::NativeState(); PRBool isOpen = PR_FALSE; nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); - rv = sXFormsService->IsDropmarkerOpen(DOMNode, &isOpen); - NS_ENSURE_SUCCESS(rv, rv); + nsresult rv = sXFormsService->IsDropmarkerOpen(DOMNode, &isOpen); + NS_ENSURE_SUCCESS(rv, state); if (isOpen) - *aState = nsIAccessibleStates::STATE_EXPANDED; + state |= states::EXPANDED; else - *aState = nsIAccessibleStates::STATE_COLLAPSED; + state |= states::COLLAPSED; - *aState |= nsIAccessibleStates::STATE_HASPOPUP | - nsIAccessibleStates::STATE_FOCUSABLE; - return NS_OK; + return state | states::HASPOPUP | states::FOCUSABLE; } PRBool nsXFormsSelectComboboxAccessible::GetAllowsAnonChildAccessibles() { return PR_TRUE; } @@ -638,32 +616,29 @@ nsXFormsItemComboboxAccessible:: } PRUint32 nsXFormsItemComboboxAccessible::NativeRole() { return nsIAccessibleRole::ROLE_LISTITEM; } -nsresult -nsXFormsItemComboboxAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXFormsItemComboboxAccessible::NativeState() { - nsresult rv = nsXFormsSelectableItemAccessible::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsXFormsSelectableItemAccessible::NativeState(); - if (*aState & nsIAccessibleStates::STATE_UNAVAILABLE) - return NS_OK; + if (state & states::UNAVAILABLE) + return state; - *aState |= nsIAccessibleStates::STATE_SELECTABLE; + state |= states::SELECTABLE; if (IsItemSelected()) - *aState |= nsIAccessibleStates::STATE_SELECTED; + state |= states::SELECTED; - return NS_OK; + return state; } NS_IMETHODIMP nsXFormsItemComboboxAccessible::GetActionName(PRUint8 aIndex, nsAString& aName) { if (aIndex != eAction_Click) return NS_ERROR_INVALID_ARG;
--- a/accessible/src/xforms/nsXFormsFormControlsAccessible.h +++ b/accessible/src/xforms/nsXFormsFormControlsAccessible.h @@ -122,17 +122,17 @@ public: // nsIAccessible NS_IMETHOD GetNumActions(PRUint8 *aCount); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD DoAction(PRUint8 aIndex); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Accessible object for xforms:input[type="xsd:date"]. */ class nsXFormsInputDateAccessible : public nsXFormsContainerAccessible { @@ -152,17 +152,17 @@ class nsXFormsSecretAccessible : public public: nsXFormsSecretAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsIAccessible NS_IMETHOD GetValue(nsAString& aValue); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Accessible object for xforms:range. */ class nsXFormsRangeAccessible : public nsXFormsAccessible @@ -173,32 +173,32 @@ public: // nsIAccessibleValue NS_IMETHOD GetMaximumValue(double *aMaximumValue); NS_IMETHOD GetMinimumValue(double *aMinimumValue); NS_IMETHOD GetMinimumIncrement(double *aMinimumIncrement); NS_IMETHOD GetCurrentValue(double *aCurrentValue); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Accessible object for xforms:select and xforms:select1 that are implemented * using host document's native widget. */ class nsXFormsSelectAccessible : public nsXFormsContainerAccessible { public: nsXFormsSelectAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsAccessible - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Accessible object for xforms:choices. */ class nsXFormsChoicesAccessible : public nsXFormsAccessible @@ -249,17 +249,17 @@ public: nsXFormsItemCheckgroupAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsIAccessible NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Accessible object for a xforms:item when it is represented by a radiobutton. * This occurs when the item is contained in a xforms:select1 with full * appearance. Such a xforms:select1 is represented as a radiogroup. */ @@ -270,34 +270,34 @@ public: nsXFormsItemRadiogroupAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsIAccessible NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Accessible object for xforms:select1 of minimal appearance that is * represented by combobox. */ class nsXFormsSelectComboboxAccessible : public nsXFormsSelectableAccessible { public: nsXFormsSelectComboboxAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual PRBool GetAllowsAnonChildAccessibles(); }; /** * Accessible object for xforms:item element when it is represented by a * listitem. This occurs when the item is contained in a xforms:select with * minimal appearance. Such a xforms:select is represented by a combobox. @@ -309,13 +309,13 @@ public: nsXFormsItemComboboxAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsIAccessible NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; #endif
--- a/accessible/src/xforms/nsXFormsWidgetsAccessible.cpp +++ b/accessible/src/xforms/nsXFormsWidgetsAccessible.cpp @@ -33,16 +33,18 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsXFormsWidgetsAccessible.h" +#include "States.h" + //////////////////////////////////////////////////////////////////////////////// // nsXFormsDropmarkerWidgetAccessible //////////////////////////////////////////////////////////////////////////////// nsXFormsDropmarkerWidgetAccessible:: nsXFormsDropmarkerWidgetAccessible(nsIContent *aContent, nsIWeakReference *aShell) : nsLeafAccessible(aContent, aShell) @@ -50,42 +52,29 @@ nsXFormsDropmarkerWidgetAccessible:: } PRUint32 nsXFormsDropmarkerWidgetAccessible::NativeRole() { return nsIAccessibleRole::ROLE_PUSHBUTTON; } -nsresult -nsXFormsDropmarkerWidgetAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXFormsDropmarkerWidgetAccessible::NativeState() { - NS_ENSURE_ARG_POINTER(aState); - *aState = 0; - if (IsDefunct()) { - if (aExtraState) - *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - - return NS_OK_DEFUNCT_OBJECT; - } - - if (aExtraState) - *aExtraState = 0; + if (IsDefunct()) + return states::DEFUNCT; PRBool isOpen = PR_FALSE; nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); nsresult rv = sXFormsService->IsDropmarkerOpen(DOMNode, &isOpen); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, 0); - if (isOpen) - *aState = nsIAccessibleStates::STATE_PRESSED; - - return NS_OK; + return isOpen ? states::PRESSED: 0; } NS_IMETHODIMP nsXFormsDropmarkerWidgetAccessible::GetNumActions(PRUint8 *aCount) { NS_ENSURE_ARG_POINTER(aCount); *aCount = 1; @@ -152,38 +141,34 @@ nsXFormsComboboxPopupWidgetAccessible:: } PRUint32 nsXFormsComboboxPopupWidgetAccessible::NativeRole() { return nsIAccessibleRole::ROLE_LIST; } -nsresult -nsXFormsComboboxPopupWidgetAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXFormsComboboxPopupWidgetAccessible::NativeState() { - NS_ENSURE_ARG_POINTER(aState); - - nsresult rv = nsXFormsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsXFormsAccessible::NativeState(); PRBool isOpen = PR_FALSE; nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); - rv = sXFormsService->IsDropmarkerOpen(DOMNode, &isOpen); - NS_ENSURE_SUCCESS(rv, rv); + nsresult rv = sXFormsService->IsDropmarkerOpen(DOMNode, &isOpen); + NS_ENSURE_SUCCESS(rv, state); - *aState |= nsIAccessibleStates::STATE_FOCUSABLE; + state |= states::FOCUSABLE; if (isOpen) - *aState = nsIAccessibleStates::STATE_FLOATING; + state = states::FLOATING; else - *aState = nsIAccessibleStates::STATE_INVISIBLE; + state = states::INVISIBLE; - return NS_OK; + return state; } NS_IMETHODIMP nsXFormsComboboxPopupWidgetAccessible::GetValue(nsAString& aValue) { aValue.Truncate(); return NS_OK; }
--- a/accessible/src/xforms/nsXFormsWidgetsAccessible.h +++ b/accessible/src/xforms/nsXFormsWidgetsAccessible.h @@ -56,17 +56,17 @@ public: // nsIAccessible NS_IMETHOD GetNumActions(PRUint8 *aCount); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD DoAction(PRUint8 aIndex); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Accessible object for calendar widget. It is used by xforms:input[xsd:date]. */ class nsXFormsCalendarWidgetAccessible : public nsAccessibleWrap { @@ -91,16 +91,16 @@ public: // nsIAccessible NS_IMETHOD GetValue(nsAString& aValue); NS_IMETHOD GetDescription(nsAString& aDescription); // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); protected: // nsAccessible virtual void CacheChildren(); }; #endif
--- a/accessible/src/xpcom/nsAccEvent.cpp +++ b/accessible/src/xpcom/nsAccEvent.cpp @@ -32,16 +32,17 @@ * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsAccEvent.h" +#include "nsAccUtils.h" #include "nsDocAccessible.h" //////////////////////////////////////////////////////////////////////////////// // nsAccEvent //////////////////////////////////////////////////////////////////////////////// NS_IMPL_ISUPPORTS1(nsAccEvent, nsIAccessibleEvent) @@ -98,25 +99,35 @@ nsAccEvent::GetAccessibleDocument(nsIAcc NS_IMPL_ISUPPORTS_INHERITED1(nsAccStateChangeEvent, nsAccEvent, nsIAccessibleStateChangeEvent) NS_IMETHODIMP nsAccStateChangeEvent::GetState(PRUint32* aState) { NS_ENSURE_ARG_POINTER(aState); - *aState = static_cast<AccStateChangeEvent*>(mEvent.get())->GetState(); + + PRUint32 state1 = 0, state2 = 0; + PRUint64 state = static_cast<AccStateChangeEvent*>(mEvent.get())->GetState(); + nsAccUtils::To32States(state, &state1, &state2); + + *aState = state1 | state2; // only one state is not 0 return NS_OK; } NS_IMETHODIMP nsAccStateChangeEvent::IsExtraState(PRBool* aIsExtraState) { NS_ENSURE_ARG_POINTER(aIsExtraState); - *aIsExtraState = static_cast<AccStateChangeEvent*>(mEvent.get())->IsExtraState(); + + PRUint32 state1 = 0, state2 = 0; + PRUint64 state = static_cast<AccStateChangeEvent*>(mEvent.get())->GetState(); + nsAccUtils::To32States(state, &state1, &state2); + + *aIsExtraState = (state2 != 0); return NS_OK; } NS_IMETHODIMP nsAccStateChangeEvent::IsEnabled(PRBool* aIsEnabled) { NS_ENSURE_ARG_POINTER(aIsEnabled); *aIsEnabled = static_cast<AccStateChangeEvent*>(mEvent.get())->IsStateEnabled();
--- a/accessible/src/xul/nsXULAlertAccessible.cpp +++ b/accessible/src/xul/nsXULAlertAccessible.cpp @@ -32,16 +32,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsXULAlertAccessible.h" +#include "States.h" //////////////////////////////////////////////////////////////////////////////// // nsXULAlertAccessible //////////////////////////////////////////////////////////////////////////////// nsXULAlertAccessible:: nsXULAlertAccessible(nsIContent *aContent, nsIWeakReference *aShell) : nsAccessibleWrap(aContent, aShell) @@ -51,25 +52,20 @@ nsXULAlertAccessible:: NS_IMPL_ISUPPORTS_INHERITED0(nsXULAlertAccessible, nsAccessible) PRUint32 nsXULAlertAccessible::NativeRole() { return nsIAccessibleRole::ROLE_ALERT; } -nsresult -nsXULAlertAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsXULAlertAccessible::NativeState() { - nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); - - // XUL has no markup for low, medium or high - *aState |= nsIAccessibleStates::STATE_ALERT_MEDIUM; - return NS_OK; + return nsAccessible::NativeState() | states::ALERT; } NS_IMETHODIMP nsXULAlertAccessible::GetName(nsAString& aName) { // Screen readers need to read contents of alert, not the accessible name. // If we have both some screen readers will read the alert twice. aName.Truncate();
--- a/accessible/src/xul/nsXULAlertAccessible.h +++ b/accessible/src/xul/nsXULAlertAccessible.h @@ -51,12 +51,12 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIAccessible NS_IMETHOD GetName(nsAString& aName); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; #endif
--- a/accessible/src/xul/nsXULColorPickerAccessible.cpp +++ b/accessible/src/xul/nsXULColorPickerAccessible.cpp @@ -33,16 +33,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsXULColorPickerAccessible.h" +#include "States.h" #include "nsAccUtils.h" #include "nsAccTreeWalker.h" #include "nsCoreUtils.h" #include "nsDocAccessible.h" #include "nsIDOMElement.h" @@ -75,40 +76,38 @@ nsXULColorPickerTileAccessible::GetValue // nsXULColorPickerTileAccessible: nsAccessible PRUint32 nsXULColorPickerTileAccessible::NativeRole() { return nsIAccessibleRole::ROLE_PUSHBUTTON; } -nsresult -nsXULColorPickerTileAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULColorPickerTileAccessible::NativeState() { // Possible states: focused, focusable, selected. // get focus and disable status from base class - nsresult rv = nsAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 states = nsAccessibleWrap::NativeState(); - *aState |= nsIAccessibleStates::STATE_FOCUSABLE; + states |= states::FOCUSABLE; // Focused? PRBool isFocused = mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::hover); if (isFocused) - *aState |= nsIAccessibleStates::STATE_FOCUSED; + states |= states::FOCUSED; PRBool isSelected = mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::selected); if (isSelected) - *aState |= nsIAccessibleStates::STATE_SELECTED; + states |= states::SELECTED; - return NS_OK; + return states; } //////////////////////////////////////////////////////////////////////////////// // nsXULColorPickerAccessible //////////////////////////////////////////////////////////////////////////////// nsXULColorPickerAccessible:: @@ -128,30 +127,27 @@ nsXULColorPickerAccessible::Init() nsCoreUtils::GeneratePopupTree(mContent, PR_TRUE); return PR_TRUE; } //////////////////////////////////////////////////////////////////////////////// // nsXULColorPickerAccessible: nsAccessible -nsresult -nsXULColorPickerAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULColorPickerAccessible::NativeState() { // Possible states: focused, focusable, unavailable(disabled). // get focus and disable status from base class - nsresult rv = nsAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 states = nsAccessibleWrap::NativeState(); - *aState |= nsIAccessibleStates::STATE_FOCUSABLE | - nsIAccessibleStates::STATE_HASPOPUP; + states |= states::FOCUSABLE | states::HASPOPUP; - return NS_OK; + return states; } PRUint32 nsXULColorPickerAccessible::NativeRole() { return nsIAccessibleRole::ROLE_BUTTONDROPDOWNGRID; }
--- a/accessible/src/xul/nsXULColorPickerAccessible.h +++ b/accessible/src/xul/nsXULColorPickerAccessible.h @@ -51,34 +51,34 @@ public: nsXULColorPickerTileAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsIAccessible NS_IMETHOD GetValue(nsAString& _retval); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Used for colorpicker button (xul:colorpicker@type="button"). */ class nsXULColorPickerAccessible : public nsXULColorPickerTileAccessible { public: nsXULColorPickerAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsAccessNode virtual PRBool Init(); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); protected: // nsAccessible virtual void CacheChildren(); }; #endif
--- a/accessible/src/xul/nsXULComboboxAccessible.cpp +++ b/accessible/src/xul/nsXULComboboxAccessible.cpp @@ -35,16 +35,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsXULComboboxAccessible.h" +#include "States.h" #include "nsAccessibilityService.h" #include "nsCoreUtils.h" #include "nsIDOMXULMenuListElement.h" #include "nsIDOMXULSelectCntrlItemEl.h" //////////////////////////////////////////////////////////////////////////////// // nsXULComboboxAccessible @@ -70,47 +71,44 @@ PRUint32 nsXULComboboxAccessible::NativeRole() { if (mContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type, nsAccessibilityAtoms::autocomplete, eIgnoreCase)) return nsIAccessibleRole::ROLE_AUTOCOMPLETE; return nsIAccessibleRole::ROLE_COMBOBOX; } -nsresult -nsXULComboboxAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULComboboxAccessible::NativeState() { // As a nsComboboxAccessible we can have the following states: // STATE_FOCUSED // STATE_FOCUSABLE // STATE_HASPOPUP // STATE_EXPANDED // STATE_COLLAPSED // Get focus status from base class - nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 states = nsAccessible::NativeState(); nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mContent)); if (menuList) { PRBool isOpen; menuList->GetOpen(&isOpen); if (isOpen) { - *aState |= nsIAccessibleStates::STATE_EXPANDED; + states |= states::EXPANDED; } else { - *aState |= nsIAccessibleStates::STATE_COLLAPSED; + states |= states::COLLAPSED; } } - *aState |= nsIAccessibleStates::STATE_HASPOPUP | - nsIAccessibleStates::STATE_FOCUSABLE; + states |= states::HASPOPUP | states::FOCUSABLE; - return NS_OK; + return states; } NS_IMETHODIMP nsXULComboboxAccessible::GetValue(nsAString& aValue) { aValue.Truncate(); if (IsDefunct())
--- a/accessible/src/xul/nsXULComboboxAccessible.h +++ b/accessible/src/xul/nsXULComboboxAccessible.h @@ -60,13 +60,13 @@ public: NS_IMETHOD GetNumActions(PRUint8 *aNumActions); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); // nsAccessNode virtual PRBool Init(); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual PRBool GetAllowsAnonChildAccessibles(); }; #endif
--- a/accessible/src/xul/nsXULFormControlAccessible.cpp +++ b/accessible/src/xul/nsXULFormControlAccessible.cpp @@ -40,16 +40,17 @@ #include "nsXULFormControlAccessible.h" #include "nsAccessibilityAtoms.h" #include "nsAccUtils.h" #include "nsAccTreeWalker.h" #include "nsCoreUtils.h" #include "nsDocAccessible.h" #include "nsRelUtils.h" +#include "States.h" // NOTE: alphabetically ordered #include "nsHTMLFormControlAccessible.h" #include "nsXULMenuAccessible.h" #include "nsIDOMHTMLInputElement.h" #include "nsIDOMNSEditableElement.h" #include "nsIDOMXULButtonElement.h" #include "nsIDOMXULCheckboxElement.h" @@ -127,62 +128,61 @@ nsXULButtonAccessible::Init() // nsXULButtonAccessible: nsAccessible PRUint32 nsXULButtonAccessible::NativeRole() { return nsIAccessibleRole::ROLE_PUSHBUTTON; } -nsresult -nsXULButtonAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsXULButtonAccessible::NativeState() { // Possible states: focused, focusable, unavailable(disabled). // get focus and disable status from base class - nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsAccessible::NativeState(); PRBool disabled = PR_FALSE; nsCOMPtr<nsIDOMXULControlElement> xulFormElement(do_QueryInterface(mContent)); if (xulFormElement) { xulFormElement->GetDisabled(&disabled); if (disabled) - *aState |= nsIAccessibleStates::STATE_UNAVAILABLE; + state |= states::UNAVAILABLE; else - *aState |= nsIAccessibleStates::STATE_FOCUSABLE; + state |= states::FOCUSABLE; } // Buttons can be checked -- they simply appear pressed in rather than checked nsCOMPtr<nsIDOMXULButtonElement> xulButtonElement(do_QueryInterface(mContent)); if (xulButtonElement) { nsAutoString type; xulButtonElement->GetType(type); if (type.EqualsLiteral("checkbox") || type.EqualsLiteral("radio")) { - *aState |= nsIAccessibleStates::STATE_CHECKABLE; + state |= states::CHECKABLE; PRBool checked = PR_FALSE; PRInt32 checkState = 0; xulButtonElement->GetChecked(&checked); if (checked) { - *aState |= nsIAccessibleStates::STATE_PRESSED; + state |= states::PRESSED; xulButtonElement->GetCheckState(&checkState); if (checkState == nsIDOMXULButtonElement::CHECKSTATE_MIXED) { - *aState |= nsIAccessibleStates::STATE_MIXED; + state |= states::MIXED; } } } } if (ContainsMenu()) - *aState |= nsIAccessibleStates::STATE_HASPOPUP; + state |= states::HASPOPUP; if (mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::_default)) - *aState |= nsIAccessibleStates::STATE_DEFAULT; + state |= states::DEFAULT; - return NS_OK; + return state; } //////////////////////////////////////////////////////////////////////////////// // nsXULButtonAccessible: nsAccessible protected void nsXULButtonAccessible::CacheChildren() { @@ -322,36 +322,24 @@ NS_IMETHODIMP nsXULDropmarkerAccessible: } PRUint32 nsXULDropmarkerAccessible::NativeRole() { return nsIAccessibleRole::ROLE_PUSHBUTTON; } -nsresult -nsXULDropmarkerAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULDropmarkerAccessible::NativeState() { - *aState = 0; - - if (IsDefunct()) { - if (aExtraState) - *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - return NS_OK_DEFUNCT_OBJECT; - } + if (IsDefunct()) + return states::DEFUNCT; - if (aExtraState) - *aExtraState = 0; - - if (DropmarkerOpen(PR_FALSE)) - *aState = nsIAccessibleStates::STATE_PRESSED; - - return NS_OK; + return DropmarkerOpen(PR_FALSE) ? states::PRESSED : 0; } //////////////////////////////////////////////////////////////////////////////// // nsXULCheckboxAccessible //////////////////////////////////////////////////////////////////////////////// nsXULCheckboxAccessible:: @@ -374,21 +362,18 @@ NS_IMETHODIMP nsXULCheckboxAccessible::G /** * Return the name of our only action */ NS_IMETHODIMP nsXULCheckboxAccessible::GetActionName(PRUint8 aIndex, nsAString& aName) { if (aIndex == eAction_Click) { // check or uncheck - PRUint32 state; - nsresult rv = GetStateInternal(&state, nsnull); - NS_ENSURE_SUCCESS(rv, rv); - if (state & nsIAccessibleStates::STATE_CHECKED) + if (NativeState() & states::CHECKED) aName.AssignLiteral("uncheck"); else aName.AssignLiteral("check"); return NS_OK; } return NS_ERROR_INVALID_ARG; } @@ -401,45 +386,41 @@ nsXULCheckboxAccessible::DoAction(PRUint { if (aIndex != eAction_Click) return NS_ERROR_INVALID_ARG; DoCommand(); return NS_OK; } -/** - * Possible states: focused, focusable, unavailable(disabled), checked - */ -nsresult -nsXULCheckboxAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULCheckboxAccessible::NativeState() { + // Possible states: focused, focusable, unavailable(disabled), checked // Get focus and disable status from base class - nsresult rv = nsFormControlAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsFormControlAccessible::NativeState(); - *aState |= nsIAccessibleStates::STATE_CHECKABLE; + state |= states::CHECKABLE; // Determine Checked state nsCOMPtr<nsIDOMXULCheckboxElement> xulCheckboxElement = do_QueryInterface(mContent); if (xulCheckboxElement) { PRBool checked = PR_FALSE; xulCheckboxElement->GetChecked(&checked); if (checked) { - *aState |= nsIAccessibleStates::STATE_CHECKED; + state |= states::CHECKED; PRInt32 checkState = 0; xulCheckboxElement->GetCheckState(&checkState); if (checkState == nsIDOMXULCheckboxElement::CHECKSTATE_MIXED) - *aState |= nsIAccessibleStates::STATE_MIXED; + state |= states::MIXED; } } - return NS_OK; + return state; } //////////////////////////////////////////////////////////////////////////////// // nsXULGroupboxAccessible //////////////////////////////////////////////////////////////////////////////// nsXULGroupboxAccessible:: nsXULGroupboxAccessible(nsIContent *aContent, nsIWeakReference *aShell) : @@ -640,37 +621,35 @@ nsXULProgressMeterAccessible::SetCurrent nsXULRadioButtonAccessible:: nsXULRadioButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell) : nsRadioButtonAccessible(aContent, aShell) { } /** We are Focusable and can be Checked and focused */ -nsresult -nsXULRadioButtonAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULRadioButtonAccessible::NativeState() { - nsresult rv = nsFormControlAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsFormControlAccessible::NativeState(); - *aState |= nsIAccessibleStates::STATE_CHECKABLE; + state |= states::CHECKABLE; PRBool selected = PR_FALSE; // Radio buttons can be selected nsCOMPtr<nsIDOMXULSelectControlItemElement> radioButton = do_QueryInterface(mContent); if (radioButton) { radioButton->GetSelected(&selected); if (selected) { - *aState |= nsIAccessibleStates::STATE_CHECKED; + state |= states::CHECKED; } } - return NS_OK; + return state; } void nsXULRadioButtonAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet, PRInt32 *aSetSize) { nsAccUtils::GetPositionAndSizeForXULSelectControlItem(mContent, aPosInSet, aSetSize); @@ -697,30 +676,23 @@ nsXULRadioGroupAccessible:: } PRUint32 nsXULRadioGroupAccessible::NativeRole() { return nsIAccessibleRole::ROLE_GROUPING; } -nsresult -nsXULRadioGroupAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULRadioGroupAccessible::NativeState() { - nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); - // The radio group is not focusable. Sometimes the focus controller will // report that it is focused. That means that the actual selected radio button // should be considered focused. - *aState &= ~(nsIAccessibleStates::STATE_FOCUSABLE | - nsIAccessibleStates::STATE_FOCUSED); - - return NS_OK; + return nsAccessible::NativeState() & ~(states::FOCUSABLE | states::FOCUSED); } //////////////////////////////////////////////////////////////////////////////// // nsXULStatusBarAccessible //////////////////////////////////////////////////////////////////////////////// nsXULStatusBarAccessible:: @@ -835,33 +807,20 @@ nsXULToolbarSeparatorAccessible:: } PRUint32 nsXULToolbarSeparatorAccessible::NativeRole() { return nsIAccessibleRole::ROLE_SEPARATOR; } -nsresult -nsXULToolbarSeparatorAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULToolbarSeparatorAccessible::NativeState() { - *aState = 0; // no special state flags for toolbar separator - - if (IsDefunct()) { - if (aExtraState) - *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - - return NS_OK_DEFUNCT_OBJECT; - } - - if (aExtraState) - *aExtraState = 0; - - return NS_OK; + return IsDefunct() ? states::DEFUNCT : 0; } //////////////////////////////////////////////////////////////////////////////// // nsXULTextFieldAccessible //////////////////////////////////////////////////////////////////////////////// nsXULTextFieldAccessible:: nsXULTextFieldAccessible(nsIContent *aContent, nsIWeakReference *aShell) : @@ -871,81 +830,72 @@ nsXULTextFieldAccessible:: NS_IMPL_ISUPPORTS_INHERITED3(nsXULTextFieldAccessible, nsAccessible, nsHyperTextAccessible, nsIAccessibleText, nsIAccessibleEditableText) //////////////////////////////////////////////////////////////////////////////// // nsXULTextFieldAccessible: nsIAccessible NS_IMETHODIMP nsXULTextFieldAccessible::GetValue(nsAString& aValue) { - PRUint32 state; - nsresult rv = GetStateInternal(&state, nsnull); - NS_ENSURE_SUCCESS(rv, rv); + PRUint64 state = NativeState(); - if (state & nsIAccessibleStates::STATE_PROTECTED) // Don't return password text! + if (state & states::PROTECTED) // Don't return password text! return NS_ERROR_FAILURE; nsCOMPtr<nsIDOMXULTextBoxElement> textBox(do_QueryInterface(mContent)); if (textBox) { return textBox->GetValue(aValue); } nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mContent)); if (menuList) { return menuList->GetLabel(aValue); } return NS_ERROR_FAILURE; } -nsresult -nsXULTextFieldAccessible::GetARIAState(PRUint32 *aState, PRUint32 *aExtraState) +void +nsXULTextFieldAccessible::ApplyARIAState(PRUint64* aState) { - nsresult rv = nsHyperTextAccessibleWrap::GetARIAState(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + nsHyperTextAccessibleWrap::ApplyARIAState(aState); - nsStateMapEntry::MapToStates(mContent, aState, aExtraState, eARIAAutoComplete); + nsStateMapEntry::MapToStates(mContent, aState, eARIAAutoComplete); - return NS_OK; } -nsresult -nsXULTextFieldAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULTextFieldAccessible::NativeState() { - nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsHyperTextAccessibleWrap::NativeState(); nsCOMPtr<nsIContent> inputField(GetInputField()); - NS_ENSURE_TRUE(inputField, NS_ERROR_FAILURE); + NS_ENSURE_TRUE(inputField, state); - // Create a temporary accessible from the HTML text field - // to get the accessible state from. Doesn't add to cache - // because Init() is not called. + // Create a temporary accessible from the HTML text field to get + // the accessible state from. Doesn't add to cache into document cache. nsRefPtr<nsHTMLTextFieldAccessible> tempAccessible = new nsHTMLTextFieldAccessible(inputField, mWeakShell); if (!tempAccessible) - return NS_ERROR_OUT_OF_MEMORY; + return state; - rv = tempAccessible->GetStateInternal(aState, aExtraState); - NS_ENSURE_SUCCESS(rv, rv); + state |= tempAccessible->NativeState(); if (gLastFocusedNode == mContent) - *aState |= nsIAccessibleStates::STATE_FOCUSED; + state |= states::FOCUSED; nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mContent)); if (menuList) { // <xul:menulist droppable="false"> if (!mContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::editable, nsAccessibilityAtoms::_true, eIgnoreCase)) { - *aState |= nsIAccessibleStates::STATE_READONLY; + state |= states::READONLY; } } - return NS_OK; + return state; } PRUint32 nsXULTextFieldAccessible::NativeRole() { if (mContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type, nsAccessibilityAtoms::password, eIgnoreCase)) return nsIAccessibleRole::ROLE_PASSWORD_TEXT;
--- a/accessible/src/xul/nsXULFormControlAccessible.h +++ b/accessible/src/xul/nsXULFormControlAccessible.h @@ -66,17 +66,17 @@ public: NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD DoAction(PRUint8 index); // nsAccessNode virtual PRBool Init(); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); protected: // nsAccessible virtual void CacheChildren(); // nsXULButtonAccessible PRBool ContainsMenu(); @@ -94,17 +94,17 @@ public: // nsIAccessible NS_IMETHOD GetNumActions(PRUint8 *_retval); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD DoAction(PRUint8 index); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Used for XUL dropmarker element. */ class nsXULDropmarkerAccessible : public nsFormControlAccessible { public: @@ -113,17 +113,17 @@ public: // nsIAccessible NS_IMETHOD GetNumActions(PRUint8 *_retval); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD DoAction(PRUint8 index); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); private: PRBool DropmarkerOpen(PRBool aToggleOpen); }; /** * Used for XUL groupbox element. */ @@ -162,32 +162,32 @@ public: */ class nsXULRadioButtonAccessible : public nsRadioButtonAccessible { public: nsXULRadioButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsAccessible - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet, PRInt32 *aSetSize); + virtual PRUint64 NativeState(); }; /** * Used for XUL radiogroup element. */ class nsXULRadioGroupAccessible : public nsXULSelectableAccessible { public: nsXULRadioGroupAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Used for XUL statusbar element. */ class nsXULStatusBarAccessible : public nsAccessibleWrap { public: @@ -232,17 +232,17 @@ public: class nsXULToolbarSeparatorAccessible : public nsLeafAccessible { public: nsXULToolbarSeparatorAccessible(nsIContent* aContent, nsIWeakReference *aShell); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Used for XUL textbox element. */ class nsXULTextFieldAccessible : public nsHyperTextAccessibleWrap { public: @@ -257,19 +257,19 @@ public: NS_IMETHOD GetNumActions(PRUint8 *_retval); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD DoAction(PRUint8 index); // nsIAccessibleEditableText NS_IMETHOD GetAssociatedEditor(nsIEditor **aEditor); // nsAccessible - virtual nsresult GetARIAState(PRUint32 *aState, PRUint32 *aExtraState); + virtual void ApplyARIAState(PRUint64* aState); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual PRBool GetAllowsAnonChildAccessibles(); protected: // nsAccessible virtual void CacheChildren(); // nsXULTextFieldAccessible already_AddRefed<nsIContent> GetInputField() const;
--- a/accessible/src/xul/nsXULListboxAccessible.cpp +++ b/accessible/src/xul/nsXULListboxAccessible.cpp @@ -35,16 +35,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsXULListboxAccessible.h" +#include "States.h" #include "nsAccessibilityService.h" #include "nsAccUtils.h" #include "nsIDOMXULPopupElement.h" #include "nsIDOMXULMultSelectCntrlEl.h" #include "nsIDOMXULSelectCntrlItemEl.h" //////////////////////////////////////////////////////////////////////////////// @@ -58,36 +59,20 @@ nsXULColumnsAccessible:: } PRUint32 nsXULColumnsAccessible::NativeRole() { return nsIAccessibleRole::ROLE_LIST; } -nsresult -nsXULColumnsAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULColumnsAccessible::NativeState() { - NS_ENSURE_ARG_POINTER(aState); - *aState = 0; - - if (IsDefunct()) { - if (aExtraState) - *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - - return NS_OK_DEFUNCT_OBJECT; - } - - *aState = nsIAccessibleStates::STATE_READONLY; - - if (aExtraState) - *aExtraState = 0; - - return NS_OK; + return IsDefunct() ? states::DEFUNCT : states::READONLY; } //////////////////////////////////////////////////////////////////////////////// // nsXULColumnItemAccessible //////////////////////////////////////////////////////////////////////////////// nsXULColumnItemAccessible:: @@ -97,34 +82,20 @@ nsXULColumnItemAccessible:: } PRUint32 nsXULColumnItemAccessible::NativeRole() { return nsIAccessibleRole::ROLE_COLUMNHEADER; } -nsresult -nsXULColumnItemAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULColumnItemAccessible::NativeState() { - NS_ENSURE_ARG_POINTER(aState); - - if (IsDefunct()) { - if (aExtraState) - *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - - return NS_OK_DEFUNCT_OBJECT; - } - - *aState = nsIAccessibleStates::STATE_READONLY; - if (aExtraState) - *aExtraState = 0; - - return NS_OK; + return IsDefunct() ? states::DEFUNCT : states::READONLY; } NS_IMETHODIMP nsXULColumnItemAccessible::GetNumActions(PRUint8 *aNumActions) { NS_ENSURE_ARG_POINTER(aNumActions); *aNumActions = 1; @@ -189,38 +160,33 @@ nsXULListboxAccessible::IsMulticolumn() return PR_FALSE; return numColumns > 1; } //////////////////////////////////////////////////////////////////////////////// // nsXULListboxAccessible. nsIAccessible -nsresult -nsXULListboxAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULListboxAccessible::NativeState() { // As a nsXULListboxAccessible we can have the following states: - // STATE_FOCUSED - // STATE_READONLY - // STATE_FOCUSABLE + // FOCUSED, READONLY, FOCUSABLE // Get focus status from base class - nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 states = nsAccessible::NativeState(); // see if we are multiple select if so set ourselves as such if (mContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::seltype, nsAccessibilityAtoms::multiple, eCaseMatters)) { - *aState |= nsIAccessibleStates::STATE_MULTISELECTABLE | - nsIAccessibleStates::STATE_EXTSELECTABLE; + states |= states::MULTISELECTABLE | states::EXTSELECTABLE; } - return NS_OK; + return states; } /** * Our value is the label of our ( first ) selected child. */ NS_IMETHODIMP nsXULListboxAccessible::GetValue(nsAString& _retval) { _retval.Truncate(); @@ -932,65 +898,52 @@ nsXULListitemAccessible::NativeRole() return nsIAccessibleRole::ROLE_CHECKBUTTON; if (mParent && mParent->Role() == nsIAccessibleRole::ROLE_COMBOBOX_LIST) return nsIAccessibleRole::ROLE_COMBOBOX_OPTION; return nsIAccessibleRole::ROLE_RICH_OPTION; } -nsresult -nsXULListitemAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULListitemAccessible::NativeState() { if (mIsCheckbox) { - return nsXULMenuitemAccessible::GetStateInternal(aState, aExtraState); + return nsXULMenuitemAccessible::NativeState(); } - *aState = 0; - - if (IsDefunct()) { - if (aExtraState) - *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; + if (IsDefunct()) + return states::DEFUNCT; - return NS_OK_DEFUNCT_OBJECT; - } - - if (aExtraState) - *aExtraState = 0; - - *aState = nsIAccessibleStates::STATE_FOCUSABLE | - nsIAccessibleStates::STATE_SELECTABLE; + PRUint64 states = states::FOCUSABLE | states::SELECTABLE; nsCOMPtr<nsIDOMXULSelectControlItemElement> listItem = do_QueryInterface(mContent); if (listItem) { PRBool isSelected; listItem->GetSelected(&isSelected); if (isSelected) - *aState |= nsIAccessibleStates::STATE_SELECTED; + states |= states::SELECTED; if (gLastFocusedNode == mContent) - *aState |= nsIAccessibleStates::STATE_FOCUSED; + states |= states::FOCUSED; } - return NS_OK; + return states; } NS_IMETHODIMP nsXULListitemAccessible::GetActionName(PRUint8 aIndex, nsAString& aName) { if (aIndex == eAction_Click && mIsCheckbox) { // check or uncheck - PRUint32 state; - nsresult rv = GetStateInternal(&state, nsnull); - NS_ENSURE_SUCCESS(rv, rv); + PRUint64 states = NativeState(); - if (state & nsIAccessibleStates::STATE_CHECKED) + if (states & states::CHECKED) aName.AssignLiteral("uncheck"); else aName.AssignLiteral("check"); return NS_OK; } return NS_ERROR_INVALID_ARG; }
--- a/accessible/src/xul/nsXULListboxAccessible.h +++ b/accessible/src/xul/nsXULListboxAccessible.h @@ -54,17 +54,17 @@ class nsIWeakReference; */ class nsXULColumnsAccessible : public nsAccessibleWrap { public: nsXULColumnsAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * nsXULColumnAccessible are accessibles for list and tree column elements * (xul:listcol and xul:treecol). */ class nsXULColumnItemAccessible : public nsLeafAccessible { @@ -73,17 +73,17 @@ public: // nsIAccessible NS_IMETHOD GetNumActions(PRUint8 *aNumActions); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD DoAction(PRUint8 aIndex); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); enum { eAction_Click = 0 }; }; /* * A class the represents the XUL Listbox widget. */ class nsXULListboxAccessible : public nsXULSelectableAccessible, @@ -96,17 +96,17 @@ public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIACCESSIBLETABLE // nsIAccessible NS_IMETHOD GetValue(nsAString& aValue); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); protected: PRBool IsMulticolumn(); }; /** * Listitems -- used in listboxes */ @@ -123,17 +123,17 @@ public: // nsIAccessible NS_IMETHOD GetActionName(PRUint8 index, nsAString& aName); // Don't use XUL menuitems's description attribute NS_IMETHOD GetDescription(nsAString& aDesc) { return nsAccessibleWrap::GetDescription(aDesc); } // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet, PRInt32 *aSetSize); virtual PRBool GetAllowsAnonChildAccessibles(); protected: /** * Return listbox accessible for the listitem. */
--- a/accessible/src/xul/nsXULMenuAccessible.cpp +++ b/accessible/src/xul/nsXULMenuAccessible.cpp @@ -36,16 +36,17 @@ * * ***** END LICENSE BLOCK ***** */ #include "nsXULMenuAccessible.h" #include "nsAccessibilityService.h" #include "nsAccUtils.h" #include "nsXULFormControlAccessible.h" +#include "States.h" #include "nsIDOMElement.h" #include "nsIDOMXULElement.h" #include "nsIMutableArray.h" #include "nsIDOMXULContainerElement.h" #include "nsIDOMXULSelectCntrlItemEl.h" #include "nsIDOMXULMultSelectCntrlEl.h" #include "nsIDOMKeyEvent.h" @@ -284,113 +285,105 @@ nsXULMenuitemAccessible::Init() { if (!nsAccessibleWrap::Init()) return PR_FALSE; nsCoreUtils::GeneratePopupTree(mContent); return PR_TRUE; } -nsresult -nsXULMenuitemAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULMenuitemAccessible::NativeState() { - nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsAccessible::NativeState(); // Focused? if (mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::_moz_menuactive)) - *aState |= nsIAccessibleStates::STATE_FOCUSED; + state |= states::FOCUSED; // Has Popup? if (mContent->NodeInfo()->Equals(nsAccessibilityAtoms::menu, kNameSpaceID_XUL)) { - *aState |= nsIAccessibleStates::STATE_HASPOPUP; + state |= states::HASPOPUP; if (mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::open)) - *aState |= nsIAccessibleStates::STATE_EXPANDED; + state |= states::EXPANDED; else - *aState |= nsIAccessibleStates::STATE_COLLAPSED; + state |= states::COLLAPSED; } // Checkable/checked? static nsIContent::AttrValuesArray strings[] = { &nsAccessibilityAtoms::radio, &nsAccessibilityAtoms::checkbox, nsnull }; if (mContent->FindAttrValueIn(kNameSpaceID_None, nsAccessibilityAtoms::type, strings, eCaseMatters) >= 0) { // Checkable? - *aState |= nsIAccessibleStates::STATE_CHECKABLE; + state |= states::CHECKABLE; // Checked? if (mContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::checked, nsAccessibilityAtoms::_true, eCaseMatters)) - *aState |= nsIAccessibleStates::STATE_CHECKED; + state |= states::CHECKED; } // Combo box listitem PRBool isComboboxOption = (Role() == nsIAccessibleRole::ROLE_COMBOBOX_OPTION); if (isComboboxOption) { // Is selected? PRBool isSelected = PR_FALSE; nsCOMPtr<nsIDOMXULSelectControlItemElement> item(do_QueryInterface(mContent)); - NS_ENSURE_TRUE(item, NS_ERROR_FAILURE); + NS_ENSURE_TRUE(item, state); item->GetSelected(&isSelected); // Is collapsed? PRBool isCollapsed = PR_FALSE; nsAccessible* parentAcc = GetParent(); - if (nsAccUtils::State(parentAcc) & nsIAccessibleStates::STATE_INVISIBLE) + if (parentAcc->State() & states::INVISIBLE) isCollapsed = PR_TRUE; if (isSelected) { - *aState |= nsIAccessibleStates::STATE_SELECTED; + state |= states::SELECTED; // Selected and collapsed? if (isCollapsed) { // Set selected option offscreen/invisible according to combobox state nsAccessible* grandParentAcc = parentAcc->GetParent(); - NS_ENSURE_TRUE(grandParentAcc, NS_ERROR_FAILURE); + NS_ENSURE_TRUE(grandParentAcc, state); NS_ASSERTION(grandParentAcc->Role() == nsIAccessibleRole::ROLE_COMBOBOX, "grandparent of combobox listitem is not combobox"); - PRUint32 grandParentState, grandParentExtState; - grandParentAcc->GetState(&grandParentState, &grandParentExtState); - *aState &= ~(nsIAccessibleStates::STATE_OFFSCREEN | - nsIAccessibleStates::STATE_INVISIBLE); - *aState |= (grandParentState & nsIAccessibleStates::STATE_OFFSCREEN) | - (grandParentState & nsIAccessibleStates::STATE_INVISIBLE); - if (aExtraState) { - *aExtraState |= - grandParentExtState & nsIAccessibleStates::EXT_STATE_OPAQUE; - } + PRUint64 grandParentState = grandParentAcc->State(); + state &= ~(states::OFFSCREEN | states::INVISIBLE); + state |= (grandParentState & states::OFFSCREEN) | + (grandParentState & states::INVISIBLE) | + (grandParentState & states::OPAQUE1); } // isCollapsed } // isSelected } // ROLE_COMBOBOX_OPTION // Set focusable and selectable for items that are available // and whose metric setting does allow disabled items to be focused. - if (*aState & nsIAccessibleStates::STATE_UNAVAILABLE) { + if (state & states::UNAVAILABLE) { // Honour the LookAndFeel metric. nsCOMPtr<nsILookAndFeel> lookNFeel(do_GetService(kLookAndFeelCID)); PRInt32 skipDisabledMenuItems = 0; lookNFeel->GetMetric(nsILookAndFeel::eMetric_SkipNavigatingDisabledMenuItem, skipDisabledMenuItems); // We don't want the focusable and selectable states for combobox items, // so exclude them here as well. if (skipDisabledMenuItems || isComboboxOption) { - return NS_OK; + return state; } } - *aState|= (nsIAccessibleStates::STATE_FOCUSABLE | - nsIAccessibleStates::STATE_SELECTABLE); + state |= (states::FOCUSABLE | states::SELECTABLE); - return NS_OK; + return state; } nsresult nsXULMenuitemAccessible::GetNameInternal(nsAString& aName) { mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::label, aName); return NS_OK; } @@ -555,28 +548,22 @@ NS_IMETHODIMP nsXULMenuitemAccessible::G //////////////////////////////////////////////////////////////////////////////// nsXULMenuSeparatorAccessible:: nsXULMenuSeparatorAccessible(nsIContent *aContent, nsIWeakReference *aShell) : nsXULMenuitemAccessible(aContent, aShell) { } -nsresult -nsXULMenuSeparatorAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULMenuSeparatorAccessible::NativeState() { // Isn't focusable, but can be offscreen/invisible -- only copy those states - nsresult rv = nsXULMenuitemAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); - - *aState &= (nsIAccessibleStates::STATE_OFFSCREEN | - nsIAccessibleStates::STATE_INVISIBLE); - - return NS_OK; + return nsXULMenuitemAccessible::NativeState() & + (states::OFFSCREEN | states::INVISIBLE); } nsresult nsXULMenuSeparatorAccessible::GetNameInternal(nsAString& aName) { return NS_OK; } @@ -609,47 +596,44 @@ NS_IMETHODIMP nsXULMenuSeparatorAccessib nsXULMenupopupAccessible:: nsXULMenupopupAccessible(nsIContent *aContent, nsIWeakReference *aShell) : nsXULSelectableAccessible(aContent, aShell) { // May be the anonymous <menupopup> inside <menulist> (a combobox) mSelectControl = do_QueryInterface(mContent->GetParent()); } -nsresult -nsXULMenupopupAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULMenupopupAccessible::NativeState() { - nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsAccessible::NativeState(); #ifdef DEBUG_A11Y // We are onscreen if our parent is active PRBool isActive = mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::menuactive); if (!isActive) { nsAccessible* parent(GetParent()); - NS_ENSURE_STATE(parent); + NS_ENSURE_TRUE(parent, state); nsIContent *parentContent = parnet->GetContent(); - NS_ENSURE_STATE(parentContent); + NS_ENSURE_TRUE(parentContent, state); isActive = parentContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::open); } - NS_ASSERTION(isActive || *aState & nsIAccessibleStates::STATE_INVISIBLE, - "XULMenupopup doesn't have STATE_INVISIBLE when it's inactive"); + NS_ASSERTION(isActive || states & states::INVISIBLE, + "XULMenupopup doesn't have INVISIBLE when it's inactive"); #endif - if (*aState & nsIAccessibleStates::STATE_INVISIBLE) - *aState |= (nsIAccessibleStates::STATE_OFFSCREEN | - nsIAccessibleStates::STATE_COLLAPSED); + if (state & states::INVISIBLE) + state |= states::OFFSCREEN | states::COLLAPSED; - return NS_OK; + return state; } nsresult nsXULMenupopupAccessible::GetNameInternal(nsAString& aName) { nsIContent *content = mContent; while (content && aName.IsEmpty()) { content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::label, aName); @@ -689,26 +673,24 @@ nsXULMenupopupAccessible::NativeRole() //////////////////////////////////////////////////////////////////////////////// nsXULMenubarAccessible:: nsXULMenubarAccessible(nsIContent *aContent, nsIWeakReference *aShell) : nsAccessibleWrap(aContent, aShell) { } -nsresult -nsXULMenubarAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULMenubarAccessible::NativeState() { - nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsAccessible::NativeState(); - // Menu bar iteself is not actually focusable - *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; - return rv; + // Menu bar itself is not actually focusable + state &= ~states::FOCUSABLE; + return state; } nsresult nsXULMenubarAccessible::GetNameInternal(nsAString& aName) { aName.AssignLiteral("Application"); return NS_OK;
--- a/accessible/src/xul/nsXULMenuAccessible.h +++ b/accessible/src/xul/nsXULMenuAccessible.h @@ -90,17 +90,17 @@ public: NS_IMETHOD GetNumActions(PRUint8 *_retval); // nsAccessNode virtual PRBool Init(); // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual PRInt32 GetLevelInternal(); virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet, PRInt32 *aSetSize); virtual PRBool GetAllowsAnonChildAccessibles(); }; /** @@ -114,41 +114,41 @@ public: // nsIAccessible NS_IMETHOD DoAction(PRUint8 index); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD GetNumActions(PRUint8 *_retval); // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Used for XUL menupopup and panel. */ class nsXULMenupopupAccessible : public nsXULSelectableAccessible { public: nsXULMenupopupAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Used for XUL menubar element. */ class nsXULMenubarAccessible : public nsAccessibleWrap { public: nsXULMenubarAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; #endif
--- a/accessible/src/xul/nsXULSliderAccessible.cpp +++ b/accessible/src/xul/nsXULSliderAccessible.cpp @@ -34,16 +34,17 @@ * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsXULSliderAccessible.h" #include "nsAccessibilityAtoms.h" +#include "States.h" #include "nsIDOMDocument.h" #include "nsIDOMDocumentXBL.h" #include "nsIFrame.h" //////////////////////////////////////////////////////////////////////////////// // nsXULSliderAccessible //////////////////////////////////////////////////////////////////////////////// @@ -63,34 +64,32 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsXULSlider // nsAccessible PRUint32 nsXULSliderAccessible::NativeRole() { return nsIAccessibleRole::ROLE_SLIDER; } -nsresult -nsXULSliderAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULSliderAccessible::NativeState() { - nsresult rv = nsAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 states = nsAccessibleWrap::NativeState(); nsCOMPtr<nsIContent> sliderContent(GetSliderNode()); NS_ENSURE_STATE(sliderContent); nsIFrame *frame = sliderContent->GetPrimaryFrame(); if (frame && frame->IsFocusable()) - *aState |= nsIAccessibleStates::STATE_FOCUSABLE; + states |= states::FOCUSABLE; if (gLastFocusedNode == mContent) - *aState |= nsIAccessibleStates::STATE_FOCUSED; + states |= states::FOCUSED; - return NS_OK; + return states; } // nsIAccessible NS_IMETHODIMP nsXULSliderAccessible::GetValue(nsAString& aValue) { return GetSliderAttr(nsAccessibilityAtoms::curpos, aValue);
--- a/accessible/src/xul/nsXULSliderAccessible.h +++ b/accessible/src/xul/nsXULSliderAccessible.h @@ -60,17 +60,17 @@ public: NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD DoAction(PRUint8 aIndex); // nsIAccessibleValue NS_DECL_NSIACCESSIBLEVALUE // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual PRBool GetAllowsAnonChildAccessibles(); protected: already_AddRefed<nsIContent> GetSliderNode(); nsresult GetSliderAttr(nsIAtom *aName, nsAString& aValue); nsresult SetSliderAttr(nsIAtom *aName, const nsAString& aValue);
--- a/accessible/src/xul/nsXULTabAccessible.cpp +++ b/accessible/src/xul/nsXULTabAccessible.cpp @@ -35,16 +35,17 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsXULTabAccessible.h" #include "nsAccUtils.h" #include "nsRelUtils.h" +#include "States.h" // NOTE: alphabetically ordered #include "nsIDocument.h" #include "nsIFrame.h" #include "nsIDOMDocument.h" #include "nsIDOMXULSelectCntrlEl.h" #include "nsIDOMXULSelectCntrlItemEl.h" #include "nsIDOMXULRelatedElement.h" @@ -97,47 +98,46 @@ NS_IMETHODIMP nsXULTabAccessible::DoActi // nsXULTabAccessible: nsAccessible PRUint32 nsXULTabAccessible::NativeRole() { return nsIAccessibleRole::ROLE_PAGETAB; } -nsresult -nsXULTabAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsXULTabAccessible::NativeState() { // Possible states: focused, focusable, unavailable(disabled), offscreen. // get focus and disable status from base class - nsresult rv = nsAccessibleWrap::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsAccessibleWrap::NativeState(); // In the past, tabs have been focusable in classic theme // They may be again in the future // Check style for -moz-user-focus: normal to see if it's focusable - *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; + state &= ~states::FOCUSABLE; nsIFrame *frame = mContent->GetPrimaryFrame(); if (frame) { const nsStyleUserInterface* ui = frame->GetStyleUserInterface(); if (ui->mUserFocus == NS_STYLE_USER_FOCUS_NORMAL) - *aState |= nsIAccessibleStates::STATE_FOCUSABLE; + state |= states::FOCUSABLE; } // Check whether the tab is selected - *aState |= nsIAccessibleStates::STATE_SELECTABLE; - *aState &= ~nsIAccessibleStates::STATE_SELECTED; + state |= states::SELECTABLE; + state &= ~states::SELECTED; nsCOMPtr<nsIDOMXULSelectControlItemElement> tab(do_QueryInterface(mContent)); if (tab) { PRBool selected = PR_FALSE; if (NS_SUCCEEDED(tab->GetSelected(&selected)) && selected) - *aState |= nsIAccessibleStates::STATE_SELECTED; + state |= states::SELECTED; } - return NS_OK; + return state; } // nsIAccessible NS_IMETHODIMP nsXULTabAccessible::GetRelationByType(PRUint32 aRelationType, nsIAccessibleRelation **aRelation) { nsresult rv = nsAccessibleWrap::GetRelationByType(aRelationType,
--- a/accessible/src/xul/nsXULTabAccessible.h +++ b/accessible/src/xul/nsXULTabAccessible.h @@ -59,17 +59,17 @@ public: NS_IMETHOD DoAction(PRUint8 index); NS_IMETHOD GetRelationByType(PRUint32 aRelationType, nsIAccessibleRelation **aRelation); // nsAccessible virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet, PRInt32 *aSetSize); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * A container of tab objects, xul:tabs element. */ class nsXULTabsAccessible : public nsXULSelectableAccessible {
--- a/accessible/src/xul/nsXULTextAccessible.cpp +++ b/accessible/src/xul/nsXULTextAccessible.cpp @@ -41,16 +41,17 @@ #include "nsXULTextAccessible.h" #include "nsAccessibilityAtoms.h" #include "nsAccUtils.h" #include "nsBaseWidgetAccessible.h" #include "nsCoreUtils.h" #include "nsRelUtils.h" #include "nsTextEquivUtils.h" +#include "States.h" #include "nsIDOMXULDescriptionElement.h" #include "nsINameSpaceManager.h" #include "nsString.h" #include "nsNetUtil.h" //////////////////////////////////////////////////////////////////////////////// // nsXULTextAccessible @@ -72,27 +73,22 @@ nsXULTextAccessible::GetNameInternal(nsA } PRUint32 nsXULTextAccessible::NativeRole() { return nsIAccessibleRole::ROLE_LABEL; } -nsresult -nsXULTextAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsXULTextAccessible::NativeState() { - nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); - // Labels and description have read only state // They are not focusable or selectable - *aState |= nsIAccessibleStates::STATE_READONLY; - return NS_OK; + return nsHyperTextAccessibleWrap::NativeState() | states::READONLY; } NS_IMETHODIMP nsXULTextAccessible::GetRelationByType(PRUint32 aRelationType, nsIAccessibleRelation **aRelation) { nsresult rv = nsHyperTextAccessibleWrap::GetRelationByType(aRelationType, aRelation); @@ -117,26 +113,24 @@ nsXULTextAccessible::GetRelationByType(P //////////////////////////////////////////////////////////////////////////////// nsXULTooltipAccessible:: nsXULTooltipAccessible(nsIContent *aContent, nsIWeakReference *aShell) : nsLeafAccessible(aContent, aShell) { } -nsresult -nsXULTooltipAccessible::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULTooltipAccessible::NativeState() { - nsresult rv = nsLeafAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 states = nsLeafAccessible::NativeState(); - *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; - *aState |= nsIAccessibleStates::STATE_READONLY; - return NS_OK; + states &= ~states::FOCUSABLE; + states |= states::READONLY; + return states; } PRUint32 nsXULTooltipAccessible::NativeRole() { return nsIAccessibleRole::ROLE_TOOLTIP; } @@ -182,25 +176,20 @@ nsXULLinkAccessible::GetNameInternal(nsA PRUint32 nsXULLinkAccessible::NativeRole() { return nsIAccessibleRole::ROLE_LINK; } -nsresult -nsXULLinkAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsXULLinkAccessible::NativeState() { - nsresult rv = nsHyperTextAccessibleWrap::GetStateInternal(aState, - aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); - - *aState |= nsIAccessibleStates::STATE_LINKED; - return NS_OK; + return nsHyperTextAccessible::NativeState() | states::LINKED; } NS_IMETHODIMP nsXULLinkAccessible::GetNumActions(PRUint8 *aNumActions) { NS_ENSURE_ARG_POINTER(aNumActions); *aNumActions = 1;
--- a/accessible/src/xul/nsXULTextAccessible.h +++ b/accessible/src/xul/nsXULTextAccessible.h @@ -54,31 +54,31 @@ public: // nsIAccessible NS_IMETHOD GetRelationByType(PRUint32 aRelationType, nsIAccessibleRelation **aRelation); // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; /** * Used for XUL tooltip element. */ class nsXULTooltipAccessible : public nsLeafAccessible { public: nsXULTooltipAccessible(nsIContent *aContent, nsIWeakReference *aShell); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); }; class nsXULLinkAccessible : public nsHyperTextAccessibleWrap { public: nsXULLinkAccessible(nsIContent *aContent, nsIWeakReference *aShell); @@ -89,17 +89,17 @@ public: NS_IMETHOD GetNumActions(PRUint8 *aNumActions); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD DoAction(PRUint8 aIndex); // nsAccessible virtual nsresult GetNameInternal(nsAString& aName); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); // HyperLinkAccessible virtual bool IsHyperLink(); virtual PRUint32 StartOffset(); virtual PRUint32 EndOffset(); virtual already_AddRefed<nsIURI> GetAnchorURI(PRUint32 aAnchorIndex); protected:
--- a/accessible/src/xul/nsXULTreeAccessible.cpp +++ b/accessible/src/xul/nsXULTreeAccessible.cpp @@ -38,16 +38,17 @@ #include "nsXULTreeAccessible.h" #include "nsAccCache.h" #include "nsAccUtils.h" #include "nsCoreUtils.h" #include "nsDocAccessible.h" #include "nsRelUtils.h" +#include "States.h" #include "nsIDOMXULElement.h" #include "nsIDOMXULMultSelectCntrlEl.h" #include "nsIDOMXULTreeElement.h" #include "nsITreeSelection.h" #include "nsIMutableArray.h" #include "nsComponentManagerUtils.h" @@ -88,43 +89,41 @@ NS_INTERFACE_MAP_STATIC_AMBIGUOUS(nsXULT NS_INTERFACE_MAP_END_INHERITING(nsAccessible) NS_IMPL_ADDREF_INHERITED(nsXULTreeAccessible, nsAccessible) NS_IMPL_RELEASE_INHERITED(nsXULTreeAccessible, nsAccessible) //////////////////////////////////////////////////////////////////////////////// // nsXULTreeAccessible: nsAccessible implementation -nsresult -nsXULTreeAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) +PRUint64 +nsXULTreeAccessible::NativeState() { // Get focus status from base class. - nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState); - NS_ENSURE_A11Y_SUCCESS(rv, rv); + PRUint64 state = nsAccessible::NativeState(); // readonly state - *aState |= nsIAccessibleStates::STATE_READONLY; + state |= states::READONLY; // remove focusable and focused states since tree items are focusable for AT - *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE; - *aState &= ~nsIAccessibleStates::STATE_FOCUSED; + state &= ~(states::FOCUSABLE | states::FOCUSED); // multiselectable state. nsCOMPtr<nsITreeSelection> selection; mTreeView->GetSelection(getter_AddRefs(selection)); - NS_ENSURE_STATE(selection); + NS_ENSURE_TRUE(selection, state); PRBool isSingle = PR_FALSE; - rv = selection->GetSingle(&isSingle); - NS_ENSURE_SUCCESS(rv, rv); + nsresult rv = selection->GetSingle(&isSingle); + NS_ENSURE_SUCCESS(rv, state); if (!isSingle) - *aState |= nsIAccessibleStates::STATE_MULTISELECTABLE; + state |= states::MULTISELECTABLE; - return NS_OK; + return state; } NS_IMETHODIMP nsXULTreeAccessible::GetValue(nsAString& aValue) { // Return the value is the first selected child. aValue.Truncate(); @@ -920,74 +919,62 @@ nsXULTreeItemAccessibleBase::GroupPositi *aGroupLevel = level + 1; *aSimilarItemsInGroup = setSize; *aPositionInGroup = posInSet; return NS_OK; } -nsresult -nsXULTreeItemAccessibleBase::GetStateInternal(PRUint32 *aState, - PRUint32 *aExtraState) +PRUint64 +nsXULTreeItemAccessibleBase::NativeState() { - NS_ENSURE_ARG_POINTER(aState); - *aState = 0; - if (aExtraState) - *aExtraState = 0; - - if (IsDefunct()) { - if (aExtraState) - *aExtraState = nsIAccessibleStates::EXT_STATE_DEFUNCT; - return NS_OK_DEFUNCT_OBJECT; - } + if (IsDefunct()) + return states::DEFUNCT; // focusable and selectable states - *aState = nsIAccessibleStates::STATE_FOCUSABLE | - nsIAccessibleStates::STATE_SELECTABLE; + PRUint64 state = states::FOCUSABLE | states::SELECTABLE; // expanded/collapsed state if (IsExpandable()) { PRBool isContainerOpen; mTreeView->IsContainerOpen(mRow, &isContainerOpen); - *aState |= isContainerOpen ? - static_cast<PRUint32>(nsIAccessibleStates::STATE_EXPANDED) : - static_cast<PRUint32>(nsIAccessibleStates::STATE_COLLAPSED); + state |= isContainerOpen ? states::EXPANDED : states::COLLAPSED; } // selected state nsCOMPtr<nsITreeSelection> selection; mTreeView->GetSelection(getter_AddRefs(selection)); if (selection) { PRBool isSelected; selection->IsSelected(mRow, &isSelected); if (isSelected) - *aState |= nsIAccessibleStates::STATE_SELECTED; + state |= states::SELECTED; } // focused state nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelect = do_QueryInterface(mContent); if (multiSelect) { PRInt32 currentIndex; multiSelect->GetCurrentIndex(¤tIndex); if (currentIndex == mRow) { - *aState |= nsIAccessibleStates::STATE_FOCUSED; + state |= states::FOCUSED; } } // invisible state PRInt32 firstVisibleRow, lastVisibleRow; mTree->GetFirstVisibleRow(&firstVisibleRow); mTree->GetLastVisibleRow(&lastVisibleRow); if (mRow < firstVisibleRow || mRow > lastVisibleRow) - *aState |= nsIAccessibleStates::STATE_INVISIBLE; + state |= states::INVISIBLE; - return NS_OK; + return state; } PRInt32 nsXULTreeItemAccessibleBase::GetIndexInParent() const { return mParent ? mParent->GetCachedChildCount() + mRow : -1; }
--- a/accessible/src/xul/nsXULTreeAccessible.h +++ b/accessible/src/xul/nsXULTreeAccessible.h @@ -80,17 +80,17 @@ public: NS_IMETHOD GetFocusedChild(nsIAccessible **aFocusedChild); // nsAccessNode virtual PRBool IsDefunct(); virtual void Shutdown(); // nsAccessible virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual nsAccessible* GetChildAtPoint(PRInt32 aX, PRInt32 aY, EWhichChildAtPoint aWhichChild); virtual nsAccessible* GetChildAt(PRUint32 aIndex); virtual PRInt32 GetChildCount(); // SelectAccessible virtual bool IsSelect(); @@ -201,17 +201,17 @@ public: NS_IMETHOD DoAction(PRUint8 aIndex); // nsAccessNode virtual PRBool IsDefunct(); virtual void Shutdown(); virtual bool IsPrimaryForNode() const; // nsAccessible - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual PRInt32 GetIndexInParent() const; // nsXULTreeItemAccessibleBase NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULTREEITEMBASEACCESSIBLE_IMPL_CID) /** * Return row index associated with the accessible. */
--- a/accessible/src/xul/nsXULTreeGridAccessible.cpp +++ b/accessible/src/xul/nsXULTreeGridAccessible.cpp @@ -38,16 +38,17 @@ #include "nsXULTreeGridAccessibleWrap.h" #include "nsAccCache.h" #include "nsAccessibilityService.h" #include "nsAccUtils.h" #include "nsDocAccessible.h" #include "nsEventShell.h" +#include "States.h" #include "nsITreeSelection.h" //////////////////////////////////////////////////////////////////////////////// // nsXULTreeGridAccessible //////////////////////////////////////////////////////////////////////////////// nsXULTreeGridAccessible:: @@ -1156,56 +1157,47 @@ nsXULTreeGridCellAccessible::GetAttribut } PRUint32 nsXULTreeGridCellAccessible::NativeRole() { return nsIAccessibleRole::ROLE_GRID_CELL; } -nsresult -nsXULTreeGridCellAccessible::GetStateInternal(PRUint32 *aStates, - PRUint32 *aExtraStates) +PRUint64 +nsXULTreeGridCellAccessible::NativeState() { - NS_ENSURE_ARG_POINTER(aStates); - *aStates = 0; - if (aExtraStates) - *aExtraStates = 0; - - if (IsDefunct()) { - if (aExtraStates) - *aExtraStates = nsIAccessibleStates::EXT_STATE_DEFUNCT; - return NS_OK_DEFUNCT_OBJECT; - } + if (IsDefunct()) + return states::DEFUNCT; // selectable/selected state - *aStates |= nsIAccessibleStates::STATE_SELECTABLE; + PRUint64 states = states::SELECTABLE; nsCOMPtr<nsITreeSelection> selection; mTreeView->GetSelection(getter_AddRefs(selection)); if (selection) { PRBool isSelected = PR_FALSE; selection->IsSelected(mRow, &isSelected); if (isSelected) - *aStates |= nsIAccessibleStates::STATE_SELECTED; + states |= states::SELECTED; } // checked state PRInt16 type; mColumn->GetType(&type); if (type == nsITreeColumn::TYPE_CHECKBOX) { - *aStates |= nsIAccessibleStates::STATE_CHECKABLE; + states |= states::CHECKABLE; nsAutoString checked; mTreeView->GetCellValue(mRow, mColumn, checked); if (checked.EqualsIgnoreCase("true")) - *aStates |= nsIAccessibleStates::STATE_CHECKED; + states |= states::CHECKED; } - return NS_OK; + return states; } PRInt32 nsXULTreeGridCellAccessible::GetIndexInParent() const { return GetColumnIndex(); } @@ -1230,18 +1222,17 @@ nsXULTreeGridCellAccessible::CellInvalid PRInt16 type; mColumn->GetType(&type); if (type == nsITreeColumn::TYPE_CHECKBOX) { mTreeView->GetCellValue(mRow, mColumn, textEquiv); if (mCachedTextEquiv != textEquiv) { PRBool isEnabled = textEquiv.EqualsLiteral("true"); nsRefPtr<AccEvent> accEvent = - new AccStateChangeEvent(this, nsIAccessibleStates::STATE_CHECKED, - PR_FALSE, isEnabled); + new AccStateChangeEvent(this, states::CHECKED, isEnabled); nsEventShell::FireEvent(accEvent); mCachedTextEquiv = textEquiv; } return; }
--- a/accessible/src/xul/nsXULTreeGridAccessible.h +++ b/accessible/src/xul/nsXULTreeGridAccessible.h @@ -157,17 +157,17 @@ public: // nsAccessNode virtual PRBool IsDefunct(); virtual PRBool Init(); virtual bool IsPrimaryForNode() const; // nsAccessible virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes); virtual PRUint32 NativeRole(); - virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + virtual PRUint64 NativeState(); virtual PRInt32 GetIndexInParent() const; // nsXULTreeGridCellAccessible NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULTREEGRIDCELLACCESSIBLE_IMPL_CID) /** * Return index of the column. */