| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 this._drawerTabbedLocation.enableMoreTabsButton(); | 51 this._drawerTabbedLocation.enableMoreTabsButton(); |
| 52 this._drawerTabbedPane = this._drawerTabbedLocation.tabbedPane(); | 52 this._drawerTabbedPane = this._drawerTabbedLocation.tabbedPane(); |
| 53 this._drawerTabbedPane.setMinimumSize(0, 27); | 53 this._drawerTabbedPane.setMinimumSize(0, 27); |
| 54 var closeDrawerButton = new WebInspector.ToolbarButton(WebInspector.UIString
("Close drawer"), "delete-toolbar-item"); | 54 var closeDrawerButton = new WebInspector.ToolbarButton(WebInspector.UIString
("Close drawer"), "delete-toolbar-item"); |
| 55 closeDrawerButton.addEventListener("click", this._closeDrawer.bind(this)); | 55 closeDrawerButton.addEventListener("click", this._closeDrawer.bind(this)); |
| 56 this._drawerTabbedPane.rightToolbar().appendToolbarItem(closeDrawerButton); | 56 this._drawerTabbedPane.rightToolbar().appendToolbarItem(closeDrawerButton); |
| 57 this._drawerSplitWidget.installResizer(this._drawerTabbedPane.headerElement(
)); | 57 this._drawerSplitWidget.installResizer(this._drawerTabbedPane.headerElement(
)); |
| 58 this._drawerSplitWidget.setSidebarWidget(this._drawerTabbedPane); | 58 this._drawerSplitWidget.setSidebarWidget(this._drawerTabbedPane); |
| 59 | 59 |
| 60 // Create main area tabbed pane. | 60 // Create main area tabbed pane. |
| 61 this._tabbedPane = new WebInspector.TabbedPane(); | 61 this._tabbedLocation = WebInspector.viewManager.createTabbedLocation(Inspect
orFrontendHost.bringToFront.bind(InspectorFrontendHost), "panel", true, true); |
| 62 this._tabbedPane = this._tabbedLocation.tabbedPane(); |
| 62 this._tabbedPane.registerRequiredCSS("ui/inspectorViewTabbedPane.css"); | 63 this._tabbedPane.registerRequiredCSS("ui/inspectorViewTabbedPane.css"); |
| 63 this._tabbedPane.setTabSlider(true); | 64 this._tabbedPane.setTabSlider(true); |
| 64 this._tabbedPane.setAllowTabReorder(true, false); | 65 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabSelected
, this._tabSelected, this); |
| 65 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabOrderCha
nged, this._persistPanelOrder, this); | 66 |
| 66 this._tabOrderSetting = WebInspector.settings.createSetting("InspectorView.p
anelOrder", {}); | 67 if (InspectorFrontendHost.isUnderTest()) |
| 68 this._tabbedPane.setAutoSelectFirstItemOnShow(false); |
| 67 this._drawerSplitWidget.setMainWidget(this._tabbedPane); | 69 this._drawerSplitWidget.setMainWidget(this._tabbedPane); |
| 68 | 70 |
| 69 this._panels = {}; | |
| 70 // Used by tests. | |
| 71 WebInspector["panels"] = this._panels; | |
| 72 | |
| 73 this._history = []; | |
| 74 this._historyIterator = -1; | |
| 75 this._keyDownBound = this._keyDown.bind(this); | 71 this._keyDownBound = this._keyDown.bind(this); |
| 76 this._keyPressBound = this._keyPress.bind(this); | |
| 77 /** @type {!Object.<string, !WebInspector.PanelDescriptor>} */ | |
| 78 this._panelDescriptors = {}; | |
| 79 /** @type {!Object.<string, !Promise.<!WebInspector.Panel> >} */ | |
| 80 this._panelPromises = {}; | |
| 81 | |
| 82 this._lastActivePanelSetting = WebInspector.settings.createSetting("lastActi
vePanel", "elements"); | |
| 83 | |
| 84 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.ShowPanel, showPanel.bind(this)); | 72 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.ShowPanel, showPanel.bind(this)); |
| 85 this._loadPanelDesciptors(); | |
| 86 | 73 |
| 87 /** | 74 /** |
| 88 * @this {WebInspector.InspectorView} | 75 * @this {WebInspector.InspectorView} |
| 89 * @param {!WebInspector.Event} event | 76 * @param {!WebInspector.Event} event |
| 90 */ | 77 */ |
| 91 function showPanel(event) | 78 function showPanel(event) |
| 92 { | 79 { |
| 93 var panelName = /** @type {string} */ (event.data); | 80 var panelName = /** @type {string} */ (event.data); |
| 94 this.showPanel(panelName); | 81 this.showPanel(panelName); |
| 95 } | 82 } |
| 96 } | 83 } |
| 97 | 84 |
| 98 /** | 85 /** |
| 99 * @return {!WebInspector.InspectorView} | 86 * @return {!WebInspector.InspectorView} |
| 100 */ | 87 */ |
| 101 WebInspector.InspectorView.instance = function() | 88 WebInspector.InspectorView.instance = function() |
| 102 { | 89 { |
| 103 return /** @type {!WebInspector.InspectorView} */ (self.runtime.sharedInstan
ce(WebInspector.InspectorView)); | 90 return /** @type {!WebInspector.InspectorView} */ (self.runtime.sharedInstan
ce(WebInspector.InspectorView)); |
| 104 } | 91 } |
| 105 | 92 |
| 106 WebInspector.InspectorView.prototype = { | 93 WebInspector.InspectorView.prototype = { |
| 107 wasShown: function() | 94 wasShown: function() |
| 108 { | 95 { |
| 109 this.element.ownerDocument.addEventListener("keydown", this._keyDownBoun
d, false); | 96 this.element.ownerDocument.addEventListener("keydown", this._keyDownBoun
d, false); |
| 110 this.element.ownerDocument.addEventListener("keypress", this._keyPressBo
und, false); | |
| 111 }, | 97 }, |
| 112 | 98 |
| 113 willHide: function() | 99 willHide: function() |
| 114 { | 100 { |
| 115 this.element.ownerDocument.removeEventListener("keydown", this._keyDownB
ound, false); | 101 this.element.ownerDocument.removeEventListener("keydown", this._keyDownB
ound, false); |
| 116 this.element.ownerDocument.removeEventListener("keypress", this._keyPres
sBound, false); | |
| 117 }, | 102 }, |
| 118 | 103 |
| 119 /** | 104 /** |
| 120 * @override | 105 * @override |
| 121 * @param {string} locationName | 106 * @param {string} locationName |
| 122 * @return {?WebInspector.ViewLocation} | 107 * @return {?WebInspector.ViewLocation} |
| 123 */ | 108 */ |
| 124 resolveLocation: function(locationName) | 109 resolveLocation: function(locationName) |
| 125 { | 110 { |
| 126 return this._drawerTabbedLocation; | 111 return this._drawerTabbedLocation; |
| 127 }, | 112 }, |
| 128 | 113 |
| 129 _loadPanelDesciptors: function() | |
| 130 { | |
| 131 /** | |
| 132 * @param {!Runtime.Extension} extension | |
| 133 * @this {!WebInspector.InspectorView} | |
| 134 */ | |
| 135 function processPanelExtensions(extension) | |
| 136 { | |
| 137 var descriptor = new WebInspector.ExtensionPanelDescriptor(extension
); | |
| 138 var weight = this._tabOrderSetting.get()[descriptor.name()]; | |
| 139 if (weight === undefined) | |
| 140 weight = extension.descriptor()["order"]; | |
| 141 if (weight === undefined) | |
| 142 weight = 10000; | |
| 143 panelWeights.set(descriptor, weight); | |
| 144 } | |
| 145 | |
| 146 /** | |
| 147 * @param {!WebInspector.PanelDescriptor} left | |
| 148 * @param {!WebInspector.PanelDescriptor} right | |
| 149 */ | |
| 150 function orderComparator(left, right) | |
| 151 { | |
| 152 return panelWeights.get(left) > panelWeights.get(right); | |
| 153 } | |
| 154 | |
| 155 WebInspector.startBatchUpdate(); | |
| 156 /** @type {!Map<!WebInspector.PanelDescriptor, number>} */ | |
| 157 var panelWeights = new Map(); | |
| 158 self.runtime.extensions(WebInspector.Panel).forEach(processPanelExtensio
ns.bind(this)); | |
| 159 var sortedPanels = panelWeights.keysArray().sort(orderComparator); | |
| 160 for (var panelDescriptor of sortedPanels) | |
| 161 this._innerAddPanel(panelDescriptor); | |
| 162 WebInspector.endBatchUpdate(); | |
| 163 }, | |
| 164 | |
| 165 createToolbars: function() | 114 createToolbars: function() |
| 166 { | 115 { |
| 167 this._tabbedPane.leftToolbar().appendLocationItems("main-toolbar-left"); | 116 this._tabbedPane.leftToolbar().appendLocationItems("main-toolbar-left"); |
| 168 this._tabbedPane.rightToolbar().appendLocationItems("main-toolbar-right"
); | 117 this._tabbedPane.rightToolbar().appendLocationItems("main-toolbar-right"
); |
| 169 }, | 118 }, |
| 170 | 119 |
| 171 /** | 120 /** |
| 172 * @param {!WebInspector.PanelDescriptor} panelDescriptor | 121 * @param {!WebInspector.View} view |
| 173 * @param {number=} index | |
| 174 */ | 122 */ |
| 175 _innerAddPanel: function(panelDescriptor, index) | 123 addPanel: function(view) |
| 176 { | 124 { |
| 177 var panelName = panelDescriptor.name(); | 125 this._tabbedLocation.appendView(view); |
| 178 this._panelDescriptors[panelName] = panelDescriptor; | |
| 179 this._tabbedPane.appendTab(panelName, panelDescriptor.title(), new WebIn
spector.Widget(), undefined, undefined, undefined, index); | |
| 180 if (this._lastActivePanelSetting.get() === panelName) | |
| 181 this._tabbedPane.selectTab(panelName); | |
| 182 }, | 126 }, |
| 183 | 127 |
| 184 /** | 128 /** |
| 185 * @param {!WebInspector.PanelDescriptor} panelDescriptor | |
| 186 */ | |
| 187 addPanel: function(panelDescriptor) | |
| 188 { | |
| 189 var weight = this._tabOrderSetting.get()[panelDescriptor.name()]; | |
| 190 // Keep in sync with _persistPanelOrder(). | |
| 191 if (weight) | |
| 192 weight = Math.max(0, Math.round(weight / 10) - 1); | |
| 193 this._innerAddPanel(panelDescriptor, weight); | |
| 194 }, | |
| 195 | |
| 196 /** | |
| 197 * @param {string} panelName | 129 * @param {string} panelName |
| 198 * @return {boolean} | 130 * @return {boolean} |
| 199 */ | 131 */ |
| 200 hasPanel: function(panelName) | 132 hasPanel: function(panelName) |
| 201 { | 133 { |
| 202 return !!this._panelDescriptors[panelName]; | 134 return this._tabbedPane.hasTab(panelName); |
| 203 }, | 135 }, |
| 204 | 136 |
| 205 /** | 137 /** |
| 206 * @param {string} panelName | 138 * @param {string} panelName |
| 207 * @return {!Promise.<!WebInspector.Panel>} | 139 * @return {!Promise.<!WebInspector.Panel>} |
| 208 */ | 140 */ |
| 209 panel: function(panelName) | 141 panel: function(panelName) |
| 210 { | 142 { |
| 211 var panelDescriptor = this._panelDescriptors[panelName]; | 143 return /** @type {!Promise.<!WebInspector.Panel>} */ (WebInspector.viewM
anager.view(panelName).widget()); |
| 212 if (!panelDescriptor) | |
| 213 return Promise.reject(new Error("Can't load panel without the descri
ptor: " + panelName)); | |
| 214 | |
| 215 var promise = this._panelPromises[panelName]; | |
| 216 if (promise) | |
| 217 return promise; | |
| 218 | |
| 219 promise = panelDescriptor.panel(); | |
| 220 this._panelPromises[panelName] = promise; | |
| 221 | |
| 222 promise.then(cachePanel.bind(this)); | |
| 223 | |
| 224 /** | |
| 225 * @param {!WebInspector.Panel} panel | |
| 226 * @return {!WebInspector.Panel} | |
| 227 * @this {WebInspector.InspectorView} | |
| 228 */ | |
| 229 function cachePanel(panel) | |
| 230 { | |
| 231 delete this._panelPromises[panelName]; | |
| 232 this._panels[panelName] = panel; | |
| 233 return panel; | |
| 234 } | |
| 235 return promise; | |
| 236 }, | 144 }, |
| 237 | 145 |
| 238 /** | 146 /** |
| 239 * @param {boolean} allTargetsSuspended | 147 * @param {boolean} allTargetsSuspended |
| 240 */ | 148 */ |
| 241 onSuspendStateChanged: function(allTargetsSuspended) | 149 onSuspendStateChanged: function(allTargetsSuspended) |
| 242 { | 150 { |
| 243 this._currentPanelLocked = allTargetsSuspended; | 151 this._currentPanelLocked = allTargetsSuspended; |
| 244 this._tabbedPane.setCurrentTabLocked(this._currentPanelLocked); | 152 this._tabbedPane.setCurrentTabLocked(this._currentPanelLocked); |
| 245 this._tabbedPane.leftToolbar().setEnabled(!this._currentPanelLocked); | 153 this._tabbedPane.leftToolbar().setEnabled(!this._currentPanelLocked); |
| 246 this._tabbedPane.rightToolbar().setEnabled(!this._currentPanelLocked); | 154 this._tabbedPane.rightToolbar().setEnabled(!this._currentPanelLocked); |
| 247 }, | 155 }, |
| 248 | 156 |
| 249 /** | 157 /** |
| 250 * The returned Promise is resolved with null if another showPanel() | 158 * @param {string} panelName |
| 251 * gets called while this.panel(panelName) Promise is in flight. | 159 * @return {boolean} |
| 252 * | 160 */ |
| 161 canSelectPanel: function(panelName) |
| 162 { |
| 163 return !this._currentPanelLocked || this._tabbedPane.selectedTabId === p
anelName; |
| 164 }, |
| 165 |
| 166 /** |
| 253 * @param {string} panelName | 167 * @param {string} panelName |
| 254 * @return {!Promise.<?WebInspector.Panel>} | 168 * @return {!Promise.<?WebInspector.Panel>} |
| 255 */ | 169 */ |
| 256 showPanel: function(panelName) | 170 showPanel: function(panelName) |
| 257 { | 171 { |
| 258 if (this._currentPanelLocked) { | 172 return WebInspector.viewManager.showView(panelName); |
| 259 if (this._currentPanel !== this._panels[panelName]) | |
| 260 return Promise.reject(new Error("Current panel locked")); | |
| 261 return Promise.resolve(this._currentPanel); | |
| 262 } | |
| 263 | |
| 264 this._panelForShowPromise = this.panel(panelName); | |
| 265 return this._panelForShowPromise.then(setCurrentPanelIfNecessary.bind(th
is, this._panelForShowPromise)); | |
| 266 | |
| 267 /** | |
| 268 * @param {!Promise.<!WebInspector.Panel>} panelPromise | |
| 269 * @param {!WebInspector.Panel} panel | |
| 270 * @return {?WebInspector.Panel} | |
| 271 * @this {WebInspector.InspectorView} | |
| 272 */ | |
| 273 function setCurrentPanelIfNecessary(panelPromise, panel) | |
| 274 { | |
| 275 if (this._panelForShowPromise !== panelPromise) | |
| 276 return null; | |
| 277 | |
| 278 this.setCurrentPanel(panel); | |
| 279 return panel; | |
| 280 } | |
| 281 }, | 173 }, |
| 282 | 174 |
| 283 /** | 175 /** |
| 284 * @param {string} panelName | 176 * @param {string} panelName |
| 285 * @param {string} iconType | 177 * @param {string} iconType |
| 286 * @param {string=} iconTooltip | 178 * @param {string=} iconTooltip |
| 287 */ | 179 */ |
| 288 setPanelIcon: function(panelName, iconType, iconTooltip) | 180 setPanelIcon: function(panelName, iconType, iconTooltip) |
| 289 { | 181 { |
| 290 this._tabbedPane.setTabIcon(panelName, iconType, iconTooltip); | 182 this._tabbedPane.setTabIcon(panelName, iconType, iconTooltip); |
| 291 }, | 183 }, |
| 292 | 184 |
| 293 /** | 185 /** |
| 294 * @return {!WebInspector.Panel} | 186 * @return {!WebInspector.Panel} |
| 295 */ | 187 */ |
| 296 currentPanel: function() | 188 currentPanelDeprecated: function() |
| 297 { | 189 { |
| 298 return this._currentPanel; | 190 return /** @type {!WebInspector.Panel} */ (WebInspector.viewManager.mate
rializedWidget(this._tabbedPane.selectedTabId || "")); |
| 299 }, | |
| 300 | |
| 301 showInitialPanel: function() | |
| 302 { | |
| 303 if (InspectorFrontendHost.isUnderTest()) | |
| 304 return; | |
| 305 this._showInitialPanel(); | |
| 306 }, | |
| 307 | |
| 308 _showInitialPanel: function() | |
| 309 { | |
| 310 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabSele
cted, this._tabSelected, this); | |
| 311 this._tabSelected(); | |
| 312 }, | 191 }, |
| 313 | 192 |
| 314 /** | 193 /** |
| 315 * @param {string} panelName | |
| 316 */ | |
| 317 showInitialPanelForTest: function(panelName) | |
| 318 { | |
| 319 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabSele
cted, this._tabSelected, this); | |
| 320 this.setCurrentPanel(this._panels[panelName]); | |
| 321 }, | |
| 322 | |
| 323 _tabSelected: function() | |
| 324 { | |
| 325 var panelName = this._tabbedPane.selectedTabId; | |
| 326 if (!panelName) | |
| 327 return; | |
| 328 | |
| 329 this.showPanel(panelName); | |
| 330 }, | |
| 331 | |
| 332 /** | |
| 333 * @param {!WebInspector.Panel} panel | |
| 334 * @param {boolean=} suppressBringToFront | |
| 335 * @return {!WebInspector.Panel} | |
| 336 */ | |
| 337 setCurrentPanel: function(panel, suppressBringToFront) | |
| 338 { | |
| 339 delete this._panelForShowPromise; | |
| 340 | |
| 341 if (this._currentPanelLocked) | |
| 342 return this._currentPanel; | |
| 343 | |
| 344 if (!suppressBringToFront) | |
| 345 InspectorFrontendHost.bringToFront(); | |
| 346 | |
| 347 if (this._currentPanel === panel) | |
| 348 return panel; | |
| 349 | |
| 350 this._currentPanel = panel; | |
| 351 if (!this._panels[panel.name]) | |
| 352 this._panels[panel.name] = panel; | |
| 353 this._tabbedPane.changeTabView(panel.name, panel); | |
| 354 this._tabbedPane.removeEventListener(WebInspector.TabbedPane.Events.TabS
elected, this._tabSelected, this); | |
| 355 this._tabbedPane.selectTab(panel.name); | |
| 356 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabSele
cted, this._tabSelected, this); | |
| 357 | |
| 358 this._lastActivePanelSetting.set(panel.name); | |
| 359 this._pushToHistory(panel.name); | |
| 360 WebInspector.userMetrics.panelShown(panel.name); | |
| 361 panel.focus(); | |
| 362 | |
| 363 return panel; | |
| 364 }, | |
| 365 | |
| 366 /** | |
| 367 * @param {boolean} focus | 194 * @param {boolean} focus |
| 368 */ | 195 */ |
| 369 _showDrawer: function(focus) | 196 _showDrawer: function(focus) |
| 370 { | 197 { |
| 371 if (this._drawerTabbedPane.isShowing()) | 198 if (this._drawerTabbedPane.isShowing()) |
| 372 return; | 199 return; |
| 373 this._drawerSplitWidget.showBoth(); | 200 this._drawerSplitWidget.showBoth(); |
| 374 if (focus) | 201 if (focus) |
| 375 this._focusRestorer = new WebInspector.WidgetFocusRestorer(this._dra
werTabbedPane); | 202 this._focusRestorer = new WebInspector.WidgetFocusRestorer(this._dra
werTabbedPane); |
| 376 else | 203 else |
| (...skipping 27 matching lines...) Expand all Loading... |
| 404 }, | 231 }, |
| 405 | 232 |
| 406 /** | 233 /** |
| 407 * @return {boolean} | 234 * @return {boolean} |
| 408 */ | 235 */ |
| 409 isDrawerMinimized: function() | 236 isDrawerMinimized: function() |
| 410 { | 237 { |
| 411 return this._drawerSplitWidget.isSidebarMinimized(); | 238 return this._drawerSplitWidget.isSidebarMinimized(); |
| 412 }, | 239 }, |
| 413 | 240 |
| 414 _keyPress: function(event) | |
| 415 { | |
| 416 // BUG 104250: Windows 7 posts a WM_CHAR message upon the Ctrl+']' keypr
ess. | |
| 417 // Any charCode < 32 is not going to be a valid keypress. | |
| 418 if (event.charCode < 32 && WebInspector.isWin()) | |
| 419 return; | |
| 420 clearTimeout(this._keyDownTimer); | |
| 421 delete this._keyDownTimer; | |
| 422 }, | |
| 423 | |
| 424 _keyDown: function(event) | 241 _keyDown: function(event) |
| 425 { | 242 { |
| 426 if (!WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event)) | 243 if (!WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event)) |
| 427 return; | 244 return; |
| 428 | 245 |
| 429 var keyboardEvent = /** @type {!KeyboardEvent} */ (event); | 246 var keyboardEvent = /** @type {!KeyboardEvent} */ (event); |
| 430 // Ctrl/Cmd + 1-9 should show corresponding panel. | 247 // Ctrl/Cmd + 1-9 should show corresponding panel. |
| 431 var panelShortcutEnabled = WebInspector.moduleSetting("shortcutPanelSwit
ch").get(); | 248 var panelShortcutEnabled = WebInspector.moduleSetting("shortcutPanelSwit
ch").get(); |
| 432 if (panelShortcutEnabled && !event.shiftKey && !event.altKey) { | 249 if (panelShortcutEnabled && !event.shiftKey && !event.altKey) { |
| 433 var panelIndex = -1; | 250 var panelIndex = -1; |
| 434 if (event.keyCode > 0x30 && event.keyCode < 0x3A) | 251 if (event.keyCode > 0x30 && event.keyCode < 0x3A) |
| 435 panelIndex = event.keyCode - 0x31; | 252 panelIndex = event.keyCode - 0x31; |
| 436 else if (event.keyCode > 0x60 && event.keyCode < 0x6A && keyboardEve
nt.location === KeyboardEvent.DOM_KEY_LOCATION_NUMPAD) | 253 else if (event.keyCode > 0x60 && event.keyCode < 0x6A && keyboardEve
nt.location === KeyboardEvent.DOM_KEY_LOCATION_NUMPAD) |
| 437 panelIndex = event.keyCode - 0x61; | 254 panelIndex = event.keyCode - 0x61; |
| 438 if (panelIndex !== -1) { | 255 if (panelIndex !== -1) { |
| 439 var panelName = this._tabbedPane.allTabs()[panelIndex]; | 256 var panelName = this._tabbedPane.allTabs()[panelIndex]; |
| 440 if (panelName) { | 257 if (panelName) { |
| 441 if (!WebInspector.Dialog.hasInstance() && !this._currentPane
lLocked) | 258 if (!WebInspector.Dialog.hasInstance() && !this._currentPane
lLocked) |
| 442 this.showPanel(panelName); | 259 this.showPanel(panelName); |
| 443 event.consume(true); | 260 event.consume(true); |
| 444 } | 261 } |
| 445 return; | |
| 446 } | 262 } |
| 447 } | 263 } |
| 448 | |
| 449 // BUG85312: On French AZERTY keyboards, AltGr-]/[ combinations (synonym
ous to Ctrl-Alt-]/[ on Windows) are used to enter ]/[, | |
| 450 // so for a ]/[-related keydown we delay the panel switch using a timer,
to see if there is a keypress event following this one. | |
| 451 // If there is, we cancel the timer and do not consider this a panel swi
tch. | |
| 452 if (!WebInspector.isWin() || (event.key !== "[" && event.key !== "]")) { | |
| 453 this._keyDownInternal(event); | |
| 454 return; | |
| 455 } | |
| 456 | |
| 457 this._keyDownTimer = setTimeout(this._keyDownInternal.bind(this, event),
0); | |
| 458 }, | |
| 459 | |
| 460 _keyDownInternal: function(event) | |
| 461 { | |
| 462 if (this._currentPanelLocked) | |
| 463 return; | |
| 464 | |
| 465 var direction = 0; | |
| 466 | |
| 467 if (event.key === "[") | |
| 468 direction = -1; | |
| 469 | |
| 470 if (event.key === "]") | |
| 471 direction = 1; | |
| 472 | |
| 473 if (!direction) | |
| 474 return; | |
| 475 | |
| 476 if (!event.shiftKey && !event.altKey) { | |
| 477 if (!WebInspector.Dialog.hasInstance()) | |
| 478 this._changePanelInDirection(direction); | |
| 479 event.consume(true); | |
| 480 return; | |
| 481 } | |
| 482 | |
| 483 if (event.altKey && this._moveInHistory(direction)) | |
| 484 event.consume(true); | |
| 485 }, | |
| 486 | |
| 487 /** | |
| 488 * @param {number} direction | |
| 489 */ | |
| 490 _changePanelInDirection: function(direction) | |
| 491 { | |
| 492 var panelOrder = this._tabbedPane.allTabs(); | |
| 493 var index = panelOrder.indexOf(this.currentPanel().name); | |
| 494 index = (index + panelOrder.length + direction) % panelOrder.length; | |
| 495 this.showPanel(panelOrder[index]); | |
| 496 }, | |
| 497 | |
| 498 /** | |
| 499 * @param {number} move | |
| 500 */ | |
| 501 _moveInHistory: function(move) | |
| 502 { | |
| 503 var newIndex = this._historyIterator + move; | |
| 504 if (newIndex >= this._history.length || newIndex < 0) | |
| 505 return false; | |
| 506 | |
| 507 this._inHistory = true; | |
| 508 this._historyIterator = newIndex; | |
| 509 if (!WebInspector.Dialog.hasInstance()) | |
| 510 this.setCurrentPanel(this._panels[this._history[this._historyIterato
r]]); | |
| 511 delete this._inHistory; | |
| 512 | |
| 513 return true; | |
| 514 }, | |
| 515 | |
| 516 _pushToHistory: function(panelName) | |
| 517 { | |
| 518 if (this._inHistory) | |
| 519 return; | |
| 520 | |
| 521 this._history.splice(this._historyIterator + 1, this._history.length - t
his._historyIterator - 1); | |
| 522 if (!this._history.length || this._history[this._history.length - 1] !==
panelName) | |
| 523 this._history.push(panelName); | |
| 524 this._historyIterator = this._history.length - 1; | |
| 525 }, | 264 }, |
| 526 | 265 |
| 527 onResize: function() | 266 onResize: function() |
| 528 { | 267 { |
| 529 WebInspector.Dialog.modalHostRepositioned(); | 268 WebInspector.Dialog.modalHostRepositioned(); |
| 530 }, | 269 }, |
| 531 | 270 |
| 532 /** | 271 /** |
| 533 * @return {!Element} | 272 * @return {!Element} |
| 534 */ | 273 */ |
| 535 topResizerElement: function() | 274 topResizerElement: function() |
| 536 { | 275 { |
| 537 return this._tabbedPane.headerElement(); | 276 return this._tabbedPane.headerElement(); |
| 538 }, | 277 }, |
| 539 | 278 |
| 540 toolbarItemResized: function() | 279 toolbarItemResized: function() |
| 541 { | 280 { |
| 542 this._tabbedPane.headerResized(); | 281 this._tabbedPane.headerResized(); |
| 543 }, | 282 }, |
| 544 | 283 |
| 545 /** | 284 /** |
| 546 * @param {!WebInspector.Event} event | 285 * @param {!WebInspector.Event} event |
| 547 */ | 286 */ |
| 548 _persistPanelOrder: function(event) | 287 _tabSelected: function(event) |
| 549 { | 288 { |
| 550 var tabs = /** @type {!Array.<!WebInspector.TabbedPaneTab>} */(event.dat
a); | 289 var tabId = /** @type {string} */(event.data["tabId"]); |
| 551 var tabOrders = this._tabOrderSetting.get(); | 290 WebInspector.userMetrics.panelShown(tabId); |
| 552 for (var i = 0; i < tabs.length; i++) | |
| 553 tabOrders[tabs[i].id] = (i + 1) * 10; | |
| 554 this._tabOrderSetting.set(tabOrders); | |
| 555 }, | 291 }, |
| 556 | 292 |
| 557 /** | 293 /** |
| 558 * @param {!WebInspector.SplitWidget} splitWidget | 294 * @param {!WebInspector.SplitWidget} splitWidget |
| 559 */ | 295 */ |
| 560 setOwnerSplit: function(splitWidget) | 296 setOwnerSplit: function(splitWidget) |
| 561 { | 297 { |
| 562 this._ownerSplitWidget = splitWidget; | 298 this._ownerSplitWidget = splitWidget; |
| 563 }, | 299 }, |
| 564 | 300 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 */ | 335 */ |
| 600 handleAction: function(context, actionId) | 336 handleAction: function(context, actionId) |
| 601 { | 337 { |
| 602 if (WebInspector.inspectorView.drawerVisible()) | 338 if (WebInspector.inspectorView.drawerVisible()) |
| 603 WebInspector.inspectorView._closeDrawer(); | 339 WebInspector.inspectorView._closeDrawer(); |
| 604 else | 340 else |
| 605 WebInspector.inspectorView._showDrawer(true); | 341 WebInspector.inspectorView._showDrawer(true); |
| 606 return true; | 342 return true; |
| 607 } | 343 } |
| 608 } | 344 } |
| OLD | NEW |