Commit 1de64c7a authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Commit Bot

Sets the parent of an AXVirtualObject when adding its children

This is the only remaining occasion, as far as I can tell, where we
are still forgetting to set the parent of a child object properly.
All other cases have been fixed either by my previous patches or by
patches recently authored by aleventhal@.
Also added a few DCHECKs in AXSlider and AXMenuList.

AX-Relnotes: n/a.

R=dmazzoni@chromium.org, aleventhal@chromium.org

Change-Id: I22af3f276cc325a71968f6b2956d17120ce03320
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2356484
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820752}
parent 7685c196
......@@ -74,15 +74,15 @@ void AXMenuList::AddChildren() {
have_children_ = true;
AXObjectCacheImpl& cache = AXObjectCache();
AXObject* popup = cache.Create(ax::mojom::blink::Role::kMenuListPopup, this);
DCHECK(popup);
if (!popup->AccessibilityIsIncludedInTree()) {
cache.Remove(popup->AXObjectID());
return;
}
children_.push_back(popup);
popup->AddChildren();
}
......
......@@ -109,8 +109,8 @@ void AXMenuListPopup::AddChildren() {
for (auto* const option_element : html_select_element->GetOptionList()) {
AXMenuListOption* option = MenuListOptionAXObject(option_element);
if (option) {
option->SetParent(this);
children_.push_back(option);
option->SetParent(this);
}
}
}
......
......@@ -78,23 +78,24 @@ AccessibilityOrientation AXSlider::Orientation() const {
void AXSlider::AddChildren() {
DCHECK(!IsDetached());
DCHECK(!have_children_);
have_children_ = true;
AXObjectCacheImpl& cache = AXObjectCache();
AXObject* thumb = cache.Create(ax::mojom::blink::Role::kSliderThumb, this);
DCHECK(thumb);
// Before actually adding the value indicator to the hierarchy,
// allow the platform to make a final decision about it.
if (!thumb->AccessibilityIsIncludedInTree())
if (!thumb->AccessibilityIsIncludedInTree()) {
cache.Remove(thumb->AXObjectID());
else
children_.push_back(thumb);
return;
}
children_.push_back(thumb);
}
AXObject* AXSlider::ElementAccessibilityHitTest(const IntPoint& point) const {
if (children_.size()) {
if (HasChildren()) {
DCHECK(children_.size() == 1);
if (children_[0]->GetBoundsInFrameCoordinates().Contains(point))
return children_[0].Get();
......
......@@ -29,8 +29,14 @@ void AXVirtualObject::AddChildren() {
if (!accessible_node_)
return;
for (const auto& child : accessible_node_->GetChildren())
children_.push_back(AXObjectCache().GetOrCreate(child));
for (const auto& child : accessible_node_->GetChildren()) {
AXObject* ax_child = AXObjectCache().GetOrCreate(child);
if (!ax_child)
continue;
children_.push_back(ax_child);
ax_child->SetParent(this);
}
}
void AXVirtualObject::ChildrenChanged() {
......
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