Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui_lazy/ViewportDataGrid.js

Issue 2523633003: [Devtools] Prepare network log view for grouping support (Closed)
Patch Set: changes Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 b63999f89bea63d8c0e0e3cda66fb1f44df69cf4..4e8d558ea4b472d3f5e6ebd1d1e70e0d64940bb9 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,7 @@ 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 +89,6 @@ UI.ViewportDataGrid = class extends UI.DataGrid {
* @protected
*/
scheduleUpdateStructure() {
- this._flatNodes = null;
this.scheduleUpdate();
}
@@ -120,40 +118,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.flatenChildren();
if (this._inline)
return {topPadding: 0, bottomPadding: 0, contentHeight: 0, visibleNodes: nodes, offset: 0};
@@ -187,7 +157,7 @@ UI.ViewportDataGrid = class extends UI.DataGrid {
* @return {number}
*/
_contentHeight() {
- var nodes = this.flatNodesList();
+ var nodes = this._rootNode.flatenChildren();
var result = 0;
for (var i = 0, size = nodes.length; i < size; ++i)
result += nodes[i].nodeSelfHeight();
@@ -263,7 +233,7 @@ UI.ViewportDataGrid = class extends UI.DataGrid {
* @param {!UI.ViewportDataGridNode} node
*/
_revealViewportNode(node) {
- var nodes = this.flatNodesList();
+ var nodes = this._rootNode.flatenChildren();
var index = nodes.indexOf(node);
if (index === -1)
return;
@@ -299,6 +269,8 @@ UI.ViewportDataGridNode = class extends UI.DataGridNode {
super(data, hasChildren);
/** @type {boolean} */
this._stale = false;
+ /** @type {?Array<!UI.ViewportDataGridNode>} */
+ this._flatNodes = null;
}
/**
@@ -321,6 +293,35 @@ UI.ViewportDataGridNode = class extends UI.DataGridNode {
}
/**
+ * @return {!Array<!UI.ViewportDataGridNode>}
+ */
+ flatenChildren() {
dgozman 2016/11/28 18:39:51 Let's land this in a separate patch with a test.
allada 2016/11/29 00:35:09 Done.
+ if (this._flatNodes)
+ return this._flatNodes;
+ var flatNodes = [];
+ var children = [this.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 flatNodes;
+ }
+
+ /**
* @param {number} depth
*/
setDepth(depth) {
@@ -333,6 +334,7 @@ UI.ViewportDataGridNode = class extends UI.DataGridNode {
* @param {number} index
*/
insertChild(child, index) {
+ this._flatNodes = null;
if (child.parent === this) {
var currentIndex = this.children.indexOf(child);
if (currentIndex < 0)
@@ -358,6 +360,7 @@ UI.ViewportDataGridNode = class extends UI.DataGridNode {
* @param {!UI.DataGridNode} child
*/
removeChild(child) {
+ this._flatNodes = null;
if (this.dataGrid)
this.dataGrid.updateSelectionBeforeRemoval(child, false);
if (child.previousSibling)
@@ -379,6 +382,7 @@ UI.ViewportDataGridNode = class extends UI.DataGridNode {
* @override
*/
removeChildren() {
+ this._flatNodes = null;
if (this.dataGrid)
this.dataGrid.updateSelectionBeforeRemoval(this, true);
for (var i = 0; i < this.children.length; ++i)
@@ -465,4 +469,13 @@ UI.ViewportDataGridNode = class extends UI.DataGridNode {
reveal() {
this.dataGrid._revealViewportNode(this);
}
+
+ /**
+ * @override
+ * @param {number} index
+ */
+ recalculateSiblings(index) {
+ this._flatNodes = null;
+ super.recalculateSiblings(index);
+ }
};

Powered by Google App Engine
This is Rietveld 408576698