Bug 1899960 - P1: Don't cache implicit states. r=Jamie
This also removes some duplication and unifies the logic we use for states that are calculated from other ones. Differential Revision: https://phabricator.services.mozilla.com/D250356
This commit is contained in:
committed by
eisaacson@mozilla.com
parent
2d6a0f17e3
commit
dd5d2cd561
@@ -295,9 +295,9 @@ const uint64_t LAST_ENTRY = CURRENT;
|
|||||||
/**
|
/**
|
||||||
* States that must be calculated by RemoteAccessible and are thus not cached.
|
* States that must be calculated by RemoteAccessible and are thus not cached.
|
||||||
*/
|
*/
|
||||||
const uint64_t kRemoteCalculatedStates =
|
const uint64_t kRemoteCalculatedStates = states::FOCUSED | states::INVISIBLE |
|
||||||
states::FOCUSED | states::INVISIBLE | states::OFFSCREEN | states::ENABLED |
|
states::OFFSCREEN | states::SENSITIVE |
|
||||||
states::SENSITIVE | states::COLLAPSED | states::OPAQUE1;
|
states::OPAQUE1;
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|||||||
@@ -698,6 +698,24 @@ void Accessible::ApplyImplicitState(uint64_t& aState) const {
|
|||||||
if (Opacity() == 1.0f && !(aState & states::INVISIBLE)) {
|
if (Opacity() == 1.0f && !(aState & states::INVISIBLE)) {
|
||||||
aState |= states::OPAQUE1;
|
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 {
|
bool Accessible::NameIsEmpty() const {
|
||||||
|
|||||||
@@ -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;
|
if (IsDefunct()) return states::DEFUNCT;
|
||||||
|
|
||||||
uint64_t state = NativeState();
|
uint64_t state = NativeState();
|
||||||
// Apply ARIA states to be sure accessible states will be overridden.
|
// Apply ARIA states to be sure accessible states will be overridden.
|
||||||
ApplyARIAState(&state);
|
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)) {
|
if (!(state & states::UNAVAILABLE)) {
|
||||||
state |= states::ENABLED | states::SENSITIVE;
|
|
||||||
|
|
||||||
// If the object is a current item of container widget then mark it as
|
// 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
|
// ACTIVE. This allows screen reader virtual buffer modes to know which
|
||||||
// descendant is the current one that would get focus if the user navigates
|
// 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 (widget && widget->CurrentItem() == this) state |= states::ACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((state & states::COLLAPSED) || (state & states::EXPANDED)) {
|
return state;
|
||||||
state |= states::EXPANDABLE;
|
}
|
||||||
}
|
|
||||||
|
uint64_t LocalAccessible::State() {
|
||||||
|
uint64_t state = ExplicitState();
|
||||||
|
|
||||||
ApplyImplicitState(state);
|
ApplyImplicitState(state);
|
||||||
return state;
|
return state;
|
||||||
@@ -3938,7 +3928,7 @@ already_AddRefed<AccAttributes> LocalAccessible::BundleFieldsForCache(
|
|||||||
if (IsInitialPush(CacheDomain::State)) {
|
if (IsInitialPush(CacheDomain::State)) {
|
||||||
// Most states are updated using state change events, so we only send
|
// Most states are updated using state change events, so we only send
|
||||||
// these for the initial cache push.
|
// these for the initial cache push.
|
||||||
uint64_t state = State();
|
uint64_t state = ExplicitState();
|
||||||
// Exclude states which must be calculated by RemoteAccessible.
|
// Exclude states which must be calculated by RemoteAccessible.
|
||||||
state &= ~kRemoteCalculatedStates;
|
state &= ~kRemoteCalculatedStates;
|
||||||
fields->SetAttribute(CacheKey::State, state);
|
fields->SetAttribute(CacheKey::State, state);
|
||||||
|
|||||||
@@ -765,6 +765,8 @@ class LocalAccessible : public nsISupports, public Accessible {
|
|||||||
*/
|
*/
|
||||||
void NativeDescription(nsString& aDescription) const;
|
void NativeDescription(nsString& aDescription) const;
|
||||||
|
|
||||||
|
uint64_t ExplicitState() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return object attributes provided by native markup. It doesn't take into
|
* Return object attributes provided by native markup. It doesn't take into
|
||||||
* account ARIA.
|
* account ARIA.
|
||||||
|
|||||||
@@ -1580,13 +1580,6 @@ uint64_t RemoteAccessible::State() {
|
|||||||
mCachedFields->GetAttribute<uint64_t>(CacheKey::State)) {
|
mCachedFields->GetAttribute<uint64_t>(CacheKey::State)) {
|
||||||
VERIFY_CACHE(CacheDomain::State);
|
VERIFY_CACHE(CacheDomain::State);
|
||||||
state = *rawState;
|
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);
|
ApplyImplicitState(state);
|
||||||
|
|||||||
Reference in New Issue
Block a user