[a11y] Move some of serialization pipeline from RAI to cache. #43243
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This CL aims to start moving some of the code path starting from HandleAXEvent to ScheduleImmediateAXUpdate over to cache side. The old code is still left in RAI for legacy support.
The aim is to eventually delete the code from RAI side, and then RAI would only be called from ProcessDeferredAccessibilityEvents to AXReadyCallback.
Details (only explaining post-lifecyle mode):
Before this CL, a11y events (kind of) go like this: AXObjectCacheImpl::PostPlatformNotification -> RenderAccessibilityImpl::HandleAXEvent which also calls AXObjectCacheImpl::AddPendingEvent --> RenderAccessibilityImpl::ScheduleImmediateAXUpdate -> AXObjectCacheImpl::ScheduleAXUpdate --> AXObjectCacheImpl::ProcessDeferredAccessibilityEvents -> RenderAccessibilityImpl::AXReadyCallback
Note that -> doesn't mean direct calls. Some calls in the middle may have been skipped. The CL prevents these excessively unnecessary calls in between RAI (RenderAccessibilityImpl) and AXObjectCacheImpl. The calls now go like this (again kinda): AXObjectCacheImpl::PostPlatformNotification -> AXObjectCacheImpl::AddEventToSerializationQueue -> AXObjectCacheImpl::ScheduleImmediateSerialization -> AXObjectCacheImpl::ScheduleAXUpdate -> AXObjectCacheImpl::ProcessDeferredAccessibilityEvents -> RenderAccessibilityImpl::AXReadyCallback
Notice how RAI is only called at the very end. Of course, to make this possible many of the side logic had to be moved too like the delaying code that used to be AXReadyCallback is now at AXObjectCacheImpl::ProcessDeferredAccessibilityEvents.
This image describes the above: https://i.imgur.com/U3tODTX.png
What the CL achieves is moving the code in the blue square over to the left-hand side, thus making the code stay in AXObjectCache longer and only move to RAI at RenderAccessibilityImpl::AXReadyCallback. The serialization delay is moved to ProcessDeferredAccessibilityEvents.
Legacy scheduling mode (as opposed to post-lifecycle serialization) still uses the old code which goes back and forth between RAI and AXObjectCache. The reason they were not moved as well is that legacy mode will get removed eventually anyway. When legacy mode is removed, we can safely remove the old code from RAI.
Also, with the cleaner code, it'll be feasible to change the scheduling logic further to limit some events like scrolling. Scrolling improvements discussed here https://docs.google.com/document/d/1fBK1BBrG8souqZpyv7q_3kxCYF1IYoXNPXmoVL7X8Gk/edit#heading=h.uo8ebdp7cxl
Change-Id: I4662c29ee0185b8554b80b71db5ffb0aa6fc2319
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4994320
Reviewed-by: Peter Beverloo <peter@chromium.org>
Auto-Submit: Ahmed Elwasefi (Ahmad45123) <a.m.elwasefi@gmail.com>
Reviewed-by: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Commit-Queue: Ahmed Elwasefi (Ahmad45123) <a.m.elwasefi@gmail.com>
Cr-Commit-Position: refs/heads/main@{#1227944}