Change View.show to call detach if the parentNode dosen't
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 May 2008 22:29:08 +0000 (22:29 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 May 2008 22:29:08 +0000 (22:29 +0000)
match before appending to the passed in parent element.
This also prevents appending to the same parent element
multiple times.

Reviewed by John Sullivan.

* page/inspector/FontView.js:
(WebInspector.FontView.prototype.show): Pass the parent element to View.show.
* page/inspector/ResourceView.js: Optimize the attach method to no append if
there is a parentNode already.
* page/inspector/SourceView.js: Ditto.
* page/inspector/View.js: Call detach before appending if the parentNode
doesn't match the passed in element.

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

WebCore/ChangeLog
WebCore/page/inspector/FontView.js
WebCore/page/inspector/ResourceView.js
WebCore/page/inspector/SourceView.js
WebCore/page/inspector/View.js

index 9fdca8b..c125b78 100644 (file)
@@ -1,5 +1,22 @@
 2008-05-13  Timothy Hatcher  <timothy@apple.com>
 
+        Change View.show to call detach if the parentNode dosen't
+        match before appending to the passed in parent element.
+        This also prevents appending to the same parent element
+        multiple times.
+
+        Reviewed by John Sullivan.
+
+        * page/inspector/FontView.js:
+        (WebInspector.FontView.prototype.show): Pass the parent element to View.show.
+        * page/inspector/ResourceView.js: Optimize the attach method to no append if
+        there is a parentNode already.
+        * page/inspector/SourceView.js: Ditto.
+        * page/inspector/View.js: Call detach before appending if the parentNode
+        doesn't match the passed in element.
+
+2008-05-13  Timothy Hatcher  <timothy@apple.com>
+
         Optimize the panel attach method to no append if there is a
         parentNode already.
 
index 2059c04..cafff31 100644 (file)
@@ -45,9 +45,9 @@ WebInspector.FontView = function(resource)
 }
 
 WebInspector.FontView.prototype = {
-    show: function()
+    show: function(parentElement)
     {
-        WebInspector.ResourceView.prototype.show.call(this);
+        WebInspector.ResourceView.prototype.show.call(this, parentElement);
         this.updateFontPreviewSize();
     },
 
index 46d8a66..73e6971 100644 (file)
@@ -42,7 +42,8 @@ WebInspector.ResourceView = function(resource)
 WebInspector.ResourceView.prototype = {
     attach: function()
     {
-        document.getElementById("resource-views").appendChild(this.element);
+        if (!this.element.parentNode)
+            document.getElementById("resource-views").appendChild(this.element);
     }
 }
 
index 8d888e4..b12c42a 100644 (file)
@@ -42,9 +42,9 @@ WebInspector.SourceView = function(resource)
 }
 
 WebInspector.SourceView.prototype = {
-    show: function()
+    show: function(parentElement)
     {
-        WebInspector.ResourceView.prototype.show.call(this);
+        WebInspector.ResourceView.prototype.show.call(this, parentElement);
         this.setupSourceFrameIfNeeded();
     },
 
index 9e22482..9daad12 100644 (file)
@@ -49,8 +49,10 @@ WebInspector.View.prototype = {
     show: function(parentElement)
     {
         this._visible = true;
-        if (!this.element.parentNode && parentElement)
+        if (parentElement && parentElement !== this.element.parentNode) {
+            this.detach();
             parentElement.appendChild(this.element);
+        }
         if (!this.element.parentNode && this.attach)
             this.attach();
         this.element.addStyleClass("visible");