Bug 1771736 part 2: Only push a cache update for text if the text actually changes. r=morgan

Layout sends a11y text update notifications during reflow even if the text hasn't changed.
TextUpdater already detects this case, so just move our cache update calls to TextUpdater.

Differential Revision: https://phabricator.services.mozilla.com/D147656
This commit is contained in:
James Teh 2022-06-01 00:35:26 +00:00
parent 1fcd045e66
commit 5f868bebc7
2 changed files with 7 additions and 5 deletions

View File

@ -5,7 +5,6 @@
#include "NotificationController.h"
#include "CacheConstants.h"
#include "DocAccessible-inl.h"
#include "DocAccessibleChild.h"
#include "nsEventShell.h"
@ -745,10 +744,6 @@ void NotificationController::WillRefresh(mozilla::TimeStamp aTime) {
#endif
TextUpdater::Run(mDocument, textAcc->AsTextLeaf(), text.mString);
if (IPCAccessibilityActive() &&
StaticPrefs::accessibility_cache_enabled_AtStartup()) {
mDocument->QueueCacheUpdate(textAcc, CacheDomain::Text);
}
continue;
}

View File

@ -6,7 +6,10 @@
#include "TextUpdater.h"
#include "LocalAccessible-inl.h"
#include "CacheConstants.h"
#include "DocAccessible-inl.h"
#include "mozilla/StaticPrefs_accessibility.h"
#include "nsAccessibilityService.h"
#include "TextLeafAccessible.h"
#include <algorithm>
@ -30,6 +33,10 @@ void TextUpdater::Run(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf,
if (skipStart != minLen || oldLen != newLen) {
TextUpdater updater(aDocument, aTextLeaf);
updater.DoUpdate(aNewText, oldText, skipStart);
if (IPCAccessibilityActive() &&
StaticPrefs::accessibility_cache_enabled_AtStartup()) {
aDocument->QueueCacheUpdate(aTextLeaf, CacheDomain::Text);
}
}
}