Commit fd5b3024 authored by Keren Zhu's avatar Keren Zhu Committed by Chromium LUCI CQ

ui_devtools: Sends node remove request to frontend only it exists in DOM

DOMAgent’s OnUIElementRemoved() DCHECKs if the UIElement to be removed
exists. Yet, elements of a bubble are currently being removed twice,
breaking this DCHECK.

The first removal is in WidgetElement::OnWidgetDestroyed(). The second
is in WidgetDelegate::DeleteDelegate(), where eventually
ViewElement::OnChildViewRemoved() is called. Because the whole DOM tree
is removed in the first call, the DCHECK fails in the second call.

This change removes the above DCHECK and sends the removal request only
when the node exists in the DOM.


Bug: 1167240
Change-Id: Ia6fc327a8fc5004dce7333f232b323f7b677fbfe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2639134
Commit-Queue: Keren Zhu <kerenzhu@chromium.org>
Reviewed-by: default avatarWei Li <weili@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845799}
parent a48029ff
......@@ -167,9 +167,15 @@ void DOMAgent::OnUIElementReordered(UIElement* parent, UIElement* child) {
}
void DOMAgent::OnUIElementRemoved(UIElement* ui_element) {
DCHECK(node_id_to_ui_element_.count(ui_element->node_id()));
if (node_id_to_ui_element_.count(ui_element->node_id())) {
// Check if |ui_element| exists in DOM before asking the frontend to remove
// it. It is possible that this node is already removed along with its
// ancestor. This happens for example when a bubble closes.
// The DOM tree is first requested to be removed in
// |WidgetElement::OnWidgetDestroyed()| then in
// |ViewElement::OnChildViewRemoved()|.
RemoveDomNode(ui_element, true);
}
}
void DOMAgent::OnUIElementBoundsChanged(UIElement* ui_element) {
......
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