| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * | |
| 8 * 1. Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | |
| 11 * notice, this list of conditions and the following disclaimer in the | |
| 12 * documentation and/or other materials provided with the distribution. | |
| 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 | |
| 15 * from this software without specific prior written permission. | |
| 16 * | |
| 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 | |
| 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 | |
| 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 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 | |
| 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 | |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 27 */ | |
| 28 | |
| 29 /** | |
| 30 * @extends {WebInspector.VBox} | |
| 31 * @constructor | |
| 32 */ | |
| 33 WebInspector.Panel = function(name) | |
| 34 { | |
| 35 WebInspector.VBox.call(this); | |
| 36 | |
| 37 this.element.classList.add("panel"); | |
| 38 this.element.classList.add(name); | |
| 39 this._panelName = name; | |
| 40 | |
| 41 this._shortcuts = /** !Object.<number, function(Event=):boolean> */ ({}); | |
| 42 } | |
| 43 | |
| 44 // Should by in sync with style declarations. | |
| 45 WebInspector.Panel.counterRightMargin = 25; | |
| 46 | |
| 47 WebInspector.Panel.prototype = { | |
| 48 get name() | |
| 49 { | |
| 50 return this._panelName; | |
| 51 }, | |
| 52 | |
| 53 reset: function() | |
| 54 { | |
| 55 }, | |
| 56 | |
| 57 /** | |
| 58 * @return {!Element} | |
| 59 */ | |
| 60 defaultFocusedElement: function() | |
| 61 { | |
| 62 return this.element; | |
| 63 }, | |
| 64 | |
| 65 /** | |
| 66 * @return {?WebInspector.SearchableView} | |
| 67 */ | |
| 68 searchableView: function() | |
| 69 { | |
| 70 return null; | |
| 71 }, | |
| 72 | |
| 73 /** | |
| 74 * @return {!Array.<!Element>} | |
| 75 */ | |
| 76 elementsToRestoreScrollPositionsFor: function() | |
| 77 { | |
| 78 return []; | |
| 79 }, | |
| 80 | |
| 81 /** | |
| 82 * @param {!KeyboardEvent} event | |
| 83 */ | |
| 84 handleShortcut: function(event) | |
| 85 { | |
| 86 var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); | |
| 87 var handler = this._shortcuts[shortcutKey]; | |
| 88 if (handler && handler(event)) { | |
| 89 event.handled = true; | |
| 90 return; | |
| 91 } | |
| 92 | |
| 93 var searchableView = this.searchableView(); | |
| 94 if (!searchableView) | |
| 95 return; | |
| 96 | |
| 97 function handleSearchShortcuts(shortcuts, handler) | |
| 98 { | |
| 99 for (var i = 0; i < shortcuts.length; ++i) { | |
| 100 if (shortcuts[i].key !== shortcutKey) | |
| 101 continue; | |
| 102 return handler.call(searchableView); | |
| 103 } | |
| 104 return false; | |
| 105 } | |
| 106 | |
| 107 if (handleSearchShortcuts(WebInspector.SearchableView.findShortcuts(), s
earchableView.handleFindShortcut)) | |
| 108 event.handled = true; | |
| 109 else if (handleSearchShortcuts(WebInspector.SearchableView.cancelSearchS
hortcuts(), searchableView.handleCancelSearchShortcut)) | |
| 110 event.handled = true; | |
| 111 }, | |
| 112 | |
| 113 /** | |
| 114 * @param {!Array.<!WebInspector.KeyboardShortcut.Descriptor>} keys | |
| 115 * @param {function(!Event=):boolean} handler | |
| 116 */ | |
| 117 registerShortcuts: function(keys, handler) | |
| 118 { | |
| 119 for (var i = 0; i < keys.length; ++i) | |
| 120 this._shortcuts[keys[i].key] = handler; | |
| 121 }, | |
| 122 | |
| 123 __proto__: WebInspector.VBox.prototype | |
| 124 } | |
| 125 | |
| 126 /** | |
| 127 * @extends {WebInspector.Panel} | |
| 128 * @param {string} name | |
| 129 * @param {number=} defaultWidth | |
| 130 * @constructor | |
| 131 */ | |
| 132 WebInspector.PanelWithSidebarTree = function(name, defaultWidth) | |
| 133 { | |
| 134 WebInspector.Panel.call(this, name); | |
| 135 | |
| 136 this._panelSplitView = new WebInspector.SplitView(true, false, this._panelNa
me + "PanelSplitViewState", defaultWidth || 200); | |
| 137 this._panelSplitView.show(this.element); | |
| 138 | |
| 139 var sidebarView = new WebInspector.VBox(); | |
| 140 sidebarView.setMinimumSize(100, 25); | |
| 141 sidebarView.show(this._panelSplitView.sidebarElement()); | |
| 142 | |
| 143 this._sidebarElement = sidebarView.element; | |
| 144 this._sidebarElement.classList.add("sidebar"); | |
| 145 var sidebarTreeElement = this._sidebarElement.createChild("ol", "sidebar-tre
e"); | |
| 146 this.sidebarTree = new TreeOutline(sidebarTreeElement); | |
| 147 } | |
| 148 | |
| 149 WebInspector.PanelWithSidebarTree.prototype = { | |
| 150 /** | |
| 151 * @return {!Element} | |
| 152 */ | |
| 153 sidebarElement: function() | |
| 154 { | |
| 155 return this._sidebarElement; | |
| 156 }, | |
| 157 | |
| 158 /** | |
| 159 * @return {!Element} element | |
| 160 */ | |
| 161 mainElement: function() | |
| 162 { | |
| 163 return this._panelSplitView.mainElement(); | |
| 164 }, | |
| 165 | |
| 166 /** | |
| 167 * @return {!Element} | |
| 168 */ | |
| 169 defaultFocusedElement: function() | |
| 170 { | |
| 171 return this.sidebarTree.element || this.element; | |
| 172 }, | |
| 173 | |
| 174 __proto__: WebInspector.Panel.prototype | |
| 175 } | |
| 176 | |
| 177 /** | |
| 178 * @interface | |
| 179 */ | |
| 180 WebInspector.PanelDescriptor = function() | |
| 181 { | |
| 182 } | |
| 183 | |
| 184 WebInspector.PanelDescriptor.prototype = { | |
| 185 /** | |
| 186 * @return {string} | |
| 187 */ | |
| 188 name: function() {}, | |
| 189 | |
| 190 /** | |
| 191 * @return {string} | |
| 192 */ | |
| 193 title: function() {}, | |
| 194 | |
| 195 /** | |
| 196 * @return {!Promise.<!WebInspector.Panel>} | |
| 197 */ | |
| 198 panel: function() {} | |
| 199 } | |
| 200 | |
| 201 /** | |
| 202 * @interface | |
| 203 */ | |
| 204 WebInspector.PanelFactory = function() | |
| 205 { | |
| 206 } | |
| 207 | |
| 208 WebInspector.PanelFactory.prototype = { | |
| 209 /** | |
| 210 * @return {!WebInspector.Panel} | |
| 211 */ | |
| 212 createPanel: function() { } | |
| 213 } | |
| 214 | |
| 215 /** | |
| 216 * @constructor | |
| 217 * @param {!Runtime.Extension} extension | |
| 218 * @implements {WebInspector.PanelDescriptor} | |
| 219 */ | |
| 220 WebInspector.RuntimeExtensionPanelDescriptor = function(extension) | |
| 221 { | |
| 222 this._name = extension.descriptor()["name"]; | |
| 223 this._title = WebInspector.UIString(extension.descriptor()["title"]); | |
| 224 this._extension = extension; | |
| 225 } | |
| 226 | |
| 227 WebInspector.RuntimeExtensionPanelDescriptor.prototype = { | |
| 228 /** | |
| 229 * @return {string} | |
| 230 */ | |
| 231 name: function() | |
| 232 { | |
| 233 return this._name; | |
| 234 }, | |
| 235 | |
| 236 /** | |
| 237 * @return {string} | |
| 238 */ | |
| 239 title: function() | |
| 240 { | |
| 241 return this._title; | |
| 242 }, | |
| 243 | |
| 244 /** | |
| 245 * @return {!Promise.<!WebInspector.Panel>} | |
| 246 */ | |
| 247 panel: function() | |
| 248 { | |
| 249 return this._extension.instancePromise().then(createPanel); | |
| 250 | |
| 251 /** | |
| 252 * @param {!Object} panelFactory | |
| 253 * @return {!WebInspector.Panel} | |
| 254 */ | |
| 255 function createPanel(panelFactory) | |
| 256 { | |
| 257 return /** @type {!WebInspector.PanelFactory} */ (panelFactory).crea
tePanel(); | |
| 258 } | |
| 259 } | |
| 260 } | |
| OLD | NEW |