Web Inspector: Exceptions in Network timeline when resource updates and filters are...
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Jul 2015 07:13:43 +0000 (07:13 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Jul 2015 07:13:43 +0000 (07:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=146609

Reviewed by Joseph Pecoraro.

* UserInterface/Views/DataGrid.js:
(WebInspector.DataGrid.prototype.insertChild):
(WebInspector.DataGrid.prototype.removeChild):
(WebInspector.DataGridNode.prototype.savePosition):
Convert exceptions to asserts and early returns.

* UserInterface/Views/TimelineDataGrid.js:
(WebInspector.TimelineDataGrid.prototype._refreshDirtyDataGridNodes): Add some asserts and checks.

* UserInterface/Views/TreeOutline.js:
(WebInspector.TreeOutline.prototype.appendChild):
(WebInspector.TreeOutline.prototype.insertChild):
(WebInspector.TreeOutline.prototype.removeChildAtIndex):
(WebInspector.TreeOutline.prototype.removeChild):
Convert exceptions to asserts and early returns.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@186306 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/DataGrid.js
Source/WebInspectorUI/UserInterface/Views/TimelineDataGrid.js
Source/WebInspectorUI/UserInterface/Views/TreeOutline.js

index dc606ae..2341e52 100644 (file)
@@ -1,3 +1,26 @@
+2015-07-06  Timothy Hatcher  <timothy@apple.com>
+
+        Web Inspector: Exceptions in Network timeline when resource updates and filters are applied
+        https://bugs.webkit.org/show_bug.cgi?id=146609
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/DataGrid.js:
+        (WebInspector.DataGrid.prototype.insertChild):
+        (WebInspector.DataGrid.prototype.removeChild):
+        (WebInspector.DataGridNode.prototype.savePosition):
+        Convert exceptions to asserts and early returns.
+
+        * UserInterface/Views/TimelineDataGrid.js:
+        (WebInspector.TimelineDataGrid.prototype._refreshDirtyDataGridNodes): Add some asserts and checks.
+
+        * UserInterface/Views/TreeOutline.js:
+        (WebInspector.TreeOutline.prototype.appendChild):
+        (WebInspector.TreeOutline.prototype.insertChild):
+        (WebInspector.TreeOutline.prototype.removeChildAtIndex):
+        (WebInspector.TreeOutline.prototype.removeChild):
+        Convert exceptions to asserts and early returns.
+
 2015-07-05  Timothy Hatcher  <timothy@apple.com>
 
         Web Inspector: Cached resources are missing startTime and size in Network timeline
index 5e8c145..a7fa134 100644 (file)
@@ -719,10 +719,13 @@ WebInspector.DataGrid.prototype = {
 
     insertChild: function(child, index)
     {
+        console.assert(child);
         if (!child)
-            throw("insertChild: Node can't be undefined or null.");
+            return;
+
+        console.assert(child.parent !== this);
         if (child.parent === this)
-            throw("insertChild: Node is already a child of this node.");
+            return;
 
         if (child.parent)
             child.parent.removeChild(child);
@@ -755,10 +758,13 @@ WebInspector.DataGrid.prototype = {
 
     removeChild: function(child)
     {
+        console.assert(child);
         if (!child)
-            throw("removeChild: Node can't be undefined or null.");
+            return;
+
+        console.assert(child.parent === this);
         if (child.parent !== this)
-            throw("removeChild: Node is not a child of this node.");
+            return;
 
         child.deselect();
         child._detach();
@@ -1869,8 +1875,10 @@ WebInspector.DataGridNode.prototype = {
         if (this._savedPosition)
             return;
 
+        console.assert(this.parent);
         if (!this.parent)
-            throw("savePosition: Node must have a parent.");
+            return;
+
         this._savedPosition = {
             parent: this.parent,
             index: this.parent.children.indexOf(this)
index 9fdefcf..db3b875 100644 (file)
@@ -244,8 +244,13 @@ WebInspector.TimelineDataGrid.prototype = {
             var treeElement = this._treeOutlineDataGridSynchronizer.treeElementForDataGridNode(dataGridNode);
             console.assert(treeElement);
 
-            treeOutline.removeChild(treeElement);
-            this.removeChild(dataGridNode);
+            console.assert(!treeElement.parent || treeElement.parent === treeOutline);
+            if (treeElement.parent === treeOutline)
+                treeOutline.removeChild(treeElement);
+
+            console.assert(!dataGridNode.parent || dataGridNode.parent === this);
+            if (dataGridNode.parent === this)
+                this.removeChild(dataGridNode);
 
             var insertionIndex = insertionIndexForObjectInListSortedByFunction(dataGridNode, this.children, sortComparator);
             treeOutline.insertChild(treeElement, insertionIndex);
index 3e1d219..ac80825 100644 (file)
@@ -55,8 +55,9 @@ WebInspector.TreeOutline = class TreeOutline extends WebInspector.Object
 
     appendChild(child)
     {
+        console.assert(child);
         if (!child)
-            throw "child can't be undefined or null";
+            return;
 
         var lastChild = this.children[this.children.length - 1];
         if (lastChild) {
@@ -97,8 +98,9 @@ WebInspector.TreeOutline = class TreeOutline extends WebInspector.Object
 
     insertChild(child, index)
     {
+        console.assert(child);
         if (!child)
-            throw "child can't be undefined or null";
+            return;
 
         var previousChild = (index > 0 ? this.children[index - 1] : null);
         if (previousChild) {
@@ -146,8 +148,9 @@ WebInspector.TreeOutline = class TreeOutline extends WebInspector.Object
 
     removeChildAtIndex(childIndex, suppressOnDeselect, suppressSelectSibling)
     {
+        console.assert(childIndex >= 0 && childIndex < this.children.length);
         if (childIndex < 0 || childIndex >= this.children.length)
-            throw "childIndex out of range";
+            return;
 
         var child = this.children[childIndex];
         this.children.splice(childIndex, 1);
@@ -184,12 +187,14 @@ WebInspector.TreeOutline = class TreeOutline extends WebInspector.Object
 
     removeChild(child, suppressOnDeselect, suppressSelectSibling)
     {
+        console.assert(child);
         if (!child)
-            throw "child can't be undefined or null";
+            return;
 
         var childIndex = this.children.indexOf(child);
+        console.assert(childIndex !== -1);
         if (childIndex === -1)
-            throw "child not found in this node's children";
+            return;
 
         this.removeChildAtIndex(childIndex, suppressOnDeselect, suppressSelectSibling);