Web Inspector: build Elements, Resources, Timeline, Audits and Console panels lazily.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Aug 2012 09:08:56 +0000 (09:08 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Aug 2012 09:08:56 +0000 (09:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=94222

Reviewed by Vsevolod Vlasov.

Source/WebCore:

There is no need to construct these panels on inspector startup - we can do that lazily.
This change introduces the concept of PanelDescriptor that is sufficient for the panel
representation before it has been selected. It also makes selected panels build lazily.

The next step is to migrate rest of the panels and load the panel code lazily as well.
That should speed up startup time significantly.

* inspector/front-end/AuditsPanel.js:
(WebInspector.AuditsPanel):
(WebInspector.AuditsPanel.prototype._auditFinishedCallback):
(WebInspector.AuditsSidebarTreeElement):
(WebInspector.AuditsSidebarTreeElement.prototype.onselect):
(WebInspector.AuditResultSidebarTreeElement):
(WebInspector.AuditResultSidebarTreeElement.prototype.onselect):
* inspector/front-end/ConsolePanel.js:
* inspector/front-end/DOMStorage.js:
(WebInspector.DOMStorageDispatcher.prototype.addDOMStorage):
(WebInspector.DOMStorageDispatcher.prototype.domStorageUpdated):
* inspector/front-end/Database.js:
(WebInspector.DatabaseDispatcher.prototype.addDatabase):
* inspector/front-end/ElementsPanel.js:
(WebInspector.ElementsPanel):
(WebInspector.ElementsPanel.prototype.revealAndSelectNode):
(WebInspector.ElementsPanel.prototype.setSearchingForNode):
(WebInspector.ElementsPanel.prototype.toggleSearchingForNode):
* inspector/front-end/ElementsTreeOutline.js:
(WebInspector.ElementsTreeElement.prototype._populateForcedPseudoStateItems):
* inspector/front-end/ExtensionPanel.js:
(WebInspector.ExtensionPanel):
(WebInspector.ExtensionPanel.prototype.jumpToPreviousSearchResult):
* inspector/front-end/ExtensionServer.js:
(WebInspector.ExtensionServer.prototype._onCreatePanel):
(WebInspector.ExtensionServer.prototype._onAddAuditCategory):
* inspector/front-end/InspectorFrontendAPI.js:
(InspectorFrontendAPI.isTimelineProfilingEnabled):
(InspectorFrontendAPI.setTimelineProfilingEnabled):
(InspectorFrontendAPI.showConsole):
(InspectorFrontendAPI.showResources):
(InspectorFrontendAPI.enterInspectElementMode):
* inspector/front-end/InspectorView.js:
(WebInspector.InspectorView):
(WebInspector.InspectorView.prototype.addPanel):
(WebInspector.InspectorView.prototype.panel):
(WebInspector.InspectorView.prototype.showPanel):
(WebInspector.InspectorView.prototype._keyDownInternal):
* inspector/front-end/NetworkPanel.js:
* inspector/front-end/Panel.js:
(WebInspector.Panel.prototype.wasShown):
(WebInspector.Panel.prototype.willHide):
(WebInspector.PanelDescriptor):
(WebInspector.PanelDescriptor.prototype.name):
(WebInspector.PanelDescriptor.prototype.title):
(WebInspector.PanelDescriptor.prototype.iconURL):
(WebInspector.PanelDescriptor.prototype.setIconURL):
(WebInspector.PanelDescriptor.prototype.panel):
(WebInspector.PanelDescriptor.prototype.lazy):
* inspector/front-end/ProfilesPanel.js:
* inspector/front-end/ResourceTreeModel.js:
(WebInspector.ResourceTreeModel.prototype.cachedResourcesLoaded):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourcesPanel):
* inspector/front-end/ScriptsPanel.js:
* inspector/front-end/StylesSidebarPane.js:
(WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted.successCallback):
(WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted):
(WebInspector.StylePropertyTreeElement.prototype.updateTitle.linkifyURL):
* inspector/front-end/TimelinePanel.js:
* inspector/front-end/Toolbar.js:
(WebInspector.Toolbar.prototype.addPanel):
(WebInspector.Toolbar.prototype._createPanelToolbarItem.onToolbarItemClicked):
(WebInspector.Toolbar.prototype._createPanelToolbarItem.panelSelected):
(WebInspector.Toolbar.prototype._createPanelToolbarItem):
(WebInspector.Toolbar.prototype._panelSelected):
(WebInspector.Toolbar.prototype._setDropdownVisible):
(WebInspector.ToolbarDropdown):
(WebInspector.ToolbarDropdown.prototype.show):
(WebInspector.ToolbarDropdown.prototype._populate):
* inspector/front-end/inspector.css:
(.toolbar-small .toolbar-icon.custom-toolbar-icon):
* inspector/front-end/inspector.js:
(WebInspector._panelDescriptors):
(WebInspector._panelSelected):
(WebInspector._createGlobalStatusBarItems):
(WebInspector.documentClick.followLink):
(WebInspector.documentClick):
(WebInspector.openResource):
(WebInspector.showPanel):
(WebInspector.panel):
(WebInspector.inspect.):
(WebInspector.inspect):
(WebInspector._showAnchorLocation):
(WebInspector.showProfileForURL):
(WebInspector.frontendReused):

LayoutTests:

* http/tests/inspector/elements-test.js:
(initialize_ElementTest.InspectorTest.selectNodeWithId.onNodeFound):
(initialize_ElementTest.InspectorTest.selectNodeWithId):
(initialize_ElementTest.InspectorTest.expandElementsTree):
* http/tests/inspector/extensions-test.js:
(initialize_ExtensionsTest.InspectorTest.showPanel):
* http/tests/inspector/inspect-element.html:
* http/tests/inspector/resource-har-pages.html:
* http/tests/inspector/resource-tree/resource-tree-frame-add.html:
* http/tests/inspector/resource-tree/resource-tree-non-unique-url.html:
* http/tests/inspector/resource-tree/resource-tree-reload.html:
* http/tests/inspector/resource-tree/resource-tree-test.js:
(initialize_ResourceTreeTest.InspectorTest.dumpResourcesTree):
* inspector/console/command-line-api-inspect.html:
* inspector/debugger/dom-breakpoints.html:
* inspector/debugger/source-frame.html:
* inspector/elements/edit-dom-actions.html:
* inspector/elements/elements-img-tooltip.html:
* inspector/elements/elements-panel-limited-children.html:
* inspector/elements/highlight-node-scaled.html:
* inspector/extensions/extensions-panel.html:
* inspector/extensions/extensions-sidebar.html:
* inspector/styles/force-pseudo-state.html:
* inspector/styles/set-property-boundaries.html:
* inspector/styles/styles-new-API.html:
* inspector/timeline/timeline-test.js:
(initialize_Timeline.InspectorTest.stopTimeline):

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

45 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/elements-test.js
LayoutTests/http/tests/inspector/extensions-test.js
LayoutTests/http/tests/inspector/inspect-element.html
LayoutTests/http/tests/inspector/resource-har-pages.html
LayoutTests/http/tests/inspector/resource-tree/resource-tree-frame-add.html
LayoutTests/http/tests/inspector/resource-tree/resource-tree-non-unique-url.html
LayoutTests/http/tests/inspector/resource-tree/resource-tree-reload.html
LayoutTests/http/tests/inspector/resource-tree/resource-tree-test.js
LayoutTests/inspector/console/command-line-api-inspect.html
LayoutTests/inspector/debugger/dom-breakpoints.html
LayoutTests/inspector/debugger/source-frame.html
LayoutTests/inspector/elements/edit-dom-actions.html
LayoutTests/inspector/elements/elements-img-tooltip.html
LayoutTests/inspector/elements/elements-panel-limited-children.html
LayoutTests/inspector/elements/highlight-node-scaled.html
LayoutTests/inspector/extensions/extensions-panel.html
LayoutTests/inspector/extensions/extensions-sidebar.html
LayoutTests/inspector/styles/force-pseudo-state.html
LayoutTests/inspector/styles/set-property-boundaries.html
LayoutTests/inspector/styles/styles-new-API.html
LayoutTests/inspector/timeline/timeline-test.js
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/AuditsPanel.js
Source/WebCore/inspector/front-end/ConsolePanel.js
Source/WebCore/inspector/front-end/DOMAgent.js
Source/WebCore/inspector/front-end/DOMStorage.js
Source/WebCore/inspector/front-end/Database.js
Source/WebCore/inspector/front-end/ElementsPanel.js
Source/WebCore/inspector/front-end/ElementsTreeOutline.js
Source/WebCore/inspector/front-end/ExtensionPanel.js
Source/WebCore/inspector/front-end/ExtensionServer.js
Source/WebCore/inspector/front-end/InspectorFrontendAPI.js
Source/WebCore/inspector/front-end/InspectorView.js
Source/WebCore/inspector/front-end/NetworkPanel.js
Source/WebCore/inspector/front-end/Panel.js
Source/WebCore/inspector/front-end/ProfilesPanel.js
Source/WebCore/inspector/front-end/ResourceTreeModel.js
Source/WebCore/inspector/front-end/ResourcesPanel.js
Source/WebCore/inspector/front-end/ScriptsPanel.js
Source/WebCore/inspector/front-end/StylesSidebarPane.js
Source/WebCore/inspector/front-end/TimelinePanel.js
Source/WebCore/inspector/front-end/Toolbar.js
Source/WebCore/inspector/front-end/inspector.css
Source/WebCore/inspector/front-end/inspector.js

index 7e83dba..8c56aa2 100644 (file)
@@ -1,3 +1,38 @@
+2012-08-16  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: build Elements, Resources, Timeline, Audits and Console panels lazily.
+        https://bugs.webkit.org/show_bug.cgi?id=94222
+
+        Reviewed by Vsevolod Vlasov.
+
+        * http/tests/inspector/elements-test.js:
+        (initialize_ElementTest.InspectorTest.selectNodeWithId.onNodeFound):
+        (initialize_ElementTest.InspectorTest.selectNodeWithId):
+        (initialize_ElementTest.InspectorTest.expandElementsTree):
+        * http/tests/inspector/extensions-test.js:
+        (initialize_ExtensionsTest.InspectorTest.showPanel):
+        * http/tests/inspector/inspect-element.html:
+        * http/tests/inspector/resource-har-pages.html:
+        * http/tests/inspector/resource-tree/resource-tree-frame-add.html:
+        * http/tests/inspector/resource-tree/resource-tree-non-unique-url.html:
+        * http/tests/inspector/resource-tree/resource-tree-reload.html:
+        * http/tests/inspector/resource-tree/resource-tree-test.js:
+        (initialize_ResourceTreeTest.InspectorTest.dumpResourcesTree):
+        * inspector/console/command-line-api-inspect.html:
+        * inspector/debugger/dom-breakpoints.html:
+        * inspector/debugger/source-frame.html:
+        * inspector/elements/edit-dom-actions.html:
+        * inspector/elements/elements-img-tooltip.html:
+        * inspector/elements/elements-panel-limited-children.html:
+        * inspector/elements/highlight-node-scaled.html:
+        * inspector/extensions/extensions-panel.html:
+        * inspector/extensions/extensions-sidebar.html:
+        * inspector/styles/force-pseudo-state.html:
+        * inspector/styles/set-property-boundaries.html:
+        * inspector/styles/styles-new-API.html:
+        * inspector/timeline/timeline-test.js:
+        (initialize_Timeline.InspectorTest.stopTimeline):
+
 2012-08-17  Zan Dobersek  <zandobersek@gmail.com>
 
         Unreviewed GTK gardening.
index 426d7b1..2722045 100644 (file)
@@ -63,7 +63,7 @@ InspectorTest.selectNodeWithId = function(idValue, callback)
     function onNodeFound(node)
     {
         if (node)
-            WebInspector.updateFocusedNode(node.id);
+            WebInspector._updateFocusedNode(node.id);
         callback(node);
     }
     InspectorTest.nodeWithId(idValue, onNodeFound);
@@ -407,7 +407,7 @@ InspectorTest.expandElementsTree = function(callback)
         expand(WebInspector.panels.elements.treeOutline);
         callback();
     }
-    WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.elements);
+    WebInspector.showPanel("elements");
     InspectorTest.findNode(function() { return false; }, onAllNodesAvailable);
 };
 
index c66c579..3271637 100644 (file)
@@ -36,7 +36,7 @@ window.addEventListener("message", InspectorTest.safeWrap(onMessage), false);
 InspectorTest.showPanel = function(panelId)
 {
     if (panelId === "extension")
-        panelId = WebInspector.inspectorView._panelOrder[WebInspector.inspectorView._panelOrder.length - 1].name;
+        panelId = WebInspector.inspectorView._panelOrder[WebInspector.inspectorView._panelOrder.length - 1];
     WebInspector.showPanel(panelId);
 }
 
index c87baa5..93a3054 100644 (file)
@@ -6,8 +6,8 @@
 
 function test()
 {
-    WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.elements);
-    WebInspector.panels.elements.treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged, selectedNodeChanged, this);
+    WebInspector.showPanel("elements").treeOutline.
+        addEventListener(WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged, selectedNodeChanged, this);
     function selectedNodeChanged(event)
     {
         var node = event.data;
index c57d14e..e5d62c0 100644 (file)
@@ -22,7 +22,7 @@ var test = function()
                 step2();
             }
         }
-        WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.network);
+        WebInspector.showPanel("network");
         var networkLogView = WebInspector.panels.network._networkLogView;
         // networkLogView.clear();
         networkLogView._preserveLogToggle.toggled = true;
index 75b95f8..17dac27 100644 (file)
@@ -23,6 +23,7 @@ function onIframeLoad()
 
 function test()
 {
+    WebInspector.showPanel("resources");
     InspectorTest.runAfterResourcesAreFinished(["resource-tree-frame-add.html", "resource-tree-test.js", "styles-initial.css"], step1);
 
     function step1()
index 9d60156..37f18ca 100644 (file)
@@ -14,7 +14,7 @@ function loadIframe()
 function test()
 {
     InspectorTest.addSniffer(WebInspector.ResourcesPanel.prototype, "_resourceAdded", onResource, true);
-    WebInspector.panels.resources.show();
+    WebInspector.showPanel("resources");
 
     var cssRequestsCount = 0;
     function onResource(event)
index eae7564..0d56b32 100644 (file)
@@ -65,7 +65,7 @@ InspectorTest.dumpResourcesTree = function()
     }
 
     WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.resources);
-    dump(WebInspector.panels.resources.resourcesListTreeElement, "");
+    dump(WebInspector.panel("resources").resourcesListTreeElement, "");
 }
 
 InspectorTest.dumpResourceTreeEverything = function()
index fab85ac..935594d 100644 (file)
@@ -32,7 +32,7 @@ function test()
     InspectorTest.runTestSuite([
         function testRevealElement(next)
         {
-            InspectorTest.addSniffer(WebInspector, "updateFocusedNode", step2);
+            InspectorTest.addSniffer(WebInspector, "_updateFocusedNode", step2);
             evalAndDump("inspect($('p1'))");
 
             function step2()
index 80dd4d9..9fb3836 100644 (file)
@@ -57,7 +57,7 @@ function breakDebugger()
 
 function test()
 {
-    WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.elements);
+    WebInspector.showPanel("elements");
 
     var pane = WebInspector.domBreakpointsSidebarPane;
     var rootElement;
index 4a87906..4f7b666 100644 (file)
@@ -17,7 +17,7 @@ function methodForBreakpoint()
 
 function test()
 {
-    WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.resources);
+    WebInspector.showPanel("resources");
     InspectorTest.runDebuggerTestSuite([
         function testSetBreakpoint(next)
         {
index f6d83fc..bf386e8 100644 (file)
@@ -106,7 +106,7 @@ function test()
                 var childNodes = testNode.children;
                 for (var i = 0; i < childNodes.length; ++i) {
                     if (childNodes[i].nodeType() === 8) {
-                        WebInspector.updateFocusedNode(childNodes[i].id);
+                        WebInspector._updateFocusedNode(childNodes[i].id);
                         callback(childNodes[i]);
                         return;
                     }
index 1e009a4..db0a121 100644 (file)
@@ -7,7 +7,7 @@
 
 var test = function()
 {
-    WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.elements);
+    WebInspector.showPanel("elements");
 
     var treeElement;
     InspectorTest.nodeWithId("image", step1);
index 812877d..d8f1bbd 100644 (file)
@@ -18,7 +18,7 @@ function insertNode()
 function test()
 {
     var dataTreeElement;
-    WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.elements);
+    WebInspector.showPanel("elements");
     InspectorTest.nodeWithId("data", step1);
 
     function step1(node)
index 0e79fcd..93748e2 100644 (file)
@@ -30,7 +30,7 @@ function onload()
     
 function test()
 {
-    WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.elements);
+    WebInspector.showPanel("elements");
     WebInspector.panels.elements.treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged, selectedNodeChanged, this);
 
     function selectedNodeChanged(event)
index 9c25b11..b2240dc 100644 (file)
@@ -12,7 +12,6 @@ function initialize_extensionsPanelTest()
 {
     InspectorTest.getPanelSize = function()
     {
-        var extensionPanel = WebInspector.inspectorView._panelOrder[WebInspector.inspectorView._panelOrder.length - 1];
         var boundingRect = document.getElementById("main-panels").getBoundingClientRect();
         return {
             width: boundingRect.width,
@@ -47,7 +46,7 @@ function initialize_extensionsPanelTest()
     {
         WebInspector.showPanel("console");
         var xpathResult = document.evaluate("//a[starts-with(., 'extensions-panel.html')]",
-                                            WebInspector.panels.console.element, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null);
+                                            WebInspector.panel("console").element, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null);
         var click = document.createEvent("MouseEvent");
         click.initMouseEvent("click", true, true);
         xpathResult.singleNodeValue.dispatchEvent(click);
index 1386506..2d5495d 100644 (file)
@@ -8,7 +8,7 @@ function initialize_extensionsSidebarTest()
 {
     InspectorTest.dumpSidebarContent = function(callback)
     {
-        var sidebarPanes = WebInspector.panels.elements.sidebarPanes;
+        var sidebarPanes = WebInspector.panel("elements").sidebarPanes;
         // the sidebar of interest is presumed to always be last.
         var sidebar = sidebarPanes[Object.keys(sidebarPanes).pop()];
         InspectorTest.runAfterPendingDispatches(function() {
index a6146dd..e95e461 100644 (file)
@@ -6,7 +6,7 @@
 
 function test()
 {
-    WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.elements);
+    WebInspector.showPanel("elements");
 
     InspectorTest.nodeWithId("div", foundDiv);
 
index 92a95d6..d56a15e 100644 (file)
@@ -13,7 +13,7 @@ h1 {
 
 function test()
 {
-    WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.elements);
+    WebInspector.showPanel("elements");
     CSSAgent.getAllStyleSheets(styleSheetInfosLoaded);
 
     function styleSheetInfosLoaded(error, infos)
index d50ba21..5e6f393 100644 (file)
@@ -9,7 +9,7 @@
 
 function test()
 {
-    WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.elements);
+    WebInspector.showPanel("elements");
 
     test_styles();
 
index 9e69935..2199093 100644 (file)
@@ -26,8 +26,8 @@ InspectorTest.timelinePropertyFormatters = {
 InspectorTest.startTimeline = function(callback)
 {
     InspectorTest._timelineRecords = [];
-    WebInspector.panels.timeline.toggleTimelineButton.toggled = true;
-    WebInspector.panels.timeline._model._collectionEnabled = true;
+    WebInspector.panel("timeline").toggleTimelineButton.toggled = true;
+    WebInspector.panel("timeline")._model._collectionEnabled = true;
     TimelineAgent.start(callback);
     function addRecord(record)
     {
@@ -62,8 +62,8 @@ InspectorTest.stopTimeline = function(callback)
 {
     function didStop()
     {
-        WebInspector.panels.timeline.toggleTimelineButton.toggled = false;
-        WebInspector.panels.timeline._model._collectionEnabled = false;
+        WebInspector.panel("timeline").toggleTimelineButton.toggled = false;
+        WebInspector.panel("timeline")._model._collectionEnabled = false;
         callback(InspectorTest._timelineRecords);
     }
     TimelineAgent.stop(didStop);
index 5193464..6bff9a1 100644 (file)
@@ -1,3 +1,104 @@
+2012-08-16  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: build Elements, Resources, Timeline, Audits and Console panels lazily.
+        https://bugs.webkit.org/show_bug.cgi?id=94222
+
+        Reviewed by Vsevolod Vlasov.
+
+        There is no need to construct these panels on inspector startup - we can do that lazily.
+        This change introduces the concept of PanelDescriptor that is sufficient for the panel
+        representation before it has been selected. It also makes selected panels build lazily.
+
+        The next step is to migrate rest of the panels and load the panel code lazily as well.
+        That should speed up startup time significantly.
+
+        * inspector/front-end/AuditsPanel.js:
+        (WebInspector.AuditsPanel):
+        (WebInspector.AuditsPanel.prototype._auditFinishedCallback):
+        (WebInspector.AuditsSidebarTreeElement):
+        (WebInspector.AuditsSidebarTreeElement.prototype.onselect):
+        (WebInspector.AuditResultSidebarTreeElement):
+        (WebInspector.AuditResultSidebarTreeElement.prototype.onselect):
+        * inspector/front-end/ConsolePanel.js:
+        * inspector/front-end/DOMStorage.js:
+        (WebInspector.DOMStorageDispatcher.prototype.addDOMStorage):
+        (WebInspector.DOMStorageDispatcher.prototype.domStorageUpdated):
+        * inspector/front-end/Database.js:
+        (WebInspector.DatabaseDispatcher.prototype.addDatabase):
+        * inspector/front-end/ElementsPanel.js:
+        (WebInspector.ElementsPanel):
+        (WebInspector.ElementsPanel.prototype.revealAndSelectNode):
+        (WebInspector.ElementsPanel.prototype.setSearchingForNode):
+        (WebInspector.ElementsPanel.prototype.toggleSearchingForNode):
+        * inspector/front-end/ElementsTreeOutline.js:
+        (WebInspector.ElementsTreeElement.prototype._populateForcedPseudoStateItems):
+        * inspector/front-end/ExtensionPanel.js:
+        (WebInspector.ExtensionPanel):
+        (WebInspector.ExtensionPanel.prototype.jumpToPreviousSearchResult):
+        * inspector/front-end/ExtensionServer.js:
+        (WebInspector.ExtensionServer.prototype._onCreatePanel):
+        (WebInspector.ExtensionServer.prototype._onAddAuditCategory):
+        * inspector/front-end/InspectorFrontendAPI.js:
+        (InspectorFrontendAPI.isTimelineProfilingEnabled):
+        (InspectorFrontendAPI.setTimelineProfilingEnabled):
+        (InspectorFrontendAPI.showConsole):
+        (InspectorFrontendAPI.showResources):
+        (InspectorFrontendAPI.enterInspectElementMode):
+        * inspector/front-end/InspectorView.js:
+        (WebInspector.InspectorView):
+        (WebInspector.InspectorView.prototype.addPanel):
+        (WebInspector.InspectorView.prototype.panel):
+        (WebInspector.InspectorView.prototype.showPanel):
+        (WebInspector.InspectorView.prototype._keyDownInternal):
+        * inspector/front-end/NetworkPanel.js:
+        * inspector/front-end/Panel.js:
+        (WebInspector.Panel.prototype.wasShown):
+        (WebInspector.Panel.prototype.willHide):
+        (WebInspector.PanelDescriptor):
+        (WebInspector.PanelDescriptor.prototype.name):
+        (WebInspector.PanelDescriptor.prototype.title):
+        (WebInspector.PanelDescriptor.prototype.iconURL):
+        (WebInspector.PanelDescriptor.prototype.setIconURL):
+        (WebInspector.PanelDescriptor.prototype.panel):
+        (WebInspector.PanelDescriptor.prototype.lazy):
+        * inspector/front-end/ProfilesPanel.js:
+        * inspector/front-end/ResourceTreeModel.js:
+        (WebInspector.ResourceTreeModel.prototype.cachedResourcesLoaded):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel):
+        * inspector/front-end/ScriptsPanel.js:
+        * inspector/front-end/StylesSidebarPane.js:
+        (WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted.successCallback):
+        (WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted):
+        (WebInspector.StylePropertyTreeElement.prototype.updateTitle.linkifyURL):
+        * inspector/front-end/TimelinePanel.js:
+        * inspector/front-end/Toolbar.js:
+        (WebInspector.Toolbar.prototype.addPanel):
+        (WebInspector.Toolbar.prototype._createPanelToolbarItem.onToolbarItemClicked):
+        (WebInspector.Toolbar.prototype._createPanelToolbarItem.panelSelected):
+        (WebInspector.Toolbar.prototype._createPanelToolbarItem):
+        (WebInspector.Toolbar.prototype._panelSelected):
+        (WebInspector.Toolbar.prototype._setDropdownVisible):
+        (WebInspector.ToolbarDropdown):
+        (WebInspector.ToolbarDropdown.prototype.show):
+        (WebInspector.ToolbarDropdown.prototype._populate):
+        * inspector/front-end/inspector.css:
+        (.toolbar-small .toolbar-icon.custom-toolbar-icon):
+        * inspector/front-end/inspector.js:
+        (WebInspector._panelDescriptors):
+        (WebInspector._panelSelected):
+        (WebInspector._createGlobalStatusBarItems):
+        (WebInspector.documentClick.followLink):
+        (WebInspector.documentClick):
+        (WebInspector.openResource):
+        (WebInspector.showPanel):
+        (WebInspector.panel):
+        (WebInspector.inspect.):
+        (WebInspector.inspect):
+        (WebInspector._showAnchorLocation):
+        (WebInspector.showProfileForURL):
+        (WebInspector.frontendReused):
+
 2012-08-17  Pascal Massimino  <pascal.massimino@gmail.com>
 
         libwebp-0.2.0: handle alpha channel if present
index b834a0b..56bc4a8 100644 (file)
@@ -43,7 +43,7 @@ WebInspector.AuditsPanel = function()
     this.sidebarTree.appendChild(this.auditsTreeElement);
     this.auditsTreeElement.listItemElement.addStyleClass("hidden");
 
-    this.auditsItemTreeElement = new WebInspector.AuditsSidebarTreeElement();
+    this.auditsItemTreeElement = new WebInspector.AuditsSidebarTreeElement(this);
     this.auditsTreeElement.appendChild(this.auditsItemTreeElement);
 
     this.auditResultsTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("RESULTS"), {}, true);
@@ -65,11 +65,6 @@ WebInspector.AuditsPanel = function()
 }
 
 WebInspector.AuditsPanel.prototype = {
-    get toolbarItemLabel()
-    {
-        return WebInspector.UIString("Audits");
-    },
-
     get statusBarItems()
     {
         return [this.clearResultsButton.element];
@@ -151,7 +146,7 @@ WebInspector.AuditsPanel.prototype = {
                 ordinal++;
         }
 
-        var resultTreeElement = new WebInspector.AuditResultSidebarTreeElement(results, mainResourceURL, ordinal);
+        var resultTreeElement = new WebInspector.AuditResultSidebarTreeElement(this, results, mainResourceURL, ordinal);
         this.auditResultsTreeElement.appendChild(resultTreeElement);
         resultTreeElement.revealAndSelect();
         if (!this._progressMonitor.canceled && launcherCallback)
@@ -526,11 +521,12 @@ WebInspector.AuditProgressMonitor.prototype = {
 /**
  * @constructor
  * @extends {WebInspector.SidebarTreeElement}
+ * @param {WebInspector.AuditsPanel} panel
  */
-WebInspector.AuditsSidebarTreeElement = function()
+WebInspector.AuditsSidebarTreeElement = function(panel)
 {
+    this._panel = panel;
     this.small = false;
-
     WebInspector.SidebarTreeElement.call(this, "audits-sidebar-tree-item", WebInspector.UIString("Audits"), "", null, false);
 }
 
@@ -542,7 +538,7 @@ WebInspector.AuditsSidebarTreeElement.prototype = {
 
     onselect: function()
     {
-        WebInspector.panels.audits.showLauncherView();
+        this._panel.showLauncherView();
     },
 
     get selectable()
@@ -561,19 +557,20 @@ WebInspector.AuditsSidebarTreeElement.prototype.__proto__ = WebInspector.Sidebar
 /**
  * @constructor
  * @extends {WebInspector.SidebarTreeElement}
+ * @param {WebInspector.AuditsPanel} panel
  */
-WebInspector.AuditResultSidebarTreeElement = function(results, mainResourceURL, ordinal)
+WebInspector.AuditResultSidebarTreeElement = function(panel, results, mainResourceURL, ordinal)
 {
+    this._panel = panel;
     this.results = results;
     this.mainResourceURL = mainResourceURL;
-
     WebInspector.SidebarTreeElement.call(this, "audit-result-sidebar-tree-item", String.sprintf("%s (%d)", mainResourceURL, ordinal), "", {}, false);
 }
 
 WebInspector.AuditResultSidebarTreeElement.prototype = {
     onselect: function()
     {
-        WebInspector.panels.audits.showResults(this.results);
+        this._panel.showResults(this.results);
     },
 
     get selectable()
index b7af2a9..8012b19 100644 (file)
@@ -40,11 +40,6 @@ WebInspector.ConsolePanel = function()
 }
 
 WebInspector.ConsolePanel.prototype = {
-    get toolbarItemLabel()
-    {
-        return WebInspector.UIString("Console");
-    },
-
     get statusBarItems()
     {
         return this._view.statusBarItems;
index 0bb07f9..eedebe5 100644 (file)
@@ -825,6 +825,14 @@ WebInspector.DOMAgent.prototype = {
     },
 
     /**
+     * @return {WebInspector.DOMDocument?}
+     */
+    existingDocument: function()
+    {
+        return this._document;
+    },
+
+    /**
      * @param {RuntimeAgent.RemoteObjectId} objectId
      * @param {function(?DOMAgent.NodeId)=} callback
      */
index 0c96693..cdb32f4 100644 (file)
@@ -102,7 +102,7 @@ WebInspector.DOMStorageDispatcher.prototype = {
             payload.id,
             payload.origin,
             payload.isLocalStorage);
-        WebInspector.panels.resources.addDOMStorage(domStorage);
+        WebInspector.panel("resources").addDOMStorage(domStorage);
     },
 
     /**
@@ -110,6 +110,6 @@ WebInspector.DOMStorageDispatcher.prototype = {
      */
     domStorageUpdated: function(storageId)
     {
-        WebInspector.panels.resources.domStorageUpdated(storageId);
+        WebInspector.panel("resources").domStorageUpdated(storageId);
     }
 }
index 7fa41a9..6e94adb 100644 (file)
@@ -140,7 +140,7 @@ WebInspector.DatabaseDispatcher.prototype = {
             payload.domain,
             payload.name,
             payload.version);
-        WebInspector.panels.resources.addDatabase(database);
+        WebInspector.panel("resources").addDatabase(database);
     },
 
     /**
index 5fd2322..cc26ed3 100644 (file)
@@ -90,25 +90,20 @@ WebInspector.ElementsPanel = function()
             this.sidebarPanes[pane].onattach();
     }
 
-    this.nodeSearchButton = new WebInspector.StatusBarButton(WebInspector.UIString("Select an element in the page to inspect it."), "node-search-status-bar-item");
-    this.nodeSearchButton.addEventListener("click", this.toggleSearchingForNode, this);
-
     this._registerShortcuts();
 
     this._popoverHelper = new WebInspector.PopoverHelper(document.body, this._getPopoverAnchor.bind(this), this._showPopover.bind(this));
     this._popoverHelper.setTimeout(0);
 
     WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.NodeRemoved, this._nodeRemoved, this);
-    WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.DocumentUpdated, this._documentUpdated, this);
+    WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.DocumentUpdated, this._documentUpdatedEvent, this);
     WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.InspectElementRequested, this._inspectElementRequested, this);
+
+    if (WebInspector.domAgent.existingDocument())
+        this._documentUpdated(WebInspector.domAgent.existingDocument());
 }
 
 WebInspector.ElementsPanel.prototype = {
-    get toolbarItemLabel()
-    {
-        return WebInspector.UIString("Elements");
-    },
-
     get statusBarItems()
     {
         return [this.crumbsElement];
@@ -145,7 +140,6 @@ WebInspector.ElementsPanel.prototype = {
     willHide: function()
     {
         WebInspector.domAgent.hideDOMNodeHighlight();
-        this.setSearchingForNode(false);
         this.treeOutline.setVisible(false);
         this._popoverHelper.hidePopover();
 
@@ -230,10 +224,13 @@ WebInspector.ElementsPanel.prototype = {
         delete this.currentQuery;
     },
 
-    _documentUpdated: function(event)
+    _documentUpdatedEvent: function(event)
     {
-        var inspectedRootDocument = event.data;
+        this._documentUpdated(event.data);
+    },
 
+    _documentUpdated: function(inspectedRootDocument)
+    {
         this._reset();
         this.searchCanceled();
 
@@ -1073,22 +1070,6 @@ WebInspector.ElementsPanel.prototype = {
 
     handleShortcut: function(event)
     {
-        // Cmd/Control + Shift + C should be a shortcut to clicking the Node Search Button.
-        // This shortcut matches Firebug.
-        if (event.keyIdentifier === "U+0043") { // C key
-            if (WebInspector.isMac())
-                var isNodeSearchKey = event.metaKey && !event.ctrlKey && !event.altKey && event.shiftKey;
-            else
-                var isNodeSearchKey = event.ctrlKey && !event.metaKey && !event.altKey && event.shiftKey;
-
-            if (isNodeSearchKey) {
-                this.toggleSearchingForNode();
-                event.handled = true;
-                return;
-            }
-            return;
-        }
-
         if (WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && !event.shiftKey && event.keyIdentifier === "U+005A") { // Z key
             WebInspector.domAgent.undo(this._updateSidebars.bind(this));
             event.handled = true;
@@ -1137,28 +1118,6 @@ WebInspector.ElementsPanel.prototype = {
 
         WebInspector.domAgent.highlightDOMNodeForTwoSeconds(nodeId);
         this.selectDOMNode(node, true);
-        if (this.nodeSearchButton.toggled) {
-            InspectorFrontendHost.bringToFront();
-            this.nodeSearchButton.toggled = false;
-        }
-    },
-
-    setSearchingForNode: function(enabled)
-    {
-        /**
-         * @param {?Protocol.Error} error
-         */
-        function callback(error)
-        {
-            if (!error)
-                this.nodeSearchButton.toggled = enabled;
-        }
-        WebInspector.domAgent.setInspectModeEnabled(enabled, callback.bind(this));
-    },
-
-    toggleSearchingForNode: function()
-    {
-        this.setSearchingForNode(!this.nodeSearchButton.toggled);
     }
 }
 
index 3413031..18cab8a 100644 (file)
@@ -1172,7 +1172,6 @@ WebInspector.ElementsTreeElement.prototype = {
         const pseudoClasses = ["active", "hover", "focus", "visited"];
         var node = this.representedObject;
         var forcedPseudoState = (node ? node.getUserProperty("pseudoState") : null) || [];
-        var elementsPanel = WebInspector.panels.elements;
         for (var i = 0; i < pseudoClasses.length; ++i) {
             var pseudoClassForced = forcedPseudoState.indexOf(pseudoClasses[i]) >= 0;
             subMenu.appendCheckboxItem(":" + pseudoClasses[i], this.treeOutline._setPseudoClassCallback.bind(null, node.id, pseudoClasses[i], !pseudoClassForced), pseudoClassForced, false);
index 1c69653..46cdb11 100644 (file)
  * @constructor
  * @extends {WebInspector.Panel}
  * @param {string} id
- * @param {string} label
  * @param {string} pageURL
- * @param {string} iconURL
  */
-WebInspector.ExtensionPanel = function(id, label, pageURL, iconURL)
+WebInspector.ExtensionPanel = function(id, pageURL)
 {
     WebInspector.Panel.call(this, id);
     this.setHideOnDetach();
-    this._toolbarItemLabel = label;
     this._statusBarItems = [];
-
-    if (iconURL) {
-        this._addStyleRule(".toolbar-item." + id + " .toolbar-icon", "background-image: url(" + iconURL + ");");
-        this._addStyleRule(".toolbar-small .toolbar-item." + id + " .toolbar-icon", "background-position-x: -32px;");
-    }
     var extensionView = new WebInspector.ExtensionView(id, pageURL, "extension panel");
     extensionView.show(this.element);
 }
 
 WebInspector.ExtensionPanel.prototype = {
-    get toolbarItemLabel()
-    {
-        return this._toolbarItemLabel;
-    },
-
     defaultFocusedElement: function()
     {
         return this.sidebarTreeElement || this.element;
@@ -100,13 +87,6 @@ WebInspector.ExtensionPanel.prototype = {
     {
         WebInspector.extensionServer.notifySearchAction(this.name, WebInspector.extensionAPI.panels.SearchAction.PreviousSearchResult);
         WebInspector.Panel.prototype.jumpToPreviousSearchResult.call(this);
-    },
-
-    _addStyleRule: function(selector, body)
-    {
-        var style = document.createElement("style");
-        style.textContent = selector + " { " + body + " }";
-        document.head.appendChild(style);
     }
 }
 
index ce0157f..4b5f320 100644 (file)
@@ -197,11 +197,10 @@ WebInspector.ExtensionServer.prototype = {
             return this._status.E_EXISTS(id);
 
         var page = this._expandResourcePath(port._extensionOrigin, message.page);
-        var icon = this._expandResourcePath(port._extensionOrigin, message.icon)
-        var panel = new WebInspector.ExtensionPanel(id, message.title, page, icon);
-        this._clientObjects[id] = panel;
-        WebInspector.panels[id] = panel;
-        WebInspector.addPanel(panel);
+        var panelDescriptor = new WebInspector.PanelDescriptor(id, message.title, WebInspector.ExtensionPanel.bind(null, id, page));
+        panelDescriptor.setIconURL(this._expandResourcePath(port._extensionOrigin, message.icon));
+        this._clientObjects[id] = panelDescriptor.panel();
+        WebInspector.inspectorView.addPanel(panelDescriptor);
         return this._status.OK();
     },
 
@@ -233,7 +232,7 @@ WebInspector.ExtensionServer.prototype = {
 
     _onCreateSidebarPane: function(message)
     {
-        var panel = WebInspector.panels[message.panel];
+        var panel = WebInspector.panel(message.panel);
         if (!panel)
             return this._status.E_NOTFOUND(message.panel);
         if (!panel.sidebarElement || !panel.sidebarPanes)
@@ -532,10 +531,10 @@ WebInspector.ExtensionServer.prototype = {
     _onAddAuditCategory: function(message, port)
     {
         var category = new WebInspector.ExtensionAuditCategory(port._extensionOrigin, message.id, message.displayName, message.resultCount);
-        if (WebInspector.panels.audits.getCategory(category.id))
+        if (WebInspector.panel("audits").getCategory(category.id))
             return this._status.E_EXISTS(category.id);
         this._clientObjects[message.id] = category;
-        WebInspector.panels.audits.addCategory(category);
+        WebInspector.panel("audits").addCategory(category);
     },
 
     _onAddAuditResult: function(message)
@@ -575,12 +574,17 @@ WebInspector.ExtensionServer.prototype = {
             WebInspector.workspace,
             WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded,
             this._notifyResourceAdded);
-        if (WebInspector.panels.elements) {
-            this._registerAutosubscriptionHandler(WebInspector.extensionAPI.Events.ElementsPanelObjectSelected,
-                WebInspector.panels.elements.treeOutline,
-                WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged,
-                this._notifyElementsSelectionChanged);
-        }
+        this._registerSubscriptionHandler(WebInspector.extensionAPI.Events.ElementsPanelObjectSelected,
+            function()
+            {
+                WebInspector.panel("elements").treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged, this._notifyElementsSelectionChanged, this);
+            }.bind(this),
+            function()
+            {
+                WebInspector.panel("elements").treeOutline.removeEventListener(WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged, this._notifyElementsSelectionChanged, this);
+            }.bind(this)
+        );
+
         this._registerAutosubscriptionHandler(WebInspector.extensionAPI.Events.ResourceContentCommitted,
             WebInspector.workspace,
             WebInspector.Workspace.Events.UISourceCodeContentCommitted,
index 4732670..2ca29f3 100644 (file)
@@ -47,12 +47,12 @@ InspectorFrontendAPI = {
 
     isTimelineProfilingEnabled: function()
     {
-        return WebInspector.panels.timeline.timelineProfilingEnabled;
+        return WebInspector.panels.timeline && WebInspector.panels.timeline.timelineProfilingEnabled;
     },
 
     setTimelineProfilingEnabled: function(enabled)
     {
-        WebInspector.panels.timeline.setTimelineProfilingEnabled(enabled);
+        WebInspector.panel("timeline").setTimelineProfilingEnabled(enabled);
     },
 
     isProfilingJavaScript: function()
@@ -82,7 +82,7 @@ InspectorFrontendAPI = {
 
     showConsole: function()
     {
-        WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.console);
+        WebInspector.showPanel("console");
     },
 
     showMainResourceForFrame: function(frameId)
@@ -92,7 +92,7 @@ InspectorFrontendAPI = {
 
     showResources: function()
     {
-        WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.resources);
+        WebInspector.showPanel("resources");
     },
 
     setDockingUnavailable: function(unavailable)
@@ -102,7 +102,7 @@ InspectorFrontendAPI = {
 
     enterInspectElementMode: function()
     {
-        WebInspector.toggleSearchingForNode();
+        WebInspector.panel("elements").toggleSearchingForNode();
     },
 
     savedURL: function(url)
index c6601c7..d49b04e 100644 (file)
@@ -43,6 +43,7 @@ WebInspector.InspectorView = function()
     document.addEventListener("keydown", this._keyDown.bind(this), false);
     document.addEventListener("keypress", this._keyPress.bind(this), false);
     this._panelOrder = [];
+    this._panelDescriptors = {};
 
     // Windows and Mac have two different definitions of '[' and ']', so accept both of each.
     this._openBracketIdentifiers = ["U+005B", "U+00DB"].keySet();
@@ -52,14 +53,42 @@ WebInspector.InspectorView = function()
 }
 
 WebInspector.InspectorView.Events = {
-    PanelSelected: "panel-selected"
+    PanelSelected: "PanelSelected"
 }
 
 WebInspector.InspectorView.prototype = {
-    addPanel: function(panel)
+    /**
+     * @param {WebInspector.PanelDescriptor} panelDescriptor
+     */
+    addPanel: function(panelDescriptor)
+    {
+        this._panelOrder.push(panelDescriptor.name());
+        this._panelDescriptors[panelDescriptor.name()] = panelDescriptor;
+        WebInspector.toolbar.addPanel(panelDescriptor);
+    },
+
+    /**
+     * @param {string} panelName
+     * @return {?WebInspector.Panel}
+     */
+    panel: function(panelName)
+    {
+        var panelDescriptor = this._panelDescriptors[panelName];
+        if (!panelDescriptor && this._panelOrder.length)
+            panelDescriptor = this._panelDescriptors[this._panelOrder[0]];
+        return panelDescriptor ? panelDescriptor.panel() : null;
+    },
+
+    /**
+     * @param {string} panelName
+     * @return {?WebInspector.Panel}
+     */
+    showPanel: function(panelName)
     {
-        this._panelOrder.push(panel);
-        WebInspector.toolbar.addPanel(panel);
+        var panel = this.panel(panelName);
+        if (panel)
+            this.setCurrentPanel(panel);
+        return panel;
     },
 
     currentPanel: function()
@@ -116,9 +145,9 @@ WebInspector.InspectorView.prototype = {
         if (this._openBracketIdentifiers.hasOwnProperty(event.keyIdentifier)) {
             var isRotateLeft = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && !event.shiftKey && !event.altKey;
             if (isRotateLeft) {
-                var index = this._panelOrder.indexOf(this.currentPanel());
+                var index = this._panelOrder.indexOf(this.currentPanel().name);
                 index = (index === 0) ? this._panelOrder.length - 1 : index - 1;
-                this._panelOrder[index].toolbarItem.click();
+                this.showPanel(this._panelOrder[index]);
                 event.consume(true);
                 return;
             }
@@ -134,9 +163,9 @@ WebInspector.InspectorView.prototype = {
         if (this._closeBracketIdentifiers.hasOwnProperty(event.keyIdentifier)) {
             var isRotateRight = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && !event.shiftKey && !event.altKey;
             if (isRotateRight) {
-                var index = this._panelOrder.indexOf(this.currentPanel());
+                var index = this._panelOrder.indexOf(this.currentPanel().name);
                 index = (index + 1) % this._panelOrder.length;
-                this._panelOrder[index].toolbarItem.click();
+                this.showPanel(this._panelOrder[index]);
                 event.consume(true);
                 return;
             }
index 2efc1da..4c9b99b 100644 (file)
@@ -1251,11 +1251,6 @@ WebInspector.NetworkPanel = function()
 }
 
 WebInspector.NetworkPanel.prototype = {
-    get toolbarItemLabel()
-    {
-        return WebInspector.UIString("Network");
-    },
-
     get statusBarItems()
     {
         return this._networkLogView.statusBarItems;
index f65f5ea..f997eda 100644 (file)
@@ -47,15 +47,6 @@ WebInspector.Panel = function(name)
 WebInspector.Panel.counterRightMargin = 25;
 
 WebInspector.Panel.prototype = {
-    get toolbarItem()
-    {
-        if (this._toolbarItem)
-            return this._toolbarItem;
-
-        this._toolbarItem = WebInspector.Toolbar.createPanelToolbarItem(this);
-        return this._toolbarItem;
-    },
-
     get name()
     {
         return this._panelName;
@@ -76,9 +67,6 @@ WebInspector.Panel.prototype = {
             document.getElementById("panel-status-bar").appendChild(this._statusBarItemContainer);
         }
 
-        if ("_toolbarItem" in this)
-            this._toolbarItem.addStyleClass("toggled-on");
-
         this.focus();
     },
 
@@ -87,8 +75,6 @@ WebInspector.Panel.prototype = {
         if (this._statusBarItemContainer && this._statusBarItemContainer.parentNode)
             this._statusBarItemContainer.parentNode.removeChild(this._statusBarItemContainer);
         delete this._statusBarItemContainer;
-        if ("_toolbarItem" in this)
-            this._toolbarItem.removeStyleClass("toggled-on");
     },
 
     reset: function()
@@ -193,10 +179,6 @@ WebInspector.Panel.prototype = {
 
     // Should be implemented by ancestors.
 
-    get toolbarItemLabel()
-    {
-    },
-
     get statusBarItems()
     {
     },
@@ -252,3 +234,63 @@ WebInspector.Panel.prototype = {
 }
 
 WebInspector.Panel.prototype.__proto__ = WebInspector.View.prototype;
+
+/**
+ * @constructor
+ * @param {string} name
+ * @param {string} title
+ * @param {function(new:WebInspector.Panel)} constructor
+ * @param {boolean=} lazyInit
+ */
+WebInspector.PanelDescriptor = function(name, title, constructor, lazyInit)
+{
+    this._name = name;
+    this._title = title;
+    this._constructor = constructor;
+    this._panel = lazyInit ? null : this.panel();
+}
+
+WebInspector.PanelDescriptor.prototype = {
+    /**
+     * @return {string}
+     */
+    name: function()
+    {
+        return this._name;
+    },
+
+    /**
+     * @return {string}
+     */
+    title: function()
+    {
+        return this._title;
+    },
+
+    /**
+     * @return {string}
+     */
+    iconURL: function()
+    {
+        return this._iconURL;
+    },
+
+    /**
+     * @param {string} iconURL
+     */
+    setIconURL: function(iconURL)
+    {
+        this._iconURL = iconURL;
+    },
+
+    /**
+     * @return {WebInspector.Panel}
+     */
+    panel: function()
+    {
+        if (!this._panel)
+            this._panel = new this._constructor();
+        WebInspector.panels[this._name] = this._panel;
+        return this._panel;
+    }
+}
index ff532b5..276517e 100644 (file)
@@ -294,11 +294,6 @@ WebInspector.ProfilesPanel.prototype = {
         this._createFileSelectorElement();
     },
 
-    get toolbarItemLabel()
-    {
-        return WebInspector.UIString("Profiles");
-    },
-
     get statusBarItems()
     {
         return this._statusBarButtons.select("element").concat([this.profileViewStatusBarItemsContainer]);
index 3616571..ca25c95 100644 (file)
@@ -89,6 +89,11 @@ WebInspector.ResourceTreeModel.prototype = {
         this._cachedResourcesProcessed = true;
     },
 
+    cachedResourcesLoaded: function()
+    {
+        return this._cachedResourcesProcessed;
+    },
+
     _dispatchInspectedURLChanged: function()
     {
         InspectorFrontendHost.inspectedURLChanged(WebInspector.inspectedPageURL);
index 85d3c22..b2a6a2b 100644 (file)
@@ -96,14 +96,11 @@ WebInspector.ResourcesPanel = function(database)
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.OnLoad, this._onLoadEventFired, this);
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded, this._cachedResourcesLoaded, this);
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.WillLoadCachedResources, this._resetWithFrames, this);
+    if (WebInspector.resourceTreeModel.cachedResourcesLoaded())
+        this._cachedResourcesLoaded();
 }
 
 WebInspector.ResourcesPanel.prototype = {
-    get toolbarItemLabel()
-    {
-        return WebInspector.UIString("Resources");
-    },
-
     get statusBarItems()
     {
         return [this.storageViewStatusBarItemsContainer];
index 13b0507..0a7f2b4 100644 (file)
@@ -189,11 +189,6 @@ WebInspector.ScriptsPanel.PauseOnExceptionsState = {
 };
 
 WebInspector.ScriptsPanel.prototype = {
-    get toolbarItemLabel()
-    {
-        return WebInspector.UIString("Sources");
-    },
-
     get statusBarItems()
     {
         return [this.enableToggleButton.element, this._pauseOnExceptionButton.element, this._toggleFormatSourceButton.element, this._scriptViewStatusBarItemsContainer];
index 28681f0..adeaaf5 100644 (file)
@@ -1332,12 +1332,12 @@ WebInspector.StylePropertiesSection.prototype = {
             this.rule = newRule;
             this.styleRule = { section: this, style: newRule.style, selectorText: newRule.selectorText, media: newRule.media, sourceURL: newRule.sourceURL, rule: newRule };
 
-            this.pane.update();
+            this._parentPane.update();
 
             this._moveEditorFromSelector(moveDirection);
         }
 
-        var selectedNode = WebInspector.panels.elements.selectedDOMNode();
+        var selectedNode = this._parentPane.node;
         WebInspector.cssModel.setRuleSelector(this.rule.id, selectedNode ? selectedNode.id : 0, newContent, successCallback.bind(this), this._moveEditorFromSelector.bind(this, moveDirection));
     },
 
@@ -1729,8 +1729,8 @@ WebInspector.StylePropertyTreeElement.prototype = {
                 container.appendChild(document.createTextNode("url("));
                 if (self._styleRule.sourceURL)
                     hrefUrl = WebInspector.completeURL(self._styleRule.sourceURL, hrefUrl);
-                else if (WebInspector.panels.elements.selectedDOMNode())
-                    hrefUrl = WebInspector.resourceURLForRelatedNode(WebInspector.panels.elements.selectedDOMNode(), hrefUrl);
+                else if (this._parentPane.node)
+                    hrefUrl = WebInspector.resourceURLForRelatedNode(this._parentPane.node, hrefUrl);
                 var hasResource = !!WebInspector.resourceForURL(hrefUrl);
                 // FIXME: WebInspector.linkifyURLAsNode() should really use baseURI.
                 container.appendChild(WebInspector.linkifyURLAsNode(hrefUrl, url, undefined, !hasResource));
@@ -1904,7 +1904,7 @@ WebInspector.StylePropertyTreeElement.prototype = {
             var colorRegex = /((?:rgb|hsl)a?\([^)]+\)|#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3}|\b\w+\b(?!-))/g;
             var colorProcessor = processValue.bind(window, colorRegex, processColor, null);
 
-            valueElement.appendChild(processValue(/url\(\s*([^)\s]+)\s*\)/g, linkifyURL, WebInspector.CSSKeywordCompletions.isColorAwareProperty(self.name) ? colorProcessor : null, value));
+            valueElement.appendChild(processValue(/url\(\s*([^)\s]+)\s*\)/g, linkifyURL.bind(this), WebInspector.CSSKeywordCompletions.isColorAwareProperty(self.name) ? colorProcessor : null, value));
         }
 
         this.listItemElement.removeChildren();
@@ -2439,7 +2439,6 @@ WebInspector.StylePropertyTreeElement.prototype = {
             return;
 
         var section = this.treeOutline.section;
-        var elementsPanel = WebInspector.panels.elements;
         styleText = styleText.replace(/\s/g, " ").trim(); // Replace &nbsp; with whitespace.
         var styleTextLength = styleText.length;
         if (!styleTextLength && updateInterface && !isRevert && this._newProperty && !this._hasBeenModifiedIncrementally()) {
index 3d318c6..320fc0d 100644 (file)
@@ -195,11 +195,6 @@ WebInspector.TimelinePanel.prototype = {
         return this._calculator;
     },
 
-    get toolbarItemLabel()
-    {
-        return WebInspector.UIString("Timeline");
-    },
-
     get statusBarItems()
     {
         return this._statusBarButtons.select("element").concat([
index 372ff67..f588e97 100644 (file)
@@ -59,13 +59,53 @@ WebInspector.Toolbar.prototype = {
         this._updateDropdownButtonAndHideDropdown();
     },
 
-    addPanel: function(panel)
+    /**
+     * @param {WebInspector.PanelDescriptor} panelDescriptor
+     */
+    addPanel: function(panelDescriptor)
     {
-        this.element.appendChild(panel.toolbarItem);
+        this.element.appendChild(this._createPanelToolbarItem(panelDescriptor));
         this.resize();
     },
 
     /**
+     * @param {WebInspector.PanelDescriptor} panelDescriptor
+     * @return {Element}
+     */
+    _createPanelToolbarItem: function(panelDescriptor)
+    {
+        var toolbarItem = document.createElement("button");
+        toolbarItem.className = "toolbar-item toggleable";
+        toolbarItem.panelDescriptor = panelDescriptor;
+        toolbarItem.addStyleClass(panelDescriptor.name());
+
+        function onToolbarItemClicked()
+        {
+            this._updateDropdownButtonAndHideDropdown();
+            WebInspector.inspectorView.setCurrentPanel(panelDescriptor.panel());
+        }
+        toolbarItem.addEventListener("click", onToolbarItemClicked.bind(this), false);
+
+        function panelSelected()
+        {
+            if (WebInspector.inspectorView.currentPanel() && panelDescriptor.name() === WebInspector.inspectorView.currentPanel().name)
+                toolbarItem.addStyleClass("toggled-on");
+            else
+                toolbarItem.removeStyleClass("toggled-on");
+        }
+        WebInspector.inspectorView.addEventListener(WebInspector.InspectorView.Events.PanelSelected, panelSelected);
+
+        var iconElement = toolbarItem.createChild("div", "toolbar-icon");
+        toolbarItem.createChild("div", "toolbar-label").textContent = panelDescriptor.title();
+        if (panelDescriptor.iconURL()) {
+            iconElement.addStyleClass("custom-toolbar-icon");
+            iconElement.style.backgroundImage = "url(" + panelDescriptor.iconURL() + ")";
+        }
+        panelSelected();
+        return toolbarItem;
+    },
+
+    /**
      * @return {boolean}
      */
     _toolbarDragStart: function(event)
@@ -122,7 +162,7 @@ WebInspector.Toolbar.prototype = {
         if (!this._dropdown) {
             if (!visible)
                 return;
-            this._dropdown = new WebInspector.ToolbarDropdown();
+            this._dropdown = new WebInspector.ToolbarDropdown(this);
         }
         if (visible)
             this._dropdown.show();
@@ -147,36 +187,13 @@ WebInspector.Toolbar.prototype = {
     }
 }
 
-WebInspector.Toolbar.createPanelToolbarItem = function(panel)
-{
-    var toolbarItem = document.createElement("button");
-    toolbarItem.className = "toolbar-item toggleable";
-    toolbarItem.panel = panel;
-    toolbarItem.addStyleClass(panel._panelName);
-    function onToolbarItemClicked()
-    {
-        WebInspector.toolbar._updateDropdownButtonAndHideDropdown();
-        WebInspector.inspectorView.setCurrentPanel(panel);
-    }
-    toolbarItem.addEventListener("click", onToolbarItemClicked, false);
-
-    var iconElement = toolbarItem.createChild("div", "toolbar-icon");
-
-    if ("toolbarItemLabel" in panel)
-        toolbarItem.createChild("div", "toolbar-label").textContent = panel.toolbarItemLabel;
-
-    if (panel === WebInspector.inspectorView.currentPanel())
-        toolbarItem.addStyleClass("toggled-on");
-
-    return toolbarItem;
-}
-
 /**
  * @constructor
+ * @param {WebInspector.Toolbar} toolbar
  */
-WebInspector.ToolbarDropdown = function()
+WebInspector.ToolbarDropdown = function(toolbar)
 {
-    this._toolbar = document.getElementById("toolbar");
+    this._toolbar = toolbar;
     this._arrow = document.getElementById("toolbar-dropdown-arrow");
     this.element = document.createElement("div");
     this.element.id = "toolbar-dropdown";
@@ -198,7 +215,7 @@ WebInspector.ToolbarDropdown.prototype = {
         this.element.style.top = top + "px";
         this.element.style.left = this._arrow.totalOffsetLeft() + "px";
         this._contentElement.style.maxHeight = window.innerHeight - top - 20 + "px";
-        this._toolbar.appendChild(this.element);
+        this._toolbar.element.appendChild(this.element);
     },
 
     hide: function()
@@ -217,11 +234,11 @@ WebInspector.ToolbarDropdown.prototype = {
 
     _populate: function()
     {
-        var toolbarItems = this._toolbar.querySelectorAll(".toolbar-item.toggleable");
+        var toolbarItems = this._toolbar.element.querySelectorAll(".toolbar-item.toggleable");
 
         for (var i = 0; i < toolbarItems.length; ++i) {
             if (toolbarItems[i].offsetTop > 0)
-                this._contentElement.appendChild(WebInspector.Toolbar.createPanelToolbarItem(toolbarItems[i].panel));
+                this._contentElement.appendChild(this._toolbar._createPanelToolbarItem(toolbarItems[i].panelDescriptor));
         }
     },
 
index ea5eedc..f6527e2 100644 (file)
@@ -118,6 +118,10 @@ body.compact.inactive #toolbar {
     background-image: url(Images/toolbarIconsSmall.png);
 }
 
+.toolbar-small .toolbar-icon.custom-toolbar-icon {
+    background-position-x: -32px;
+}
+
 .toolbar-item:active .toolbar-icon {
     background-position-y: 32px;
 }
index 21cfc02..6dd1080 100644 (file)
@@ -29,7 +29,7 @@
  */
 
 var WebInspector = {
-    _createPanels: function()
+    _panelDescriptors: function()
     {
         this.panels = {};
         WebInspector.inspectorView = new WebInspector.InspectorView();
@@ -37,35 +37,36 @@ var WebInspector = {
         WebInspector.inspectorView.show(parentElement);
         WebInspector.inspectorView.addEventListener(WebInspector.InspectorView.Events.PanelSelected, this._panelSelected, this);
 
+        var elements = new WebInspector.PanelDescriptor("elements", WebInspector.UIString("Elements"), WebInspector.ElementsPanel, true);
+        var resources = new WebInspector.PanelDescriptor("resources", WebInspector.UIString("Resources"), WebInspector.ResourcesPanel, true);
+        var network = new WebInspector.PanelDescriptor("network", WebInspector.UIString("Network"), WebInspector.NetworkPanel);
+        var scripts = new WebInspector.PanelDescriptor("scripts", WebInspector.UIString("Sources"), WebInspector.ScriptsPanel);
+        var timeline = new WebInspector.PanelDescriptor("timeline", WebInspector.UIString("Timeline"), WebInspector.TimelinePanel, true);
+        var profiles = new WebInspector.PanelDescriptor("profiles", WebInspector.UIString("Profiles"), WebInspector.ProfilesPanel);
+        var audits = new WebInspector.PanelDescriptor("audits", WebInspector.UIString("Audits"), WebInspector.AuditsPanel, true);
+        var console = new WebInspector.PanelDescriptor("console", WebInspector.UIString("Console"), WebInspector.ConsolePanel, true);
+        var allDescriptors = [elements, resources, network, scripts, timeline, profiles, audits, console];
+
+        var panelDescriptors = [];
         if (WebInspector.WorkerManager.isWorkerFrontend()) {
-            this.panels.scripts = new WebInspector.ScriptsPanel();
-            this.panels.timeline = new WebInspector.TimelinePanel();
-            this.panels.profiles = new WebInspector.ProfilesPanel();
-            this.panels.console = new WebInspector.ConsolePanel();
-            return;
+            panelDescriptors.push(scripts);
+            panelDescriptors.push(timeline);
+            panelDescriptors.push(profiles);
+            panelDescriptors.push(console);
+            return panelDescriptors;
         }
+        var allDescriptors = [elements, resources, network, scripts, timeline, profiles, audits, console];
         var hiddenPanels = (InspectorFrontendHost.hiddenPanels() || "").split(',');
-        if (hiddenPanels.indexOf("elements") === -1)
-            this.panels.elements = new WebInspector.ElementsPanel();
-        if (hiddenPanels.indexOf("resources") === -1)
-            this.panels.resources = new WebInspector.ResourcesPanel();
-        if (hiddenPanels.indexOf("network") === -1)
-            this.panels.network = new WebInspector.NetworkPanel();
-        if (hiddenPanels.indexOf("scripts") === -1)
-            this.panels.scripts = new WebInspector.ScriptsPanel();
-        if (hiddenPanels.indexOf("timeline") === -1)
-            this.panels.timeline = new WebInspector.TimelinePanel();
-        if (hiddenPanels.indexOf("profiles") === -1)
-            this.panels.profiles = new WebInspector.ProfilesPanel();
-        if (hiddenPanels.indexOf("audits") === -1)
-            this.panels.audits = new WebInspector.AuditsPanel();
-        if (hiddenPanels.indexOf("console") === -1)
-            this.panels.console = new WebInspector.ConsolePanel();
+        for (var i = 0; i < allDescriptors.length; ++i) {
+            if (hiddenPanels.indexOf(allDescriptors[i].name) === -1)
+                panelDescriptors.push(allDescriptors[i]);
+        }
+        return panelDescriptors;
     },
 
     _panelSelected: function()
     {
-        this._toggleConsoleButton.disabled = WebInspector.inspectorView.currentPanel() === WebInspector.panels.console;
+        this._toggleConsoleButton.disabled = WebInspector.inspectorView.currentPanel().name === "console";
     },
 
     _createGlobalStatusBarItems: function()
@@ -83,8 +84,12 @@ var WebInspector = {
         this._toggleConsoleButton.addEventListener("click", this._toggleConsoleButtonClicked.bind(this), false);
         mainStatusBar.insertBefore(this._toggleConsoleButton.element, bottomStatusBarContainer);
 
-        if (this.panels.elements)
-            mainStatusBar.insertBefore(this.panels.elements.nodeSearchButton.element, bottomStatusBarContainer);
+        if (!WebInspector.WorkerManager.isWorkerFrontend()) {
+            this._nodeSearchButton = new WebInspector.StatusBarButton(WebInspector.UIString("Select an element in the page to inspect it."), "node-search-status-bar-item");
+            this._nodeSearchButton.addEventListener("click", this._toggleSearchingForNode, this);
+            mainStatusBar.insertBefore(this._nodeSearchButton.element, bottomStatusBarContainer);
+        }
+
         mainStatusBar.appendChild(this.settingsController.statusBarItem);
     },
 
@@ -365,6 +370,20 @@ var WebInspector = {
     {
         WebInspector.settings.zoomLevel.set(this._zoomLevel);
         InspectorFrontendHost.setZoomFactor(Math.pow(1.2, this._zoomLevel));
+    },
+
+    _toggleSearchingForNode: function()
+    {
+        var enabled = !this._nodeSearchButton.toggled;
+        /**
+         * @param {?Protocol.Error} error
+         */
+        function callback(error)
+        {
+            if (!error)
+                this._nodeSearchButton.toggled = enabled;
+        }
+        WebInspector.domAgent.setInspectModeEnabled(enabled, callback.bind(this));
     }
 }
 
@@ -496,14 +515,14 @@ WebInspector._doLoadedDoneWithCapabilities = function()
     this.workspace = new WebInspector.Workspace();
     this.breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, this.debuggerModel, this.workspace);
 
-    this._createPanels();
     this._createGlobalStatusBarItems();
 
     this.toolbar = new WebInspector.Toolbar();
     WebInspector._installDockToRight();
 
-    for (var panelName in this.panels)
-        this.addPanel(this.panels[panelName]);
+    var panelDescriptors = this._panelDescriptors();
+    for (var i = 0; i < panelDescriptors.length; ++i)
+        WebInspector.inspectorView.addPanel(panelDescriptors[i]);
 
     this.addMainEventListeners(document);
 
@@ -569,11 +588,6 @@ WebInspector._installDockToRight = function()
     }
 }
 
-WebInspector.addPanel = function(panel)
-{
-    WebInspector.inspectorView.addPanel(panel);
-}
-
 var windowLoaded = function()
 {
     var localizedStringsURL = InspectorFrontendHost.localizedStringsURL();
@@ -665,7 +679,7 @@ WebInspector.documentClick = function(event)
         if (parsedURL && parsedURL.scheme === "webkit-link-action") {
             if (parsedURL.host === "show-panel") {
                 var panel = parsedURL.path.substring(1);
-                if (WebInspector.panels[panel])
+                if (WebInspector.panel(panel))
                     WebInspector.showPanel(panel);
             }
             return;
@@ -691,10 +705,9 @@ WebInspector.documentClick = function(event)
 WebInspector.openResource = function(resourceURL, inResourcesPanel)
 {
     var resource = WebInspector.resourceForURL(resourceURL);
-    if (inResourcesPanel && resource) {
-        WebInspector.showPanel("resources");
-        WebInspector.panels.resources.showResource(resource);
-    } else
+    if (inResourcesPanel && resource)
+        WebInspector.showPanel("resources").showResource(resource);
+    else
         InspectorFrontendHost.openInNewTab(resourceURL);
 }
 
@@ -814,6 +827,22 @@ WebInspector.documentKeyDown = function(event)
             }
             break;
     }
+
+    // Cmd/Control + Shift + C should be a shortcut to clicking the Node Search Button.
+    // This shortcut matches Firebug.
+    if (event.keyIdentifier === "U+0043") { // C key
+        if (WebInspector.isMac())
+            var isNodeSearchKey = event.metaKey && !event.ctrlKey && !event.altKey && event.shiftKey;
+        else
+            var isNodeSearchKey = event.ctrlKey && !event.metaKey && !event.altKey && event.shiftKey;
+
+        if (isNodeSearchKey) {
+            this._toggleSearchingForNode();
+            event.consume(true);
+            return;
+        }
+        return;
+    }
 }
 
 WebInspector.postDocumentKeyDown = function(event)
@@ -853,14 +882,6 @@ WebInspector.contextMenuEventFired = function(event)
         event.preventDefault();
 }
 
-WebInspector.toggleSearchingForNode = function()
-{
-    if (this.panels.elements) {
-        this.showPanel("elements");
-        this.panels.elements.toggleSearchingForNode();
-    }
-}
-
 WebInspector.showConsole = function()
 {
     if (WebInspector._toggleConsoleButton && !WebInspector._toggleConsoleButton.toggled) {
@@ -872,13 +893,12 @@ WebInspector.showConsole = function()
 
 WebInspector.showPanel = function(panel)
 {
-    if (!(panel in this.panels)) {
-        if (WebInspector.WorkerManager.isWorkerFrontend())
-            panel = "scripts";
-        else
-            panel = "elements";
-    }
-    WebInspector.inspectorView.setCurrentPanel(this.panels[panel]);
+    return WebInspector.inspectorView.showPanel(panel);
+}
+
+WebInspector.panel = function(panel)
+{
+    return WebInspector.inspectorView.panel(panel);
 }
 
 WebInspector.bringToFront = function()
@@ -965,45 +985,45 @@ WebInspector.inspect = function(payload, hints)
 {
     var object = WebInspector.RemoteObject.fromPayload(payload);
     if (object.subtype === "node") {
-        // Request node from backend and focus it.
-        WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.elements);
-        object.pushNodeToFrontend(WebInspector.updateFocusedNode.bind(WebInspector), object.release.bind(object));
+        function callback(nodeId)
+        {
+            WebInspector._updateFocusedNode(nodeId);
+            object.release();
+        }
+        object.pushNodeToFrontend(callback);
         return;
     }
 
-    if (hints.databaseId) {
-        WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.resources);
-        WebInspector.panels.resources.selectDatabase(hints.databaseId);
-    } else if (hints.domStorageId) {
-        WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.resources);
-        WebInspector.panels.resources.selectDOMStorage(hints.domStorageId);
-    }
+    if (hints.databaseId)
+        WebInspector.showPanel("resources").selectDatabase(hints.databaseId);
+    else if (hints.domStorageId)
+        WebInspector.showPanel("resources").selectDOMStorage(hints.domStorageId);
 
     object.release();
 }
 
-WebInspector.updateFocusedNode = function(nodeId)
+WebInspector._updateFocusedNode = function(nodeId)
 {
-    this.panels.elements.revealAndSelectNode(nodeId);
+    if (WebInspector._nodeSearchButton.toggled) {
+        InspectorFrontendHost.bringToFront();
+        WebInspector._nodeSearchButton.toggled = false;
+    }
+    WebInspector.showPanel("elements").revealAndSelectNode(nodeId);
 }
 
 WebInspector._showAnchorLocation = function(anchor)
 {
     if (WebInspector.openAnchorLocationRegistry.dispatch({ url: anchor.href, lineNumber: anchor.lineNumber}))
         return true;
-    var preferredPanels = [];
-    if (this.panels[anchor.preferredPanel])
-        preferredPanels.push(this.panels[anchor.preferredPanel]);
-    if (this.panels.scripts)
-        preferredPanels.push(this.panels.scripts);
-    if (this.panels.resources)
-        preferredPanels.push(this.panels.resources);
-    if (this.panels.network)
-        preferredPanels.push(this.panels.network);
-    for (var i = 0; i < preferredPanels.length; ++i) {
-        if (WebInspector._showAnchorLocationInPanel(anchor, preferredPanels[i]))
-            return true;
-    }
+    var preferredPanel = this.panels[anchor.preferredPanel];
+    if (preferredPanel && WebInspector._showAnchorLocationInPanel(anchor, preferredPanel))
+        return true;
+    if (WebInspector._showAnchorLocationInPanel(anchor, this.panels.scripts))
+        return true;
+    if (WebInspector._showAnchorLocationInPanel(anchor, this.panel("resources")))
+        return true;
+    if (WebInspector._showAnchorLocationInPanel(anchor, this.panels.network))
+        return true;
     return false;
 }
 
@@ -1031,8 +1051,7 @@ WebInspector.showPanelForAnchorNavigation = function(panel)
 
 WebInspector.showProfileForURL = function(url)
 {
-    WebInspector.showPanel("profiles");
-    WebInspector.panels.profiles.showProfileForURL(url);
+    WebInspector.showPanel("profiles").showProfileForURL(url);
 }
 
 WebInspector.evaluateInConsole = function(expression, showResultOnly)
@@ -1055,10 +1074,3 @@ WebInspector.frontendReused = function()
 {
     this.resourceTreeModel.frontendReused();
 }
-
-WebInspector._toolbarItemClicked = function(event)
-{
-    var toolbarItem = event.currentTarget;
-    WebInspector.inspectorView.setCurrentPanel(toolbarItem.panel);
-}
-