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

Side by Side Diff: trunk/Source/devtools/front_end/components/InspectorView.js

Issue 416983006: Revert 178848 "[DevTools] Make toolbar counters declarative." (Closed) Base URL: svn://svn.chromium.org/blink/
Patch Set: Created 6 years, 4 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 this._toolbarElement = document.createElement("div"); 54 this._toolbarElement = document.createElement("div");
55 this._toolbarElement.className = "toolbar toolbar-background toolbar-colors" ; 55 this._toolbarElement.className = "toolbar toolbar-background toolbar-colors" ;
56 var headerElement = this._tabbedPane.headerElement(); 56 var headerElement = this._tabbedPane.headerElement();
57 headerElement.parentElement.insertBefore(this._toolbarElement, headerElement ); 57 headerElement.parentElement.insertBefore(this._toolbarElement, headerElement );
58 58
59 this._leftToolbarElement = this._toolbarElement.createChild("div", "toolbar- controls-left"); 59 this._leftToolbarElement = this._toolbarElement.createChild("div", "toolbar- controls-left");
60 this._toolbarElement.appendChild(headerElement); 60 this._toolbarElement.appendChild(headerElement);
61 this._rightToolbarElement = this._toolbarElement.createChild("div", "toolbar -controls-right"); 61 this._rightToolbarElement = this._toolbarElement.createChild("div", "toolbar -controls-right");
62 this._toolbarItems = []; 62 this._toolbarItems = [];
63 63
64 if (WebInspector.experimentsSettings.devicesPanel.isEnabled()) {
65 this._remoteDeviceCountElement = this._rightToolbarElement.createChild(" div", "hidden");
66 this._remoteDeviceCountElement.addEventListener("click", this.showViewIn Drawer.bind(this, "devices", true), false);
67 this._remoteDeviceCountElement.id = "remote-device-count";
68 InspectorFrontendHost.setDeviceCountUpdatesEnabled(true);
69 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.E vents.DeviceCountUpdated, this._onDeviceCountUpdated, this);
70 }
71
72 this._errorWarningCountElement = this._rightToolbarElement.createChild("div" , "hidden");
73 this._errorWarningCountElement.id = "error-warning-count";
74
64 this._closeButtonToolbarItem = document.createElementWithClass("div", "toolb ar-close-button-item"); 75 this._closeButtonToolbarItem = document.createElementWithClass("div", "toolb ar-close-button-item");
65 var closeButtonElement = this._closeButtonToolbarItem.createChild("div", "cl ose-button"); 76 var closeButtonElement = this._closeButtonToolbarItem.createChild("div", "cl ose-button");
66 closeButtonElement.addEventListener("click", InspectorFrontendHost.closeWind ow.bind(InspectorFrontendHost), true); 77 closeButtonElement.addEventListener("click", InspectorFrontendHost.closeWind ow.bind(InspectorFrontendHost), true);
67 this._rightToolbarElement.appendChild(this._closeButtonToolbarItem); 78 this._rightToolbarElement.appendChild(this._closeButtonToolbarItem);
68 79
80 this.appendToRightToolbar(this._drawer.toggleButton());
81
69 this._panels = {}; 82 this._panels = {};
70 // Used by tests. 83 // Used by tests.
71 WebInspector["panels"] = this._panels; 84 WebInspector["panels"] = this._panels;
72 85
73 this._history = []; 86 this._history = [];
74 this._historyIterator = -1; 87 this._historyIterator = -1;
75 document.addEventListener("keydown", this._keyDown.bind(this), false); 88 document.addEventListener("keydown", this._keyDown.bind(this), false);
76 document.addEventListener("keypress", this._keyPress.bind(this), false); 89 document.addEventListener("keypress", this._keyPress.bind(this), false);
77 this._panelDescriptors = {}; 90 this._panelDescriptors = {};
78 91
79 // Windows and Mac have two different definitions of '[' and ']', so accept both of each. 92 // Windows and Mac have two different definitions of '[' and ']', so accept both of each.
80 this._openBracketIdentifiers = ["U+005B", "U+00DB"].keySet(); 93 this._openBracketIdentifiers = ["U+005B", "U+00DB"].keySet();
81 this._closeBracketIdentifiers = ["U+005D", "U+00DD"].keySet(); 94 this._closeBracketIdentifiers = ["U+005D", "U+00DD"].keySet();
82 this._lastActivePanelSetting = WebInspector.settings.createSetting("lastActi vePanel", "elements"); 95 this._lastActivePanelSetting = WebInspector.settings.createSetting("lastActi vePanel", "elements");
83 96
84 this._loadPanelDesciptors(); 97 this._loadPanelDesciptors();
85 98
86 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.ShowConsole, this.showPanel.bind(this, "console")); 99 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.ShowConsole, this.showPanel.bind(this, "console"));
87 }; 100 };
88 101
102 WebInspector.InspectorView.Events = {
103 DeviceCountChanged: "DeviceCountChanged"
104 }
105
89 WebInspector.InspectorView.prototype = { 106 WebInspector.InspectorView.prototype = {
90 _loadPanelDesciptors: function() 107 _loadPanelDesciptors: function()
91 { 108 {
92 WebInspector.startBatchUpdate(); 109 WebInspector.startBatchUpdate();
93 WebInspector.moduleManager.extensions(WebInspector.Panel).forEach(proces sPanelExtensions.bind(this)); 110 WebInspector.moduleManager.extensions(WebInspector.Panel).forEach(proces sPanelExtensions.bind(this));
94 /** 111 /**
95 * @param {!WebInspector.ModuleManager.Extension} extension 112 * @param {!WebInspector.ModuleManager.Extension} extension
96 * @this {!WebInspector.InspectorView} 113 * @this {!WebInspector.InspectorView}
97 */ 114 */
98 function processPanelExtensions(extension) 115 function processPanelExtensions(extension)
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 }, 445 },
429 446
430 /** 447 /**
431 * @return {!Element} 448 * @return {!Element}
432 */ 449 */
433 topResizerElement: function() 450 topResizerElement: function()
434 { 451 {
435 return this._tabbedPane.headerElement(); 452 return this._tabbedPane.headerElement();
436 }, 453 },
437 454
438 toolbarItemResized: function() 455 _createImagedCounterElementIfNeeded: function(parent, count, id, styleName)
439 { 456 {
457 if (!count)
458 return;
459
460 var imageElement = parent.createChild("div", styleName);
461 var counterElement = parent.createChild("span");
462 counterElement.id = id;
463 counterElement.textContent = count;
464 },
465
466 /**
467 * @param {number} errors
468 * @param {number} warnings
469 */
470 setErrorAndWarningCounts: function(errors, warnings)
471 {
472 if (this._errors === errors && this._warnings === warnings)
473 return;
474 this._errors = errors;
475 this._warnings = warnings;
476 this._errorWarningCountElement.classList.toggle("hidden", !errors && !wa rnings);
477 this._errorWarningCountElement.removeChildren();
478
479 this._createImagedCounterElementIfNeeded(this._errorWarningCountElement, errors, "error-count", "error-icon-small");
480 this._createImagedCounterElementIfNeeded(this._errorWarningCountElement, warnings, "warning-count", "warning-icon-small");
481
482 var errorString = errors ? WebInspector.UIString("%d error%s", errors, errors > 1 ? "s" : "") : "";
483 var warningString = warnings ? WebInspector.UIString("%d warning%s", wa rnings, warnings > 1 ? "s" : "") : "";
484 var commaString = errors && warnings ? ", " : "";
485 this._errorWarningCountElement.title = errorString + commaString + warni ngString;
486 this._tabbedPane.headerResized();
487 },
488
489 /**
490 * @param {!WebInspector.Event} event
491 */
492 _onDeviceCountUpdated: function(event)
493 {
494 var count = /** @type {number} */ (event.data);
495 if (count === this.deviceCount_)
496 return;
497 this.deviceCount_ = count;
498 this._remoteDeviceCountElement.classList.toggle("hidden", !count);
499 this._remoteDeviceCountElement.removeChildren();
500 this._createImagedCounterElementIfNeeded(this._remoteDeviceCountElement, count, "device-count", "device-icon-small");
501 this._remoteDeviceCountElement.title = WebInspector.UIString(((count > 1 ) ? "%d devices found" : "%d device found"), count);
440 this._tabbedPane.headerResized(); 502 this._tabbedPane.headerResized();
441 }, 503 },
442 504
443 __proto__: WebInspector.VBox.prototype 505 __proto__: WebInspector.VBox.prototype
444 }; 506 };
445 507
446 /** 508 /**
447 * @type {!WebInspector.InspectorView} 509 * @type {!WebInspector.InspectorView}
448 */ 510 */
449 WebInspector.inspectorView; 511 WebInspector.inspectorView;
(...skipping 16 matching lines...) Expand all
466 WebInspector.inspectorView.closeDrawer(); 528 WebInspector.inspectorView.closeDrawer();
467 return true; 529 return true;
468 } 530 }
469 WebInspector.inspectorView.showDrawer(); 531 WebInspector.inspectorView.showDrawer();
470 return true; 532 return true;
471 } 533 }
472 } 534 }
473 535
474 /** 536 /**
475 * @constructor 537 * @constructor
476 * @implements {WebInspector.StatusBarItem.Provider}
477 */
478 WebInspector.InspectorView.ToggleDrawerButtonProvider = function()
479 {
480 }
481
482 WebInspector.InspectorView.ToggleDrawerButtonProvider.prototype = {
483 /**
484 * @return {?WebInspector.StatusBarItem}
485 */
486 item: function()
487 {
488 return WebInspector.inspectorView._drawer.toggleButton();
489 }
490 }
491
492 /**
493 * @constructor
494 * @extends {WebInspector.VBox} 538 * @extends {WebInspector.VBox}
495 */ 539 */
496 WebInspector.RootView = function() 540 WebInspector.RootView = function()
497 { 541 {
498 WebInspector.VBox.call(this); 542 WebInspector.VBox.call(this);
499 this.markAsRoot(); 543 this.markAsRoot();
500 this.element.classList.add("root-view"); 544 this.element.classList.add("root-view");
501 this.element.setAttribute("spellcheck", false); 545 this.element.setAttribute("spellcheck", false);
502 window.addEventListener("resize", this.doResize.bind(this), true); 546 window.addEventListener("resize", this.doResize.bind(this), true);
503 this._onScrollBound = this._onScroll.bind(this); 547 this._onScrollBound = this._onScroll.bind(this);
(...skipping 28 matching lines...) Expand all
532 window.addEventListener("scroll", this._onScrollBound, false); 576 window.addEventListener("scroll", this._onScrollBound, false);
533 else 577 else
534 window.removeEventListener("scroll", this._onScrollBound, false); 578 window.removeEventListener("scroll", this._onScrollBound, false);
535 579
536 WebInspector.VBox.prototype.doResize.call(this); 580 WebInspector.VBox.prototype.doResize.call(this);
537 this._onScroll(); 581 this._onScroll();
538 }, 582 },
539 583
540 __proto__: WebInspector.VBox.prototype 584 __proto__: WebInspector.VBox.prototype
541 }; 585 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698