OLD | NEW |
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 Loading... |
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 | |
75 this._closeButtonToolbarItem = document.createElementWithClass("div", "toolb
ar-close-button-item"); | 64 this._closeButtonToolbarItem = document.createElementWithClass("div", "toolb
ar-close-button-item"); |
76 var closeButtonElement = this._closeButtonToolbarItem.createChild("div", "cl
ose-button"); | 65 var closeButtonElement = this._closeButtonToolbarItem.createChild("div", "cl
ose-button"); |
77 closeButtonElement.addEventListener("click", InspectorFrontendHost.closeWind
ow.bind(InspectorFrontendHost), true); | 66 closeButtonElement.addEventListener("click", InspectorFrontendHost.closeWind
ow.bind(InspectorFrontendHost), true); |
78 this._rightToolbarElement.appendChild(this._closeButtonToolbarItem); | 67 this._rightToolbarElement.appendChild(this._closeButtonToolbarItem); |
79 | 68 |
80 this.appendToRightToolbar(this._drawer.toggleButton()); | |
81 | |
82 this._panels = {}; | 69 this._panels = {}; |
83 // Used by tests. | 70 // Used by tests. |
84 WebInspector["panels"] = this._panels; | 71 WebInspector["panels"] = this._panels; |
85 | 72 |
86 this._history = []; | 73 this._history = []; |
87 this._historyIterator = -1; | 74 this._historyIterator = -1; |
88 document.addEventListener("keydown", this._keyDown.bind(this), false); | 75 document.addEventListener("keydown", this._keyDown.bind(this), false); |
89 document.addEventListener("keypress", this._keyPress.bind(this), false); | 76 document.addEventListener("keypress", this._keyPress.bind(this), false); |
90 this._panelDescriptors = {}; | 77 this._panelDescriptors = {}; |
91 | 78 |
92 // Windows and Mac have two different definitions of '[' and ']', so accept
both of each. | 79 // Windows and Mac have two different definitions of '[' and ']', so accept
both of each. |
93 this._openBracketIdentifiers = ["U+005B", "U+00DB"].keySet(); | 80 this._openBracketIdentifiers = ["U+005B", "U+00DB"].keySet(); |
94 this._closeBracketIdentifiers = ["U+005D", "U+00DD"].keySet(); | 81 this._closeBracketIdentifiers = ["U+005D", "U+00DD"].keySet(); |
95 this._lastActivePanelSetting = WebInspector.settings.createSetting("lastActi
vePanel", "elements"); | 82 this._lastActivePanelSetting = WebInspector.settings.createSetting("lastActi
vePanel", "elements"); |
96 | 83 |
97 this._loadPanelDesciptors(); | 84 this._loadPanelDesciptors(); |
98 | 85 |
99 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.ShowConsole, this.showPanel.bind(this, "console")); | 86 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.ShowConsole, this.showPanel.bind(this, "console")); |
100 }; | 87 }; |
101 | 88 |
102 WebInspector.InspectorView.Events = { | |
103 DeviceCountChanged: "DeviceCountChanged" | |
104 } | |
105 | |
106 WebInspector.InspectorView.prototype = { | 89 WebInspector.InspectorView.prototype = { |
107 _loadPanelDesciptors: function() | 90 _loadPanelDesciptors: function() |
108 { | 91 { |
109 WebInspector.startBatchUpdate(); | 92 WebInspector.startBatchUpdate(); |
110 WebInspector.moduleManager.extensions(WebInspector.Panel).forEach(proces
sPanelExtensions.bind(this)); | 93 WebInspector.moduleManager.extensions(WebInspector.Panel).forEach(proces
sPanelExtensions.bind(this)); |
111 /** | 94 /** |
112 * @param {!WebInspector.ModuleManager.Extension} extension | 95 * @param {!WebInspector.ModuleManager.Extension} extension |
113 * @this {!WebInspector.InspectorView} | 96 * @this {!WebInspector.InspectorView} |
114 */ | 97 */ |
115 function processPanelExtensions(extension) | 98 function processPanelExtensions(extension) |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 }, | 428 }, |
446 | 429 |
447 /** | 430 /** |
448 * @return {!Element} | 431 * @return {!Element} |
449 */ | 432 */ |
450 topResizerElement: function() | 433 topResizerElement: function() |
451 { | 434 { |
452 return this._tabbedPane.headerElement(); | 435 return this._tabbedPane.headerElement(); |
453 }, | 436 }, |
454 | 437 |
455 _createImagedCounterElementIfNeeded: function(parent, count, id, styleName) | 438 toolbarItemResized: function() |
456 { | 439 { |
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(); | 440 this._tabbedPane.headerResized(); |
487 }, | 441 }, |
488 | 442 |
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); | |
502 this._tabbedPane.headerResized(); | |
503 }, | |
504 | |
505 __proto__: WebInspector.VBox.prototype | 443 __proto__: WebInspector.VBox.prototype |
506 }; | 444 }; |
507 | 445 |
508 /** | 446 /** |
509 * @type {!WebInspector.InspectorView} | 447 * @type {!WebInspector.InspectorView} |
510 */ | 448 */ |
511 WebInspector.inspectorView; | 449 WebInspector.inspectorView; |
512 | 450 |
513 /** | 451 /** |
514 * @constructor | 452 * @constructor |
(...skipping 13 matching lines...) Expand all Loading... |
528 WebInspector.inspectorView.closeDrawer(); | 466 WebInspector.inspectorView.closeDrawer(); |
529 return true; | 467 return true; |
530 } | 468 } |
531 WebInspector.inspectorView.showDrawer(); | 469 WebInspector.inspectorView.showDrawer(); |
532 return true; | 470 return true; |
533 } | 471 } |
534 } | 472 } |
535 | 473 |
536 /** | 474 /** |
537 * @constructor | 475 * @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 |
538 * @extends {WebInspector.VBox} | 494 * @extends {WebInspector.VBox} |
539 */ | 495 */ |
540 WebInspector.RootView = function() | 496 WebInspector.RootView = function() |
541 { | 497 { |
542 WebInspector.VBox.call(this); | 498 WebInspector.VBox.call(this); |
543 this.markAsRoot(); | 499 this.markAsRoot(); |
544 this.element.classList.add("root-view"); | 500 this.element.classList.add("root-view"); |
545 this.element.setAttribute("spellcheck", false); | 501 this.element.setAttribute("spellcheck", false); |
546 window.addEventListener("resize", this.doResize.bind(this), true); | 502 window.addEventListener("resize", this.doResize.bind(this), true); |
547 this._onScrollBound = this._onScroll.bind(this); | 503 this._onScrollBound = this._onScroll.bind(this); |
(...skipping 28 matching lines...) Expand all Loading... |
576 window.addEventListener("scroll", this._onScrollBound, false); | 532 window.addEventListener("scroll", this._onScrollBound, false); |
577 else | 533 else |
578 window.removeEventListener("scroll", this._onScrollBound, false); | 534 window.removeEventListener("scroll", this._onScrollBound, false); |
579 | 535 |
580 WebInspector.VBox.prototype.doResize.call(this); | 536 WebInspector.VBox.prototype.doResize.call(this); |
581 this._onScroll(); | 537 this._onScroll(); |
582 }, | 538 }, |
583 | 539 |
584 __proto__: WebInspector.VBox.prototype | 540 __proto__: WebInspector.VBox.prototype |
585 }; | 541 }; |
OLD | NEW |