Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.VBox} | 33 * @extends {WebInspector.VBox} |
| 34 * @implements {WebInspector.ViewLocationResolver} | |
| 34 */ | 35 */ |
| 35 WebInspector.InspectorView = function() | 36 WebInspector.InspectorView = function() |
| 36 { | 37 { |
| 37 WebInspector.VBox.call(this); | 38 WebInspector.VBox.call(this); |
| 38 WebInspector.Dialog.setModalHostView(this); | 39 WebInspector.Dialog.setModalHostView(this); |
| 39 this.setMinimumSize(240, 72); | 40 this.setMinimumSize(240, 72); |
| 40 | 41 |
| 41 // DevTools sidebar is a vertical split of panels tabbed pane and a drawer. | 42 // DevTools sidebar is a vertical split of panels tabbed pane and a drawer. |
| 42 this._drawerSplitWidget = new WebInspector.SplitWidget(false, true, "Inspect or.drawerSplitViewState", 200, 200); | 43 this._drawerSplitWidget = new WebInspector.SplitWidget(false, true, "Inspect or.drawerSplitViewState", 200, 200); |
| 43 this._drawerSplitWidget.hideSidebar(); | 44 this._drawerSplitWidget.hideSidebar(); |
| 45 this._drawerSplitWidget.hideDefaultResizer(); | |
| 44 this._drawerSplitWidget.enableShowModeSaving(); | 46 this._drawerSplitWidget.enableShowModeSaving(); |
| 45 this._drawerSplitWidget.show(this.element); | 47 this._drawerSplitWidget.show(this.element); |
| 46 | 48 |
| 49 // Create drawer tabbed pane. | |
| 50 this._drawerTabbedPane = new WebInspector.ExtensibleTabbedPane("drawer-view" , true); | |
| 51 this._drawerTabbedPane.setMinimumSize(0, 27); | |
| 52 this._drawerTabbedPane.enableMoreTabsButton(); | |
| 53 var drawerToolbar = new WebInspector.Toolbar("drawer-close-toolbar"); | |
| 54 var closeDrawerButton = new WebInspector.ToolbarButton(WebInspector.UIString ("Close drawer"), "delete-toolbar-item"); | |
| 55 closeDrawerButton.addEventListener("click", this.closeDrawer.bind(this)); | |
| 56 drawerToolbar.appendToolbarItem(closeDrawerButton); | |
| 57 this._drawerTabbedPane.tabbedPane().appendAfterTabStrip(drawerToolbar.elemen t); | |
| 58 this._drawerSplitWidget.installResizer(this._drawerTabbedPane.tabbedPane().h eaderElement()); | |
| 59 this._drawerSplitWidget.setSidebarWidget(this._drawerTabbedPane); | |
| 60 | |
| 61 // Create main area tabbed pane. | |
| 47 this._tabbedPane = new WebInspector.TabbedPane(); | 62 this._tabbedPane = new WebInspector.TabbedPane(); |
| 48 this._tabbedPane.registerRequiredCSS("ui/inspectorViewTabbedPane.css"); | 63 this._tabbedPane.registerRequiredCSS("ui/inspectorViewTabbedPane.css"); |
| 49 this._tabbedPane.element.classList.add("inspector-view-tabbed-pane"); | 64 this._tabbedPane.element.classList.add("inspector-view-tabbed-pane"); |
| 50 this._tabbedPane.setTabSlider(true); | 65 this._tabbedPane.setTabSlider(true); |
| 51 this._tabbedPane.setAllowTabReorder(true, false); | 66 this._tabbedPane.setAllowTabReorder(true, false); |
| 52 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabOrde rChanged, this._persistPanelOrder, this); | 67 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabOrde rChanged, this._persistPanelOrder, this); |
| 53 this._tabOrderSetting = WebInspector.settings.createSetting("InspectorView.p anelOrder", {}); | 68 this._tabOrderSetting = WebInspector.settings.createSetting("InspectorView.p anelOrder", {}); |
| 54 this._drawerSplitWidget.setMainWidget(this._tabbedPane); | 69 this._drawerSplitWidget.setMainWidget(this._tabbedPane); |
| 55 this._drawer = new WebInspector.Drawer(this._drawerSplitWidget); | |
| 56 | 70 |
| 57 this._panels = {}; | 71 this._panels = {}; |
| 58 // Used by tests. | 72 // Used by tests. |
| 59 WebInspector["panels"] = this._panels; | 73 WebInspector["panels"] = this._panels; |
| 60 | 74 |
| 61 this._history = []; | 75 this._history = []; |
| 62 this._historyIterator = -1; | 76 this._historyIterator = -1; |
| 63 this._keyDownBound = this._keyDown.bind(this); | 77 this._keyDownBound = this._keyDown.bind(this); |
| 64 this._keyPressBound = this._keyPress.bind(this); | 78 this._keyPressBound = this._keyPress.bind(this); |
| 65 /** @type {!Object.<string, !WebInspector.PanelDescriptor>} */ | 79 /** @type {!Object.<string, !WebInspector.PanelDescriptor>} */ |
| 66 this._panelDescriptors = {}; | 80 this._panelDescriptors = {}; |
| 67 /** @type {!Object.<string, !Promise.<!WebInspector.Panel> >} */ | 81 /** @type {!Object.<string, !Promise.<!WebInspector.Panel> >} */ |
| 68 this._panelPromises = {}; | 82 this._panelPromises = {}; |
| 69 | 83 |
| 70 this._lastActivePanelSetting = WebInspector.settings.createSetting("lastActi vePanel", "elements"); | 84 this._lastActivePanelSetting = WebInspector.settings.createSetting("lastActi vePanel", "elements"); |
| 71 | 85 |
| 72 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.ShowPanel, showPanel.bind(this)); | 86 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.ShowPanel, showPanel.bind(this)); |
| 73 this._loadPanelDesciptors(); | 87 this._loadPanelDesciptors(); |
| 74 | 88 |
| 75 /** | 89 /** |
| 76 * @this {WebInspector.InspectorView} | 90 * @this {WebInspector.InspectorView} |
| 77 * @param {!WebInspector.Event} event | 91 * @param {!WebInspector.Event} event |
| 78 */ | 92 */ |
| 79 function showPanel(event) | 93 function showPanel(event) |
| 80 { | 94 { |
| 81 var panelName = /** @type {string} */ (event.data); | 95 var panelName = /** @type {string} */ (event.data); |
| 82 this.showPanel(panelName); | 96 this.showPanel(panelName); |
| 83 } | 97 } |
| 84 }; | 98 } |
| 99 | |
| 100 /** | |
| 101 * @return {!WebInspector.InspectorView} | |
| 102 */ | |
| 103 WebInspector.InspectorView.instance = function() | |
| 104 { | |
| 105 return /** @type {!WebInspector.InspectorView} */ (self.runtime.sharedInstan ce(WebInspector.InspectorView)); | |
| 106 } | |
| 85 | 107 |
| 86 WebInspector.InspectorView.prototype = { | 108 WebInspector.InspectorView.prototype = { |
| 87 wasShown: function() | 109 wasShown: function() |
| 88 { | 110 { |
| 89 this.element.ownerDocument.addEventListener("keydown", this._keyDownBoun d, false); | 111 this.element.ownerDocument.addEventListener("keydown", this._keyDownBoun d, false); |
| 90 this.element.ownerDocument.addEventListener("keypress", this._keyPressBo und, false); | 112 this.element.ownerDocument.addEventListener("keypress", this._keyPressBo und, false); |
| 91 }, | 113 }, |
| 92 | 114 |
| 93 willHide: function() | 115 willHide: function() |
| 94 { | 116 { |
| 95 this.element.ownerDocument.removeEventListener("keydown", this._keyDownB ound, false); | 117 this.element.ownerDocument.removeEventListener("keydown", this._keyDownB ound, false); |
| 96 this.element.ownerDocument.removeEventListener("keypress", this._keyPres sBound, false); | 118 this.element.ownerDocument.removeEventListener("keypress", this._keyPres sBound, false); |
| 97 }, | 119 }, |
| 98 | 120 |
| 121 /** | |
| 122 * @override | |
| 123 * @param {string} locationName | |
| 124 * @return {?WebInspector.ViewLocation} | |
| 125 */ | |
| 126 resolveLocation: function(locationName) | |
| 127 { | |
| 128 this.showDrawer(); | |
| 129 return this._drawerTabbedPane; | |
| 130 }, | |
| 131 | |
| 99 _loadPanelDesciptors: function() | 132 _loadPanelDesciptors: function() |
| 100 { | 133 { |
| 101 /** | 134 /** |
| 102 * @param {!Runtime.Extension} extension | 135 * @param {!Runtime.Extension} extension |
| 103 * @this {!WebInspector.InspectorView} | 136 * @this {!WebInspector.InspectorView} |
| 104 */ | 137 */ |
| 105 function processPanelExtensions(extension) | 138 function processPanelExtensions(extension) |
| 106 { | 139 { |
| 107 var descriptor = new WebInspector.ExtensionPanelDescriptor(extension ); | 140 var descriptor = new WebInspector.ExtensionPanelDescriptor(extension ); |
| 108 var weight = this._tabOrderSetting.get()[descriptor.name()]; | 141 var weight = this._tabOrderSetting.get()[descriptor.name()]; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 this._lastActivePanelSetting.set(panel.name); | 372 this._lastActivePanelSetting.set(panel.name); |
| 340 this._pushToHistory(panel.name); | 373 this._pushToHistory(panel.name); |
| 341 WebInspector.userMetrics.panelShown(panel.name); | 374 WebInspector.userMetrics.panelShown(panel.name); |
| 342 panel.focus(); | 375 panel.focus(); |
| 343 | 376 |
| 344 return panel; | 377 return panel; |
| 345 }, | 378 }, |
| 346 | 379 |
| 347 showDrawer: function() | 380 showDrawer: function() |
| 348 { | 381 { |
| 349 this._drawer.showDrawer(); | 382 if (!this._drawerTabbedPane.isShowing()) |
| 383 this._drawerSplitWidget.showBoth(); | |
| 384 this._drawerTabbedPane.focus(); | |
| 350 }, | 385 }, |
| 351 | 386 |
| 352 /** | 387 /** |
| 353 * @return {boolean} | 388 * @return {boolean} |
| 354 */ | 389 */ |
| 355 drawerVisible: function() | 390 drawerVisible: function() |
| 356 { | 391 { |
| 357 return this._drawer.isShowing(); | 392 return this._drawerTabbedPane.isShowing(); |
| 358 }, | |
| 359 | |
| 360 /** | |
| 361 * @param {string} id | |
| 362 * @param {boolean=} immediate | |
| 363 */ | |
| 364 showViewInDrawer: function(id, immediate) | |
| 365 { | |
| 366 this._drawer.showView(id, immediate); | |
| 367 }, | 393 }, |
| 368 | 394 |
| 369 closeDrawer: function() | 395 closeDrawer: function() |
| 370 { | 396 { |
| 371 this._drawer.closeDrawer(); | 397 if (!this._drawerTabbedPane.isShowing()) |
| 398 return; | |
| 399 WebInspector.restoreFocusFromElement(this._drawerTabbedPane.element); | |
| 400 this._drawerSplitWidget.hideSidebar(true); | |
| 372 }, | 401 }, |
| 373 | 402 |
| 374 /** | 403 /** |
| 375 * @param {boolean} minimized | 404 * @param {boolean} minimized |
| 376 */ | 405 */ |
| 377 setDrawerMinimized: function(minimized) | 406 setDrawerMinimized: function(minimized) |
| 378 { | 407 { |
| 379 this._drawerSplitWidget.setSidebarMinimized(minimized); | 408 this._drawerSplitWidget.setSidebarMinimized(minimized); |
| 380 this._drawerSplitWidget.setResizable(!minimized); | 409 this._drawerSplitWidget.setResizable(!minimized); |
| 381 }, | 410 }, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 if (this._ownerSplitWidget) | 579 if (this._ownerSplitWidget) |
| 551 this._ownerSplitWidget.setSidebarMinimized(false); | 580 this._ownerSplitWidget.setSidebarMinimized(false); |
| 552 }, | 581 }, |
| 553 | 582 |
| 554 __proto__: WebInspector.VBox.prototype | 583 __proto__: WebInspector.VBox.prototype |
| 555 }; | 584 }; |
| 556 | 585 |
| 557 /** | 586 /** |
| 558 * @type {!WebInspector.InspectorView} | 587 * @type {!WebInspector.InspectorView} |
| 559 */ | 588 */ |
| 560 WebInspector.inspectorView; | 589 WebInspector.inspectorView; |
|
dgozman
2016/08/03 19:18:18
Remove this one. And you can move this to the "mai
pfeldman
2016/08/03 21:52:18
Wat?
| |
| 561 | 590 |
| 562 /** | 591 /** |
| 563 * @constructor | 592 * @constructor |
| 564 * @implements {WebInspector.ActionDelegate} | 593 * @implements {WebInspector.ActionDelegate} |
| 565 */ | 594 */ |
| 566 WebInspector.InspectorView.DrawerToggleActionDelegate = function() | 595 WebInspector.InspectorView.DrawerToggleActionDelegate = function() |
| 567 { | 596 { |
| 568 } | 597 } |
| 569 | 598 |
| 570 WebInspector.InspectorView.DrawerToggleActionDelegate.prototype = { | 599 WebInspector.InspectorView.DrawerToggleActionDelegate.prototype = { |
| 571 /** | 600 /** |
| 572 * @override | 601 * @override |
| 573 * @param {!WebInspector.Context} context | 602 * @param {!WebInspector.Context} context |
| 574 * @param {string} actionId | 603 * @param {string} actionId |
| 575 * @return {boolean} | 604 * @return {boolean} |
| 576 */ | 605 */ |
| 577 handleAction: function(context, actionId) | 606 handleAction: function(context, actionId) |
| 578 { | 607 { |
| 579 if (WebInspector.inspectorView.drawerVisible()) | 608 if (WebInspector.inspectorView.drawerVisible()) |
| 580 WebInspector.inspectorView.closeDrawer(); | 609 WebInspector.inspectorView.closeDrawer(); |
| 581 else | 610 else |
| 582 WebInspector.inspectorView.showDrawer(); | 611 WebInspector.inspectorView.showDrawer(); |
| 583 return true; | 612 return true; |
| 584 } | 613 } |
| 585 } | 614 } |
| OLD | NEW |