diff --git a/accessible/base/States.h b/accessible/base/States.h index 5588568d89ba..09b0a21d29d1 100644 --- a/accessible/base/States.h +++ b/accessible/base/States.h @@ -295,9 +295,9 @@ const uint64_t LAST_ENTRY = CURRENT; /** * States that must be calculated by RemoteAccessible and are thus not cached. */ -const uint64_t kRemoteCalculatedStates = - states::FOCUSED | states::INVISIBLE | states::OFFSCREEN | states::ENABLED | - states::SENSITIVE | states::COLLAPSED | states::OPAQUE1; +const uint64_t kRemoteCalculatedStates = states::FOCUSED | states::INVISIBLE | + states::OFFSCREEN | states::SENSITIVE | + states::OPAQUE1; } // namespace a11y } // namespace mozilla diff --git a/accessible/basetypes/Accessible.cpp b/accessible/basetypes/Accessible.cpp index 8e439040f93f..e2b53c73f6c4 100644 --- a/accessible/basetypes/Accessible.cpp +++ b/accessible/basetypes/Accessible.cpp @@ -698,6 +698,24 @@ void Accessible::ApplyImplicitState(uint64_t& aState) const { if (Opacity() == 1.0f && !(aState & states::INVISIBLE)) { aState |= states::OPAQUE1; } + + const uint32_t kExpandCollapseStates = states::COLLAPSED | states::EXPANDED; + if ((aState & kExpandCollapseStates) == kExpandCollapseStates) { + // Cannot be both expanded and collapsed -- this happens in ARIA expanded + // combobox because of limitation of ARIAMap. + // XXX: Perhaps we will be able to make this less hacky if we support + // extended states in ARIAMap, e.g. derive COLLAPSED from + // EXPANDABLE && !EXPANDED. + aState &= ~states::COLLAPSED; + } + + if (!(aState & states::UNAVAILABLE)) { + aState |= states::ENABLED | states::SENSITIVE; + } + + if (aState & kExpandCollapseStates) { + aState |= states::EXPANDABLE; + } } bool Accessible::NameIsEmpty() const { diff --git a/accessible/generic/LocalAccessible.cpp b/accessible/generic/LocalAccessible.cpp index da5ff5257a65..ef354364c814 100644 --- a/accessible/generic/LocalAccessible.cpp +++ b/accessible/generic/LocalAccessible.cpp @@ -1602,26 +1602,14 @@ void LocalAccessible::ARIAGroupPosition(int32_t* aLevel, int32_t* aSetSize, } } -uint64_t LocalAccessible::State() { +uint64_t LocalAccessible::ExplicitState() const { if (IsDefunct()) return states::DEFUNCT; uint64_t state = NativeState(); // Apply ARIA states to be sure accessible states will be overridden. ApplyARIAState(&state); - const uint32_t 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 ARIAMap. - // XXX: Perhaps we will be able to make this less hacky if we support - // extended states in ARIAMap, e.g. derive COLLAPSED from - // EXPANDABLE && !EXPANDED. - state &= ~states::COLLAPSED; - } - if (!(state & states::UNAVAILABLE)) { - state |= states::ENABLED | states::SENSITIVE; - // If the object is a current item of container widget then mark it as // ACTIVE. This allows screen reader virtual buffer modes to know which // descendant is the current one that would get focus if the user navigates @@ -1630,9 +1618,11 @@ uint64_t LocalAccessible::State() { if (widget && widget->CurrentItem() == this) state |= states::ACTIVE; } - if ((state & states::COLLAPSED) || (state & states::EXPANDED)) { - state |= states::EXPANDABLE; - } + return state; +} + +uint64_t LocalAccessible::State() { + uint64_t state = ExplicitState(); ApplyImplicitState(state); return state; @@ -3938,7 +3928,7 @@ already_AddRefed LocalAccessible::BundleFieldsForCache( if (IsInitialPush(CacheDomain::State)) { // Most states are updated using state change events, so we only send // these for the initial cache push. - uint64_t state = State(); + uint64_t state = ExplicitState(); // Exclude states which must be calculated by RemoteAccessible. state &= ~kRemoteCalculatedStates; fields->SetAttribute(CacheKey::State, state); diff --git a/accessible/generic/LocalAccessible.h b/accessible/generic/LocalAccessible.h index 334da902b3a1..488047ad9435 100644 --- a/accessible/generic/LocalAccessible.h +++ b/accessible/generic/LocalAccessible.h @@ -765,6 +765,8 @@ class LocalAccessible : public nsISupports, public Accessible { */ void NativeDescription(nsString& aDescription) const; + uint64_t ExplicitState() const; + /** * Return object attributes provided by native markup. It doesn't take into * account ARIA. diff --git a/accessible/ipc/RemoteAccessible.cpp b/accessible/ipc/RemoteAccessible.cpp index 9955e5a2cdbd..0facb88dc618 100644 --- a/accessible/ipc/RemoteAccessible.cpp +++ b/accessible/ipc/RemoteAccessible.cpp @@ -1580,13 +1580,6 @@ uint64_t RemoteAccessible::State() { mCachedFields->GetAttribute(CacheKey::State)) { VERIFY_CACHE(CacheDomain::State); state = *rawState; - // Handle states that are derived from other states. - if (!(state & states::UNAVAILABLE)) { - state |= states::ENABLED | states::SENSITIVE; - } - if (state & states::EXPANDABLE && !(state & states::EXPANDED)) { - state |= states::COLLAPSED; - } } ApplyImplicitState(state);