Bug 1821969 part 3: Remove Mac state cache. r=morgan

Now that we always have the core parent process cache, this is no longer necessary.

Differential Revision: https://phabricator.services.mozilla.com/D178427
This commit is contained in:
James Teh 2023-05-24 10:50:46 +00:00
parent 46b80585f4
commit fc2dd4ac56
3 changed files with 2 additions and 64 deletions

View File

@ -65,11 +65,6 @@ enum CheckedState {
*/
mozilla::a11y::role mRole;
/**
* A cache of a subset of our states.
*/
uint64_t mCachedState;
nsStaticAtom* mARIARole;
bool mIsLiveRegion;
@ -109,12 +104,9 @@ enum CheckedState {
// Get gecko accessible's state filtered through given mask.
- (uint64_t)stateWithMask:(uint64_t)mask;
// Notify of a state change, so the cache can be altered.
// Notify of a state change, so notifications can be fired.
- (void)stateChanged:(uint64_t)state isEnabled:(BOOL)enabled;
// Invalidate cached state.
- (void)invalidateState;
// Get top level (tab) web area.
- (mozAccessible*)topWebArea;

View File

@ -112,63 +112,20 @@ using namespace mozilla::a11y;
NS_OBJC_END_TRY_BLOCK_RETURN(nil);
}
static const uint64_t kCachedStates =
states::CHECKED | states::PRESSED | states::MIXED | states::EXPANDED |
states::EXPANDABLE | states::CURRENT | states::SELECTED |
states::TRAVERSED | states::LINKED | states::HASPOPUP | states::BUSY |
states::MULTI_LINE | states::CHECKABLE;
static const uint64_t kCacheInitialized = ((uint64_t)0x1) << 63;
- (uint64_t)state {
uint64_t state = 0;
if (LocalAccessible* acc = mGeckoAccessible->AsLocal()) {
state = acc->State();
}
if (RemoteAccessible* proxy = mGeckoAccessible->AsRemote()) {
state = proxy->State();
}
if (!(mCachedState & kCacheInitialized)) {
mCachedState = state & kCachedStates;
mCachedState |= kCacheInitialized;
}
return state;
return mGeckoAccessible->State();
}
- (uint64_t)stateWithMask:(uint64_t)mask {
if ((mask & kCachedStates) == mask &&
(mCachedState & kCacheInitialized) != 0) {
return mCachedState & mask;
}
return [self state] & mask;
}
- (void)stateChanged:(uint64_t)state isEnabled:(BOOL)enabled {
if ((state & kCachedStates) != 0) {
if (!(mCachedState & kCacheInitialized)) {
[self state];
} else {
if (enabled) {
mCachedState |= state;
} else {
mCachedState &= ~state;
}
}
}
if (state == states::BUSY) {
[self moxPostNotification:@"AXElementBusyChanged"];
}
}
- (void)invalidateState {
mCachedState = 0;
}
- (BOOL)providesLabelNotTitle {
// These accessible types are the exception to the rule of label vs. title:
// They may be named explicitly, but they still provide a label not a title.
@ -894,9 +851,6 @@ struct RoleDescrComparator {
} else {
mGeckoAccessible->AsRemote()->DoAction(0);
}
// Activating accessible may alter its state.
[self invalidateState];
}
#pragma mark -
@ -1050,8 +1004,6 @@ struct RoleDescrComparator {
- (void)expire {
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
[self invalidateState];
mGeckoAccessible = nullptr;
[self moxPostNotification:NSAccessibilityUIElementDestroyedNotification];

View File

@ -76,11 +76,6 @@ using namespace mozilla::a11y;
}
mGeckoAccessible->SetSelected([selected boolValue]);
// We need to invalidate the state because the accessibility service
// may check the selected attribute synchornously and not wait for
// selection events.
[self invalidateState];
}
@end
@ -315,7 +310,6 @@ using namespace mozilla::a11y;
- (void)handleAccessibleEvent:(uint32_t)eventType {
switch (eventType) {
case nsIAccessibleEvent::EVENT_FOCUS:
[self invalidateState];
// Our focused state is equivelent to native selected states for menus.
mozAccessible* parent = (mozAccessible*)[self moxUnignoredParent];
[parent moxPostNotification: