Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1213)

Side by Side Diff: Source/devtools/front_end/main/Main.js

Issue 408853002: [DevTools] Make toolbar counters declarative. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed comment Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 { 43 {
44 this._loaded(); 44 this._loaded();
45 window.removeEventListener("DOMContentLoaded", boundListener, false); 45 window.removeEventListener("DOMContentLoaded", boundListener, false);
46 } 46 }
47 window.addEventListener("DOMContentLoaded", boundListener, false); 47 window.addEventListener("DOMContentLoaded", boundListener, false);
48 } 48 }
49 49
50 WebInspector.Main.prototype = { 50 WebInspector.Main.prototype = {
51 _createGlobalStatusBarItems: function() 51 _createGlobalStatusBarItems: function()
52 { 52 {
53 var extensions = WebInspector.moduleManager.extensions(WebInspector.Stat usBarButton.Provider); 53 var extensions = WebInspector.moduleManager.extensions(WebInspector.Stat usBarItem.Provider);
54 54
55 /** 55 /**
56 * @param {!WebInspector.ModuleManager.Extension} left 56 * @param {!WebInspector.ModuleManager.Extension} left
57 * @param {!WebInspector.ModuleManager.Extension} right 57 * @param {!WebInspector.ModuleManager.Extension} right
58 */ 58 */
59 function orderComparator(left, right) 59 function orderComparator(left, right)
60 { 60 {
61 return left.descriptor()["order"] - right.descriptor()["order"]; 61 return left.descriptor()["order"] - right.descriptor()["order"];
62 } 62 }
63 extensions.sort(orderComparator); 63 extensions.sort(orderComparator);
64 extensions.forEach(function(extension) { 64 extensions.forEach(function(extension) {
65 var button; 65 var item;
66 switch (extension.descriptor()["location"]) { 66 switch (extension.descriptor()["location"]) {
67 case "toolbar-left": 67 case "toolbar-left":
68 button = createButton(extension); 68 item = createItem(extension);
69 if (button) 69 if (item)
70 WebInspector.inspectorView.appendToLeftToolbar(button); 70 WebInspector.inspectorView.appendToLeftToolbar(item);
71 break; 71 break;
72 case "toolbar-right": 72 case "toolbar-right":
73 button = createButton(extension); 73 item = createItem(extension);
74 if (button) 74 if (item)
75 WebInspector.inspectorView.appendToRightToolbar(button); 75 WebInspector.inspectorView.appendToRightToolbar(item);
76 break; 76 break;
77 } 77 }
78 if (button && extension.descriptor()["actionId"]) { 78 if (item && extension.descriptor()["actionId"]) {
79 button.addEventListener("click", function() { 79 item.addEventListener("click", function() {
80 WebInspector.actionRegistry.execute(extension.descriptor()[" actionId"]); 80 WebInspector.actionRegistry.execute(extension.descriptor()[" actionId"]);
81 }); 81 });
82 } 82 }
83 }); 83 });
84 84
85 function createButton(extension) 85 function createItem(extension)
86 { 86 {
87 var descriptor = extension.descriptor(); 87 var descriptor = extension.descriptor();
88 if (descriptor.className) 88 if (descriptor.className)
89 return extension.instance().button(); 89 return extension.instance().item();
90 return new WebInspector.StatusBarButton(WebInspector.UIString(descri ptor["title"]), descriptor["elementClass"]); 90 return new WebInspector.StatusBarButton(WebInspector.UIString(descri ptor["title"]), descriptor["elementClass"]);
91 } 91 }
92 }, 92 },
93 93
94 _calculateWorkerInspectorTitle: function() 94 _calculateWorkerInspectorTitle: function()
95 { 95 {
96 var expression = "location.href"; 96 var expression = "location.href";
97 if (WebInspector.queryParam("isSharedWorker")) 97 if (WebInspector.queryParam("isSharedWorker"))
98 expression += " + (this.name ? ' (' + this.name + ')' : '')"; 98 expression += " + (this.name ? ' (' + this.name + ')' : '')";
99 RuntimeAgent.invoke_evaluate({expression:expression, doNotPauseOnExcepti onsAndMuteConsole:true, returnByValue: true}, evalCallback); 99 RuntimeAgent.invoke_evaluate({expression:expression, doNotPauseOnExcepti onsAndMuteConsole:true, returnByValue: true}, evalCallback);
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 WebInspector.domBreakpointsSidebarPane = new WebInspector.DOMBreakpoints SidebarPane(); 355 WebInspector.domBreakpointsSidebarPane = new WebInspector.DOMBreakpoints SidebarPane();
356 var autoselectPanel = WebInspector.UIString("a panel chosen automaticall y"); 356 var autoselectPanel = WebInspector.UIString("a panel chosen automaticall y");
357 var openAnchorLocationSetting = WebInspector.settings.createSetting("ope nLinkHandler", autoselectPanel); 357 var openAnchorLocationSetting = WebInspector.settings.createSetting("ope nLinkHandler", autoselectPanel);
358 WebInspector.openAnchorLocationRegistry = new WebInspector.HandlerRegist ry(openAnchorLocationSetting); 358 WebInspector.openAnchorLocationRegistry = new WebInspector.HandlerRegist ry(openAnchorLocationSetting);
359 WebInspector.openAnchorLocationRegistry.registerHandler(autoselectPanel, function() { return false; }); 359 WebInspector.openAnchorLocationRegistry.registerHandler(autoselectPanel, function() { return false; });
360 WebInspector.Linkifier.setLinkHandler(new WebInspector.HandlerRegistry.L inkHandler()); 360 WebInspector.Linkifier.setLinkHandler(new WebInspector.HandlerRegistry.L inkHandler());
361 new WebInspector.WorkspaceController(WebInspector.workspace); 361 new WebInspector.WorkspaceController(WebInspector.workspace);
362 new WebInspector.CSSStyleSheetMapping(WebInspector.cssModel, WebInspecto r.workspace, WebInspector.networkWorkspaceBinding); 362 new WebInspector.CSSStyleSheetMapping(WebInspector.cssModel, WebInspecto r.workspace, WebInspector.networkWorkspaceBinding);
363 new WebInspector.RenderingOptions(); 363 new WebInspector.RenderingOptions();
364 new WebInspector.Main.PauseListener(); 364 new WebInspector.Main.PauseListener();
365 new WebInspector.Main.WarningErrorCounter();
366 new WebInspector.Main.InspectedNodeRevealer(); 365 new WebInspector.Main.InspectedNodeRevealer();
367 366
368 this._addMainEventListeners(document); 367 this._addMainEventListeners(document);
369 368
370 var errorWarningCount = document.getElementById("error-warning-count");
371 function showConsole()
372 {
373 WebInspector.console.show();
374 }
375 errorWarningCount.addEventListener("click", showConsole, false);
376
377 WebInspector.extensionServerProxy.setFrontendReady(); 369 WebInspector.extensionServerProxy.setFrontendReady();
378 370
379 InspectorAgent.enable(inspectorAgentEnableCallback); 371 InspectorAgent.enable(inspectorAgentEnableCallback);
380 372
381 function inspectorAgentEnableCallback() 373 function inspectorAgentEnableCallback()
382 { 374 {
383 console.timeStamp("Main.inspectorAgentEnableCallback"); 375 console.timeStamp("Main.inspectorAgentEnableCallback");
384 WebInspector.app.presentUI(mainTarget); 376 WebInspector.app.presentUI(mainTarget);
385 console.timeStamp("Main.inspectorAgentEnableCallbackPresentUI"); 377 console.timeStamp("Main.inspectorAgentEnableCallbackPresentUI");
386 } 378 }
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 * @param {string} name 821 * @param {string} name
830 * @return {?WebInspector.Panel} 822 * @return {?WebInspector.Panel}
831 */ 823 */
832 WebInspector.panel = function(name) 824 WebInspector.panel = function(name)
833 { 825 {
834 return WebInspector.inspectorView.panel(name); 826 return WebInspector.inspectorView.panel(name);
835 } 827 }
836 828
837 /** 829 /**
838 * @constructor 830 * @constructor
831 * @implements {WebInspector.StatusBarItem.Provider}
839 */ 832 */
840 WebInspector.Main.WarningErrorCounter = function() 833 WebInspector.Main.WarningErrorCounter = function()
841 { 834 {
835 this._counter = new WebInspector.StatusBarCounter(["error-icon-small", "warn ing-icon-small"]);
836 this._counter.addEventListener("click", showConsole);
837
838 function showConsole()
839 {
840 WebInspector.console.show();
841 }
842
842 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleMo del.Events.ConsoleCleared, this._updateErrorAndWarningCounts, this); 843 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleMo del.Events.ConsoleCleared, this._updateErrorAndWarningCounts, this);
843 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleMo del.Events.MessageAdded, this._updateErrorAndWarningCounts, this); 844 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleMo del.Events.MessageAdded, this._updateErrorAndWarningCounts, this);
844 } 845 }
845 846
846 WebInspector.Main.WarningErrorCounter.prototype = { 847 WebInspector.Main.WarningErrorCounter.prototype = {
847 _updateErrorAndWarningCounts: function() 848 _updateErrorAndWarningCounts: function()
848 { 849 {
849 var errors = 0; 850 var errors = 0;
850 var warnings = 0; 851 var warnings = 0;
851 var targets = WebInspector.targetManager.targets(); 852 var targets = WebInspector.targetManager.targets();
852 for (var i = 0; i < targets.length; ++i) { 853 for (var i = 0; i < targets.length; ++i) {
853 errors = errors + targets[i].consoleModel.errors; 854 errors = errors + targets[i].consoleModel.errors;
854 warnings = warnings + targets[i].consoleModel.warnings; 855 warnings = warnings + targets[i].consoleModel.warnings;
855 } 856 }
856 WebInspector.inspectorView.setErrorAndWarningCounts(errors, warnings); 857 this._counter.setCounter("error-icon-small", errors, WebInspector.UIStri ng(errors > 1 ? "%d errors" : "%d error", errors));
858 this._counter.setCounter("warning-icon-small", warnings, WebInspector.UI String(warnings > 1 ? "%d warnings" : "%d warning", warnings));
859 WebInspector.inspectorView.toolbarItemResized();
860 },
861
862 /**
863 * @return {?WebInspector.StatusBarItem}
864 */
865 item: function()
866 {
867 return this._counter;
857 } 868 }
858 } 869 }
859 870
860 /** 871 /**
861 * @constructor 872 * @constructor
862 */ 873 */
863 WebInspector.Main.PauseListener = function() 874 WebInspector.Main.PauseListener = function()
864 { 875 {
865 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this); 876 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
866 } 877 }
(...skipping 21 matching lines...) Expand all
888 899
889 WebInspector.Main.InspectedNodeRevealer.prototype = { 900 WebInspector.Main.InspectedNodeRevealer.prototype = {
890 /** 901 /**
891 * @param {!WebInspector.Event} event 902 * @param {!WebInspector.Event} event
892 */ 903 */
893 _inspectNode: function(event) 904 _inspectNode: function(event)
894 { 905 {
895 WebInspector.Revealer.reveal(/** @type {!WebInspector.DOMNode} */ (event .data)); 906 WebInspector.Revealer.reveal(/** @type {!WebInspector.DOMNode} */ (event .data));
896 } 907 }
897 } 908 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/main/AdvancedApp.js ('k') | Source/devtools/front_end/main/ScreencastApp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698