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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/Panel.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) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived 14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission. 15 * from this software without specific prior written permission.
16 * 16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 // For testing. 28 // For testing.
29 WebInspector.panels = []; 29 UI.panels = [];
30 30
31 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.Panel = class extends WebInspector.VBox { 34 UI.Panel = class extends UI.VBox {
35 constructor(name) { 35 constructor(name) {
36 super(); 36 super();
37 37
38 this.element.classList.add('panel'); 38 this.element.classList.add('panel');
39 this.element.setAttribute('aria-label', name); 39 this.element.setAttribute('aria-label', name);
40 this.element.classList.add(name); 40 this.element.classList.add(name);
41 this._panelName = name; 41 this._panelName = name;
42 42
43 // For testing. 43 // For testing.
44 WebInspector.panels[name] = this; 44 UI.panels[name] = this;
45 45
46 this._shortcuts = /** !Object.<number, function(Event=):boolean> */ ({}); 46 this._shortcuts = /** !Object.<number, function(Event=):boolean> */ ({});
47 } 47 }
48 48
49 get name() { 49 get name() {
50 return this._panelName; 50 return this._panelName;
51 } 51 }
52 52
53 /** 53 /**
54 * @return {?WebInspector.SearchableView} 54 * @return {?UI.SearchableView}
55 */ 55 */
56 searchableView() { 56 searchableView() {
57 return null; 57 return null;
58 } 58 }
59 59
60 /** 60 /**
61 * @override 61 * @override
62 * @return {!Array.<!Element>} 62 * @return {!Array.<!Element>}
63 */ 63 */
64 elementsToRestoreScrollPositionsFor() { 64 elementsToRestoreScrollPositionsFor() {
65 return []; 65 return [];
66 } 66 }
67 67
68 /** 68 /**
69 * @param {!KeyboardEvent} event 69 * @param {!KeyboardEvent} event
70 */ 70 */
71 handleShortcut(event) { 71 handleShortcut(event) {
72 var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); 72 var shortcutKey = UI.KeyboardShortcut.makeKeyFromEvent(event);
73 var handler = this._shortcuts[shortcutKey]; 73 var handler = this._shortcuts[shortcutKey];
74 if (handler && handler(event)) 74 if (handler && handler(event))
75 event.handled = true; 75 event.handled = true;
76 } 76 }
77 77
78 /** 78 /**
79 * @param {!Array.<!WebInspector.KeyboardShortcut.Descriptor>} keys 79 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} keys
80 * @param {function(!Event=):boolean} handler 80 * @param {function(!Event=):boolean} handler
81 */ 81 */
82 registerShortcuts(keys, handler) { 82 registerShortcuts(keys, handler) {
83 for (var i = 0; i < keys.length; ++i) 83 for (var i = 0; i < keys.length; ++i)
84 this._shortcuts[keys[i].key] = handler; 84 this._shortcuts[keys[i].key] = handler;
85 } 85 }
86 86
87 /** 87 /**
88 * @param {!WebInspector.Infobar} infobar 88 * @param {!UI.Infobar} infobar
89 */ 89 */
90 showInfobar(infobar) { 90 showInfobar(infobar) {
91 infobar.setCloseCallback(this._onInfobarClosed.bind(this, infobar)); 91 infobar.setCloseCallback(this._onInfobarClosed.bind(this, infobar));
92 if (this.element.firstChild) 92 if (this.element.firstChild)
93 this.element.insertBefore(infobar.element, this.element.firstChild); 93 this.element.insertBefore(infobar.element, this.element.firstChild);
94 else 94 else
95 this.element.appendChild(infobar.element); 95 this.element.appendChild(infobar.element);
96 infobar.setParentView(this); 96 infobar.setParentView(this);
97 this.doResize(); 97 this.doResize();
98 } 98 }
99 99
100 /** 100 /**
101 * @param {!WebInspector.Infobar} infobar 101 * @param {!UI.Infobar} infobar
102 */ 102 */
103 _onInfobarClosed(infobar) { 103 _onInfobarClosed(infobar) {
104 infobar.element.remove(); 104 infobar.element.remove();
105 this.doResize(); 105 this.doResize();
106 } 106 }
107 }; 107 };
108 108
109 // Should by in sync with style declarations. 109 // Should by in sync with style declarations.
110 WebInspector.Panel.counterRightMargin = 25; 110 UI.Panel.counterRightMargin = 25;
111 111
112 /** 112 /**
113 * @unrestricted 113 * @unrestricted
114 */ 114 */
115 WebInspector.PanelWithSidebar = class extends WebInspector.Panel { 115 UI.PanelWithSidebar = class extends UI.Panel {
116 /** 116 /**
117 * @param {string} name 117 * @param {string} name
118 * @param {number=} defaultWidth 118 * @param {number=} defaultWidth
119 */ 119 */
120 constructor(name, defaultWidth) { 120 constructor(name, defaultWidth) {
121 super(name); 121 super(name);
122 122
123 this._panelSplitWidget = 123 this._panelSplitWidget =
124 new WebInspector.SplitWidget(true, false, this._panelName + 'PanelSplitV iewState', defaultWidth || 200); 124 new UI.SplitWidget(true, false, this._panelName + 'PanelSplitViewState', defaultWidth || 200);
125 this._panelSplitWidget.show(this.element); 125 this._panelSplitWidget.show(this.element);
126 126
127 this._mainWidget = new WebInspector.VBox(); 127 this._mainWidget = new UI.VBox();
128 this._panelSplitWidget.setMainWidget(this._mainWidget); 128 this._panelSplitWidget.setMainWidget(this._mainWidget);
129 129
130 this._sidebarWidget = new WebInspector.VBox(); 130 this._sidebarWidget = new UI.VBox();
131 this._sidebarWidget.setMinimumSize(100, 25); 131 this._sidebarWidget.setMinimumSize(100, 25);
132 this._panelSplitWidget.setSidebarWidget(this._sidebarWidget); 132 this._panelSplitWidget.setSidebarWidget(this._sidebarWidget);
133 133
134 this._sidebarWidget.element.classList.add('panel-sidebar'); 134 this._sidebarWidget.element.classList.add('panel-sidebar');
135 } 135 }
136 136
137 /** 137 /**
138 * @return {!Element} 138 * @return {!Element}
139 */ 139 */
140 panelSidebarElement() { 140 panelSidebarElement() {
141 return this._sidebarWidget.element; 141 return this._sidebarWidget.element;
142 } 142 }
143 143
144 /** 144 /**
145 * @return {!Element} 145 * @return {!Element}
146 */ 146 */
147 mainElement() { 147 mainElement() {
148 return this._mainWidget.element; 148 return this._mainWidget.element;
149 } 149 }
150 150
151 /** 151 /**
152 * @return {!WebInspector.SplitWidget} 152 * @return {!UI.SplitWidget}
153 */ 153 */
154 splitWidget() { 154 splitWidget() {
155 return this._panelSplitWidget; 155 return this._panelSplitWidget;
156 } 156 }
157 }; 157 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698