OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /** | 7 /** |
8 * @constructor | 8 * @constructor |
9 * @extends {WebInspector.DialogDelegate} | 9 * @extends {WebInspector.DialogDelegate} |
10 */ | 10 */ |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 var contents = this.element.createChild("div", "contents"); | 23 var contents = this.element.createChild("div", "contents"); |
24 | 24 |
25 var blockHeader = contents.createChild("div", "columns-header"); | 25 var blockHeader = contents.createChild("div", "columns-header"); |
26 blockHeader.createChild("span").textContent = WebInspector.UIString("URI pat
tern"); | 26 blockHeader.createChild("span").textContent = WebInspector.UIString("URI pat
tern"); |
27 blockHeader.createChild("span").textContent = WebInspector.UIString("Behavio
r"); | 27 blockHeader.createChild("span").textContent = WebInspector.UIString("Behavio
r"); |
28 | 28 |
29 var section = contents.createChild("div", "section"); | 29 var section = contents.createChild("div", "section"); |
30 var container = section.createChild("div", "settings-list-container"); | 30 var container = section.createChild("div", "settings-list-container"); |
31 | 31 |
| 32 this._blackboxLabel = WebInspector.UIString("Blackbox"); |
| 33 this._disabledLabel = WebInspector.UIString("Disabled"); |
| 34 |
32 var column1 = { id: "pattern", placeholder: "/framework\\.js$" }; | 35 var column1 = { id: "pattern", placeholder: "/framework\\.js$" }; |
33 var column2 = { id: "value", options: [WebInspector.UIString("Blackbox")] }; | 36 var column2 = { id: "value", options: [this._blackboxLabel, this._disabledLa
bel] }; |
34 | 37 |
35 this._patternsList = new WebInspector.EditableSettingsList([column1, column2
], this._patternValuesProvider.bind(this), this._patternValidate.bind(this), thi
s._patternEdit.bind(this)); | 38 this._patternsList = new WebInspector.EditableSettingsList([column1, column2
], this._patternValuesProvider.bind(this), this._patternValidate.bind(this), thi
s._patternEdit.bind(this)); |
36 this._patternsList.element.classList.add("blackbox-patterns-list"); | 39 this._patternsList.element.classList.add("blackbox-patterns-list"); |
37 this._patternsList.addEventListener(WebInspector.SettingsList.Events.Removed
, this._patternRemovedFromList.bind(this)); | 40 this._patternsList.addEventListener(WebInspector.SettingsList.Events.Removed
, this._patternRemovedFromList.bind(this)); |
38 container.appendChild(this._patternsList.element); | 41 container.appendChild(this._patternsList.element); |
39 | 42 |
40 /** @type {!Object.<string, boolean>} */ | 43 /** @type {!StringMap.<string>} */ |
41 this._entries = {}; | 44 this._entries = new StringMap(); |
42 var patterns = WebInspector.settings.skipStackFramesPattern.getAsArray(); | 45 var patterns = WebInspector.settings.skipStackFramesPattern.getAsArray(); |
43 for (var i = 0; i < patterns.length; ++i) | 46 for (var i = 0; i < patterns.length; ++i) |
44 this._addPattern(patterns[i]); | 47 this._addPattern(patterns[i].pattern, patterns[i].disabled); |
45 | 48 |
46 this.element.tabIndex = 0; | 49 this.element.tabIndex = 0; |
47 } | 50 } |
48 | 51 |
49 WebInspector.FrameworkBlackboxDialog.show = function(element) | 52 WebInspector.FrameworkBlackboxDialog.show = function(element) |
50 { | 53 { |
51 WebInspector.Dialog.show(element, new WebInspector.FrameworkBlackboxDialog()
); | 54 WebInspector.Dialog.show(element, new WebInspector.FrameworkBlackboxDialog()
); |
52 var glassPane = document.getElementById("glass-pane"); | 55 var glassPane = document.getElementById("glass-pane"); |
53 glassPane.classList.add("settings-glass-pane"); | 56 glassPane.classList.add("settings-glass-pane"); |
54 } | 57 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 * @return {string} | 104 * @return {string} |
102 */ | 105 */ |
103 _patternValuesProvider: function(itemId, columnId) | 106 _patternValuesProvider: function(itemId, columnId) |
104 { | 107 { |
105 if (!itemId) | 108 if (!itemId) |
106 return ""; | 109 return ""; |
107 switch (columnId) { | 110 switch (columnId) { |
108 case "pattern": | 111 case "pattern": |
109 return itemId; | 112 return itemId; |
110 case "value": | 113 case "value": |
111 return WebInspector.UIString("Blackbox"); | 114 return /** @type {string} */ (this._entries.get(itemId)); |
112 default: | 115 default: |
113 console.assert("Should not be reached."); | 116 console.assert("Should not be reached."); |
114 } | 117 } |
115 return ""; | 118 return ""; |
116 }, | 119 }, |
117 | 120 |
118 /** | 121 /** |
119 * @param {?string} itemId | 122 * @param {?string} itemId |
120 * @param {!Object} data | 123 * @param {!Object} data |
121 * @return {!Array.<string>} | 124 * @return {!Array.<string>} |
122 */ | 125 */ |
123 _patternValidate: function(itemId, data) | 126 _patternValidate: function(itemId, data) |
124 { | 127 { |
125 var regex; | 128 var regex; |
| 129 var oldPattern = itemId; |
126 var newPattern = data["pattern"]; | 130 var newPattern = data["pattern"]; |
127 try { | 131 try { |
128 if (newPattern && !this._entries[newPattern]) | 132 if (newPattern && (oldPattern === newPattern || !this._entries.conta
ins(newPattern))) |
129 regex = new RegExp(newPattern); | 133 regex = new RegExp(newPattern); |
130 } catch (e) { | 134 } catch (e) { |
131 } | 135 } |
132 return regex ? [] : ["pattern"]; | 136 return regex ? [] : ["pattern"]; |
133 }, | 137 }, |
134 | 138 |
135 /** | 139 /** |
136 * @param {?string} itemId | 140 * @param {?string} itemId |
137 * @param {!Object} data | 141 * @param {!Object} data |
138 */ | 142 */ |
139 _patternEdit: function(itemId, data) | 143 _patternEdit: function(itemId, data) |
140 { | 144 { |
141 var oldPattern = itemId; | 145 var oldPattern = itemId; |
142 var newPattern = data["pattern"]; | 146 var newPattern = data["pattern"]; |
143 if (!newPattern) | 147 if (!newPattern) |
144 return; | 148 return; |
| 149 var disabled = (data["value"] === this._disabledLabel); |
145 | 150 |
146 var patterns = WebInspector.settings.skipStackFramesPattern.getAsArray()
; | 151 var patterns = WebInspector.settings.skipStackFramesPattern.getAsArray()
; |
147 var pos = oldPattern ? patterns.indexOf(oldPattern) : -1; | 152 for (var i = 0; i <= patterns.length; ++i) { |
148 if (pos === -1) | 153 if (i === patterns.length) { |
149 patterns.push(newPattern); | 154 patterns.push({ pattern: newPattern, disabled: disabled }); |
150 else | 155 break; |
151 patterns[pos] = newPattern; | 156 } |
| 157 if (patterns[i].pattern === oldPattern) { |
| 158 patterns[i] = { pattern: newPattern, disabled: disabled }; |
| 159 break; |
| 160 } |
| 161 } |
152 WebInspector.settings.skipStackFramesPattern.setAsArray(patterns); | 162 WebInspector.settings.skipStackFramesPattern.setAsArray(patterns); |
153 | 163 |
| 164 if (oldPattern && oldPattern === newPattern) { |
| 165 this._entries.put(newPattern, disabled ? this._disabledLabel : this.
_blackboxLabel) |
| 166 this._patternsList.refreshItem(newPattern); |
| 167 return; |
| 168 } |
| 169 |
154 if (oldPattern) { | 170 if (oldPattern) { |
155 this._patternsList.removeItem(oldPattern); | 171 this._patternsList.removeItem(oldPattern); |
156 delete this._entries[oldPattern]; | 172 this._entries.remove(oldPattern); |
157 } | 173 } |
158 this._addPattern(newPattern); | 174 this._addPattern(newPattern, disabled); |
159 this._patternsList.selectItem(newPattern); | |
160 }, | 175 }, |
161 | 176 |
162 /** | 177 /** |
163 * @param {!WebInspector.Event} event | 178 * @param {!WebInspector.Event} event |
164 */ | 179 */ |
165 _patternRemovedFromList: function(event) | 180 _patternRemovedFromList: function(event) |
166 { | 181 { |
167 var pattern = /** @type{?string} */ (event.data); | 182 var pattern = /** @type{?string} */ (event.data); |
168 if (!pattern) | 183 if (!pattern) |
169 return; | 184 return; |
170 delete this._entries[pattern]; | 185 this._entries.remove(pattern); |
171 | 186 |
172 var patterns = WebInspector.settings.skipStackFramesPattern.getAsArray()
; | 187 var patterns = WebInspector.settings.skipStackFramesPattern.getAsArray()
; |
173 patterns.remove(pattern); | 188 for (var i = 0; i < patterns.length; ++i) { |
| 189 if (patterns[i].pattern === pattern) { |
| 190 patterns.splice(i, 1); |
| 191 break; |
| 192 } |
| 193 } |
174 WebInspector.settings.skipStackFramesPattern.setAsArray(patterns); | 194 WebInspector.settings.skipStackFramesPattern.setAsArray(patterns); |
175 }, | 195 }, |
176 | 196 |
177 /** | 197 /** |
178 * @param {string} pattern | 198 * @param {string} pattern |
| 199 * @param {boolean=} disabled |
179 */ | 200 */ |
180 _addPattern: function(pattern) | 201 _addPattern: function(pattern, disabled) |
181 { | 202 { |
182 if (!pattern || this._entries[pattern]) | 203 if (!pattern || this._entries.contains(pattern)) |
183 return; | 204 return; |
184 this._entries[pattern] = true; | 205 this._entries.put(pattern, disabled ? this._disabledLabel : this._blackb
oxLabel); |
185 this._patternsList.addItem(pattern, null); | 206 this._patternsList.addItem(pattern, null); |
186 this._resize(); | 207 this._resize(); |
187 }, | 208 }, |
188 | 209 |
189 focus: function() | 210 focus: function() |
190 { | 211 { |
191 WebInspector.setCurrentFocusElement(this.element); | 212 WebInspector.setCurrentFocusElement(this.element); |
192 }, | 213 }, |
193 | 214 |
194 _onDoneClick: function() | 215 _onDoneClick: function() |
195 { | 216 { |
196 WebInspector.Dialog.hide(); | 217 WebInspector.Dialog.hide(); |
197 }, | 218 }, |
198 | 219 |
199 onEnter: function(event) | 220 onEnter: function(event) |
200 { | 221 { |
201 var focusElement = WebInspector.currentFocusElement(); | 222 var focusElement = WebInspector.currentFocusElement(); |
202 var nodeName = focusElement && focusElement.nodeName.toLowerCase(); | 223 var nodeName = focusElement && focusElement.nodeName.toLowerCase(); |
203 if (nodeName === "input" || nodeName === "select") { | 224 if (nodeName === "input" || nodeName === "select") { |
204 this.focus(); | 225 this.focus(); |
205 event.consume(true); | 226 event.consume(true); |
206 return; | 227 return; |
207 } | 228 } |
208 }, | 229 }, |
209 | 230 |
210 __proto__: WebInspector.DialogDelegate.prototype | 231 __proto__: WebInspector.DialogDelegate.prototype |
211 } | 232 } |
OLD | NEW |