diff --git a/third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.cc b/third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.cc index 8bf69a5878dfba..d1384f5ead2614 100644 --- a/third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.cc +++ b/third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.cc @@ -719,9 +719,13 @@ void AXObjectCacheImpl::UpdateLifecycleIfNeeded(Document& document) { } void AXObjectCacheImpl::UpdateAXForAllDocuments() { +#if DCHECK_IS_ON() DCHECK(!IsFrozen()) << "Don't call UpdateAXForAllDocuments() here; layout and a11y are " "already clean at the start of serialization."; + DCHECK(!updating_layout_and_ax_) << "Undesirable recursion."; + base::AutoReset updating(&updating_layout_and_ax_, true); +#endif // First update the layout for the main and popup document. UpdateLifecycleIfNeeded(GetDocument()); @@ -2466,11 +2470,7 @@ void AXObjectCacheImpl::ProcessDeferredAccessibilityEvents(Document& document) { DCHECK_EQ(document, GetDocument()); - if (processing_deferred_events_) { - // TODO(aleventhal) Perhaps the caller should be responsible for this: - // consider changing to a DCHECK. - return; - } + DCHECK(!processing_deferred_events_); if (IsDirty()) { if (GetPopupDocumentIfShowing()) { @@ -2915,7 +2915,6 @@ void AXObjectCacheImpl::FireAXEventImmediately( ax::mojom::blink::Action event_from_action, const BlinkAXEventIntentsSet& event_intents) { #if DCHECK_IS_ON() - DCHECK(processing_deferred_events_); // Make sure none of the layout views are in the process of being laid out. // Notifications should only be sent after the layoutObject has finished auto* ax_layout_object = DynamicTo(obj); diff --git a/third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.h b/third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.h index 8dec26293c0c86..09ed6f79016ad7 100644 --- a/third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.h +++ b/third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.h @@ -670,6 +670,9 @@ class MODULES_EXPORT AXObjectCacheImpl std::unique_ptr relation_cache_; bool processing_deferred_events_ = false; +#if DCHECK_IS_ON() + bool updating_layout_and_ax_ = false; +#endif // Verified when finalizing. bool has_been_disposed_ = false;