Commit 511c6eb0 authored by Tal Pressman's avatar Tal Pressman Committed by Chromium LUCI CQ

Reland "Wait until safe time to create web document"

This reverts commit 1af362f4.

Reason for revert: The rollback did not fix bots, so I am relanding
the CL.

Original change's description:
> Revert "Wait until safe time to create web document"
>
> This reverts commit 593304b4.
>
> Reason for revert: Suspect it caused failures in content_browsertests
> Accessibility tests.
>
> Original change's description:
> > Wait until safe time to create web document
> >
> > TBR=kinuko@chromium.org
> >
> > Bug: 1156939
> > Change-Id: I23443fc4461dc61223fef249bac109a8b7e8183e
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586233
> > Reviewed-by: Aaron Leventhal <aleventhal@chromium.org>
> > Reviewed-by: Dominic Mazzoni <dmazzoni@chromium.org>
> > Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#838244}
>
> TBR=dmazzoni@chromium.org,aleventhal@chromium.org,chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Bug: 1156939
> Change-Id: Iac0282f6e1a24119a67dacf81c5e1c33ed303d33
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2596292
> Reviewed-by: Tal Pressman <talp@google.com>
> Commit-Queue: Tal Pressman <talp@google.com>
> Cr-Commit-Position: refs/heads/master@{#838585}

TBR=dmazzoni@chromium.org,aleventhal@chromium.org,chromium-scoped@luci-project-accounts.iam.gserviceaccount.com,talp@google.com

# Not skipping CQ checks because this is a reland.

Bug: 1156939
Change-Id: Ib7571aa00acc5c1202abdbebfb40e2180aba36e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2598303Reviewed-by: default avatarTal Pressman <talp@google.com>
Commit-Queue: Tal Pressman <talp@google.com>
Cr-Commit-Position: refs/heads/master@{#838596}
parent db151c96
...@@ -334,12 +334,9 @@ void RenderAccessibilityImpl::AccessibilityModeChanged(const ui::AXMode& mode) { ...@@ -334,12 +334,9 @@ void RenderAccessibilityImpl::AccessibilityModeChanged(const ui::AXMode& mode) {
// If there are any events in flight, |HandleAXEvent| will refuse to process // If there are any events in flight, |HandleAXEvent| will refuse to process
// our new event. // our new event.
pending_events_.clear(); needs_initial_ax_tree_root_ = true;
auto root_object = WebAXObject::FromWebDocument(document, false); event_schedule_mode_ = EventScheduleMode::kProcessEventsImmediately;
ax::mojom::Event event = root_object.IsLoaded() ScheduleSendPendingAccessibilityEvents();
? ax::mojom::Event::kLoadComplete
: ax::mojom::Event::kLayoutComplete;
HandleAXEvent(ui::AXEvent(root_object.AxID(), event));
} }
} }
...@@ -543,11 +540,11 @@ void RenderAccessibilityImpl::Reset(int32_t reset_token) { ...@@ -543,11 +540,11 @@ void RenderAccessibilityImpl::Reset(int32_t reset_token) {
if (!document.IsNull()) { if (!document.IsNull()) {
// Tree-only mode gets used by the automation extension API which requires a // Tree-only mode gets used by the automation extension API which requires a
// load complete event to invoke listener callbacks. // load complete event to invoke listener callbacks.
auto root_object = WebAXObject::FromWebDocument(document, false); // SendPendingAccessibilityEvents() will fire the load complete event
ax::mojom::Event event = root_object.IsLoaded() // if the page is loaded.
? ax::mojom::Event::kLoadComplete needs_initial_ax_tree_root_ = true;
: ax::mojom::Event::kLayoutComplete; event_schedule_mode_ = EventScheduleMode::kProcessEventsImmediately;
HandleAXEvent(ui::AXEvent(root_object.AxID(), event)); ScheduleSendPendingAccessibilityEvents();
} }
} }
...@@ -864,10 +861,18 @@ void RenderAccessibilityImpl::SendPendingAccessibilityEvents() { ...@@ -864,10 +861,18 @@ void RenderAccessibilityImpl::SendPendingAccessibilityEvents() {
// complete for the entire document, in order to initialize the browser's // complete for the entire document, in order to initialize the browser's
// cached accessibility tree. // cached accessibility tree.
needs_initial_ax_tree_root_ = false; needs_initial_ax_tree_root_ = false;
auto obj = WebAXObject::FromWebDocument(document); auto root_obj = WebAXObject::FromWebDocument(document);
// Always fire layout complete for a new root object.
pending_events_.insert( pending_events_.insert(
pending_events_.begin(), pending_events_.begin(),
ui::AXEvent(obj.AxID(), ax::mojom::Event::kLayoutComplete)); ui::AXEvent(root_obj.AxID(), ax::mojom::Event::kLayoutComplete));
// If loaded, insert load complete at the top.
if (root_obj.IsLoaded()) {
pending_events_.insert(
pending_events_.begin(),
ui::AXEvent(root_obj.AxID(), ax::mojom::Event::kLoadComplete));
}
} }
if (pending_events_.empty() && dirty_objects_.empty()) { if (pending_events_.empty() && dirty_objects_.empty()) {
...@@ -901,8 +906,8 @@ void RenderAccessibilityImpl::SendPendingAccessibilityEvents() { ...@@ -901,8 +906,8 @@ void RenderAccessibilityImpl::SendPendingAccessibilityEvents() {
// location changes. // location changes.
bool need_to_send_location_changes = false; bool need_to_send_location_changes = false;
// If there's a load complete message, we need to change the event schedule // Keep track of load complete messages. When a load completes, it's a good
// mode. // time to inject a stylesheet for image annotation debugging.
bool had_load_complete_messages = false; bool had_load_complete_messages = false;
ScopedFreezeBlinkAXTreeSource freeze(tree_source_.get()); ScopedFreezeBlinkAXTreeSource freeze(tree_source_.get());
......
...@@ -81,9 +81,7 @@ class WebAXObject { ...@@ -81,9 +81,7 @@ class WebAXObject {
BLINK_EXPORT bool operator>(const WebAXObject& other) const; BLINK_EXPORT bool operator>(const WebAXObject& other) const;
BLINK_EXPORT bool operator>=(const WebAXObject& other) const; BLINK_EXPORT bool operator>=(const WebAXObject& other) const;
BLINK_EXPORT static WebAXObject FromWebNode(const WebNode&); BLINK_EXPORT static WebAXObject FromWebNode(const WebNode&);
BLINK_EXPORT static WebAXObject FromWebDocument( BLINK_EXPORT static WebAXObject FromWebDocument(const WebDocument&);
const WebDocument&,
bool update_layout_if_necessary = true);
BLINK_EXPORT static WebAXObject FromWebDocumentByID(const WebDocument&, int); BLINK_EXPORT static WebAXObject FromWebDocumentByID(const WebDocument&, int);
BLINK_EXPORT static WebAXObject FromWebDocumentFocused( BLINK_EXPORT static WebAXObject FromWebDocumentFocused(
const WebDocument&, const WebDocument&,
......
...@@ -1464,12 +1464,9 @@ WebAXObject WebAXObject::FromWebNode(const WebNode& web_node) { ...@@ -1464,12 +1464,9 @@ WebAXObject WebAXObject::FromWebNode(const WebNode& web_node) {
} }
// static // static
WebAXObject WebAXObject::FromWebDocument(const WebDocument& web_document, WebAXObject WebAXObject::FromWebDocument(const WebDocument& web_document) {
bool update_layout_if_necessary) { if (!MaybeUpdateLayoutAndCheckValidity(web_document))
if (update_layout_if_necessary &&
!MaybeUpdateLayoutAndCheckValidity(web_document)) {
return WebAXObject(); return WebAXObject();
}
const Document* document = web_document.ConstUnwrap<Document>(); const Document* document = web_document.ConstUnwrap<Document>();
auto* cache = To<AXObjectCacheImpl>(document->ExistingAXObjectCache()); auto* cache = To<AXObjectCacheImpl>(document->ExistingAXObjectCache());
return cache ? WebAXObject(cache->GetOrCreate(document->GetLayoutView())) return cache ? WebAXObject(cache->GetOrCreate(document->GetLayoutView()))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment