Source/WebCore: Web Inspector: get rid of View::hide, View::set visible, View::attach,
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Oct 2011 19:31:38 +0000 (19:31 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Oct 2011 19:31:38 +0000 (19:31 +0000)
View::set visible.
https://bugs.webkit.org/show_bug.cgi?id=70523

This change also introduces assetions that forces view attach / detach operations
to be performed explicitly.

Patch by Pavel Feldman <pfeldman@google.com> on 2011-10-20
Reviewed by Yury Semikhatsky.

* inspector/front-end/ApplicationCacheItemsView.js:
(WebInspector.ApplicationCacheItemsView.prototype.wasShown):
(WebInspector.ApplicationCacheItemsView.prototype.willHide):
(WebInspector.ApplicationCacheItemsView.prototype._updateCallback):
* inspector/front-end/AuditsPanel.js:
(WebInspector.AuditsPanel.prototype.wasShown):
* inspector/front-end/ConsolePanel.js:
(WebInspector.ConsolePanel.prototype.wasShown):
(WebInspector.ConsolePanel.prototype.willHide):
* inspector/front-end/ConsoleView.js:
(WebInspector.ConsoleView.prototype.wasShown):
* inspector/front-end/CookieItemsView.js:
(WebInspector.CookieItemsView.prototype.wasShown):
(WebInspector.CookieItemsView.prototype.willHide):
(WebInspector.CookieItemsView.prototype._updateWithCookies):
* inspector/front-end/DOMStorageItemsView.js:
(WebInspector.DOMStorageItemsView.prototype.wasShown):
(WebInspector.DOMStorageItemsView.prototype.willHide):
* inspector/front-end/DatabaseQueryView.js:
* inspector/front-end/DatabaseTableView.js:
(WebInspector.DatabaseTableView.prototype.wasShown):
* inspector/front-end/DetailedHeapshotView.js:
(WebInspector.DetailedHeapshotView.prototype.willHide):
(WebInspector.DetailedHeapshotView.prototype._changeView):
* inspector/front-end/Drawer.js:
(WebInspector.Drawer.prototype.hide):
* inspector/front-end/ElementsPanel.js:
(WebInspector.ElementsPanel.prototype.wasShown):
(WebInspector.ElementsPanel.prototype.willHide):
* inspector/front-end/EmptyView.js:
(WebInspector.EmptyView.prototype.wasShown):
* inspector/front-end/FontView.js:
(WebInspector.FontView.prototype.wasShown):
* inspector/front-end/IFrameView.js:
(WebInspector.IFrameView):
* inspector/front-end/ImageView.js:
(WebInspector.ImageView.prototype.wasShown):
* inspector/front-end/NetworkItemView.js:
(WebInspector.NetworkItemView.prototype.wasShown):
(WebInspector.ResourceContentView.prototype.wasShown):
* inspector/front-end/NetworkPanel.js:
(WebInspector.NetworkLogView.prototype.wasShown):
(WebInspector.NetworkLogView.prototype.willHide):
(WebInspector.NetworkPanel.prototype.wasShown):
* inspector/front-end/Panel.js:
(WebInspector.Panel):
(WebInspector.Panel.prototype.show):
(WebInspector.Panel.prototype.wasShown):
(WebInspector.Panel.prototype.willHide):
* inspector/front-end/PanelEnablerView.js:
* inspector/front-end/ProfileView.js:
(WebInspector.CPUProfileView.prototype.willHide):
* inspector/front-end/ProfilesPanel.js:
(WebInspector.ProfilesPanel.prototype.wasShown):
(WebInspector.ProfilesPanel.prototype._addProfileHeader):
(WebInspector.ProfilesPanel.prototype._updateInterface):
(WebInspector.ProfilesPanel.prototype._enableDetailedHeapProfiles):
* inspector/front-end/ResourceCookiesView.js:
(WebInspector.ResourceCookiesView.prototype.wasShown):
* inspector/front-end/ResourceHTMLView.js:
(WebInspector.ResourceHTMLView.prototype.wasShown):
(WebInspector.ResourceHTMLView.prototype.willHide):
* inspector/front-end/ResourceJSONView.js:
(WebInspector.ResourceJSONView.parseJSON.WebInspector.ResourceJSONView.prototype.wasShown):
* inspector/front-end/ResourceTimingView.js:
(WebInspector.ResourceTimingView.prototype.wasShown):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourcesPanel.prototype.wasShown):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype.wasShown):
(WebInspector.ScriptsPanel.prototype._updateDebuggerButtons):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame.prototype.wasShown):
* inspector/front-end/TimelinePanel.js:
(WebInspector.TimelinePanel.prototype.wasShown):
(WebInspector.TimelinePanel.prototype.willHide):
* inspector/front-end/View.js:
(WebInspector.View):
(WebInspector.View.prototype.get visible):
(WebInspector.View.prototype.setHideOnDetach):
(WebInspector.View.prototype._wasShown):
(WebInspector.View.prototype._willHide):
(WebInspector.View.prototype._onResize):
(WebInspector.View.prototype.wasShown):
(WebInspector.View.prototype.willHide):
(WebInspector.View.prototype.onResize):
(WebInspector.View.prototype.show):
(WebInspector.View.prototype.detach):
(WebInspector.View.prototype.doResize):
(WebInspector.View.prototype.dispatchToSelfAndChildren):
(WebInspector.View.prototype.dispatchToChildren):
(WebInspector.View.prototype._handleInsertedIntoDocument):

LayoutTests: Web Inspector: get rid of View::hide, View::set visible, View::attach.
https://bugs.webkit.org/show_bug.cgi?id=70523

Patch by Pavel Feldman <pfeldman@google.com> on 2011-10-20
Reviewed by Yury Semikhatsky.

* inspector/debugger/scripts-panel.html:
* inspector/view-events-expected.txt:
* inspector/view-events.html:

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

40 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/debugger/scripts-panel.html
LayoutTests/inspector/view-events-expected.txt
LayoutTests/inspector/view-events.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/AdvancedSearchController.js
Source/WebCore/inspector/front-end/ApplicationCacheItemsView.js
Source/WebCore/inspector/front-end/AuditsPanel.js
Source/WebCore/inspector/front-end/ConsolePanel.js
Source/WebCore/inspector/front-end/ConsoleView.js
Source/WebCore/inspector/front-end/CookieItemsView.js
Source/WebCore/inspector/front-end/DOMStorageItemsView.js
Source/WebCore/inspector/front-end/DatabaseQueryView.js
Source/WebCore/inspector/front-end/DatabaseTableView.js
Source/WebCore/inspector/front-end/DetailedHeapshotView.js
Source/WebCore/inspector/front-end/Drawer.js
Source/WebCore/inspector/front-end/ElementsPanel.js
Source/WebCore/inspector/front-end/EmptyView.js
Source/WebCore/inspector/front-end/FontView.js
Source/WebCore/inspector/front-end/IFrameView.js
Source/WebCore/inspector/front-end/ImageView.js
Source/WebCore/inspector/front-end/NetworkItemView.js
Source/WebCore/inspector/front-end/NetworkPanel.js
Source/WebCore/inspector/front-end/Panel.js
Source/WebCore/inspector/front-end/PanelEnablerView.js
Source/WebCore/inspector/front-end/ProfileView.js
Source/WebCore/inspector/front-end/ProfilesPanel.js
Source/WebCore/inspector/front-end/ResourceCookiesView.js
Source/WebCore/inspector/front-end/ResourceHTMLView.js
Source/WebCore/inspector/front-end/ResourceJSONView.js
Source/WebCore/inspector/front-end/ResourceTimingView.js
Source/WebCore/inspector/front-end/ResourcesPanel.js
Source/WebCore/inspector/front-end/ScriptsPanel.js
Source/WebCore/inspector/front-end/SourceFrame.js
Source/WebCore/inspector/front-end/TabbedPane.js
Source/WebCore/inspector/front-end/TimelinePanel.js
Source/WebCore/inspector/front-end/View.js
Source/WebCore/inspector/front-end/externs.js
Source/WebCore/inspector/front-end/inspector.html
Source/WebCore/inspector/front-end/inspector.js

index 67add7e05dcbd39c0f10ae47776b370ed83c1329..ba3bdbfb2f6ba3430f99aa2b4e7ef2803de47970 100644 (file)
@@ -1,3 +1,14 @@
+2011-10-20  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: get rid of View::hide, View::set visible, View::attach.
+        https://bugs.webkit.org/show_bug.cgi?id=70523
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/debugger/scripts-panel.html:
+        * inspector/view-events-expected.txt:
+        * inspector/view-events.html:
+
 2011-10-21  Filip Pizlo  <fpizlo@apple.com>
 
         DFG inlining sometimes fails to reset constant references
index e3120feb064e514d259464995a20ee62824e3da5..c74b18492b349c693abd290b5fb0d3d2c1cdc69f 100644 (file)
@@ -49,6 +49,7 @@ function test()
         {
             var model = createDebuggerPresentationModelMock();
             var panel = new WebInspector.ScriptsPanel(model);
+            panel.show();
 
             panel._uiSourceCodeAdded({ data: createUISouceCode("foo.js") });
             panel._uiSourceCodeAdded({ data: createUISouceCode("bar.js") });
@@ -66,6 +67,7 @@ function test()
             // Select "baz.js".
             select.selectedIndex = 1;
             panel._filesSelectChanged();
+            panel.detach();
 
             next();
         },
@@ -74,6 +76,7 @@ function test()
         {
             var model = createDebuggerPresentationModelMock();
             var panel = new WebInspector.ScriptsPanel(model);
+            panel.show();
 
             var files = ["index.html", "script1.js", "script2.js", "script3.js"];
             for (var i = 0; i < files.length; ++i)
@@ -123,6 +126,7 @@ function test()
             panel.backButton.click();
             checkCurrentlySelectedFileName("index.html");
 
+            panel.detach();
             next();
         },
 
@@ -130,6 +134,7 @@ function test()
         {
             var model = createDebuggerPresentationModelMock();
             var panel = new WebInspector.ScriptsPanel(model);
+            panel.show();
 
             var rootURL = "http://localhost:8080/LayoutTests/inspector/debugger/";
             var nextId = 0;
@@ -156,6 +161,8 @@ function test()
                 var tooltip = option.title.replace(rootURL, "<root>/");
                 InspectorTest.addResult(text + (tooltip ? "(" + tooltip + ")" : ""));
             }
+
+            panel.detach();
             next();
         },
 
@@ -163,6 +170,7 @@ function test()
         {
             var model = createDebuggerPresentationModelMock();
             var panel = new WebInspector.ScriptsPanel(model);
+            panel.show();
 
             panel._uiSourceCodeAdded({ data: createUISouceCode("foo.js") });
             var compiledSourceCode = createUISouceCode("compiled.js");
@@ -183,6 +191,7 @@ function test()
             panel._uiSourceCodeReplaced({ data: { oldUISourceCodeList: [source1SourceCode, source2SourceCode], uiSourceCodeList: [compiledSourceCode] }});
             InspectorTest.assertEquals(2, panel._filesSelectElement.length);
 
+            panel.detach();
             next();
         }
     ]);
index 6c371c89457645bfab7f177412743b8232b664f7..acb427710874608e7d043fe125236b198eb3708f 100644 (file)
 This tests that events are properly propagated through View hierarchy.
 
-parentView.show(root)
-> ParentView.wasShown()
-> ParentView.onResize()
-parentView.doResize()
-> ParentView.onResize()
-childView.show(parentView.element)
-> ChildView.wasShown()
-> ChildView.onResize()
-parentView.doResize()
-> ParentView.onResize()
-> ChildView.onResize()
-parentView.hide()
-> ParentView.willHide()
-> ChildView.willHide()
-parentView.show(root)
-> ParentView.wasShown()
-> ParentView.onResize()
-> ChildView.wasShown()
-> ChildView.onResize()
-childView.hide()
-> ChildView.willHide()
-parentView.hide()
-> ParentView.willHide()
+
+Running: testShowView
+View()
+View.show()
+  View.wasShown()
+  View.onResize()
+View.detach()
+  View.willHide()
+
+Running: testAppendViaDOM
+View()
+Error: Attempt to add view via regular DOM operation.
+
+Running: testInsertViaDOM
+View()
+Error: Attempt to add view via regular DOM operation.
+
+Running: testAttachToOrphanNode
+View()
+View.show()
+Error: Attempt to attach view to orphan node
+
+Running: testImmediateParent
+Parent()
+Child()
+Child.show()
+OK
+
+Running: testDistantParent
+Parent()
+Child()
+Child.show()
+OK
+
+Running: testEvents
+Parent()
+Parent.show()
+  Parent.wasShown()
+  Parent.onResize()
+Child()
+Parent.show()
+  Parent.wasShown()
+  Parent.onResize()
+Parent.doResize()
+  Parent.onResize()
+Child.show()
+  Child.wasShown()
+  Child.onResize()
+Parent.doResize()
+  Parent.onResize()
+  Child.onResize()
+Parent.detach()
+  Child.willHide()
+  Parent.willHide()
+Parent.show()
+  Parent.wasShown()
+  Parent.onResize()
+  Child.wasShown()
+  Child.onResize()
+Child.detach()
+  Child.willHide()
+Parent.detach()
+  Parent.willHide()
+
+Running: testViewCounter
+Parent()
+Parent.show()
+  Parent.wasShown()
+  Parent.onResize()
+Child()
+Child.show()
+  Child.wasShown()
+  Child.onResize()
+  view counter: 1
+Child 2()
+Child 2.show()
+  Child 2.wasShown()
+  Child 2.onResize()
+  view counter: 2
+Child.detach()
+  Child.willHide()
+  view counter: 1
+Child 2.detach()
+  Child 2.willHide()
+  view counter: 0
+
+Running: testRemoveChild
+Parent()
+Parent.show()
+  Parent.wasShown()
+  Parent.onResize()
+Child()
+Child.show()
+  Child.wasShown()
+  Child.onResize()
+Error: Attempt to remove element containing view via regular DOM operation
+
+Running: testImplicitRemoveChild
+Parent()
+Child()
+Child.show()
+Error: Attempt to remove element containing view via regular DOM operation
+
+Running: testRemoveChildren
+Parent()
+Child()
+Child.show()
+Error: Attempt to remove element containing view via regular DOM operation
+
+Running: testImplicitRemoveChildren
+Parent()
+Child()
+Child.show()
+Error: Attempt to remove element containing view via regular DOM operation
 
index 783f7681012660da6c7ff017d4d97e852780611a..7188613460b5a9a45742de1d7a17797548b540f4 100644 (file)
@@ -7,54 +7,224 @@ function test()
 {
     function TestView(viewName)
     {
-        this._viewName = viewName;
         WebInspector.View.call(this);
+
+        this._viewName = viewName;
+        InspectorTest.addResult(this._viewName + "()");
     }
 
     TestView.prototype = {
+        show: function(parentElement)
+        {
+            InspectorTest.addResult(this._viewName + ".show()");
+            WebInspector.View.prototype.show.call(this, parentElement);
+        },
+
+        detach: function()
+        {
+            InspectorTest.addResult(this._viewName + ".detach()");
+            WebInspector.View.prototype.detach.call(this);
+        },
+
+        doResize: function()
+        {
+            InspectorTest.addResult(this._viewName + ".doResize()");
+            WebInspector.View.prototype.doResize.call(this);
+        },
+
         wasShown: function()
         {
-            InspectorTest.addResult("> " + this._viewName + ".wasShown()");
-            WebInspector.View.prototype.wasShown.call(this);
+            InspectorTest.addResult("  " + this._viewName + ".wasShown()");
         },
 
         willHide: function()
         {
-            InspectorTest.addResult("> " + this._viewName + ".willHide()");
-            WebInspector.View.prototype.willHide.call(this);
+            InspectorTest.addResult("  " + this._viewName + ".willHide()");
         },
 
         onResize: function()
         {
-            InspectorTest.addResult("> " + this._viewName + ".onResize()");
+            InspectorTest.addResult("  " + this._viewName + ".onResize()");
         }
     };
 
     TestView.prototype.__proto__ = WebInspector.View.prototype;
 
-    function traceEval(expressions)
-    {
-        for (var i = 0; i < expressions.length; ++i) {
-            InspectorTest.addResult(expressions[i]);
-            eval(expressions[i]);
+    InspectorTest.runTestSuite([
+        function testShowView(next)
+        {
+            var view = new TestView("View");
+            view.show(WebInspector.mainPanelsView.element);
+            view.detach();
+            next();
+        },
+
+        function testAppendViaDOM(next)
+        {
+            try {
+                var view = new TestView("View");
+                document.body.appendChild(view.element);
+            } catch (e) {
+                InspectorTest.addResult(e);
+            }
+            next();
+        },
+
+        function testInsertViaDOM(next)
+        {
+            try {
+                var view = new TestView("View");
+                document.body.insertBefore(view.element, null);
+            } catch (e) {
+                InspectorTest.addResult(e);
+            }
+            next();
+        },
+
+        function testAttachToOrphanNode(next)
+        {
+            try {
+                var view = new TestView("View");
+                var div = document.createElement("div");
+                view.show(div);
+            } catch (e) {
+                InspectorTest.addResult(e);
+            }
+            next();
+        },
+
+        function testImmediateParent(next)
+        {
+            var parentView = new TestView("Parent");
+            var childView = new TestView("Child");
+            childView.show(parentView.element);
+            if (childView._parentView === parentView)
+                InspectorTest.addResult("OK");
+            else
+                InspectorTest.addResult("FAILED");
+            next();
+        },
+
+        function testDistantParent(next)
+        {
+            var parentView = new TestView("Parent");
+            var div = document.createElement("div");
+            parentView.element.appendChild(div);
+            var childView = new TestView("Child");
+            childView.show(div);
+
+            if (childView._parentView === parentView)
+                InspectorTest.addResult("OK");
+            else
+                InspectorTest.addResult("FAILED");
+            next();
+        },
+
+        function testEvents(next)
+        {
+            var parentView = new TestView("Parent");
+            parentView.markAsRoot();
+            parentView.show(document.body);
+
+            var childView = new TestView("Child");
+            parentView.show(WebInspector.mainPanelsView.element);
+            parentView.doResize();
+            childView.show(parentView.element);
+            parentView.doResize();
+            parentView.detach();
+            parentView.show(WebInspector.mainPanelsView.element);
+            childView.detach();
+            parentView.detach();
+            next();
+        },
+
+        function testViewCounter(next)
+        {
+            var parentView = new TestView("Parent");
+            parentView.markAsRoot();
+            parentView.show(document.body);
+
+            var childView = new TestView("Child");
+            childView.show(parentView.element);
+            InspectorTest.addResult("  view counter: " + parentView.element.__viewCounter);
+
+            var childView2 = new TestView("Child 2");
+            childView2.show(parentView.element);
+            InspectorTest.addResult("  view counter: " + parentView.element.__viewCounter);
+
+            childView.detach();
+            InspectorTest.addResult("  view counter: " + parentView.element.__viewCounter);
+
+            childView2.detach();
+            InspectorTest.addResult("  view counter: " + parentView.element.__viewCounter);
+
+            next();
+        },
+
+        function testRemoveChild(next)
+        {
+            var parentView = new TestView("Parent");
+            parentView.markAsRoot();
+            parentView.show(document.body);
+
+            var childView = new TestView("Child");
+            childView.show(parentView.element);
+            try {
+                parentView.element.removeChild(childView.element);
+            } catch (e) {
+                InspectorTest.addResult(e);
+            }
+            next();
+        },
+
+        function testImplicitRemoveChild(next)
+        {
+            var parentView = new TestView("Parent");
+            var div = document.createElement("div");
+            parentView.element.appendChild(div);
+
+            var childView = new TestView("Child");
+            childView.show(div);
+
+            try {
+                parentView.element.removeChild(div);
+            } catch (e) {
+                InspectorTest.addResult(e);
+            }
+            next();
+        },
+
+        function testRemoveChildren(next)
+        {
+            var parentView = new TestView("Parent");
+            var childView = new TestView("Child");
+            childView.show(parentView.element);
+            parentView.element.appendChild(document.createElement("div"));
+            try {
+                parentView.element.removeChildren();
+            } catch (e) {
+                InspectorTest.addResult(e);
+            }
+            next();
+        },
+
+        function testImplicitRemoveChildren(next)
+        {
+            var parentView = new TestView("Parent");
+            var div = document.createElement("div");
+            parentView.element.appendChild(div);
+
+            var childView = new TestView("Child");
+            childView.show(div);
+
+            try {
+                parentView.element.removeChildren();
+            } catch (e) {
+                InspectorTest.addResult(e);
+            }
+            next();
         }
-    }
-    var parentView = new TestView("ParentView");
-    var childView = new TestView("ChildView");
-    var root = document.getElementById("main-panels");
-    traceEval([
-        "parentView.show(root)",
-        "parentView.doResize()",
-        "childView.show(parentView.element)",
-        "parentView.doResize()",
-        "parentView.hide()",
-        "parentView.show(root)",
-        "childView.hide()",
-        "parentView.hide()"
     ]);
-    childView.detach();
-    parentView.detach();
-    InspectorTest.completeTest();
 }
 
 </script>
index 71c9c8ed302d6608a93ba097620d7c0c492bca47..d00f2e1921da4a3207fb0c15c3c796b2be753776 100755 (executable)
@@ -1,3 +1,107 @@
+2011-10-20  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: get rid of View::hide, View::set visible, View::attach,
+        View::set visible.
+        https://bugs.webkit.org/show_bug.cgi?id=70523
+
+        This change also introduces assetions that forces view attach / detach operations
+        to be performed explicitly.
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/ApplicationCacheItemsView.js:
+        (WebInspector.ApplicationCacheItemsView.prototype.wasShown):
+        (WebInspector.ApplicationCacheItemsView.prototype.willHide):
+        (WebInspector.ApplicationCacheItemsView.prototype._updateCallback):
+        * inspector/front-end/AuditsPanel.js:
+        (WebInspector.AuditsPanel.prototype.wasShown):
+        * inspector/front-end/ConsolePanel.js:
+        (WebInspector.ConsolePanel.prototype.wasShown):
+        (WebInspector.ConsolePanel.prototype.willHide):
+        * inspector/front-end/ConsoleView.js:
+        (WebInspector.ConsoleView.prototype.wasShown):
+        * inspector/front-end/CookieItemsView.js:
+        (WebInspector.CookieItemsView.prototype.wasShown):
+        (WebInspector.CookieItemsView.prototype.willHide):
+        (WebInspector.CookieItemsView.prototype._updateWithCookies):
+        * inspector/front-end/DOMStorageItemsView.js:
+        (WebInspector.DOMStorageItemsView.prototype.wasShown):
+        (WebInspector.DOMStorageItemsView.prototype.willHide):
+        * inspector/front-end/DatabaseQueryView.js:
+        * inspector/front-end/DatabaseTableView.js:
+        (WebInspector.DatabaseTableView.prototype.wasShown):
+        * inspector/front-end/DetailedHeapshotView.js:
+        (WebInspector.DetailedHeapshotView.prototype.willHide):
+        (WebInspector.DetailedHeapshotView.prototype._changeView):
+        * inspector/front-end/Drawer.js:
+        (WebInspector.Drawer.prototype.hide):
+        * inspector/front-end/ElementsPanel.js:
+        (WebInspector.ElementsPanel.prototype.wasShown):
+        (WebInspector.ElementsPanel.prototype.willHide):
+        * inspector/front-end/EmptyView.js:
+        (WebInspector.EmptyView.prototype.wasShown):
+        * inspector/front-end/FontView.js:
+        (WebInspector.FontView.prototype.wasShown):
+        * inspector/front-end/IFrameView.js:
+        (WebInspector.IFrameView):
+        * inspector/front-end/ImageView.js:
+        (WebInspector.ImageView.prototype.wasShown):
+        * inspector/front-end/NetworkItemView.js:
+        (WebInspector.NetworkItemView.prototype.wasShown):
+        (WebInspector.ResourceContentView.prototype.wasShown):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkLogView.prototype.wasShown):
+        (WebInspector.NetworkLogView.prototype.willHide):
+        (WebInspector.NetworkPanel.prototype.wasShown):
+        * inspector/front-end/Panel.js:
+        (WebInspector.Panel):
+        (WebInspector.Panel.prototype.show):
+        (WebInspector.Panel.prototype.wasShown):
+        (WebInspector.Panel.prototype.willHide):
+        * inspector/front-end/PanelEnablerView.js:
+        * inspector/front-end/ProfileView.js:
+        (WebInspector.CPUProfileView.prototype.willHide):
+        * inspector/front-end/ProfilesPanel.js:
+        (WebInspector.ProfilesPanel.prototype.wasShown):
+        (WebInspector.ProfilesPanel.prototype._addProfileHeader):
+        (WebInspector.ProfilesPanel.prototype._updateInterface):
+        (WebInspector.ProfilesPanel.prototype._enableDetailedHeapProfiles):
+        * inspector/front-end/ResourceCookiesView.js:
+        (WebInspector.ResourceCookiesView.prototype.wasShown):
+        * inspector/front-end/ResourceHTMLView.js:
+        (WebInspector.ResourceHTMLView.prototype.wasShown):
+        (WebInspector.ResourceHTMLView.prototype.willHide):
+        * inspector/front-end/ResourceJSONView.js:
+        (WebInspector.ResourceJSONView.parseJSON.WebInspector.ResourceJSONView.prototype.wasShown):
+        * inspector/front-end/ResourceTimingView.js:
+        (WebInspector.ResourceTimingView.prototype.wasShown):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.prototype.wasShown):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype.wasShown):
+        (WebInspector.ScriptsPanel.prototype._updateDebuggerButtons):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame.prototype.wasShown):
+        * inspector/front-end/TimelinePanel.js:
+        (WebInspector.TimelinePanel.prototype.wasShown):
+        (WebInspector.TimelinePanel.prototype.willHide):
+        * inspector/front-end/View.js:
+        (WebInspector.View):
+        (WebInspector.View.prototype.get visible):
+        (WebInspector.View.prototype.setHideOnDetach):
+        (WebInspector.View.prototype._wasShown):
+        (WebInspector.View.prototype._willHide):
+        (WebInspector.View.prototype._onResize):
+        (WebInspector.View.prototype.wasShown):
+        (WebInspector.View.prototype.willHide):
+        (WebInspector.View.prototype.onResize):
+        (WebInspector.View.prototype.show):
+        (WebInspector.View.prototype.detach):
+        (WebInspector.View.prototype.doResize):
+        (WebInspector.View.prototype.dispatchToSelfAndChildren):
+        (WebInspector.View.prototype.dispatchToChildren):
+        (WebInspector.View.prototype._handleInsertedIntoDocument):
+
 2011-10-22  Kent Tamura  <tkent@chromium.org>
 
         REGRESSION(r92480): Passing uninitialized variable in HTMLElement::calculateAndAdjustDirectionality()
index 0c3a331f5b2a29df951ecc9c8dce388ce1a63b78..cf1b306f69c0aaba81e84a95872c572089375f6c 100644 (file)
@@ -75,7 +75,7 @@ WebInspector.AdvancedSearchController.prototype = {
         if (!this._searchView)
             this._searchView = new WebInspector.SearchView(this);
         
-        if (this._searchView.visible)
+        if (this._searchView.isShowing())
             this._searchView.focus();
         else
             WebInspector.showViewInDrawer(this._searchView);
@@ -159,7 +159,6 @@ WebInspector.SearchView = function(controller)
     
     this._controller = controller;
 
-    this.element = document.createElement("div");
     this.element.className = "search-view";
 
     this._searchPanelElement = this.element.createChild("div");
@@ -267,8 +266,9 @@ WebInspector.SearchView.prototype = {
         
         this._updateSearchResultsMessage();
         
-        var searchingView = new WebInspector.EmptyView(WebInspector.UIString("Searching..."));
-        searchingView.show(this._searchResultsElement);
+        if (!this._searchingView)
+            this._searchingView = new WebInspector.EmptyView(WebInspector.UIString("Searching..."));
+        this._searchingView.show(this._searchResultsElement);
     },
 
     _updateSearchResultsMessage: function()
@@ -287,6 +287,10 @@ WebInspector.SearchView.prototype = {
 
     resetResults: function()
     {
+        if (this._searchingView)
+            this._searchingView.detach();
+        if (this._notFoundView)
+            this._notFoundView.detach();
         this._searchResultsElement.removeChildren();
     },
 
@@ -301,8 +305,9 @@ WebInspector.SearchView.prototype = {
     {
         this.resetResults();
 
-        var notFoundView = new WebInspector.EmptyView(WebInspector.UIString("No matches found."));
-        notFoundView.show(this._searchResultsElement);
+        if (!this._notFoundView)
+            this._notFoundView = new WebInspector.EmptyView(WebInspector.UIString("No matches found."));
+        this._notFoundView.show(this._searchResultsElement);
         this._searchResultsMessageElement.textContent = WebInspector.UIString("No matches found.");
     },
 
index 8ccc88b64b9b19ac8534a747297f55b4fa0beafa..c9d6edace333cfb30facb12b3ccd6c3d6e92000e 100644 (file)
@@ -103,16 +103,14 @@ WebInspector.ApplicationCacheItemsView.prototype = {
         }
     },
 
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.View.prototype.show.call(this, parentElement);
         this.updateNetworkState(navigator.onLine);
         this._update();
     },
 
-    hide: function()
+    willHide: function()
     {
-        WebInspector.View.prototype.hide.call(this);
         this.deleteButton.visible = false;
     },
 
@@ -179,7 +177,7 @@ WebInspector.ApplicationCacheItemsView.prototype = {
         this._populateDataGrid();
         this._dataGrid.autoSizeColumns(20, 80);
         this._dataGrid.element.removeStyleClass("hidden");
-        this._emptyView.hide();
+        this._emptyView.detach();
         this.deleteButton.visible = true;
 
         var totalSizeString = Number.bytesToString(this._size);
index 57debf302b3fbb1367fd68a48ed65c8e41284978..92b531f45de3b5de988c7099c2bff3732107c165 100644 (file)
@@ -244,9 +244,9 @@ WebInspector.AuditsPanel.prototype = {
             x.show(this.viewsContainerElement);
     },
 
-    show: function()
+    wasShown: function()
     {
-        WebInspector.Panel.prototype.show.call(this);
+        WebInspector.Panel.prototype.wasShown.call(this);
         if (!this._visibleView)
             this.auditsItemTreeElement.select();
     },
index f76e5b64545e13d6f8939cd1578a18bb2a97f595..62157d26bc4e23496de1bcbf941e311bffcb5abd 100644 (file)
@@ -50,23 +50,23 @@ WebInspector.ConsolePanel.prototype = {
         return this._view.statusBarItems;
     },
 
-    show: function()
+    wasShown: function()
     {
+        WebInspector.Panel.prototype.wasShown.call(this);
         if (WebInspector.drawer.visible) {
             WebInspector.drawer.hide(WebInspector.Drawer.AnimationType.Immediately);
             this._drawerWasVisible = true;
         }
-        WebInspector.Panel.prototype.show.call(this);
         this._view.show(this.element);
     },
 
-    hide: function()
+    willHide: function()
     {
-        WebInspector.Panel.prototype.hide.call(this);
         if (this._drawerWasVisible) {
             WebInspector.drawer.show(this._view, WebInspector.Drawer.AnimationType.Immediately);
             delete this._drawerWasVisible;
         }
+        WebInspector.Panel.prototype.willHide.call(this);
     },
 
     searchCanceled: function()
@@ -132,7 +132,7 @@ WebInspector.ConsolePanel.prototype = {
 
     _consoleMessageAdded: function(event)
     {
-        if (!this._searchRegex || !this.visible)
+        if (!this._searchRegex || !this.isShowing())
             return;
         var message = event.data;
         this._searchRegex.lastIndex = 0;
@@ -148,7 +148,7 @@ WebInspector.ConsolePanel.prototype = {
             return;
         this._clearCurrentSearchResultHighlight();
         this._searchResults.length = 0;
-        if (this.visible)
+        if (this.isShowing())
             WebInspector.searchController.updateSearchMatchesCount(0, this);
     }
 }
index 84d011107f9a6b4886f6fbe398efce93662441bb..f4f8432ca981a895d0fa45596d62b571e409882a 100644 (file)
@@ -226,7 +226,6 @@ WebInspector.ConsoleView.prototype = {
 
     wasShown: function()
     {
-        WebInspector.View.prototype.wasShown.call(this);
         if (!this.prompt.isCaretInsidePrompt())
             this.prompt.moveCaretToEndOfPrompt();
     },
index bea83645720c6eb3eeb1288624f7afbcedd06b1c..48aa2934169fc667e7f56256123adc2c651f7aa0 100644 (file)
@@ -59,15 +59,13 @@ WebInspector.CookieItemsView.prototype = {
         return [this._refreshButton.element, this._deleteButton.element];
     },
 
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.View.prototype.show.call(this, parentElement);
         this._update();
     },
 
-    hide: function()
+    willHide: function()
     {
-        WebInspector.View.prototype.hide.call(this);
         this._deleteButton.visible = false;
     },
 
@@ -102,7 +100,7 @@ WebInspector.CookieItemsView.prototype = {
 
         this._cookiesTable.setCookies(this._cookies);
         this._cookiesTable.element.removeStyleClass("hidden");
-        this._emptyView.hide();
+        this._emptyView.detach();
         if (isAdvanced) {
             this._treeElement.subtitle = String.sprintf(WebInspector.UIString("%d cookies (%s)"), this._cookies.length,
                 Number.bytesToString(this._totalSize));
index 15b4c1b01d23fb96f95139620ea90e3b9e3a7894..b8694f7c394295bff669538083d2ad5a029d7b93 100644 (file)
@@ -50,15 +50,13 @@ WebInspector.DOMStorageItemsView.prototype = {
         return [this.refreshButton.element, this.deleteButton.element];
     },
 
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.View.prototype.show.call(this, parentElement);
         this.update();
     },
 
-    hide: function()
+    willHide: function()
     {
-        WebInspector.View.prototype.hide.call(this);
         this.deleteButton.visible = false;
     },
 
index 69207cf7699993d1fa0e002aa2656da98cc45dce..e04354c0daf6cfb51f8374e120360cf8821ed938 100644 (file)
@@ -54,10 +54,8 @@ WebInspector.DatabaseQueryView.Events = {
 }
 
 WebInspector.DatabaseQueryView.prototype = {
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.View.prototype.show.call(this, parentElement);
-
         function moveBackIfOutside()
         {
             if (!this.prompt.isCaretInsidePrompt() && window.getSelection().isCollapsed)
index 18a5cac6423cdb3ee0b01472c322113dcba97afa..576ece356f1e334f80e0ab4497b2aaaab6d56e04 100644 (file)
@@ -42,9 +42,8 @@ WebInspector.DatabaseTableView = function(database, tableName)
 }
 
 WebInspector.DatabaseTableView.prototype = {
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.View.prototype.show.call(this, parentElement);
         this.update();
     },
 
index b5cdc098d4ee8d1ef0cf4cf8267e188b1891bd5b..683ffa75e389292ea333c097893506fbed3959b4 100644 (file)
@@ -586,7 +586,6 @@ WebInspector.DetailedHeapshotView = function(parent, profile)
     this.containmentDataGrid.element.addEventListener("click", this._mouseClickInContentsGrid.bind(this), true);
     this.containmentDataGrid.element.addEventListener("mousedown", this._mouseDownInContentsGrid.bind(this), true);
     this.containmentView.element.appendChild(this.containmentDataGrid.element);
-    this.viewsContainer.appendChild(this.containmentView.element);
 
     this.constructorsView = new WebInspector.View();
     this.constructorsView.element.addStyleClass("view");
@@ -594,14 +593,12 @@ WebInspector.DetailedHeapshotView = function(parent, profile)
     this.constructorsDataGrid.element.addEventListener("click", this._mouseClickInContentsGrid.bind(this), true);
     this.constructorsDataGrid.element.addEventListener("mousedown", this._mouseDownInContentsGrid.bind(this), true);
     this.constructorsView.element.appendChild(this.constructorsDataGrid.element);
-    this.viewsContainer.appendChild(this.constructorsView.element);
 
     this.diffView = new WebInspector.View();
     this.diffView.element.addStyleClass("view");
     this.diffDataGrid = new WebInspector.HeapSnapshotDiffDataGrid();
     this.diffDataGrid.element.addEventListener("click", this._mouseClickInContentsGrid.bind(this), true);
     this.diffView.element.appendChild(this.diffDataGrid.element);
-    this.viewsContainer.appendChild(this.diffView.element);
 
     this.dominatorView = new WebInspector.View();
     this.dominatorView.element.addStyleClass("view");
@@ -609,7 +606,6 @@ WebInspector.DetailedHeapshotView = function(parent, profile)
     this.dominatorDataGrid.element.addEventListener("click", this._mouseClickInContentsGrid.bind(this), true);
     this.dominatorDataGrid.element.addEventListener("mousedown", this._mouseDownInContentsGrid.bind(this), true);
     this.dominatorView.element.appendChild(this.dominatorDataGrid.element);
-    this.viewsContainer.appendChild(this.dominatorView.element);
 
     this.retainmentViewHeader = document.createElement("div");
     this.retainmentViewHeader.addStyleClass("retainers-view-header");
@@ -739,9 +735,8 @@ WebInspector.DetailedHeapshotView.prototype = {
         return this.baseProfile.proxy;
     },
 
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.View.prototype.show.call(this, parentElement);
         if (!this.profileWrapper.loaded)
             this._loadProfile(this._profileUid, profileCallback1.bind(this));
         else
@@ -760,9 +755,8 @@ WebInspector.DetailedHeapshotView.prototype = {
         }
     },
 
-    hide: function()
+    willHide: function()
     {
-        WebInspector.View.prototype.hide.call(this);
         this._currentSearchResultIndex = -1;
     },
 
@@ -1068,7 +1062,7 @@ WebInspector.DetailedHeapshotView.prototype = {
             return;
 
         this.views.current = event.target.selectedIndex;
-        this.currentView.hide();
+        this.currentView.detach();
         var view = this.views[this.views.current];
         this.currentView = view.view;
         this.dataGrid = view.grid;
index c4419914aebb36bad54ac7a8d7c1ace70ebbfe2e..1b4b76b651150710081d718d0c14d1c683726bb2 100644 (file)
@@ -79,8 +79,10 @@ WebInspector.Drawer.prototype = {
 
         var drawerWasVisible = this.visible;
 
-        if (this._view)
+        if (this._view) {
+            this._view.detach();
             this._drawerContentsElement.removeChildren();
+        }
 
         this._view = view;
 
@@ -93,6 +95,7 @@ WebInspector.Drawer.prototype = {
             this._counters.insertBefore(this._view.counterElement, this._counters.firstChild);
 
         document.body.addStyleClass("drawer-visible");
+        this._view.markAsRoot();
         this._view.show(this._drawerContentsElement);
 
         if (drawerWasVisible)
@@ -181,9 +184,9 @@ WebInspector.Drawer.prototype = {
                 this._counters.insertBefore(this._currentPanelCounters, this._counters.firstChild);
             }
 
-            this._view.hide();
-            this._drawerContentsElement.removeChildren();
+            this._view.detach();
             delete this._view;
+            this._drawerContentsElement.removeChildren();
             document.body.removeStyleClass("drawer-visible");
             delete this._currentAnimation;
         }
index aa6ded0a8e0906000ecde5db7b704a72110d9946..c80b676aa0fec4dcf675de1e242a910345992133 100644 (file)
@@ -124,13 +124,14 @@ WebInspector.ElementsPanel.prototype = {
         this.updateBreadcrumbSizes();
     },
 
-    show: function()
+    wasShown: function()
     {
+        WebInspector.Panel.prototype.wasShown.call(this);
+
         // Attach heavy component lazily
         if (this.treeOutline.element.parentElement !== this.contentElement)
             this.contentElement.appendChild(this.treeOutline.element);
 
-        WebInspector.Panel.prototype.show.call(this);
         this.sidebarResizeElement.style.right = (this.sidebarElement.offsetWidth - 3) + "px";
         this.updateBreadcrumb();
         this.treeOutline.updateSelection();
@@ -140,16 +141,16 @@ WebInspector.ElementsPanel.prototype = {
             this.sidebarElement.insertBefore(this.sidebarPanes.domBreakpoints.element, this.sidebarPanes.eventListeners.element);
     },
 
-    hide: function()
+    willHide: function()
     {
-        WebInspector.Panel.prototype.hide.call(this);
-
         WebInspector.domAgent.hideDOMNodeHighlight();
         this.setSearchingForNode(false);
         this.treeOutline.setVisible(false);
 
         // Detach heavy component on hide
         this.contentElement.removeChild(this.treeOutline.element);
+
+        WebInspector.Panel.prototype.willHide.call(this);
     },
 
     onResize: function()
@@ -406,7 +407,7 @@ WebInspector.ElementsPanel.prototype = {
 
     _nodeRemoved: function(event)
     {
-        if (!this.visible)
+        if (!this.isShowing())
             return;
 
         var crumbs = this.crumbsElement;
@@ -461,7 +462,7 @@ WebInspector.ElementsPanel.prototype = {
      */
     updateBreadcrumb: function(forceUpdate)
     {
-        if (!this.visible)
+        if (!this.isShowing())
             return;
 
         var crumbs = this.crumbsElement;
@@ -588,7 +589,7 @@ WebInspector.ElementsPanel.prototype = {
      */
     updateBreadcrumbSizes: function(focusedCrumb)
     {
-        if (!this.visible)
+        if (!this.isShowing())
             return;
 
         if (document.body.offsetWidth <= 0) {
index f986612d99800eccaedbabde1ae4f0f005071ea7..1d44c8ac40bc83546b06dda5c50a52a58ef59a52 100644 (file)
@@ -39,13 +39,8 @@ WebInspector.EmptyView = function(text)
 }
 
 WebInspector.EmptyView.prototype = {
-    /**
-     * @param {Element} parentElement
-     */
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.View.prototype.show.call(this, parentElement);
-
         this.element.className = "storage-empty-view";
         this.element.textContent = this._text;
     },
index 760c75a1810b677a6bd5dc97500fe70f63f0a116..31bccf57fbecc4268503e179da489fab247f6a1b 100644 (file)
@@ -77,9 +77,8 @@ WebInspector.FontView.prototype = {
         this.element.appendChild(this.fontPreviewElement);
     },
 
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.ResourceView.prototype.show.call(this, parentElement);
         this._createContentIfNeeded();
 
         this.updateFontPreviewSize();
@@ -109,7 +108,7 @@ WebInspector.FontView.prototype = {
 
     updateFontPreviewSize: function()
     {
-        if (!this.fontPreviewElement || !this.visible)
+        if (!this.fontPreviewElement || !this.isShowing())
             return;
 
         this.fontPreviewElement.style.removeProperty("visibility");
index e2101f714e03c15393cbdd803e4b00d49fcde5ff..6df6a9ebd8f6d0ce2464bd67b55f1f1ea24ef45f 100644 (file)
@@ -38,36 +38,12 @@ WebInspector.IFrameView = function(src, className)
 {
     WebInspector.View.call(this);
     this.element.className = "fill";
-    this._src = src;
-    this._className = className;
-}
-
-WebInspector.IFrameView.prototype = {
-    willDetach: function()
-    {
-        if (this._iframe) {
-            if (!WebInspector.IFrameView._parentIframe) {
-                WebInspector.IFrameView._parentIframe = document.createElement("iframe");
-                WebInspector.IFrameView._parentIframe.style.display = "none";
-                document.body.appendChild(WebInspector.IFrameView._parentIframe);
-            }
-            WebInspector.IFrameView._parentIframe.contentDocument.adoptNode(this._iframe);
-            WebInspector.IFrameView._parentIframe.contentDocument.body.appendChild(this._iframe);
-        }
-    },
-
-    onInsertedIntoDocument: function()
-    {
-        if (!this._iframe) {
-            this._iframe = document.createElement("iframe");
-            this._iframe.src = this._src;
-            if (this._className)
-                this._iframe.className = this._className;
-        }
 
-        document.adoptNode(this._iframe);
-        this.element.appendChild(this._iframe);
-    }
+    this._iframe = document.createElement("iframe");
+    this._iframe.src = src;
+    if (className)
+        this._iframe.className = className;
+    this.element.appendChild(this._iframe);
 }
 
 WebInspector.IFrameView.prototype.__proto__ = WebInspector.View.prototype;
index 70fe0429b3c877546b37edbb586f39b0f17a6bba..f0bff1ccc2efbd45d5a5e516d1ace7a143c31080 100644 (file)
@@ -43,9 +43,8 @@ WebInspector.ImageView.prototype = {
         return true;
     },
 
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.ResourceView.prototype.show.call(this, parentElement);
         this._createContentIfNeeded();
     },
 
index 3157da6d29bae3e5b21607dfee5b4d08c93a76b7..6f6617ff51b956df058bb5d9719ffaf0c71f160c 100644 (file)
@@ -61,9 +61,9 @@ WebInspector.NetworkItemView = function(resource)
 }
 
 WebInspector.NetworkItemView.prototype = {
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.TabbedPane.prototype.show.call(this, parentElement);
+        WebInspector.TabbedPane.prototype.wasShown.call();
         this._selectTab();
     },
 
@@ -116,19 +116,11 @@ WebInspector.ResourceContentView.prototype = {
         this._innerView = innerView;
     },
 
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.ResourceView.prototype.show.call(this, parentElement);
         this._ensureInnerViewShown();
     },
 
-    hide: function()
-    {
-        if (this._innerView)
-            this._innerView.hide();
-        WebInspector.ResourceView.prototype.hide.call(this);
-    },
-
     _ensureInnerViewShown: function()
     {
         if (this._innerViewShowRequested)
index ed8e76554845aa0aec90adce8b4e5f6830b94932..83c83e6b31a5d590faecdd80792338b33bdbc91a 100644 (file)
@@ -506,7 +506,7 @@ WebInspector.NetworkLogView.prototype = {
 
         this._needsRefresh = true;
 
-        if (this.visible && !("_refreshTimeout" in this))
+        if (this.isShowing() && !this._refreshTimeout)
             this._refreshTimeout = setTimeout(this.refresh.bind(this), this._defaultRefreshDelay);
     },
 
@@ -524,7 +524,7 @@ WebInspector.NetworkLogView.prototype = {
         }
 
         var proceed = true;
-        if (!this.visible) {
+        if (!this.isShowing()) {
             this._scheduleRefresh();
             proceed = false;
         } else
@@ -646,20 +646,18 @@ WebInspector.NetworkLogView.prototype = {
 
     wasShown: function()
     {
-        WebInspector.View.prototype.wasShown.call(this);
         this._refreshIfNeeded();
     },
 
     willHide: function()
     {
-        WebInspector.View.prototype.willHide.call(this);
         this._popoverHelper.hidePopover();
     },
 
     refresh: function()
     {
         this._needsRefresh = false;
-        if ("_refreshTimeout" in this) {
+        if (this._refreshTimeout) {
             clearTimeout(this._refreshTimeout);
             delete this._refreshTimeout;
         }
@@ -1297,9 +1295,9 @@ WebInspector.NetworkPanel.prototype = {
         WebInspector.Panel.prototype.handleShortcut.call(this, event);
     },
 
-    show: function()
+    wasShown: function()
     {
-        WebInspector.Panel.prototype.show.call(this);
+        WebInspector.Panel.prototype.wasShown.call(this);
         this._networkLogView.show(this.sidebarElement);
     },
 
index 996e128b00e595680aea306f60614f85d5e3b66d..d88231ed60f7230a88c3e1f087051f09007f09dd 100644 (file)
@@ -41,7 +41,6 @@ WebInspector.Panel = function(name)
     this._shortcuts = {};
 
     WebInspector.settings[this._sidebarWidthSettingName()] = WebInspector.settings.createSetting(this._sidebarWidthSettingName(), undefined);
-    this._hideOnDetach = false;
 }
 
 // Should by in sync with style declarations.
@@ -62,18 +61,13 @@ WebInspector.Panel.prototype = {
         return this._panelName;
     },
 
-    setHideOnDetach: function()
+    show: function()
     {
-        this._hideOnDetach = true;
+        WebInspector.View.prototype.show.call(this, WebInspector.mainPanelsView.element);
     },
 
-    show: function()
+    wasShown: function()
     {
-        if (!WebInspector.Panel._mainPanelsElement)
-            WebInspector.Panel._mainPanelsElement = document.getElementById("main-panels");
-    
-        WebInspector.View.prototype.show.call(this, WebInspector.Panel._mainPanelsElement);
-
         var statusBarItems = this.statusBarItems;
         if (statusBarItems) {
             this._statusBarItemContainer = document.createElement("div");
@@ -91,13 +85,8 @@ WebInspector.Panel.prototype = {
         WebInspector.extensionServer.notifyPanelShown(this.name);
     },
 
-    detach: function()
+    willHide: function()
     {
-        if (this._hideOnDetach)
-            this.hide();
-        else
-            WebInspector.View.prototype.detach.call(this);
-
         if (this._statusBarItemContainer && this._statusBarItemContainer.parentNode)
             this._statusBarItemContainer.parentNode.removeChild(this._statusBarItemContainer);
         delete this._statusBarItemContainer;
index 459e0ccc9bae4d3de248462d91f75581354ff1f4..3ef0c0c0d250b780c2928188511292a2f0039155 100644 (file)
@@ -83,13 +83,6 @@ WebInspector.PanelEnablerView.prototype = {
         this.dispatchEventToListeners("enable clicked");
     },
 
-    show: function(parentElement)
-    {
-        WebInspector.View.prototype.show.call(this, parentElement);
-
-        setTimeout(this.doResize.bind(this), 0);
-    },
-
     onResize: function()
     {
         this.imageElement.removeStyleClass("hidden");
index 011c01b6df9ff55658be908acb038d4beb16905e..5904ac631f1c4c5371dfd51778b7f534844d03ee 100644 (file)
@@ -164,9 +164,8 @@ WebInspector.CPUProfileView.prototype = {
         return this._bottomUpTree;
     },
 
-    hide: function()
+    willHide: function()
     {
-        WebInspector.View.prototype.hide.call(this);
         this._currentSearchResultIndex = -1;
     },
 
index ea141cd6e1ff622205aa6f6039bafe4e4b6176e0..e4ab929701ea14c5b6025b8e50a1ec3ec7a10ead 100644 (file)
@@ -103,8 +103,6 @@ WebInspector.ProfilesPanel = function()
     this.panelEnablerView = new WebInspector.PanelEnablerView("profiles", panelEnablerHeading, panelEnablerDisclaimer, panelEnablerButton);
     this.panelEnablerView.addEventListener("enable clicked", this._enableProfiling, this);
 
-    this.element.appendChild(this.panelEnablerView.element);
-
     this.profileViews = document.createElement("div");
     this.profileViews.id = "profile-views";
     this.element.appendChild(this.profileViews);
@@ -119,7 +117,6 @@ WebInspector.ProfilesPanel = function()
     this.profileViewStatusBarItemsContainer.className = "status-bar-items";
 
     this.welcomeView = new WebInspector.WelcomeView("profiles", WebInspector.UIString("Welcome to the Profiles panel"));
-    this.element.appendChild(this.welcomeView.element);
 
     this._profiles = [];
     this._profilerEnabled = Preferences.profilerAlwaysEnabled;
@@ -171,9 +168,9 @@ WebInspector.ProfilesPanel.prototype = {
         return items;
     },
 
-    show: function()
+    wasShown: function()
     {
-        WebInspector.Panel.prototype.show.call(this);
+        WebInspector.Panel.prototype.wasShown.call(this);
         this._populateProfiles();
     },
 
@@ -185,7 +182,7 @@ WebInspector.ProfilesPanel.prototype = {
         this._profilerEnabled = true;
 
         this._reset();
-        if (this.visible)
+        if (this.isShowing())
             this._populateProfiles();
     },
 
@@ -346,7 +343,7 @@ WebInspector.ProfilesPanel.prototype = {
 
         sidebarParent.appendChild(profileTreeElement);
         if (!profile.isTemporary) {
-            this.welcomeView.hide();
+            this.welcomeView.detach();
             if (!this.visibleView)
                 this.showProfile(profile);
             this.dispatchEventToListeners("profile added");
@@ -753,7 +750,7 @@ WebInspector.ProfilesPanel.prototype = {
                 this._profileTypeButtonsByIdMap[typeId].removeStyleClass("hidden");
             this.profileViewStatusBarItemsContainer.removeStyleClass("hidden");
             this.clearResultsButton.element.removeStyleClass("hidden");
-            this.panelEnablerView.visible = false;
+            this.panelEnablerView.detach();
         } else {
             this.enableToggleButton.title = WebInspector.UIString("Profiling disabled. Click to enable.");
             this.enableToggleButton.toggled = false;
@@ -761,7 +758,7 @@ WebInspector.ProfilesPanel.prototype = {
                 this._profileTypeButtonsByIdMap[typeId].addStyleClass("hidden");
             this.profileViewStatusBarItemsContainer.addStyleClass("hidden");
             this.clearResultsButton.element.addStyleClass("hidden");
-            this.panelEnablerView.visible = true;
+            this.panelEnablerView.show(this.element);
         }
     },
 
@@ -870,7 +867,7 @@ WebInspector.ProfilesPanel.prototype = {
         profileType.treeElement = oldProfileType.treeElement;
         this._profileTypesByIdMap[profileType.id] = profileType;
         Preferences.detailedHeapProfiles = true;
-        this.hide();
+        this.detach();
         this.show();
     }
 }
index 5ef5598ce9dac3a2b1fec1c666102cc15d0515f7..652692f976392eae4dd5cfc45293ae507e7a251d 100644 (file)
@@ -44,21 +44,18 @@ WebInspector.ResourceCookiesView = function(resource)
 }
 
 WebInspector.ResourceCookiesView.prototype = {
-    show: function(parentElement)
+    wasShown: function()
     {
         if (!this._gotCookies) {
             if (!this._emptyView) {
                 this._emptyView = new WebInspector.EmptyView(WebInspector.UIString("This request has no cookies."));
                 this._emptyView.show(this.element);
             }
-            WebInspector.View.prototype.show.call(this, parentElement);
             return;
         }
 
         if (!this._cookiesTable)
             this._buildCookiesTable();
-        WebInspector.View.prototype.show.call(this, parentElement);
-        this._cookiesTable.updateWidths();
     },
 
     onResize: function()
@@ -85,7 +82,7 @@ WebInspector.ResourceCookiesView.prototype = {
     _refreshCookies: function()
     {
         delete this._cookiesTable;
-        if (!this._gotCookies || !this.visible)
+        if (!this._gotCookies || !this.isShowing())
             return;
         this._buildCookiesTable();
         this._cookiesTable.updateWidths();
index 933ff84733a98f06528e3e7043516a9a2bcb3e1b..9c4b55ee36e25b955a83055bfde6db09bb6ecd01 100644 (file)
@@ -44,15 +44,13 @@ WebInspector.ResourceHTMLView.prototype = {
         return true;
     },
 
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.ResourceView.prototype.show.call(this, parentElement);
         this._createIFrame();
     },
 
-    hide: function(parentElement)
+    willHide: function(parentElement)
     {
-        WebInspector.ResourceView.prototype.hide.call(this);
         this.element.removeChildren();
     },
 
index dd36db9de395b2ad24b19d2b6007424a7d53792e..4f20f2f8dba22f82913e390b565a9254150c6c23 100644 (file)
@@ -82,9 +82,8 @@ WebInspector.ResourceJSONView.prototype = {
         return true;
     },
 
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.ResourceView.prototype.show.call(this, parentElement);
         this._initialize();
     },
 
index 9b95c69c0aa13207b3f944cdfdaf8637806d9f3a..f1c86d183550d5ba68deedbde088c71387f1e74c 100644 (file)
@@ -43,7 +43,7 @@ WebInspector.ResourceTimingView = function(resource)
 }
 
 WebInspector.ResourceTimingView.prototype = {
-    show: function(parentElement)
+    wasShown: function()
     {
         if (!this._resource.timing) {
             if (!this._emptyView) {
@@ -51,7 +51,6 @@ WebInspector.ResourceTimingView.prototype = {
                 this._emptyView.show(this.element);
                 this.innerView = this._emptyView;
             }
-            WebInspector.View.prototype.show.call(this, parentElement);
             return;
         }
 
@@ -61,7 +60,6 @@ WebInspector.ResourceTimingView.prototype = {
         }
 
         this._refresh();
-        WebInspector.View.prototype.show.call(this, parentElement);
     },
 
     _refresh: function()
index 1cc604369fd28bdea8a681b5fa14607c20592c92..5380f26d2b26dc812011a5cc64fc03cf07b9c8c8 100644 (file)
@@ -104,10 +104,9 @@ WebInspector.ResourcesPanel.prototype = {
         return [this.sidebarElement];
     },
 
-    show: function()
+    wasShown: function()
     {
-        WebInspector.Panel.prototype.show.call(this);
-
+        WebInspector.Panel.prototype.wasShown.call(this);
         this._populateResourceTree();
     },
 
@@ -165,7 +164,9 @@ WebInspector.ResourcesPanel.prototype = {
         this.sessionStorageListTreeElement.removeChildren();
         this.cookieListTreeElement.removeChildren();
         this.applicationCacheListTreeElement.removeChildren();
-        this.storageViews.removeChildren();
+
+        if (this.visibleView)
+            this.visibleView.detach();
 
         this.storageViewStatusBarItemsContainer.removeChildren();
 
@@ -1335,7 +1336,7 @@ WebInspector.FrameResourceTreeElement.prototype = {
         var oldView = this._sourceView;
         var newView = this._createSourceView();
 
-        var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null;
+        var oldViewParentNode = oldView.isShowing() ? oldView.element.parentNode : null;
         newView.inheritScrollPositions(oldView);
 
         this._sourceView.detach();
index 5c444e7a1a2cdfe80524524ddf0f58130639feb4..70679d0100ca80ce42e85885658558415d11dc39 100644 (file)
@@ -142,7 +142,6 @@ WebInspector.ScriptsPanel = function(presentationModel)
     this.panelEnablerView = new WebInspector.PanelEnablerView("scripts", panelEnablerHeading, panelEnablerDisclaimer, panelEnablerButton);
     this.panelEnablerView.addEventListener("enable clicked", this._enableDebugging, this);
 
-    this.element.appendChild(this.panelEnablerView.element);
     this.element.appendChild(this.viewsContainerElement);
     this.element.appendChild(this.sidebarElement);
     this.element.appendChild(this.sidebarResizeElement);
@@ -218,9 +217,9 @@ WebInspector.ScriptsPanel.prototype = {
         return this._paused;
     },
 
-    show: function()
+    wasShown: function()
     {
-        WebInspector.Panel.prototype.show.call(this);
+        WebInspector.Panel.prototype.wasShown.call(this);
         this.sidebarResizeElement.style.right = (this.sidebarElement.offsetWidth - 3) + "px";
         if (Preferences.nativeInstrumentationEnabled)
             this.sidebarElement.insertBefore(this.sidebarPanes.domBreakpoints.element, this.sidebarPanes.xhrBreakpoints.element);
@@ -855,12 +854,12 @@ WebInspector.ScriptsPanel.prototype = {
             this.enableToggleButton.title = WebInspector.UIString("Debugging enabled. Click to disable.");
             this.enableToggleButton.toggled = true;
             this._pauseOnExceptionButton.visible = true;
-            this.panelEnablerView.visible = false;
+            this.panelEnablerView.detach();
         } else {
             this.enableToggleButton.title = WebInspector.UIString("Debugging disabled. Click to enable.");
             this.enableToggleButton.toggled = false;
             this._pauseOnExceptionButton.visible = false;
-            this.panelEnablerView.visible = true;
+            this.panelEnablerView.show(this.element);
         }
 
         if (this._paused) {
@@ -1024,11 +1023,11 @@ WebInspector.ScriptsPanel.prototype = {
         if (this.toggleBreakpointsButton.toggled) {
             DebuggerAgent.setBreakpointsActive(true);
             this.toggleBreakpointsButton.title = WebInspector.UIString("Deactivate all breakpoints.");
-            document.getElementById("main-panels").removeStyleClass("breakpoints-deactivated");
+            WebInspector.mainPanelsView.element.removeStyleClass("breakpoints-deactivated");
         } else {
             DebuggerAgent.setBreakpointsActive(false);
             this.toggleBreakpointsButton.title = WebInspector.UIString("Activate all breakpoints.");
-            document.getElementById("main-panels").addStyleClass("breakpoints-deactivated");
+            WebInspector.mainPanelsView.element.addStyleClass("breakpoints-deactivated");
         }
     },
 
index 4ead70d0e7c9d690bf61e4d0d006d723f033334f..d5db8825c3c9f6c458afc17eaad60c6522b5a14b 100644 (file)
@@ -44,7 +44,6 @@ WebInspector.SourceFrame = function(delegate, url)
 
     var textViewerDelegate = new WebInspector.TextViewerDelegateForSourceFrame(this);
     this._textViewer = new WebInspector.TextViewer(this._textModel, WebInspector.platform, this._url, textViewerDelegate);
-    this.element.appendChild(this._textViewer.element);
 
     this.popoverHelper = new WebInspector.ObjectPopoverHelper(this._textViewer.element,
             this._getPopoverAnchor.bind(this), this.onShowPopover.bind(this), this.onHidePopover.bind(this), true);
@@ -88,9 +87,8 @@ WebInspector.SourceFrame.createSearchRegex = function(query)
 
 
 WebInspector.SourceFrame.prototype = {
-    show: function(parentElement)
+    wasShown: function()
     {
-        WebInspector.View.prototype.show.call(this, parentElement);
         this._ensureContentLoaded();
         this._textViewer.show(this.element);
     },
index 57903388a46c45d35beeb978c4a79dac0cc4d103..be2c8c05cd41c4f3c7c93640ea0118e8e61ef1d6 100644 (file)
@@ -49,7 +49,6 @@ WebInspector.TabbedPane.prototype = {
         tabElement.addEventListener("click", this.selectTab.bind(this, id, true), false);
 
         this._tabsElement.appendChild(tabElement);
-        this._contentElement.appendChild(view.element);
 
         this._tabs[id] = { tabElement: tabElement, view: view };
     },
index 93fdcc53bc948a9aa0ac00ea1028e99ad9a8b5a2..67422559eb1cde75a9501e786d44f2431ed23bb6 100644 (file)
@@ -550,18 +550,18 @@ WebInspector.TimelinePanel.prototype = {
         return [this._containerElement];
     },
 
-    show: function()
+    wasShown: function()
     {
-        WebInspector.Panel.prototype.show.call(this);
+        WebInspector.Panel.prototype.wasShown.call(this);
         this._refresh();
         WebInspector.drawer.currentPanelCounters = this.recordsCounter;
     },
 
-    hide: function()
+    willHide: function()
     {
-        WebInspector.Panel.prototype.hide.call(this);
         this._closeRecordDetails();
         WebInspector.drawer.currentPanelCounters = null;
+        WebInspector.Panel.prototype.willHide.call(this);
     },
 
     _onScroll: function(event)
@@ -584,7 +584,7 @@ WebInspector.TimelinePanel.prototype = {
         this._closeRecordDetails();
         this._boundariesAreValid &= preserveBoundaries;
 
-        if (!this.visible)
+        if (!this.isShowing())
             return;
 
         if (preserveBoundaries)
index 61b92f2608875e19c8e4178d4700f8433d36546e..d8c8a248da5bb6ab920c6acc33a2b0eef7e2bf13 100644 (file)
 WebInspector.View = function()
 {
     this.element = document.createElement("div");
-    this.element.addEventListener("DOMNodeInsertedIntoDocument", this._handleInsertedIntoDocument.bind(this), false);
-    this.element.addEventListener("DOMNodeRemovedFromDocument", this._handleRemovedFromDocument.bind(this), false);
     this.element.__view = this;
-    this._visible = false;
+    this._visible = true;
+    this._isRoot = false;
+    this._isShowing = false;
     this._children = [];
-    this._inDetach = false;
+    this._hideOnDetach = false;
 }
 
 WebInspector.View.prototype = {
-    get visible()
+    markAsRoot: function()
     {
-        return this._visible;
+        this._isRoot = true;
     },
 
-    set visible(x)
+    isShowing: function()
     {
-        if (this._visible === x)
-            return;
+        return this._isShowing;
+    },
 
-        if (x)
-            this.show(this.element.parentElement);
-        else
-            this.hide();
+    setHideOnDetach: function()
+    {
+        this._hideOnDetach = true;
     },
 
-    wasShown: function()
+    _parentIsShowing: function()
+    {
+        return this._isRoot || (this._parentView && this._parentView.isShowing());
+    },
+
+    _processWasShown: function()
     {
+        if (!this._parentIsShowing())
+            return;
+
+        this._isShowing = true;
         this.restoreScrollPositions();
+
+        this.wasShown();
         this.onResize();
+        for (var i = 0; i < this._children.length; ++i)
+            this._children[i]._processWasShown();
     },
 
-    willHide: function()
+    _processWillHide: function()
     {
+        if (!this._parentIsShowing())
+            return;
+
         this.storeScrollPositions();
+
+        for (var i = 0; i < this._children.length; ++i)
+            this._children[i]._processWillHide();
+
+        this.willHide();
+        this._isShowing = false;
     },
 
-    willDetach: function()
+    _processOnResize: function()
     {
+        if (!this.isShowing())
+            return;
+
+        this.onResize();
+        for (var i = 0; i < this._children.length; ++i)
+            this._children[i]._processOnResize();
     },
 
-    /**
-     * @param {Element} parentElement
-     */
-    show: function(parentElement)
+    wasShown: function()
+    {
+    },
+
+    willHide: function()
     {
-        this._visible = true;
-        this.element.addStyleClass("visible");
-        if (parentElement && this.element.parentElement != parentElement)
-            this.attach(parentElement);
-        this.dispatchToSelfAndChildren("wasShown", true);
     },
 
-    hide: function()
+    onResize: function()
     {
-        this.dispatchToSelfAndChildren("willHide", true);
-        if (!this._inDetach)
-            this.element.removeStyleClass("visible");
-        this._visible = false;
     },
 
     /**
      * @param {Element} parentElement
+     * @param {Element=} insertBefore
      */
-    attach: function(parentElement)
+    show: function(parentElement, insertBefore)
     {
-        parentElement.appendChild(this.element);
+        WebInspector.View._assert(parentElement, "Attempt to attach view with no parent element");
+
+        this._visible = true;
+        this.element.addStyleClass("visible");
+
+        if (this.element.parentElement === parentElement) {
+            this._processWasShown();
+            return;
+        }
+
+        // Force legal append
+        WebInspector.View._incrementViewCounter(parentElement, this.element);
+        if (insertBefore)
+            WebInspector.View._originalInsertBefore.call(parentElement, this.element, insertBefore);
+        else
+            WebInspector.View._originalAppendChild.call(parentElement, this.element);
+
+        // Update view hierarchy
+        var currentParent = parentElement;
+        while (currentParent && !currentParent.__view)
+            currentParent = currentParent.parentElement;
+
+        if (currentParent) {
+            this._parentView = currentParent.__view;
+            this._parentView._children.push(this);
+            this._isRoot = false;
+        } else
+            WebInspector.View._assert(this._isRoot, "Attempt to attach view to orphan node");
+
+        this._processWasShown();
     },
 
     detach: function()
     {
-        if (this._visible) {
-            this._inDetach = true;
-            this.hide();
-            this._inDetach = false;
+        var parentElement = this.element.parentElement;
+        if (!parentElement)
+            return;
+
+        this._processWillHide();
+
+        if (this._hideOnDetach) {
+            this.element.removeStyleClass("visible");
+            return;
         }
 
-        this.dispatchToSelfAndChildren("willDetach", false);
+        // Force legal removal
+        WebInspector.View._decrementViewCounter(parentElement, this.element);
+        WebInspector.View._originalRemoveChild.call(parentElement, this.element);
+
+        // Update view hierarchy
+        if (this._parentView) {
+            var childIndex = this._parentView._children.indexOf(this);
+            WebInspector.View._assert(childIndex >= 0, "Attempt to remove non-child view");
+            this._parentView._children.splice(childIndex, 1);
+            this._parentView = null;
+        }
 
-        if (this.element.parentElement)
-            this.element.parentElement.removeChild(this.element);
+        this._visible = false;
     },
 
     elementsToRestoreScrollPositionsFor: function()
@@ -140,28 +203,6 @@ WebInspector.View.prototype = {
         }
     },
 
-    _addChildView: function(view)
-    {
-        this._children.push(view);
-        view._parentView = this;
-    },
-
-    _removeChildView: function(view)
-    {
-        var childIndex = this._children.indexOf(view);
-        if (childIndex < 0) {
-            console.error("Attempt to remove non-child view");
-            return;
-        }
-
-        this._children.splice(childIndex, 1);
-        view._parentView = null;
-    },
-
-    onResize: function()
-    {
-    },
-
     canHighlightLine: function()
     {
         return false;
@@ -173,45 +214,7 @@ WebInspector.View.prototype = {
 
     doResize: function()
     {
-        this.dispatchToSelfAndChildren("onResize", true);
-    },
-
-    dispatchToSelfAndChildren: function(methodName, visibleOnly)
-    {
-        if (visibleOnly && !this.visible)
-            return;
-        if (typeof this[methodName] === "function")
-            this[methodName].call(this);
-        this.dispatchToChildren(methodName, visibleOnly);
-    },
-
-    dispatchToChildren: function(methodName, visibleOnly)
-    {
-        if (visibleOnly && !this.visible)
-            return;
-        for (var i = 0; i < this._children.length; ++i)
-            this._children[i].dispatchToSelfAndChildren(methodName, visibleOnly);
-    },
-
-    _handleInsertedIntoDocument: function(event)
-    {
-        var parentElement = this.element.parentElement;
-        while (parentElement && !parentElement.__view)
-            parentElement = parentElement.parentElement;
-
-        var parentView = parentElement ? parentElement.__view : WebInspector._rootView;
-        parentView._addChildView(this);
-        this.onInsertedIntoDocument();
-    },
-
-    onInsertedIntoDocument: function()
-    {
-    },
-
-    _handleRemovedFromDocument: function(event)
-    {
-        if (this._parentView)
-            this._parentView._removeChildView(this);
+        this._processOnResize();
     },
 
     printViewHierarchy: function()
@@ -235,4 +238,64 @@ WebInspector.View.prototype = {
 
 WebInspector.View.prototype.__proto__ = WebInspector.Object.prototype;
 
-WebInspector._rootView = new WebInspector.View();
+WebInspector.View._originalAppendChild = Element.prototype.appendChild;
+WebInspector.View._originalInsertBefore = Element.prototype.insertBefore;
+WebInspector.View._originalRemoveChild = Element.prototype.removeChild;
+WebInspector.View._originalRemoveChildren = Element.prototype.removeChildren;
+
+WebInspector.View._incrementViewCounter = function(parentElement, childElement)
+{
+    var count = (childElement.__viewCounter || 0) + (childElement.__view ? 1 : 0);
+    if (!count)
+        return;
+
+    while (parentElement) {
+        parentElement.__viewCounter = (parentElement.__viewCounter || 0) + count;
+        parentElement = parentElement.parentElement;
+    }
+}
+
+WebInspector.View._decrementViewCounter = function(parentElement, childElement)
+{
+    var count = (childElement.__viewCounter || 0) + (childElement.__view ? 1 : 0);
+    if (!count)
+        return;
+
+    while (parentElement) {
+        parentElement.__viewCounter -= count;
+        parentElement = parentElement.parentElement;
+    }
+}
+
+WebInspector.View._assert = function(condition, message)
+{
+    if (!condition) {
+        console.trace();
+        throw new Error(message);
+    }
+}
+
+Element.prototype.appendChild = function(child)
+{
+    WebInspector.View._assert(!child.__view, "Attempt to add view via regular DOM operation.");
+    return WebInspector.View._originalAppendChild.call(this, child);
+}
+
+Element.prototype.insertBefore = function(child, anchor)
+{
+    WebInspector.View._assert(!child.__view, "Attempt to add view via regular DOM operation.");
+    return WebInspector.View._originalInsertBefore.call(this, child, anchor);
+}
+
+
+Element.prototype.removeChild = function(child)
+{
+    WebInspector.View._assert(!child.__viewCounter && !child.__view, "Attempt to remove element containing view via regular DOM operation");
+    return WebInspector.View._originalRemoveChild.call(this, child);
+}
+
+Element.prototype.removeChildren = function()
+{
+    WebInspector.View._assert(!this.__viewCounter, "Attempt to remove element containing view via regular DOM operation");
+    WebInspector.View._originalRemoveChildren.call(this);
+}
index df68c6b94bb2c0bb3b58e49039b40d071e45d3ad..9af89aa834f07b371053e59726332c5b449e557d 100644 (file)
@@ -35,6 +35,7 @@ console.warn = function(vararg) {}
 console.assert = function(vararg) {}
 /** @param {...*} vararg */
 console.error = function(vararg) {}
+console.trace = function() {}
 
 var WebInspector = {}
 
@@ -278,3 +279,8 @@ function ExtensionDescriptor() {
  * @type {WebInspector.HandlerRegistry}
  */
 WebInspector.openAnchorLocationRegistry = null;
+
+/**
+ * @type {WebInspector.View}
+ */
+WebInspector.mainPanelsView;
index e069615f7b86179216814a99a588b2f222ace8bd..d509def591685da9fd9e2a14e559557fb8127ad8 100644 (file)
@@ -199,7 +199,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
         </div>
     </div>
     <div id="main">
-        <div id="main-panels" spellcheck="false"></div>
         <div id="main-status-bar" class="status-bar"><div id="anchored-status-bar-items"><div id="counters"><div id="error-warning-count" class="hidden"></div></div></div></div>
     </div>
     <div id="drawer"></div>
index f0ace9c638d4892891cb4bda284279ecf5066e1d..8f20375d544b41eb679a1c483bd53dfb008371bc 100644 (file)
@@ -150,6 +150,13 @@ var WebInspector = {
 
     _createPanels: function()
     {
+        WebInspector.mainPanelsView = new WebInspector.View();
+        WebInspector.mainPanelsView.markAsRoot();
+        WebInspector.mainPanelsView.element.id = "main-panels";
+        WebInspector.mainPanelsView.element.setAttribute("spellcheck", false);
+        var parentElement = document.getElementById("main");
+        WebInspector.mainPanelsView.show(parentElement);
+
         if (WebInspector.WorkerManager.isWorkerFrontend()) {
             this.panels.scripts = new WebInspector.ScriptsPanel(this.debuggerPresentationModel);
             this.panels.console = new WebInspector.ConsolePanel();