| Index: third_party/WebKit/Source/devtools/front_end/ui_lazy/ViewportDataGrid.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/ui_lazy/ViewportDataGrid.js b/third_party/WebKit/Source/devtools/front_end/ui_lazy/ViewportDataGrid.js
|
| index 7bbc2e1eb33f501858d9ff34be38ae3037f519bf..af77c2881562feb0b9d347ab16617e24cc7c2078 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/ui_lazy/ViewportDataGrid.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/ui_lazy/ViewportDataGrid.js
|
| @@ -21,8 +21,6 @@ UI.ViewportDataGrid = class extends UI.DataGrid {
|
| this._scrollContainer.addEventListener('mousewheel', this._onWheel.bind(this), true);
|
| /** @type {!Array.<!UI.ViewportDataGridNode>} */
|
| this._visibleNodes = [];
|
| - /** @type {?Array.<!UI.ViewportDataGridNode>} */
|
| - this._flatNodes = null;
|
| /** @type {boolean} */
|
| this._inline = false;
|
|
|
| @@ -90,7 +88,6 @@ UI.ViewportDataGrid = class extends UI.DataGrid {
|
| * @protected
|
| */
|
| scheduleUpdateStructure() {
|
| - this._flatNodes = null;
|
| this.scheduleUpdate();
|
| }
|
|
|
| @@ -120,40 +117,12 @@ UI.ViewportDataGrid = class extends UI.DataGrid {
|
| }
|
|
|
| /**
|
| - * @return {!Array.<!UI.ViewportDataGridNode>}
|
| - */
|
| - flatNodesList() {
|
| - if (this._flatNodes)
|
| - return this._flatNodes;
|
| - var flatNodes = [];
|
| - var children = [this.rootNode().children];
|
| - var counters = [0];
|
| - var depth = 0;
|
| - while (depth >= 0) {
|
| - var node = children[depth][counters[depth]++];
|
| - if (!node) {
|
| - depth--;
|
| - continue;
|
| - }
|
| - flatNodes.push(node);
|
| - node.setDepth(depth);
|
| - if (node._expanded && node.children.length) {
|
| - depth++;
|
| - children[depth] = node.children;
|
| - counters[depth] = 0;
|
| - }
|
| - }
|
| - this._flatNodes = flatNodes;
|
| - return this._flatNodes;
|
| - }
|
| -
|
| - /**
|
| * @param {number} clientHeight
|
| * @param {number} scrollTop
|
| * @return {{topPadding: number, bottomPadding: number, contentHeight: number, visibleNodes: !Array.<!UI.ViewportDataGridNode>, offset: number}}
|
| */
|
| _calculateVisibleNodes(clientHeight, scrollTop) {
|
| - var nodes = this.flatNodesList();
|
| + var nodes = this.rootNode().flatChildren();
|
| if (this._inline)
|
| return {topPadding: 0, bottomPadding: 0, contentHeight: 0, visibleNodes: nodes, offset: 0};
|
|
|
| @@ -187,7 +156,7 @@ UI.ViewportDataGrid = class extends UI.DataGrid {
|
| * @return {number}
|
| */
|
| _contentHeight() {
|
| - var nodes = this.flatNodesList();
|
| + var nodes = this.rootNode().flatChildren();
|
| var result = 0;
|
| for (var i = 0, size = nodes.length; i < size; ++i)
|
| result += nodes[i].nodeSelfHeight();
|
| @@ -263,7 +232,7 @@ UI.ViewportDataGrid = class extends UI.DataGrid {
|
| * @param {!UI.ViewportDataGridNode} node
|
| */
|
| _revealViewportNode(node) {
|
| - var nodes = this.flatNodesList();
|
| + var nodes = this.rootNode().flatChildren();
|
| var index = nodes.indexOf(node);
|
| if (index === -1)
|
| return;
|
| @@ -299,6 +268,8 @@ UI.ViewportDataGridNode = class extends UI.DataGridNode {
|
| super(data, hasChildren);
|
| /** @type {boolean} */
|
| this._stale = false;
|
| + /** @type {?Array<!UI.ViewportDataGridNode>} */
|
| + this._flatNodes = null;
|
| }
|
|
|
| /**
|
| @@ -315,11 +286,42 @@ UI.ViewportDataGridNode = class extends UI.DataGridNode {
|
| return element;
|
| }
|
|
|
| + _clearFlatNodes() {
|
| + this._flatNodes = null;
|
| + var parent = /** @type {!UI.ViewportDataGridNode} */ (this.parent);
|
| + if (parent)
|
| + parent._clearFlatNodes();
|
| + }
|
| +
|
| /**
|
| - * @param {number} depth
|
| + * @return {!Array<!UI.ViewportDataGridNode>}
|
| */
|
| - setDepth(depth) {
|
| - this._depth = depth;
|
| + flatChildren() {
|
| + if (this._flatNodes)
|
| + return this._flatNodes;
|
| + /** @type {!Array<!UI.ViewportDataGridNode>} */
|
| + var flatNodes = [];
|
| + /** @type {!Array<!Array<!UI.ViewportDataGridNode>>} */
|
| + var children = [this.children];
|
| + /** @type {!Array<number>} */
|
| + var counters = [0];
|
| + var depth = 0;
|
| + while (depth >= 0) {
|
| + if (children[depth].length <= counters[depth]) {
|
| + depth--;
|
| + continue;
|
| + }
|
| + var node = children[depth][counters[depth]++];
|
| + flatNodes.push(node);
|
| + if (node._expanded && node.children.length) {
|
| + depth++;
|
| + children[depth] = node.children;
|
| + counters[depth] = 0;
|
| + }
|
| + }
|
| +
|
| + this._flatNodes = flatNodes;
|
| + return flatNodes;
|
| }
|
|
|
| /**
|
| @@ -328,6 +330,7 @@ UI.ViewportDataGridNode = class extends UI.DataGridNode {
|
| * @param {number} index
|
| */
|
| insertChild(child, index) {
|
| + this._clearFlatNodes();
|
| if (child.parent === this) {
|
| var currentIndex = this.children.indexOf(child);
|
| if (currentIndex < 0)
|
| @@ -353,6 +356,7 @@ UI.ViewportDataGridNode = class extends UI.DataGridNode {
|
| * @param {!UI.DataGridNode} child
|
| */
|
| removeChild(child) {
|
| + this._clearFlatNodes();
|
| if (this.dataGrid)
|
| this.dataGrid.updateSelectionBeforeRemoval(child, false);
|
| if (child.previousSibling)
|
| @@ -374,6 +378,7 @@ UI.ViewportDataGridNode = class extends UI.DataGridNode {
|
| * @override
|
| */
|
| removeChildren() {
|
| + this._clearFlatNodes();
|
| if (this.dataGrid)
|
| this.dataGrid.updateSelectionBeforeRemoval(this, true);
|
| for (var i = 0; i < this.children.length; ++i)
|
| @@ -401,6 +406,7 @@ UI.ViewportDataGridNode = class extends UI.DataGridNode {
|
| collapse() {
|
| if (!this._expanded)
|
| return;
|
| + this._clearFlatNodes();
|
| this._expanded = false;
|
| if (this.existingElement())
|
| this.existingElement().classList.remove('expanded');
|
| @@ -413,6 +419,7 @@ UI.ViewportDataGridNode = class extends UI.DataGridNode {
|
| expand() {
|
| if (this._expanded)
|
| return;
|
| + this._clearFlatNodes();
|
| super.expand();
|
| this.dataGrid.scheduleUpdateStructure();
|
| }
|
| @@ -460,4 +467,13 @@ UI.ViewportDataGridNode = class extends UI.DataGridNode {
|
| reveal() {
|
| this.dataGrid._revealViewportNode(this);
|
| }
|
| +
|
| + /**
|
| + * @override
|
| + * @param {number} index
|
| + */
|
| + recalculateSiblings(index) {
|
| + this._clearFlatNodes();
|
| + super.recalculateSiblings(index);
|
| + }
|
| };
|
|
|