Index: third_party/WebKit/Source/devtools/front_end/data_grid/DataGrid.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/data_grid/DataGrid.js b/third_party/WebKit/Source/devtools/front_end/data_grid/DataGrid.js |
index 9bb1cbc7820613553029a4c727f3c91117bac4f9..a71306fabcba2d4dd22a26454c11bdc58d53fb0e 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/data_grid/DataGrid.js |
+++ b/third_party/WebKit/Source/devtools/front_end/data_grid/DataGrid.js |
@@ -804,13 +804,13 @@ DataGrid.DataGrid = class extends Common.Object { |
else |
this.selectedNode.collapse(); |
handled = true; |
- } else if (this.selectedNode.parent && !this.selectedNode.parent._isRoot) { |
+ } else if (this.selectedNode.parent() && !this.selectedNode.parent()._isRoot) { |
handled = true; |
- if (this.selectedNode.parent.selectable) { |
- nextSelectedNode = this.selectedNode.parent; |
+ if (this.selectedNode.parent().selectable) { |
+ nextSelectedNode = this.selectedNode.parent(); |
handled = nextSelectedNode ? true : false; |
- } else if (this.selectedNode.parent) { |
- this.selectedNode.parent.collapse(); |
+ } else if (this.selectedNode.parent()) { |
+ this.selectedNode.parent().collapse(); |
} |
} |
} else if (event.key === 'ArrowRight') { |
@@ -856,14 +856,14 @@ DataGrid.DataGrid = class extends Common.Object { |
updateSelectionBeforeRemoval(root, onlyAffectsSubtree) { |
var ancestor = this.selectedNode; |
while (ancestor && ancestor !== root) |
- ancestor = ancestor.parent; |
+ ancestor = ancestor.parent(); |
// Selection is not in the subtree being deleted. |
if (!ancestor) |
return; |
var nextSelectedNode; |
// Skip subtree being deleted when looking for the next selectable node. |
- for (ancestor = root; ancestor && !ancestor.nextSibling; ancestor = ancestor.parent) { |
+ for (ancestor = root; ancestor && !ancestor.nextSibling; ancestor = ancestor.parent()) { |
} |
if (ancestor) |
nextSelectedNode = ancestor.nextSibling; |
@@ -1257,7 +1257,7 @@ DataGrid.DataGridNode = class extends Common.Object { |
/** @type {?DataGrid.DataGrid} */ |
this.dataGrid = null; |
/** @type {?NODE_TYPE} */ |
- this.parent = null; |
+ this._parent = null; |
/** @type {?NODE_TYPE} */ |
this.previousSibling = null; |
/** @type {?NODE_TYPE} */ |
@@ -1333,6 +1333,21 @@ DataGrid.DataGridNode = class extends Common.Object { |
} |
/** |
+ * @param {?NODE_TYPE} parentNode |
+ */ |
+ setParent(parentNode) { |
+ delete this._depth; |
+ this._parent = parentNode; |
luoe
2017/03/06 16:56:40
Do we need to recalculate depth of this node's gra
allada
2017/03/06 18:18:32
Done.
|
+ } |
+ |
+ /** |
+ * @return {?NODE_TYPE} |
+ */ |
+ parent() { |
+ return this._parent; |
+ } |
+ |
+ /** |
* @return {!Object.<string, *>} |
*/ |
get data() { |
@@ -1354,14 +1369,14 @@ DataGrid.DataGridNode = class extends Common.Object { |
if (this._revealed !== undefined) |
return this._revealed; |
- var currentAncestor = this.parent; |
+ var currentAncestor = this.parent(); |
while (currentAncestor && !currentAncestor._isRoot) { |
if (!currentAncestor.expanded) { |
this._revealed = false; |
return false; |
} |
- currentAncestor = currentAncestor.parent; |
+ currentAncestor = currentAncestor.parent(); |
} |
this._revealed = true; |
@@ -1458,8 +1473,8 @@ DataGrid.DataGridNode = class extends Common.Object { |
get depth() { |
if (this._depth !== undefined) |
return this._depth; |
- if (this.parent && !this.parent._isRoot) |
- this._depth = this.parent.depth + 1; |
+ if (this.parent() && !this.parent()._isRoot) |
+ this._depth = this.parent().depth + 1; |
else |
this._depth = 0; |
return this._depth; |
@@ -1603,7 +1618,7 @@ DataGrid.DataGridNode = class extends Common.Object { |
insertChild(child, index) { |
if (!child) |
throw 'insertChild: Node can\'t be undefined or null.'; |
- if (child.parent === this) { |
+ if (child.parent() === this) { |
var currentIndex = this.children.indexOf(child); |
if (currentIndex < 0) |
console.assert(false, 'Inconsistent DataGrid state'); |
@@ -1618,7 +1633,7 @@ DataGrid.DataGridNode = class extends Common.Object { |
this.children.splice(index, 0, child); |
this.setHasChildren(true); |
- child.parent = this; |
+ child.setParent(this); |
child.dataGrid = this.dataGrid; |
child.recalculateSiblings(index); |
@@ -1644,8 +1659,8 @@ DataGrid.DataGridNode = class extends Common.Object { |
} |
remove() { |
- if (this.parent) |
- this.parent.removeChild(this); |
+ if (this.parent()) |
+ this.parent().removeChild(this); |
} |
/** |
@@ -1654,7 +1669,7 @@ DataGrid.DataGridNode = class extends Common.Object { |
removeChild(child) { |
if (!child) |
throw 'removeChild: Node can\'t be undefined or null.'; |
- if (child.parent !== this) |
+ if (child.parent() !== this) |
throw 'removeChild: Node is not a child of this node.'; |
if (this.dataGrid) |
@@ -1669,7 +1684,7 @@ DataGrid.DataGridNode = class extends Common.Object { |
child.nextSibling.previousSibling = child.previousSibling; |
child.dataGrid = null; |
- child.parent = null; |
+ child.setParent(null); |
child.nextSibling = null; |
child.previousSibling = null; |
@@ -1684,7 +1699,7 @@ DataGrid.DataGridNode = class extends Common.Object { |
var child = this.children[i]; |
child._detach(); |
child.dataGrid = null; |
- child.parent = null; |
+ child.setParent(null); |
child.nextSibling = null; |
child.previousSibling = null; |
} |
@@ -1697,15 +1712,15 @@ DataGrid.DataGridNode = class extends Common.Object { |
* @param {number} myIndex |
*/ |
recalculateSiblings(myIndex) { |
- if (!this.parent) |
+ if (!this.parent()) |
return; |
- var previousChild = this.parent.children[myIndex - 1] || null; |
+ var previousChild = this.parent().children[myIndex - 1] || null; |
if (previousChild) |
previousChild.nextSibling = this; |
this.previousSibling = previousChild; |
- var nextChild = this.parent.children[myIndex + 1] || null; |
+ var nextChild = this.parent().children[myIndex + 1] || null; |
if (nextChild) |
nextChild.previousSibling = this; |
this.nextSibling = nextChild; |
@@ -1781,11 +1796,11 @@ DataGrid.DataGridNode = class extends Common.Object { |
reveal() { |
if (this._isRoot) |
return; |
- var currentAncestor = this.parent; |
+ var currentAncestor = this.parent(); |
while (currentAncestor && !currentAncestor._isRoot) { |
if (!currentAncestor.expanded) |
currentAncestor.expand(); |
- currentAncestor = currentAncestor.parent; |
+ currentAncestor = currentAncestor.parent(); |
} |
this.element().scrollIntoViewIfNeeded(false); |
@@ -1865,10 +1880,10 @@ DataGrid.DataGridNode = class extends Common.Object { |
node = this; |
while (node && !node._isRoot && !((!skipHidden || node.revealed) ? node.nextSibling : null) && |
- node.parent !== stayWithin) { |
+ node.parent() !== stayWithin) { |
if (info) |
info.depthChange -= 1; |
- node = node.parent; |
+ node = node.parent(); |
} |
if (!node) |
@@ -1897,10 +1912,10 @@ DataGrid.DataGridNode = class extends Common.Object { |
if (node) |
return node; |
- if (!this.parent || this.parent._isRoot) |
+ if (!this.parent() || this.parent()._isRoot) |
return null; |
- return this.parent; |
+ return this.parent(); |
} |
/** |
@@ -1956,17 +1971,17 @@ DataGrid.DataGridNode = class extends Common.Object { |
if (this._savedPosition) |
return; |
- if (!this.parent) |
+ if (!this.parent()) |
throw 'savePosition: Node must have a parent.'; |
- this._savedPosition = {parent: this.parent, index: this.parent.children.indexOf(this)}; |
+ this._savedPosition = {parent: this.parent(), index: this.parent().children.indexOf(this)}; |
} |
restorePosition() { |
if (!this._savedPosition) |
return; |
- if (this.parent !== this._savedPosition.parent) |
- this._savedPosition.parent.insertChild(this, this._savedPosition.index); |
+ if (this.parent() !== this._savedPosition.parent()) |
+ this._savedPosition.parent().insertChild(this, this._savedPosition.index); |
this._savedPosition = null; |
} |