DevTools: fix mismatch between DOMNode childNodeCount and children

Expanding an ElementsTreeElement used to immediately set a
populated flag to true before requesting getChildNodes().
If a ChildNodeCountUpdated event arrives before the children
are set, we may call updateModifiedParentNode() and try to
create visibleChildren when they are null, breaking the tree.

This CL moves the place where 'populated' is set, so that
updateModifiedParentNode() does not update tree children
before they are available.

Bug: 829884
Change-Id: Id68e71fb7a58336d781207b298a53354af3e5cfc
Reviewed-on: https://chromium-review.googlesource.com/1049113
Commit-Queue: Erik Luo <luoe@chromium.org>
Reviewed-by: Andrey Lushnikov <lushnikov@chromium.org>
Reviewed-by: Joel Einbinder <einbinder@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#557132}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 2e5ad0a88b7d04fe1aac8b2fd0c26b2d3475e4c2
This commit is contained in:
Erik Luo
2018-05-09 10:10:41 +00:00
committed by Commit Bot
parent d92662b9c9
commit 215e23d308
2 changed files with 4 additions and 2 deletions
@@ -287,7 +287,6 @@ Elements.ElementsTreeElement = class extends UI.TreeElement {
* @override
*/
onpopulate() {
this.populated = true;
this.treeOutline.populateTreeElement(this);
}
+4 -1
View File
@@ -1154,7 +1154,10 @@ Elements.ElementsTreeOutline = class extends UI.TreeOutline {
populateTreeElement(treeElement) {
if (treeElement.childCount() || !treeElement.isExpandable())
return;
treeElement.node().getChildNodes(() => this._updateModifiedParentNode(treeElement.node()));
treeElement.node().getChildNodes(() => {
treeElement.populated = true;
this._updateModifiedParentNode(treeElement.node());
});
}
/**