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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/InspectorView.js

Issue 2377193004: [DevTools] Rework some focus code. (Closed)
Patch Set: FocusRestorer Created 4 years, 2 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) 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 29 matching lines...) Expand all
40 this.setMinimumSize(240, 72); 40 this.setMinimumSize(240, 72);
41 41
42 // 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.
43 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);
44 this._drawerSplitWidget.hideSidebar(); 44 this._drawerSplitWidget.hideSidebar();
45 this._drawerSplitWidget.hideDefaultResizer(); 45 this._drawerSplitWidget.hideDefaultResizer();
46 this._drawerSplitWidget.enableShowModeSaving(); 46 this._drawerSplitWidget.enableShowModeSaving();
47 this._drawerSplitWidget.show(this.element); 47 this._drawerSplitWidget.show(this.element);
48 48
49 // Create drawer tabbed pane. 49 // Create drawer tabbed pane.
50 this._drawerTabbedLocation = WebInspector.viewManager.createTabbedLocation(t his.showDrawer.bind(this), "drawer-view", true); 50 this._drawerTabbedLocation = WebInspector.viewManager.createTabbedLocation(t his._showDrawer.bind(this, false), "drawer-view", true);
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._tabbedPane = new WebInspector.TabbedPane();
62 this._tabbedPane.registerRequiredCSS("ui/inspectorViewTabbedPane.css"); 62 this._tabbedPane.registerRequiredCSS("ui/inspectorViewTabbedPane.css");
63 this._tabbedPane.setTabSlider(true); 63 this._tabbedPane.setTabSlider(true);
64 this._tabbedPane.setAllowTabReorder(true, false); 64 this._tabbedPane.setAllowTabReorder(true, false);
65 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabOrderCha nged, this._persistPanelOrder, this); 65 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabOrderCha nged, this._persistPanelOrder, this);
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabSele cted, this._tabSelected, this); 356 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabSele cted, this._tabSelected, this);
357 357
358 this._lastActivePanelSetting.set(panel.name); 358 this._lastActivePanelSetting.set(panel.name);
359 this._pushToHistory(panel.name); 359 this._pushToHistory(panel.name);
360 WebInspector.userMetrics.panelShown(panel.name); 360 WebInspector.userMetrics.panelShown(panel.name);
361 panel.focus(); 361 panel.focus();
362 362
363 return panel; 363 return panel;
364 }, 364 },
365 365
366 showDrawer: function() 366 /**
367 * @param {boolean} focus
368 */
369 _showDrawer: function(focus)
367 { 370 {
368 if (!this._drawerTabbedPane.isShowing()) 371 if (this._drawerTabbedPane.isShowing())
369 this._drawerSplitWidget.showBoth(); 372 return;
370 this._drawerTabbedPane.focus(); 373 this._drawerSplitWidget.showBoth();
374 if (focus)
375 this._focusRestorer = new WebInspector.WidgetFocusRestorer(this._dra werTabbedPane);
376 else
377 this._focusRestorer = null;
371 }, 378 },
372 379
373 /** 380 /**
374 * @return {boolean} 381 * @return {boolean}
375 */ 382 */
376 drawerVisible: function() 383 drawerVisible: function()
377 { 384 {
378 return this._drawerTabbedPane.isShowing(); 385 return this._drawerTabbedPane.isShowing();
379 }, 386 },
380 387
381 closeDrawer: function() 388 _closeDrawer: function()
382 { 389 {
383 if (!this._drawerTabbedPane.isShowing()) 390 if (!this._drawerTabbedPane.isShowing())
384 return; 391 return;
385 WebInspector.restoreFocusFromElement(this._drawerTabbedPane.element); 392 if (this._focusRestorer)
393 this._focusRestorer.restore();
386 this._drawerSplitWidget.hideSidebar(true); 394 this._drawerSplitWidget.hideSidebar(true);
387 }, 395 },
388 396
389 /** 397 /**
390 * @param {boolean} minimized 398 * @param {boolean} minimized
391 */ 399 */
392 setDrawerMinimized: function(minimized) 400 setDrawerMinimized: function(minimized)
393 { 401 {
394 this._drawerSplitWidget.setSidebarMinimized(minimized); 402 this._drawerSplitWidget.setSidebarMinimized(minimized);
395 this._drawerSplitWidget.setResizable(!minimized); 403 this._drawerSplitWidget.setResizable(!minimized);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 WebInspector.InspectorView.DrawerToggleActionDelegate.prototype = { 593 WebInspector.InspectorView.DrawerToggleActionDelegate.prototype = {
586 /** 594 /**
587 * @override 595 * @override
588 * @param {!WebInspector.Context} context 596 * @param {!WebInspector.Context} context
589 * @param {string} actionId 597 * @param {string} actionId
590 * @return {boolean} 598 * @return {boolean}
591 */ 599 */
592 handleAction: function(context, actionId) 600 handleAction: function(context, actionId)
593 { 601 {
594 if (WebInspector.inspectorView.drawerVisible()) 602 if (WebInspector.inspectorView.drawerVisible())
595 WebInspector.inspectorView.closeDrawer(); 603 WebInspector.inspectorView._closeDrawer();
596 else 604 else
597 WebInspector.inspectorView.showDrawer(); 605 WebInspector.inspectorView._showDrawer(true);
598 return true; 606 return true;
599 } 607 }
600 } 608 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698