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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/InspectorView.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) 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 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
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 * @implements {WebInspector.ViewLocationResolver} 31 * @implements {UI.ViewLocationResolver}
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.InspectorView = class extends WebInspector.VBox { 34 UI.InspectorView = class extends UI.VBox {
35 constructor() { 35 constructor() {
36 super(); 36 super();
37 WebInspector.Dialog.setModalHostView(this); 37 UI.Dialog.setModalHostView(this);
38 this.setMinimumSize(240, 72); 38 this.setMinimumSize(240, 72);
39 39
40 // DevTools sidebar is a vertical split of panels tabbed pane and a drawer. 40 // DevTools sidebar is a vertical split of panels tabbed pane and a drawer.
41 this._drawerSplitWidget = new WebInspector.SplitWidget(false, true, 'Inspect or.drawerSplitViewState', 200, 200); 41 this._drawerSplitWidget = new UI.SplitWidget(false, true, 'Inspector.drawerS plitViewState', 200, 200);
42 this._drawerSplitWidget.hideSidebar(); 42 this._drawerSplitWidget.hideSidebar();
43 this._drawerSplitWidget.hideDefaultResizer(); 43 this._drawerSplitWidget.hideDefaultResizer();
44 this._drawerSplitWidget.enableShowModeSaving(); 44 this._drawerSplitWidget.enableShowModeSaving();
45 this._drawerSplitWidget.show(this.element); 45 this._drawerSplitWidget.show(this.element);
46 46
47 // Create drawer tabbed pane. 47 // Create drawer tabbed pane.
48 this._drawerTabbedLocation = 48 this._drawerTabbedLocation =
49 WebInspector.viewManager.createTabbedLocation(this._showDrawer.bind(this , false), 'drawer-view', true); 49 UI.viewManager.createTabbedLocation(this._showDrawer.bind(this, false), 'drawer-view', true);
50 this._drawerTabbedLocation.enableMoreTabsButton(); 50 this._drawerTabbedLocation.enableMoreTabsButton();
51 this._drawerTabbedPane = this._drawerTabbedLocation.tabbedPane(); 51 this._drawerTabbedPane = this._drawerTabbedLocation.tabbedPane();
52 this._drawerTabbedPane.setMinimumSize(0, 27); 52 this._drawerTabbedPane.setMinimumSize(0, 27);
53 var closeDrawerButton = 53 var closeDrawerButton =
54 new WebInspector.ToolbarButton(WebInspector.UIString('Close drawer'), 'l argeicon-delete'); 54 new UI.ToolbarButton(Common.UIString('Close drawer'), 'largeicon-delete' );
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._tabbedLocation = WebInspector.viewManager.createTabbedLocation( 61 this._tabbedLocation = UI.viewManager.createTabbedLocation(
62 InspectorFrontendHost.bringToFront.bind(InspectorFrontendHost), 'panel', true, true); 62 InspectorFrontendHost.bringToFront.bind(InspectorFrontendHost), 'panel', true, true);
63 this._tabbedPane = this._tabbedLocation.tabbedPane(); 63 this._tabbedPane = this._tabbedLocation.tabbedPane();
64 this._tabbedPane.registerRequiredCSS('ui/inspectorViewTabbedPane.css'); 64 this._tabbedPane.registerRequiredCSS('ui/inspectorViewTabbedPane.css');
65 this._tabbedPane.setTabSlider(true); 65 this._tabbedPane.setTabSlider(true);
66 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabSelected , this._tabSelected, this); 66 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta bSelected, this);
67 67
68 if (InspectorFrontendHost.isUnderTest()) 68 if (InspectorFrontendHost.isUnderTest())
69 this._tabbedPane.setAutoSelectFirstItemOnShow(false); 69 this._tabbedPane.setAutoSelectFirstItemOnShow(false);
70 this._drawerSplitWidget.setMainWidget(this._tabbedPane); 70 this._drawerSplitWidget.setMainWidget(this._tabbedPane);
71 71
72 this._keyDownBound = this._keyDown.bind(this); 72 this._keyDownBound = this._keyDown.bind(this);
73 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.ShowPanel, showPanel.bind(this)); 73 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.ShowPanel, showPanel.bind(this));
74 74
75 /** 75 /**
76 * @this {WebInspector.InspectorView} 76 * @this {UI.InspectorView}
77 * @param {!WebInspector.Event} event 77 * @param {!Common.Event} event
78 */ 78 */
79 function showPanel(event) { 79 function showPanel(event) {
80 var panelName = /** @type {string} */ (event.data); 80 var panelName = /** @type {string} */ (event.data);
81 this.showPanel(panelName); 81 this.showPanel(panelName);
82 } 82 }
83 } 83 }
84 84
85 /** 85 /**
86 * @return {!WebInspector.InspectorView} 86 * @return {!UI.InspectorView}
87 */ 87 */
88 static instance() { 88 static instance() {
89 return /** @type {!WebInspector.InspectorView} */ (self.runtime.sharedInstan ce(WebInspector.InspectorView)); 89 return /** @type {!UI.InspectorView} */ (self.runtime.sharedInstance(UI.Insp ectorView));
90 } 90 }
91 91
92 /** 92 /**
93 * @override 93 * @override
94 */ 94 */
95 wasShown() { 95 wasShown() {
96 this.element.ownerDocument.addEventListener('keydown', this._keyDownBound, f alse); 96 this.element.ownerDocument.addEventListener('keydown', this._keyDownBound, f alse);
97 } 97 }
98 98
99 /** 99 /**
100 * @override 100 * @override
101 */ 101 */
102 willHide() { 102 willHide() {
103 this.element.ownerDocument.removeEventListener('keydown', this._keyDownBound , false); 103 this.element.ownerDocument.removeEventListener('keydown', this._keyDownBound , false);
104 } 104 }
105 105
106 /** 106 /**
107 * @override 107 * @override
108 * @param {string} locationName 108 * @param {string} locationName
109 * @return {?WebInspector.ViewLocation} 109 * @return {?UI.ViewLocation}
110 */ 110 */
111 resolveLocation(locationName) { 111 resolveLocation(locationName) {
112 return this._drawerTabbedLocation; 112 return this._drawerTabbedLocation;
113 } 113 }
114 114
115 createToolbars() { 115 createToolbars() {
116 this._tabbedPane.leftToolbar().appendLocationItems('main-toolbar-left'); 116 this._tabbedPane.leftToolbar().appendLocationItems('main-toolbar-left');
117 this._tabbedPane.rightToolbar().appendLocationItems('main-toolbar-right'); 117 this._tabbedPane.rightToolbar().appendLocationItems('main-toolbar-right');
118 } 118 }
119 119
120 /** 120 /**
121 * @param {!WebInspector.View} view 121 * @param {!UI.View} view
122 */ 122 */
123 addPanel(view) { 123 addPanel(view) {
124 this._tabbedLocation.appendView(view); 124 this._tabbedLocation.appendView(view);
125 } 125 }
126 126
127 /** 127 /**
128 * @param {string} panelName 128 * @param {string} panelName
129 * @return {boolean} 129 * @return {boolean}
130 */ 130 */
131 hasPanel(panelName) { 131 hasPanel(panelName) {
132 return this._tabbedPane.hasTab(panelName); 132 return this._tabbedPane.hasTab(panelName);
133 } 133 }
134 134
135 /** 135 /**
136 * @param {string} panelName 136 * @param {string} panelName
137 * @return {!Promise.<!WebInspector.Panel>} 137 * @return {!Promise.<!UI.Panel>}
138 */ 138 */
139 panel(panelName) { 139 panel(panelName) {
140 return /** @type {!Promise.<!WebInspector.Panel>} */ (WebInspector.viewManag er.view(panelName).widget()); 140 return /** @type {!Promise.<!UI.Panel>} */ (UI.viewManager.view(panelName).w idget());
141 } 141 }
142 142
143 /** 143 /**
144 * @param {boolean} allTargetsSuspended 144 * @param {boolean} allTargetsSuspended
145 */ 145 */
146 onSuspendStateChanged(allTargetsSuspended) { 146 onSuspendStateChanged(allTargetsSuspended) {
147 this._currentPanelLocked = allTargetsSuspended; 147 this._currentPanelLocked = allTargetsSuspended;
148 this._tabbedPane.setCurrentTabLocked(this._currentPanelLocked); 148 this._tabbedPane.setCurrentTabLocked(this._currentPanelLocked);
149 this._tabbedPane.leftToolbar().setEnabled(!this._currentPanelLocked); 149 this._tabbedPane.leftToolbar().setEnabled(!this._currentPanelLocked);
150 this._tabbedPane.rightToolbar().setEnabled(!this._currentPanelLocked); 150 this._tabbedPane.rightToolbar().setEnabled(!this._currentPanelLocked);
151 } 151 }
152 152
153 /** 153 /**
154 * @param {string} panelName 154 * @param {string} panelName
155 * @return {boolean} 155 * @return {boolean}
156 */ 156 */
157 canSelectPanel(panelName) { 157 canSelectPanel(panelName) {
158 return !this._currentPanelLocked || this._tabbedPane.selectedTabId === panel Name; 158 return !this._currentPanelLocked || this._tabbedPane.selectedTabId === panel Name;
159 } 159 }
160 160
161 /** 161 /**
162 * @param {string} panelName 162 * @param {string} panelName
163 * @return {!Promise.<?WebInspector.Panel>} 163 * @return {!Promise.<?UI.Panel>}
164 */ 164 */
165 showPanel(panelName) { 165 showPanel(panelName) {
166 return WebInspector.viewManager.showView(panelName); 166 return UI.viewManager.showView(panelName);
167 } 167 }
168 168
169 /** 169 /**
170 * @param {string} panelName 170 * @param {string} panelName
171 * @param {string} iconType 171 * @param {string} iconType
172 * @param {string=} iconTooltip 172 * @param {string=} iconTooltip
173 */ 173 */
174 setPanelIcon(panelName, iconType, iconTooltip) { 174 setPanelIcon(panelName, iconType, iconTooltip) {
175 this._tabbedPane.setTabIcon(panelName, iconType, iconTooltip); 175 this._tabbedPane.setTabIcon(panelName, iconType, iconTooltip);
176 } 176 }
177 177
178 /** 178 /**
179 * @return {!WebInspector.Panel} 179 * @return {!UI.Panel}
180 */ 180 */
181 currentPanelDeprecated() { 181 currentPanelDeprecated() {
182 return /** @type {!WebInspector.Panel} */ ( 182 return /** @type {!UI.Panel} */ (
183 WebInspector.viewManager.materializedWidget(this._tabbedPane.selectedTab Id || '')); 183 UI.viewManager.materializedWidget(this._tabbedPane.selectedTabId || '')) ;
184 } 184 }
185 185
186 /** 186 /**
187 * @param {boolean} focus 187 * @param {boolean} focus
188 */ 188 */
189 _showDrawer(focus) { 189 _showDrawer(focus) {
190 if (this._drawerTabbedPane.isShowing()) 190 if (this._drawerTabbedPane.isShowing())
191 return; 191 return;
192 this._drawerSplitWidget.showBoth(); 192 this._drawerSplitWidget.showBoth();
193 if (focus) 193 if (focus)
194 this._focusRestorer = new WebInspector.WidgetFocusRestorer(this._drawerTab bedPane); 194 this._focusRestorer = new UI.WidgetFocusRestorer(this._drawerTabbedPane);
195 else 195 else
196 this._focusRestorer = null; 196 this._focusRestorer = null;
197 } 197 }
198 198
199 /** 199 /**
200 * @return {boolean} 200 * @return {boolean}
201 */ 201 */
202 drawerVisible() { 202 drawerVisible() {
203 return this._drawerTabbedPane.isShowing(); 203 return this._drawerTabbedPane.isShowing();
204 } 204 }
(...skipping 15 matching lines...) Expand all
220 } 220 }
221 221
222 /** 222 /**
223 * @return {boolean} 223 * @return {boolean}
224 */ 224 */
225 isDrawerMinimized() { 225 isDrawerMinimized() {
226 return this._drawerSplitWidget.isSidebarMinimized(); 226 return this._drawerSplitWidget.isSidebarMinimized();
227 } 227 }
228 228
229 _keyDown(event) { 229 _keyDown(event) {
230 if (!WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event)) 230 if (!UI.KeyboardShortcut.eventHasCtrlOrMeta(event))
231 return; 231 return;
232 232
233 var keyboardEvent = /** @type {!KeyboardEvent} */ (event); 233 var keyboardEvent = /** @type {!KeyboardEvent} */ (event);
234 // Ctrl/Cmd + 1-9 should show corresponding panel. 234 // Ctrl/Cmd + 1-9 should show corresponding panel.
235 var panelShortcutEnabled = WebInspector.moduleSetting('shortcutPanelSwitch') .get(); 235 var panelShortcutEnabled = Common.moduleSetting('shortcutPanelSwitch').get() ;
236 if (panelShortcutEnabled && !event.shiftKey && !event.altKey) { 236 if (panelShortcutEnabled && !event.shiftKey && !event.altKey) {
237 var panelIndex = -1; 237 var panelIndex = -1;
238 if (event.keyCode > 0x30 && event.keyCode < 0x3A) 238 if (event.keyCode > 0x30 && event.keyCode < 0x3A)
239 panelIndex = event.keyCode - 0x31; 239 panelIndex = event.keyCode - 0x31;
240 else if ( 240 else if (
241 event.keyCode > 0x60 && event.keyCode < 0x6A && 241 event.keyCode > 0x60 && event.keyCode < 0x6A &&
242 keyboardEvent.location === KeyboardEvent.DOM_KEY_LOCATION_NUMPAD) 242 keyboardEvent.location === KeyboardEvent.DOM_KEY_LOCATION_NUMPAD)
243 panelIndex = event.keyCode - 0x61; 243 panelIndex = event.keyCode - 0x61;
244 if (panelIndex !== -1) { 244 if (panelIndex !== -1) {
245 var panelName = this._tabbedPane.allTabs()[panelIndex]; 245 var panelName = this._tabbedPane.allTabs()[panelIndex];
246 if (panelName) { 246 if (panelName) {
247 if (!WebInspector.Dialog.hasInstance() && !this._currentPanelLocked) 247 if (!UI.Dialog.hasInstance() && !this._currentPanelLocked)
248 this.showPanel(panelName); 248 this.showPanel(panelName);
249 event.consume(true); 249 event.consume(true);
250 } 250 }
251 } 251 }
252 } 252 }
253 } 253 }
254 254
255 /** 255 /**
256 * @override 256 * @override
257 */ 257 */
258 onResize() { 258 onResize() {
259 WebInspector.Dialog.modalHostRepositioned(); 259 UI.Dialog.modalHostRepositioned();
260 } 260 }
261 261
262 /** 262 /**
263 * @return {!Element} 263 * @return {!Element}
264 */ 264 */
265 topResizerElement() { 265 topResizerElement() {
266 return this._tabbedPane.headerElement(); 266 return this._tabbedPane.headerElement();
267 } 267 }
268 268
269 toolbarItemResized() { 269 toolbarItemResized() {
270 this._tabbedPane.headerResized(); 270 this._tabbedPane.headerResized();
271 } 271 }
272 272
273 /** 273 /**
274 * @param {!WebInspector.Event} event 274 * @param {!Common.Event} event
275 */ 275 */
276 _tabSelected(event) { 276 _tabSelected(event) {
277 var tabId = /** @type {string} */ (event.data['tabId']); 277 var tabId = /** @type {string} */ (event.data['tabId']);
278 WebInspector.userMetrics.panelShown(tabId); 278 Host.userMetrics.panelShown(tabId);
279 } 279 }
280 280
281 /** 281 /**
282 * @param {!WebInspector.SplitWidget} splitWidget 282 * @param {!UI.SplitWidget} splitWidget
283 */ 283 */
284 setOwnerSplit(splitWidget) { 284 setOwnerSplit(splitWidget) {
285 this._ownerSplitWidget = splitWidget; 285 this._ownerSplitWidget = splitWidget;
286 } 286 }
287 287
288 minimize() { 288 minimize() {
289 if (this._ownerSplitWidget) 289 if (this._ownerSplitWidget)
290 this._ownerSplitWidget.setSidebarMinimized(true); 290 this._ownerSplitWidget.setSidebarMinimized(true);
291 } 291 }
292 292
293 restore() { 293 restore() {
294 if (this._ownerSplitWidget) 294 if (this._ownerSplitWidget)
295 this._ownerSplitWidget.setSidebarMinimized(false); 295 this._ownerSplitWidget.setSidebarMinimized(false);
296 } 296 }
297 }; 297 };
298 298
299 299
300 /** 300 /**
301 * @type {!WebInspector.InspectorView} 301 * @type {!UI.InspectorView}
302 */ 302 */
303 WebInspector.inspectorView; 303 UI.inspectorView;
304 304
305 /** 305 /**
306 * @implements {WebInspector.ActionDelegate} 306 * @implements {UI.ActionDelegate}
307 * @unrestricted 307 * @unrestricted
308 */ 308 */
309 WebInspector.InspectorView.DrawerToggleActionDelegate = class { 309 UI.InspectorView.DrawerToggleActionDelegate = class {
310 /** 310 /**
311 * @override 311 * @override
312 * @param {!WebInspector.Context} context 312 * @param {!UI.Context} context
313 * @param {string} actionId 313 * @param {string} actionId
314 * @return {boolean} 314 * @return {boolean}
315 */ 315 */
316 handleAction(context, actionId) { 316 handleAction(context, actionId) {
317 if (WebInspector.inspectorView.drawerVisible()) 317 if (UI.inspectorView.drawerVisible())
318 WebInspector.inspectorView._closeDrawer(); 318 UI.inspectorView._closeDrawer();
319 else 319 else
320 WebInspector.inspectorView._showDrawer(true); 320 UI.inspectorView._showDrawer(true);
321 return true; 321 return true;
322 } 322 }
323 }; 323 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698