| 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..a07682a7df8070fc4223143f0a06b8e1c1b47965 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,24 @@ DataGrid.DataGridNode = class extends Common.Object {
|
| }
|
|
|
| /**
|
| + * @param {?NODE_TYPE} parentNode
|
| + * @protected
|
| + */
|
| + setParent(parentNode) {
|
| + delete this._depth;
|
| + this.children.forEach(child => child.setParent(this));
|
| + if (this._parent !== parentNode)
|
| + this._parent = parentNode;
|
| + }
|
| +
|
| + /**
|
| + * @return {?NODE_TYPE}
|
| + */
|
| + parent() {
|
| + return this._parent;
|
| + }
|
| +
|
| + /**
|
| * @return {!Object.<string, *>}
|
| */
|
| get data() {
|
| @@ -1354,14 +1372,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 +1476,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 +1621,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,11 +1636,10 @@ 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);
|
|
|
| - child._depth = undefined;
|
| child._revealed = undefined;
|
| child._attached = false;
|
| child._shouldRefreshChildren = true;
|
| @@ -1630,7 +1647,6 @@ DataGrid.DataGridNode = class extends Common.Object {
|
| var current = child.children[0];
|
| while (current) {
|
| current.dataGrid = this.dataGrid;
|
| - current._depth = undefined;
|
| current._revealed = undefined;
|
| current._attached = false;
|
| current._shouldRefreshChildren = true;
|
| @@ -1644,8 +1660,8 @@ DataGrid.DataGridNode = class extends Common.Object {
|
| }
|
|
|
| remove() {
|
| - if (this.parent)
|
| - this.parent.removeChild(this);
|
| + if (this.parent())
|
| + this.parent().removeChild(this);
|
| }
|
|
|
| /**
|
| @@ -1654,7 +1670,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 +1685,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 +1700,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 +1713,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 +1797,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 +1881,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 +1913,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 +1972,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;
|
| }
|
|
|