OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 var hbox = this.element.createChild('div', 'hbox styles-sidebar-pane-toolbar
'); | 50 var hbox = this.element.createChild('div', 'hbox styles-sidebar-pane-toolbar
'); |
51 var filterContainerElement = hbox.createChild('div', 'styles-sidebar-pane-fi
lter-box'); | 51 var filterContainerElement = hbox.createChild('div', 'styles-sidebar-pane-fi
lter-box'); |
52 var filterInput = Elements.StylesSidebarPane.createPropertyFilterElement( | 52 var filterInput = Elements.StylesSidebarPane.createPropertyFilterElement( |
53 Common.UIString('Filter'), hbox, filterCallback.bind(this)); | 53 Common.UIString('Filter'), hbox, filterCallback.bind(this)); |
54 filterContainerElement.appendChild(filterInput); | 54 filterContainerElement.appendChild(filterInput); |
55 | 55 |
56 var toolbar = new UI.Toolbar('styles-pane-toolbar', hbox); | 56 var toolbar = new UI.Toolbar('styles-pane-toolbar', hbox); |
57 toolbar.appendToolbarItem(new UI.ToolbarCheckbox( | 57 toolbar.appendToolbarItem(new UI.ToolbarCheckbox( |
58 Common.UIString('Show all'), undefined, this._showInheritedComputedStyle
PropertiesSetting)); | 58 Common.UIString('Show all'), undefined, this._showInheritedComputedStyle
PropertiesSetting)); |
59 | 59 |
60 this._propertiesOutline = new TreeOutlineInShadow(); | 60 this._propertiesOutline = new UI.TreeOutlineInShadow(); |
61 this._propertiesOutline.hideOverflow(); | 61 this._propertiesOutline.hideOverflow(); |
62 this._propertiesOutline.registerRequiredCSS('elements/computedStyleSidebarPa
ne.css'); | 62 this._propertiesOutline.registerRequiredCSS('elements/computedStyleSidebarPa
ne.css'); |
63 this._propertiesOutline.element.classList.add('monospace', 'computed-propert
ies'); | 63 this._propertiesOutline.element.classList.add('monospace', 'computed-propert
ies'); |
64 this.element.appendChild(this._propertiesOutline.element); | 64 this.element.appendChild(this._propertiesOutline.element); |
65 | 65 |
66 this._linkifier = new Components.Linkifier(Elements.ComputedStyleWidget._max
LinkLength); | 66 this._linkifier = new Components.Linkifier(Elements.ComputedStyleWidget._max
LinkLength); |
67 | 67 |
68 /** | 68 /** |
69 * @param {?RegExp} regex | 69 * @param {?RegExp} regex |
70 * @this {Elements.ComputedStyleWidget} | 70 * @this {Elements.ComputedStyleWidget} |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 var propertyValueElement = propertyElement.createChild('span', 'property-v
alue'); | 177 var propertyValueElement = propertyElement.createChild('span', 'property-v
alue'); |
178 | 178 |
179 var propertyValueText = renderer.renderValue(); | 179 var propertyValueText = renderer.renderValue(); |
180 propertyValueText.classList.add('property-value-text'); | 180 propertyValueText.classList.add('property-value-text'); |
181 propertyValueElement.appendChild(propertyValueText); | 181 propertyValueElement.appendChild(propertyValueText); |
182 | 182 |
183 var semicolon = createElementWithClass('span', 'delimeter'); | 183 var semicolon = createElementWithClass('span', 'delimeter'); |
184 semicolon.textContent = ';'; | 184 semicolon.textContent = ';'; |
185 propertyValueElement.appendChild(semicolon); | 185 propertyValueElement.appendChild(semicolon); |
186 | 186 |
187 var treeElement = new TreeElement(); | 187 var treeElement = new UI.TreeElement(); |
188 treeElement.selectable = false; | 188 treeElement.selectable = false; |
189 treeElement.title = propertyElement; | 189 treeElement.title = propertyElement; |
190 treeElement[Elements.ComputedStyleWidget._propertySymbol] = {name: propert
yName, value: propertyValue}; | 190 treeElement[Elements.ComputedStyleWidget._propertySymbol] = {name: propert
yName, value: propertyValue}; |
191 var isOdd = this._propertiesOutline.rootElement().children().length % 2 ==
= 0; | 191 var isOdd = this._propertiesOutline.rootElement().children().length % 2 ==
= 0; |
192 treeElement.listItemElement.classList.toggle('odd-row', isOdd); | 192 treeElement.listItemElement.classList.toggle('odd-row', isOdd); |
193 this._propertiesOutline.appendChild(treeElement); | 193 this._propertiesOutline.appendChild(treeElement); |
194 | 194 |
195 var trace = propertyTraces.get(propertyName); | 195 var trace = propertyTraces.get(propertyName); |
196 if (trace) { | 196 if (trace) { |
197 var activeProperty = this._renderPropertyTrace(cssModel, matchedStyles,
nodeStyle.node, treeElement, trace); | 197 var activeProperty = this._renderPropertyTrace(cssModel, matchedStyles,
nodeStyle.node, treeElement, trace); |
(...skipping 17 matching lines...) Expand all Loading... |
215 */ | 215 */ |
216 function propertySorter(a, b) { | 216 function propertySorter(a, b) { |
217 if (a.startsWith('-webkit') ^ b.startsWith('-webkit')) | 217 if (a.startsWith('-webkit') ^ b.startsWith('-webkit')) |
218 return a.startsWith('-webkit') ? 1 : -1; | 218 return a.startsWith('-webkit') ? 1 : -1; |
219 var canonical1 = SDK.cssMetadata().canonicalPropertyName(a); | 219 var canonical1 = SDK.cssMetadata().canonicalPropertyName(a); |
220 var canonical2 = SDK.cssMetadata().canonicalPropertyName(b); | 220 var canonical2 = SDK.cssMetadata().canonicalPropertyName(b); |
221 return canonical1.compareTo(canonical2); | 221 return canonical1.compareTo(canonical2); |
222 } | 222 } |
223 | 223 |
224 /** | 224 /** |
225 * @param {!TreeElement} treeElement | 225 * @param {!UI.TreeElement} treeElement |
226 * @param {!Event} event | 226 * @param {!Event} event |
227 */ | 227 */ |
228 function handleClick(treeElement, event) { | 228 function handleClick(treeElement, event) { |
229 if (!treeElement.expanded) | 229 if (!treeElement.expanded) |
230 treeElement.expand(); | 230 treeElement.expand(); |
231 else | 231 else |
232 treeElement.collapse(); | 232 treeElement.collapse(); |
233 event.consume(); | 233 event.consume(); |
234 } | 234 } |
235 } | 235 } |
236 | 236 |
237 /** | 237 /** |
238 * @param {!SDK.CSSProperty} cssProperty | 238 * @param {!SDK.CSSProperty} cssProperty |
239 * @param {!Event} event | 239 * @param {!Event} event |
240 */ | 240 */ |
241 _navigateToSource(cssProperty, event) { | 241 _navigateToSource(cssProperty, event) { |
242 Common.Revealer.reveal(cssProperty); | 242 Common.Revealer.reveal(cssProperty); |
243 event.consume(true); | 243 event.consume(true); |
244 } | 244 } |
245 | 245 |
246 /** | 246 /** |
247 * @param {!SDK.CSSModel} cssModel | 247 * @param {!SDK.CSSModel} cssModel |
248 * @param {!SDK.CSSMatchedStyles} matchedStyles | 248 * @param {!SDK.CSSMatchedStyles} matchedStyles |
249 * @param {!SDK.DOMNode} node | 249 * @param {!SDK.DOMNode} node |
250 * @param {!TreeElement} rootTreeElement | 250 * @param {!UI.TreeElement} rootTreeElement |
251 * @param {!Array<!SDK.CSSProperty>} tracedProperties | 251 * @param {!Array<!SDK.CSSProperty>} tracedProperties |
252 * @return {!SDK.CSSProperty} | 252 * @return {!SDK.CSSProperty} |
253 */ | 253 */ |
254 _renderPropertyTrace(cssModel, matchedStyles, node, rootTreeElement, tracedPro
perties) { | 254 _renderPropertyTrace(cssModel, matchedStyles, node, rootTreeElement, tracedPro
perties) { |
255 var activeProperty = null; | 255 var activeProperty = null; |
256 for (var property of tracedProperties) { | 256 for (var property of tracedProperties) { |
257 var trace = createElement('div'); | 257 var trace = createElement('div'); |
258 trace.classList.add('property-trace'); | 258 trace.classList.add('property-trace'); |
259 if (matchedStyles.propertyState(property) === SDK.CSSMatchedStyles.Propert
yState.Overloaded) | 259 if (matchedStyles.propertyState(property) === SDK.CSSMatchedStyles.Propert
yState.Overloaded) |
260 trace.classList.add('property-trace-inactive'); | 260 trace.classList.add('property-trace-inactive'); |
(...skipping 16 matching lines...) Expand all Loading... |
277 if (rule) { | 277 if (rule) { |
278 var linkSpan = trace.createChild('span', 'trace-link'); | 278 var linkSpan = trace.createChild('span', 'trace-link'); |
279 linkSpan.appendChild( | 279 linkSpan.appendChild( |
280 Elements.StylePropertiesSection.createRuleOriginNode(matchedStyles,
this._linkifier, rule)); | 280 Elements.StylePropertiesSection.createRuleOriginNode(matchedStyles,
this._linkifier, rule)); |
281 } | 281 } |
282 | 282 |
283 var selectorElement = trace.createChild('span', 'property-trace-selector')
; | 283 var selectorElement = trace.createChild('span', 'property-trace-selector')
; |
284 selectorElement.textContent = rule ? rule.selectorText() : 'element.style'
; | 284 selectorElement.textContent = rule ? rule.selectorText() : 'element.style'
; |
285 selectorElement.title = selectorElement.textContent; | 285 selectorElement.title = selectorElement.textContent; |
286 | 286 |
287 var traceTreeElement = new TreeElement(); | 287 var traceTreeElement = new UI.TreeElement(); |
288 traceTreeElement.title = trace; | 288 traceTreeElement.title = trace; |
289 traceTreeElement.selectable = false; | 289 traceTreeElement.selectable = false; |
290 rootTreeElement.appendChild(traceTreeElement); | 290 rootTreeElement.appendChild(traceTreeElement); |
291 } | 291 } |
292 return /** @type {!SDK.CSSProperty} */ (activeProperty); | 292 return /** @type {!SDK.CSSProperty} */ (activeProperty); |
293 } | 293 } |
294 | 294 |
295 /** | 295 /** |
296 * @param {!SDK.CSSMatchedStyles} matchedStyles | 296 * @param {!SDK.CSSMatchedStyles} matchedStyles |
297 * @return {!Map<string, !Array<!SDK.CSSProperty>>} | 297 * @return {!Map<string, !Array<!SDK.CSSProperty>>} |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 var property = child[Elements.ComputedStyleWidget._propertySymbol]; | 336 var property = child[Elements.ComputedStyleWidget._propertySymbol]; |
337 var matched = !regex || regex.test(property.name) || regex.test(property.v
alue); | 337 var matched = !regex || regex.test(property.name) || regex.test(property.v
alue); |
338 child.hidden = !matched; | 338 child.hidden = !matched; |
339 } | 339 } |
340 } | 340 } |
341 }; | 341 }; |
342 | 342 |
343 Elements.ComputedStyleWidget._maxLinkLength = 30; | 343 Elements.ComputedStyleWidget._maxLinkLength = 30; |
344 | 344 |
345 Elements.ComputedStyleWidget._propertySymbol = Symbol('property'); | 345 Elements.ComputedStyleWidget._propertySymbol = Symbol('property'); |
OLD | NEW |