зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1626036 - Initial Mac state caching. r=morgan
Here I added caching for all the toggle states, and expanded. Differential Revision: https://phabricator.services.mozilla.com/D69131 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
df6032b2ba
Коммит
df0924d72a
|
@ -128,6 +128,18 @@ nsresult AccessibleWrap::HandleAccEvent(AccEvent* aEvent) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case nsIAccessibleEvent::EVENT_STATE_CHANGE:
|
||||
if (Accessible* accessible = aEvent->GetAccessible()) {
|
||||
accessible->GetNativeInterface((void**)&nativeAcc);
|
||||
if (nativeAcc) {
|
||||
AccStateChangeEvent* event = downcast_accEvent(aEvent);
|
||||
[nativeAcc stateChanged:event->GetState() isEnabled:event->IsStateEnabled()];
|
||||
return NS_OK;
|
||||
} else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -131,8 +131,11 @@ void ProxyEvent(ProxyAccessible* aProxy, uint32_t aEventType) {
|
|||
}
|
||||
}
|
||||
|
||||
void ProxyStateChangeEvent(ProxyAccessible* aProxy, uint64_t, bool) {
|
||||
// mac doesn't care about state change events
|
||||
void ProxyStateChangeEvent(ProxyAccessible* aProxy, uint64_t aState, bool aEnabled) {
|
||||
mozAccessible* wrapper = GetNativeFromProxy(aProxy);
|
||||
if (wrapper) {
|
||||
[wrapper stateChanged:aState isEnabled:aEnabled];
|
||||
}
|
||||
}
|
||||
|
||||
void ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t aOffset) {
|
||||
|
|
|
@ -62,6 +62,11 @@ static const uintptr_t IS_PROXY = 1;
|
|||
* The role of our gecko accessible.
|
||||
*/
|
||||
mozilla::a11y::role mRole;
|
||||
|
||||
/**
|
||||
* A cache of a subset of our states.
|
||||
*/
|
||||
uint64_t mCachedState;
|
||||
}
|
||||
|
||||
// return the Accessible for this mozAccessible if it exists.
|
||||
|
@ -135,6 +140,12 @@ static const uintptr_t IS_PROXY = 1;
|
|||
// 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.
|
||||
- (void)stateChanged:(uint64_t)state isEnabled:(BOOL)enabled;
|
||||
|
||||
// Invalidate cached state.
|
||||
- (void)invalidateState;
|
||||
|
||||
#pragma mark -
|
||||
|
||||
// invalidates and removes all our children from our cached array.
|
||||
|
|
|
@ -245,22 +245,57 @@ static inline NSMutableArray* ConvertToNSArray(nsTArray<ProxyAccessible*>& aArra
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
||||
}
|
||||
|
||||
static const uint64_t kCachedStates =
|
||||
states::CHECKED states::PRESSED | states::MIXED | states::EXPANDED;
|
||||
static const uint64_t kCacheInitialized = ((uint64_t)0x1) << 63;
|
||||
|
||||
- (uint64_t)state {
|
||||
uint64_t state = 0;
|
||||
if (AccessibleWrap* accWrap = [self getGeckoAccessible]) {
|
||||
return accWrap->State();
|
||||
state = accWrap->State();
|
||||
}
|
||||
|
||||
if (ProxyAccessible* proxy = [self getProxyAccessible]) {
|
||||
return proxy->State();
|
||||
state = proxy->State();
|
||||
}
|
||||
|
||||
return 0;
|
||||
if (!(mCachedState & kCacheInitialized)) {
|
||||
mCachedState = state & kCachedStates;
|
||||
mCachedState |= kCacheInitialized;
|
||||
}
|
||||
|
||||
return 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) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(mCachedState & kCacheInitialized)) {
|
||||
[self state];
|
||||
return;
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
mCachedState |= state;
|
||||
} else {
|
||||
mCachedState &= ~state;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)invalidateState {
|
||||
mCachedState = 0;
|
||||
}
|
||||
|
||||
- (id)accessibilityAttributeValue:(NSString*)attribute {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
||||
|
||||
|
@ -622,6 +657,8 @@ static inline NSMutableArray* ConvertToNSArray(nsTArray<ProxyAccessible*>& aArra
|
|||
} else if (proxy) {
|
||||
proxy->DoAction(0);
|
||||
}
|
||||
// Activating accessible may alter its state.
|
||||
[self invalidateState];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1248,6 +1285,8 @@ struct RoleDescrComparator {
|
|||
|
||||
[self invalidateChildren];
|
||||
|
||||
[self invalidateState];
|
||||
|
||||
mGeckoAccessible = 0;
|
||||
|
||||
[self postNotification:NSAccessibilityUIElementDestroyedNotification];
|
||||
|
|
Загрузка…
Ссылка в новой задаче