Skip to content

Commit

Permalink
Remove AXLayoutObject::CanHaveChildren() and reduce work
Browse files Browse the repository at this point in the history
- 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 <aleventhal@chromium.org>
Reviewed-by: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: Nektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#869325}
  • Loading branch information
aleventhal authored and Chromium LUCI CQ committed Apr 5, 2021
1 parent a99f7a1 commit 3e44422
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
Expand Up @@ -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.
//
Expand Down
Expand Up @@ -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;

Expand Down
Expand Up @@ -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:
Expand Down

0 comments on commit 3e44422

Please sign in to comment.