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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/components/DockController.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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 /** 107 /**
108 * @return {boolean} 108 * @return {boolean}
109 */ 109 */
110 isVertical: function() 110 isVertical: function()
111 { 111 {
112 return this._dockSide === WebInspector.DockController.State.DockedToRigh t; 112 return this._dockSide === WebInspector.DockController.State.DockedToRigh t;
113 }, 113 },
114 114
115 /** 115 /**
116 * @param {string} dockSide 116 * @param {string} dockSide
117 * @suppressGlobalPropertiesCheck
117 */ 118 */
118 setDockSide: function(dockSide) 119 setDockSide: function(dockSide)
119 { 120 {
120 if (this._states.indexOf(dockSide) === -1) 121 if (this._states.indexOf(dockSide) === -1)
121 dockSide = this._states[0]; 122 dockSide = this._states[0];
122 123
123 if (this._dockSide === dockSide) 124 if (this._dockSide === dockSide)
124 return; 125 return;
125 126
126 if (this._dockSide) 127 if (this._dockSide)
127 this._lastDockStateSetting.set(this._dockSide); 128 this._lastDockStateSetting.set(this._dockSide);
128 129
129 WebInspector.DockController._previousFocusedElement = WebInspector.curre ntFocusElement(); 130 this._savedFocus = document.deepActiveElement();
130 var eventData = { from: this._dockSide, to: dockSide }; 131 var eventData = { from: this._dockSide, to: dockSide };
131 this.dispatchEventToListeners(WebInspector.DockController.Events.BeforeD ockSideChanged, eventData); 132 this.dispatchEventToListeners(WebInspector.DockController.Events.BeforeD ockSideChanged, eventData);
132 console.timeStamp("DockController.setIsDocked"); 133 console.timeStamp("DockController.setIsDocked");
133 this._dockSide = dockSide; 134 this._dockSide = dockSide;
134 this._currentDockStateSetting.set(dockSide); 135 this._currentDockStateSetting.set(dockSide);
135 InspectorFrontendHost.setIsDocked(dockSide !== WebInspector.DockControll er.State.Undocked, this._setIsDockedResponse.bind(this, eventData)); 136 InspectorFrontendHost.setIsDocked(dockSide !== WebInspector.DockControll er.State.Undocked, this._setIsDockedResponse.bind(this, eventData));
136 this._updateUI(); 137 this._updateUI();
137 this.dispatchEventToListeners(WebInspector.DockController.Events.DockSid eChanged, eventData); 138 this.dispatchEventToListeners(WebInspector.DockController.Events.DockSid eChanged, eventData);
138 }, 139 },
139 140
140 /** 141 /**
141 * @param {{from: string, to: string}} eventData 142 * @param {{from: string, to: string}} eventData
142 */ 143 */
143 _setIsDockedResponse: function(eventData) 144 _setIsDockedResponse: function(eventData)
144 { 145 {
145 this.dispatchEventToListeners(WebInspector.DockController.Events.AfterDo ckSideChanged, eventData); 146 this.dispatchEventToListeners(WebInspector.DockController.Events.AfterDo ckSideChanged, eventData);
146 147 if (this._savedFocus) {
147 if (WebInspector.DockController._previousFocusedElement) 148 this._savedFocus.focus();
148 WebInspector.DockController._previousFocusedElement.focus(); 149 this._savedFocus = null;
149 delete WebInspector.DockController._previousFocusedElement; 150 }
150 }, 151 },
151 152
152 /** 153 /**
153 * @suppressGlobalPropertiesCheck 154 * @suppressGlobalPropertiesCheck
154 */ 155 */
155 _updateUI: function() 156 _updateUI: function()
156 { 157 {
157 var body = document.body; // Only for main window. 158 var body = document.body; // Only for main window.
158 switch (this._dockSide) { 159 switch (this._dockSide) {
159 case WebInspector.DockController.State.DockedToBottom: 160 case WebInspector.DockController.State.DockedToBottom:
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 item: function() 226 item: function()
226 { 227 {
227 return WebInspector.dockController._closeButton; 228 return WebInspector.dockController._closeButton;
228 } 229 }
229 } 230 }
230 231
231 /** 232 /**
232 * @type {!WebInspector.DockController} 233 * @type {!WebInspector.DockController}
233 */ 234 */
234 WebInspector.dockController; 235 WebInspector.dockController;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698