зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1744573: Add infrastructure on DocAccessible to queue cache updates r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D136661
This commit is contained in:
Родитель
1005e618d5
Коммит
c32559a480
|
@ -974,7 +974,7 @@ void NotificationController::WillRefresh(mozilla::TimeStamp aTime) {
|
|||
}
|
||||
|
||||
if (IPCAccessibilityActive() && mDocument) {
|
||||
mDocument->ProcessBoundsChanged();
|
||||
mDocument->ProcessQueuedCacheUpdates();
|
||||
}
|
||||
|
||||
mObservingState = eRefreshObserving;
|
||||
|
|
|
@ -366,8 +366,7 @@ void nsAccessibilityService::NotifyOfPossibleBoundsChange(
|
|||
if (document) {
|
||||
LocalAccessible* accessible = document->GetAccessible(aContent);
|
||||
if (accessible) {
|
||||
document->MarkForBoundsProcessing(accessible);
|
||||
document->Controller()->ScheduleProcessing();
|
||||
document->QueueCacheUpdate(accessible, CacheDomain::Bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -357,6 +357,14 @@ void DocAccessible::DocType(nsAString& aType) const {
|
|||
if (docType) docType->GetPublicId(aType);
|
||||
}
|
||||
|
||||
void DocAccessible::QueueCacheUpdate(LocalAccessible* aAcc,
|
||||
uint64_t aNewDomain) {
|
||||
uint64_t& domain = mQueuedCacheUpdates.LookupOrInsert(aAcc, 0);
|
||||
domain |= aNewDomain;
|
||||
|
||||
Controller()->ScheduleProcessing();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// LocalAccessible
|
||||
|
||||
|
@ -933,10 +941,6 @@ void DocAccessible::ContentRemoved(nsIContent* aChildNode,
|
|||
ContentRemoved(aChildNode);
|
||||
}
|
||||
|
||||
void DocAccessible::MarkForBoundsProcessing(LocalAccessible* aAcc) {
|
||||
mMaybeBoundsChanged.EnsureInserted(aAcc);
|
||||
}
|
||||
|
||||
void DocAccessible::ParentChainChanged(nsIContent* aContent) {}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1388,16 +1392,19 @@ void DocAccessible::ProcessInvalidationList() {
|
|||
mInvalidationList.Clear();
|
||||
}
|
||||
|
||||
void DocAccessible::ProcessBoundsChanged() {
|
||||
void DocAccessible::ProcessQueuedCacheUpdates() {
|
||||
if (!StaticPrefs::accessibility_cache_enabled_AtStartup()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsTArray<CacheData> data;
|
||||
for (auto* acc : mMaybeBoundsChanged) {
|
||||
for (auto iter = mQueuedCacheUpdates.Iter(); !iter.Done(); iter.Next()) {
|
||||
LocalAccessible* acc = iter.Key();
|
||||
uint64_t domain = iter.UserData();
|
||||
if (!acc->IsDefunct()) {
|
||||
RefPtr<AccAttributes> fields = acc->BundleFieldsForCache(
|
||||
CacheDomain::Bounds, CacheUpdateType::Update);
|
||||
RefPtr<AccAttributes> fields =
|
||||
acc->BundleFieldsForCache(domain, CacheUpdateType::Update);
|
||||
|
||||
if (fields->Count()) {
|
||||
data.AppendElement(CacheData(
|
||||
acc->IsDoc() ? 0 : reinterpret_cast<uint64_t>(acc->UniqueID()),
|
||||
|
@ -1406,7 +1413,7 @@ void DocAccessible::ProcessBoundsChanged() {
|
|||
}
|
||||
}
|
||||
|
||||
mMaybeBoundsChanged.Clear();
|
||||
mQueuedCacheUpdates.Clear();
|
||||
|
||||
if (data.Length()) {
|
||||
IPCDoc()->SendCache(CacheUpdateType::Update, data, true);
|
||||
|
|
|
@ -111,6 +111,17 @@ class DocAccessible : public HyperTextAccessibleWrap,
|
|||
*/
|
||||
void DocType(nsAString& aType) const;
|
||||
|
||||
/**
|
||||
* Adds an entry to mQueuedCacheUpdates indicating aAcc requires
|
||||
* a cache update on domain aNewDomain. If we've already queued an update
|
||||
* for aAcc, aNewDomain is or'd with the existing domain(s)
|
||||
* and the map is updated. Otherwise, the entry is simply inserted.
|
||||
* This function also schedules processing on the controller.
|
||||
* Note that this CANNOT be used for anything which fires events, since events
|
||||
* must be fired after their associated cache update.
|
||||
*/
|
||||
void QueueCacheUpdate(LocalAccessible* aAcc, uint64_t aNewDomain);
|
||||
|
||||
/**
|
||||
* Return virtual cursor associated with the document.
|
||||
*/
|
||||
|
@ -346,13 +357,6 @@ class DocAccessible : public HyperTextAccessibleWrap,
|
|||
void ContentRemoved(LocalAccessible* aAccessible);
|
||||
void ContentRemoved(nsIContent* aContentNode);
|
||||
|
||||
/*
|
||||
* Add the given accessible to mMaybeBoundsChanged so we
|
||||
* can (later) check if its bounds have changed, and update
|
||||
* the cache appropriately.
|
||||
*/
|
||||
void MarkForBoundsProcessing(LocalAccessible* aAcc);
|
||||
|
||||
/**
|
||||
* Updates accessible tree when rendered text is changed.
|
||||
*/
|
||||
|
@ -502,10 +506,10 @@ class DocAccessible : public HyperTextAccessibleWrap,
|
|||
|
||||
/**
|
||||
* Called from NotificationController to process this doc's
|
||||
* mMaybeBoundsChanged list. Sends a cache update for each acc in this
|
||||
* doc whose bounds have changed since reflow.
|
||||
* mQueuedCacheUpdates list. For each acc in the map, this function
|
||||
* sends a cache update with its corresponding CacheDomain.
|
||||
*/
|
||||
void ProcessBoundsChanged();
|
||||
void ProcessQueuedCacheUpdates();
|
||||
|
||||
/**
|
||||
* Only works in content process documents.
|
||||
|
@ -758,6 +762,12 @@ class DocAccessible : public HyperTextAccessibleWrap,
|
|||
DocAccessibleChild* mIPCDoc;
|
||||
|
||||
nsTHashSet<RefPtr<LocalAccessible>> mMaybeBoundsChanged;
|
||||
|
||||
// A hash map between LocalAccessibles and CacheDomains, tracking
|
||||
// cache updates that have been queued during the current tick
|
||||
// but not yet sent.
|
||||
nsTHashMap<RefPtr<LocalAccessible>, uint64_t> mQueuedCacheUpdates;
|
||||
|
||||
// A set of Accessibles moved during this tick. Only used in content
|
||||
// processes.
|
||||
nsTHashSet<RefPtr<LocalAccessible>> mMovedAccessibles;
|
||||
|
|
Загрузка…
Ссылка в новой задаче