From 3e44422f5dfb51e5b65cd1f5ff64c765951ee532 Mon Sep 17 00:00:00 2001 From: Aaron Leventhal Date: Mon, 5 Apr 2021 23:25:28 +0000 Subject: [PATCH] Remove AXLayoutObject::CanHaveChildren() and reduce work - The list marker special case is no longer needed. It was originally added to avoid adding certain AXObject's to two different parents, because it is already handled by the fact that the code to add children has been greatly refactored and simplified. - The CSS alt text case is now handled by the default logic where images are not allowed to have children. - Avoid calling IsEditable(), which does more work than necessary. We're only looking for plaintext editable objects here. Bug: 1187096,1192456 Change-Id: I51480afc18b3c4115bdabf1ae7f63091c5b10bb3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2788511 Commit-Queue: Aaron Leventhal Reviewed-by: Dominic Mazzoni Reviewed-by: Nektarios Paisios Cr-Commit-Position: refs/heads/master@{#869325} --- .../renderer/modules/accessibility/ax_layout_object.cc | 10 ---------- .../renderer/modules/accessibility/ax_layout_object.h | 2 -- .../renderer/modules/accessibility/ax_node_object.cc | 6 ++++-- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/third_party/blink/renderer/modules/accessibility/ax_layout_object.cc b/third_party/blink/renderer/modules/accessibility/ax_layout_object.cc index af5d37307d285..9b38973a76e7b 100644 --- a/third_party/blink/renderer/modules/accessibility/ax_layout_object.cc +++ b/third_party/blink/renderer/modules/accessibility/ax_layout_object.cc @@ -1149,16 +1149,6 @@ AXObject* AXLayoutObject::AccessibilityHitTest(const IntPoint& point) const { return result; } -bool AXLayoutObject::CanHaveChildren() const { - if (!layout_object_) - return false; - if (GetCSSAltText(GetNode())) - return false; - if (layout_object_->IsListMarkerForNormalContent()) - return false; - return AXNodeObject::CanHaveChildren(); -} - // // DOM and layout tree access. // diff --git a/third_party/blink/renderer/modules/accessibility/ax_layout_object.h b/third_party/blink/renderer/modules/accessibility/ax_layout_object.h index b2b41d2282dc4..2edb48cf73ca1 100644 --- a/third_party/blink/renderer/modules/accessibility/ax_layout_object.h +++ b/third_party/blink/renderer/modules/accessibility/ax_layout_object.h @@ -102,8 +102,6 @@ class MODULES_EXPORT AXLayoutObject : public AXNodeObject { // Hit testing. AXObject* AccessibilityHitTest(const IntPoint&) const override; - bool CanHaveChildren() const override; - // Called when autofill/autocomplete state changes on a form control. void HandleAutofillStateChanged(WebAXAutofillState state) override; diff --git a/third_party/blink/renderer/modules/accessibility/ax_node_object.cc b/third_party/blink/renderer/modules/accessibility/ax_node_object.cc index 308bc23fa6d44..1e25b8ccf376a 100644 --- a/third_party/blink/renderer/modules/accessibility/ax_node_object.cc +++ b/third_party/blink/renderer/modules/accessibility/ax_node_object.cc @@ -4013,11 +4013,13 @@ bool AXNodeObject::CanHaveChildren() const { break; } - // Allow editable roots to expose any children they might have, complying + // Allow plain text controls to expose any children they might have, complying // with browser-side expectations that editable controls have children // containing the actual text content. - if (IsEditable() && !IsRichlyEditable()) + if (blink::EnclosingTextControl(GetNode()) || + GetAttribute(html_names::kContenteditableAttr) == "plaintext-only") { return true; + } switch (AriaRoleAttribute()) { case ax::mojom::blink::Role::kImage: