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

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

Issue 2751173003: [DevTools] Turn ConsoleModel into a singleton (Closed)
Patch Set: rebased Created 3 years, 9 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
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 this._addMainEventListeners(document); 159 this._addMainEventListeners(document);
160 160
161 var canDock = !!Runtime.queryParam('can_dock'); 161 var canDock = !!Runtime.queryParam('can_dock');
162 UI.zoomManager = new UI.ZoomManager(window, InspectorFrontendHost); 162 UI.zoomManager = new UI.ZoomManager(window, InspectorFrontendHost);
163 UI.inspectorView = UI.InspectorView.instance(); 163 UI.inspectorView = UI.InspectorView.instance();
164 UI.ContextMenu.initialize(); 164 UI.ContextMenu.initialize();
165 UI.ContextMenu.installHandler(document); 165 UI.ContextMenu.installHandler(document);
166 UI.Tooltip.installHandler(document); 166 UI.Tooltip.installHandler(document);
167 Components.dockController = new Components.DockController(canDock); 167 Components.dockController = new Components.DockController(canDock);
168 SDK.multitargetConsoleModel = new SDK.MultitargetConsoleModel(); 168 SDK.consoleModel = new SDK.ConsoleModel();
169 SDK.multitargetNetworkManager = new SDK.MultitargetNetworkManager(); 169 SDK.multitargetNetworkManager = new SDK.MultitargetNetworkManager();
170 SDK.targetManager.addEventListener( 170 SDK.targetManager.addEventListener(
171 SDK.TargetManager.Events.SuspendStateChanged, this._onSuspendStateChange d.bind(this)); 171 SDK.TargetManager.Events.SuspendStateChanged, this._onSuspendStateChange d.bind(this));
172 172
173 UI.shortcutsScreen = new UI.ShortcutsScreen(); 173 UI.shortcutsScreen = new UI.ShortcutsScreen();
174 // set order of some sections explicitly 174 // set order of some sections explicitly
175 UI.shortcutsScreen.section(Common.UIString('Elements Panel')); 175 UI.shortcutsScreen.section(Common.UIString('Elements Panel'));
176 UI.shortcutsScreen.section(Common.UIString('Styles Pane')); 176 UI.shortcutsScreen.section(Common.UIString('Styles Pane'));
177 UI.shortcutsScreen.section(Common.UIString('Debugger')); 177 UI.shortcutsScreen.section(Common.UIString('Debugger'));
178 UI.shortcutsScreen.section(Common.UIString('Console')); 178 UI.shortcutsScreen.section(Common.UIString('Console'));
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 595
596 this._counter = createElement('div'); 596 this._counter = createElement('div');
597 this._counter.addEventListener('click', Common.console.show.bind(Common.cons ole), false); 597 this._counter.addEventListener('click', Common.console.show.bind(Common.cons ole), false);
598 this._toolbarItem = new UI.ToolbarItem(this._counter); 598 this._toolbarItem = new UI.ToolbarItem(this._counter);
599 var shadowRoot = UI.createShadowRootWithCoreStyles(this._counter, 'main/erro rWarningCounter.css'); 599 var shadowRoot = UI.createShadowRootWithCoreStyles(this._counter, 'main/erro rWarningCounter.css');
600 600
601 this._errors = this._createItem(shadowRoot, 'smallicon-error'); 601 this._errors = this._createItem(shadowRoot, 'smallicon-error');
602 this._warnings = this._createItem(shadowRoot, 'smallicon-warning'); 602 this._warnings = this._createItem(shadowRoot, 'smallicon-warning');
603 this._titles = []; 603 this._titles = [];
604 604
605 SDK.multitargetConsoleModel.addEventListener(SDK.ConsoleModel.Events.Console Cleared, this._update, this); 605 SDK.consoleModel.addEventListener(SDK.ConsoleModel.Events.ConsoleCleared, th is._update, this);
606 SDK.multitargetConsoleModel.addEventListener(SDK.ConsoleModel.Events.Message Added, this._update, this); 606 SDK.consoleModel.addEventListener(SDK.ConsoleModel.Events.MessageAdded, this ._update, this);
607 SDK.multitargetConsoleModel.addEventListener(SDK.ConsoleModel.Events.Message Updated, this._update, this); 607 SDK.consoleModel.addEventListener(SDK.ConsoleModel.Events.MessageUpdated, th is._update, this);
608 this._update(); 608 this._update();
609 } 609 }
610 610
611 /** 611 /**
612 * @param {!Node} shadowRoot 612 * @param {!Node} shadowRoot
613 * @param {string} iconType 613 * @param {string} iconType
614 * @return {!{item: !Element, text: !Element}} 614 * @return {!{item: !Element, text: !Element}}
615 */ 615 */
616 _createItem(shadowRoot, iconType) { 616 _createItem(shadowRoot, iconType) {
617 var item = createElementWithClass('span', 'counter-item'); 617 var item = createElementWithClass('span', 'counter-item');
(...skipping 12 matching lines...) Expand all
630 */ 630 */
631 _updateItem(item, count, first, title) { 631 _updateItem(item, count, first, title) {
632 item.item.classList.toggle('hidden', !count); 632 item.item.classList.toggle('hidden', !count);
633 item.item.classList.toggle('counter-item-first', first); 633 item.item.classList.toggle('counter-item-first', first);
634 item.text.textContent = count; 634 item.text.textContent = count;
635 if (count) 635 if (count)
636 this._titles.push(title); 636 this._titles.push(title);
637 } 637 }
638 638
639 _update() { 639 _update() {
640 var errors = SDK.multitargetConsoleModel.errors(); 640 var errors = SDK.consoleModel.errors();
641 var warnings = SDK.multitargetConsoleModel.warnings(); 641 var warnings = SDK.consoleModel.warnings();
642 642
643 this._titles = []; 643 this._titles = [];
644 this._toolbarItem.setVisible(!!(errors || warnings)); 644 this._toolbarItem.setVisible(!!(errors || warnings));
645 this._updateItem(this._errors, errors, false, Common.UIString(errors === 1 ? '%d error' : '%d errors', errors)); 645 this._updateItem(this._errors, errors, false, Common.UIString(errors === 1 ? '%d error' : '%d errors', errors));
646 this._updateItem( 646 this._updateItem(
647 this._warnings, warnings, !errors, Common.UIString(warnings === 1 ? '%d warning' : '%d warnings', warnings)); 647 this._warnings, warnings, !errors, Common.UIString(warnings === 1 ? '%d warning' : '%d warnings', warnings));
648 this._counter.title = this._titles.join(', '); 648 this._counter.title = this._titles.join(', ');
649 UI.inspectorView.toolbarItemResized(); 649 UI.inspectorView.toolbarItemResized();
650 } 650 }
651 651
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 * @override 952 * @override
953 * @return {?Element} 953 * @return {?Element}
954 */ 954 */
955 settingElement() { 955 settingElement() {
956 return UI.SettingsUI.createSettingCheckbox( 956 return UI.SettingsUI.createSettingCheckbox(
957 Common.UIString('Show rulers'), Common.moduleSetting('showMetricsRulers' )); 957 Common.UIString('Show rulers'), Common.moduleSetting('showMetricsRulers' ));
958 } 958 }
959 }; 959 };
960 960
961 new Main.Main(); 961 new Main.Main();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698