Commit 8b31363f authored by Aaron Leventhal's avatar Aaron Leventhal Committed by Commit Bot

Greatly reduce ancestor walking on DOM changes

Bug: None
Change-Id: I84170deec32ee211fd15a1ee7ac715cd9849bb1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2372887
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802907}
parent f565612f
...@@ -363,6 +363,7 @@ bool AXLayoutObject::IsEditable() const { ...@@ -363,6 +363,7 @@ bool AXLayoutObject::IsEditable() const {
// Requires layoutObject to be present because it relies on style // Requires layoutObject to be present because it relies on style
// user-modify. Don't move this logic to AXNodeObject. // user-modify. Don't move this logic to AXNodeObject.
// Returns true for a contenteditable or any descendant of it.
bool AXLayoutObject::IsRichlyEditable() const { bool AXLayoutObject::IsRichlyEditable() const {
if (IsDetached()) if (IsDetached())
return false; return false;
......
...@@ -3827,40 +3827,29 @@ void AXNodeObject::TextChanged() { ...@@ -3827,40 +3827,29 @@ void AXNodeObject::TextChanged() {
if (!GetLayoutObject()) if (!GetLayoutObject())
return; return;
// Go up the accessibility parent chain, but only if the element already // If this element supports ARIA live regions, then notify the AT of changes.
// exists, firing live region and value change events as necessary. // Do not fire live region changed events if aria-live="off".
// These notifications always need to be sent as screenreaders are reliant on
// First, fire live region events. // them to perform. In other words, they need to be sent even when the screen
// TODO(accessibility) Use LiveRegionRoot() so that we don't need to // reader has not accessed this live region since the last update.
// walk entire ancestor chain. AXObject* live_region_root = LiveRegionRoot();
for (AXObject* parent = this; parent; if (live_region_root && live_region_root->IsActiveLiveRegionRoot()) {
parent = parent->ParentObjectIfExists()) { AXObjectCache().PostNotification(
// These notifications always need to be sent because screenreaders are live_region_root, ax::mojom::blink::Event::kLiveRegionChanged);
// reliant on them to perform. In other words, they need to be sent even
// when the screen reader has not accessed this live region since the last
// update.
// If this element supports ARIA live regions, then notify the AT of
// changes. Do not fire live region changed events if aria-live="off".
if (parent->IsLiveRegionRoot()) {
if (parent->IsActiveLiveRegionRoot()) {
AXObjectCache().PostNotification(
parent, ax::mojom::blink::Event::kLiveRegionChanged);
}
break;
}
} }
// Second, fire value changes. // If this element is an ARIA text box or content editable, post a "value
for (AXObject* parent = this; parent; // changed" notification on it so that it behaves just like a native input
parent = parent->ParentObjectIfExists()) { // element or textarea. Native text control value changes are handled
// If this element is an ARIA text box or content editable, post a "value // separately via calls into the AXObjectCache.
// changed" notification on it so that it behaves just like a native input if (IsRichlyEditable()) { // A contenteditable or descendant of it.
// element or textarea. for (AXObject* parent = this; parent;
if (parent->IsNonNativeTextControl()) { parent = parent->ParentObjectIfExists()) {
AXObjectCache().PostNotification(parent, if (parent->IsNonNativeTextControl()) {
ax::mojom::blink::Event::kValueChanged); AXObjectCache().PostNotification(
break; parent, ax::mojom::blink::Event::kValueChanged);
break;
}
} }
} }
} }
......
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