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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/components/DockController.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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 13 matching lines...) Expand all
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 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.DockController = class extends WebInspector.Object { 34 Components.DockController = class extends Common.Object {
35 /** 35 /**
36 * @param {boolean} canDock 36 * @param {boolean} canDock
37 */ 37 */
38 constructor(canDock) { 38 constructor(canDock) {
39 super(); 39 super();
40 this._canDock = canDock; 40 this._canDock = canDock;
41 41
42 this._closeButton = new WebInspector.ToolbarButton(WebInspector.UIString('Cl ose'), 'largeicon-delete'); 42 this._closeButton = new UI.ToolbarButton(Common.UIString('Close'), 'largeico n-delete');
43 this._closeButton.addEventListener('click', InspectorFrontendHost.closeWindo w.bind(InspectorFrontendHost)); 43 this._closeButton.addEventListener('click', InspectorFrontendHost.closeWindo w.bind(InspectorFrontendHost));
44 44
45 if (!canDock) { 45 if (!canDock) {
46 this._dockSide = WebInspector.DockController.State.Undocked; 46 this._dockSide = Components.DockController.State.Undocked;
47 this._updateUI(); 47 this._updateUI();
48 return; 48 return;
49 } 49 }
50 50
51 this._states = [ 51 this._states = [
52 WebInspector.DockController.State.DockedToRight, WebInspector.DockControll er.State.DockedToBottom, 52 Components.DockController.State.DockedToRight, Components.DockController.S tate.DockedToBottom,
53 WebInspector.DockController.State.Undocked 53 Components.DockController.State.Undocked
54 ]; 54 ];
55 this._currentDockStateSetting = WebInspector.settings.moduleSetting('current DockState'); 55 this._currentDockStateSetting = Common.settings.moduleSetting('currentDockSt ate');
56 this._currentDockStateSetting.addChangeListener(this._dockSideChanged, this) ; 56 this._currentDockStateSetting.addChangeListener(this._dockSideChanged, this) ;
57 this._lastDockStateSetting = WebInspector.settings.createSetting('lastDockSt ate', 'bottom'); 57 this._lastDockStateSetting = Common.settings.createSetting('lastDockState', 'bottom');
58 if (this._states.indexOf(this._currentDockStateSetting.get()) === -1) 58 if (this._states.indexOf(this._currentDockStateSetting.get()) === -1)
59 this._currentDockStateSetting.set('right'); 59 this._currentDockStateSetting.set('right');
60 if (this._states.indexOf(this._lastDockStateSetting.get()) === -1) 60 if (this._states.indexOf(this._lastDockStateSetting.get()) === -1)
61 this._currentDockStateSetting.set('bottom'); 61 this._currentDockStateSetting.set('bottom');
62 } 62 }
63 63
64 initialize() { 64 initialize() {
65 if (!this._canDock) 65 if (!this._canDock)
66 return; 66 return;
67 67
68 this._titles = [ 68 this._titles = [
69 WebInspector.UIString('Dock to right'), WebInspector.UIString('Dock to bot tom'), 69 Common.UIString('Dock to right'), Common.UIString('Dock to bottom'),
70 WebInspector.UIString('Undock into separate window') 70 Common.UIString('Undock into separate window')
71 ]; 71 ];
72 this._dockSideChanged(); 72 this._dockSideChanged();
73 } 73 }
74 74
75 _dockSideChanged() { 75 _dockSideChanged() {
76 this.setDockSide(this._currentDockStateSetting.get()); 76 this.setDockSide(this._currentDockStateSetting.get());
77 } 77 }
78 78
79 /** 79 /**
80 * @return {string} 80 * @return {string}
81 */ 81 */
82 dockSide() { 82 dockSide() {
83 return this._dockSide; 83 return this._dockSide;
84 } 84 }
85 85
86 /** 86 /**
87 * @return {boolean} 87 * @return {boolean}
88 */ 88 */
89 canDock() { 89 canDock() {
90 return this._canDock; 90 return this._canDock;
91 } 91 }
92 92
93 /** 93 /**
94 * @return {boolean} 94 * @return {boolean}
95 */ 95 */
96 isVertical() { 96 isVertical() {
97 return this._dockSide === WebInspector.DockController.State.DockedToRight; 97 return this._dockSide === Components.DockController.State.DockedToRight;
98 } 98 }
99 99
100 /** 100 /**
101 * @param {string} dockSide 101 * @param {string} dockSide
102 * @suppressGlobalPropertiesCheck 102 * @suppressGlobalPropertiesCheck
103 */ 103 */
104 setDockSide(dockSide) { 104 setDockSide(dockSide) {
105 if (this._states.indexOf(dockSide) === -1) 105 if (this._states.indexOf(dockSide) === -1)
106 dockSide = this._states[0]; 106 dockSide = this._states[0];
107 107
108 if (this._dockSide === dockSide) 108 if (this._dockSide === dockSide)
109 return; 109 return;
110 110
111 if (this._dockSide) 111 if (this._dockSide)
112 this._lastDockStateSetting.set(this._dockSide); 112 this._lastDockStateSetting.set(this._dockSide);
113 113
114 this._savedFocus = document.deepActiveElement(); 114 this._savedFocus = document.deepActiveElement();
115 var eventData = {from: this._dockSide, to: dockSide}; 115 var eventData = {from: this._dockSide, to: dockSide};
116 this.dispatchEventToListeners(WebInspector.DockController.Events.BeforeDockS ideChanged, eventData); 116 this.dispatchEventToListeners(Components.DockController.Events.BeforeDockSid eChanged, eventData);
117 console.timeStamp('DockController.setIsDocked'); 117 console.timeStamp('DockController.setIsDocked');
118 this._dockSide = dockSide; 118 this._dockSide = dockSide;
119 this._currentDockStateSetting.set(dockSide); 119 this._currentDockStateSetting.set(dockSide);
120 InspectorFrontendHost.setIsDocked( 120 InspectorFrontendHost.setIsDocked(
121 dockSide !== WebInspector.DockController.State.Undocked, this._setIsDock edResponse.bind(this, eventData)); 121 dockSide !== Components.DockController.State.Undocked, this._setIsDocked Response.bind(this, eventData));
122 this._updateUI(); 122 this._updateUI();
123 this.dispatchEventToListeners(WebInspector.DockController.Events.DockSideCha nged, eventData); 123 this.dispatchEventToListeners(Components.DockController.Events.DockSideChang ed, eventData);
124 } 124 }
125 125
126 /** 126 /**
127 * @param {{from: string, to: string}} eventData 127 * @param {{from: string, to: string}} eventData
128 */ 128 */
129 _setIsDockedResponse(eventData) { 129 _setIsDockedResponse(eventData) {
130 this.dispatchEventToListeners(WebInspector.DockController.Events.AfterDockSi deChanged, eventData); 130 this.dispatchEventToListeners(Components.DockController.Events.AfterDockSide Changed, eventData);
131 if (this._savedFocus) { 131 if (this._savedFocus) {
132 this._savedFocus.focus(); 132 this._savedFocus.focus();
133 this._savedFocus = null; 133 this._savedFocus = null;
134 } 134 }
135 } 135 }
136 136
137 /** 137 /**
138 * @suppressGlobalPropertiesCheck 138 * @suppressGlobalPropertiesCheck
139 */ 139 */
140 _updateUI() { 140 _updateUI() {
141 var body = document.body; // Only for main window. 141 var body = document.body; // Only for main window.
142 switch (this._dockSide) { 142 switch (this._dockSide) {
143 case WebInspector.DockController.State.DockedToBottom: 143 case Components.DockController.State.DockedToBottom:
144 body.classList.remove('undocked'); 144 body.classList.remove('undocked');
145 body.classList.remove('dock-to-right'); 145 body.classList.remove('dock-to-right');
146 body.classList.add('dock-to-bottom'); 146 body.classList.add('dock-to-bottom');
147 break; 147 break;
148 case WebInspector.DockController.State.DockedToRight: 148 case Components.DockController.State.DockedToRight:
149 body.classList.remove('undocked'); 149 body.classList.remove('undocked');
150 body.classList.add('dock-to-right'); 150 body.classList.add('dock-to-right');
151 body.classList.remove('dock-to-bottom'); 151 body.classList.remove('dock-to-bottom');
152 break; 152 break;
153 case WebInspector.DockController.State.Undocked: 153 case Components.DockController.State.Undocked:
154 body.classList.add('undocked'); 154 body.classList.add('undocked');
155 body.classList.remove('dock-to-right'); 155 body.classList.remove('dock-to-right');
156 body.classList.remove('dock-to-bottom'); 156 body.classList.remove('dock-to-bottom');
157 break; 157 break;
158 } 158 }
159 this._closeButton.setVisible(this._dockSide !== WebInspector.DockController. State.Undocked); 159 this._closeButton.setVisible(this._dockSide !== Components.DockController.St ate.Undocked);
160 } 160 }
161 161
162 _toggleDockSide() { 162 _toggleDockSide() {
163 if (this._lastDockStateSetting.get() === this._currentDockStateSetting.get() ) { 163 if (this._lastDockStateSetting.get() === this._currentDockStateSetting.get() ) {
164 var index = this._states.indexOf(this._currentDockStateSetting.get()) || 0 ; 164 var index = this._states.indexOf(this._currentDockStateSetting.get()) || 0 ;
165 this._lastDockStateSetting.set(this._states[(index + 1) % this._states.len gth]); 165 this._lastDockStateSetting.set(this._states[(index + 1) % this._states.len gth]);
166 } 166 }
167 this.setDockSide(this._lastDockStateSetting.get()); 167 this.setDockSide(this._lastDockStateSetting.get());
168 } 168 }
169 }; 169 };
170 170
171 WebInspector.DockController.State = { 171 Components.DockController.State = {
172 DockedToBottom: 'bottom', 172 DockedToBottom: 'bottom',
173 DockedToRight: 'right', 173 DockedToRight: 'right',
174 Undocked: 'undocked' 174 Undocked: 'undocked'
175 }; 175 };
176 176
177 // Use BeforeDockSideChanged to do something before all the UI bits are updated, 177 // Use BeforeDockSideChanged to do something before all the UI bits are updated,
178 // DockSideChanged to update UI, and AfterDockSideChanged to perform actions 178 // DockSideChanged to update UI, and AfterDockSideChanged to perform actions
179 // after frontend is docked/undocked in the browser. 179 // after frontend is docked/undocked in the browser.
180 180
181 /** @enum {symbol} */ 181 /** @enum {symbol} */
182 WebInspector.DockController.Events = { 182 Components.DockController.Events = {
183 BeforeDockSideChanged: Symbol('BeforeDockSideChanged'), 183 BeforeDockSideChanged: Symbol('BeforeDockSideChanged'),
184 DockSideChanged: Symbol('DockSideChanged'), 184 DockSideChanged: Symbol('DockSideChanged'),
185 AfterDockSideChanged: Symbol('AfterDockSideChanged') 185 AfterDockSideChanged: Symbol('AfterDockSideChanged')
186 }; 186 };
187 187
188 /** 188 /**
189 * @implements {WebInspector.ActionDelegate} 189 * @implements {UI.ActionDelegate}
190 * @unrestricted 190 * @unrestricted
191 */ 191 */
192 WebInspector.DockController.ToggleDockActionDelegate = class { 192 Components.DockController.ToggleDockActionDelegate = class {
193 /** 193 /**
194 * @override 194 * @override
195 * @param {!WebInspector.Context} context 195 * @param {!UI.Context} context
196 * @param {string} actionId 196 * @param {string} actionId
197 * @return {boolean} 197 * @return {boolean}
198 */ 198 */
199 handleAction(context, actionId) { 199 handleAction(context, actionId) {
200 WebInspector.dockController._toggleDockSide(); 200 Components.dockController._toggleDockSide();
201 return true; 201 return true;
202 } 202 }
203 }; 203 };
204 204
205 /** 205 /**
206 * @implements {WebInspector.ToolbarItem.Provider} 206 * @implements {UI.ToolbarItem.Provider}
207 * @unrestricted 207 * @unrestricted
208 */ 208 */
209 WebInspector.DockController.CloseButtonProvider = class { 209 Components.DockController.CloseButtonProvider = class {
210 /** 210 /**
211 * @override 211 * @override
212 * @return {?WebInspector.ToolbarItem} 212 * @return {?UI.ToolbarItem}
213 */ 213 */
214 item() { 214 item() {
215 return WebInspector.dockController._closeButton; 215 return Components.dockController._closeButton;
216 } 216 }
217 }; 217 };
218 218
219 /** 219 /**
220 * @type {!WebInspector.DockController} 220 * @type {!Components.DockController}
221 */ 221 */
222 WebInspector.dockController; 222 Components.dockController;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698