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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 var color = WebInspector.Color.parse(text); | 129 var color = WebInspector.Color.parse(text); |
130 if (!color) | 130 if (!color) |
131 return createTextNode(text); | 131 return createTextNode(text); |
132 var swatch = WebInspector.ColorSwatch.create(); | 132 var swatch = WebInspector.ColorSwatch.create(); |
133 swatch.setColorText(text); | 133 swatch.setColorText(text); |
134 return swatch; | 134 return swatch; |
135 }, | 135 }, |
136 | 136 |
137 /** | 137 /** |
138 * @param {?WebInspector.SharedSidebarModel.ComputedStyle} nodeStyle | 138 * @param {?WebInspector.SharedSidebarModel.ComputedStyle} nodeStyle |
139 @param {?{matched: !WebInspector.SectionCascade, pseudo: !Map.<number, !W
ebInspector.SectionCascade>}} cascades | 139 * @param {?{matched: !WebInspector.SectionCascade, pseudo: !Map.<number, !W
ebInspector.SectionCascade>}} cascades |
140 */ | 140 */ |
141 _innerRebuildUpdate: function(nodeStyle, cascades) | 141 _innerRebuildUpdate: function(nodeStyle, cascades) |
142 { | 142 { |
143 this._propertiesContainer.removeChildren(); | 143 this._propertiesContainer.removeChildren(); |
144 if (!nodeStyle || !cascades) | 144 if (!nodeStyle || !cascades) |
145 return; | 145 return; |
146 | 146 |
147 var uniqueProperties = nodeStyle.computedStyle.allProperties.slice(); | 147 var uniqueProperties = nodeStyle.computedStyle.keysArray(); |
148 uniqueProperties.sort(propertySorter); | 148 uniqueProperties.sort(propertySorter); |
149 | 149 |
150 var showInherited = this._showInheritedComputedStylePropertiesSetting.ge
t(); | 150 var showInherited = this._showInheritedComputedStylePropertiesSetting.ge
t(); |
151 for (var i = 0; i < uniqueProperties.length; ++i) { | 151 for (var i = 0; i < uniqueProperties.length; ++i) { |
152 var property = uniqueProperties[i]; | 152 var propertyName = uniqueProperties[i]; |
153 var inherited = this._isPropertyInherited(cascades.matched, property
.name); | 153 var propertyValue = nodeStyle.computedStyle.get(propertyName); |
154 if (!showInherited && inherited && !(property.name in this._alwaysSh
owComputedProperties)) | 154 var inherited = this._isPropertyInherited(cascades.matched, property
Name); |
| 155 if (!showInherited && inherited && !(propertyName in this._alwaysSho
wComputedProperties)) |
155 continue; | 156 continue; |
156 var canonicalName = WebInspector.CSSMetadata.canonicalPropertyName(p
roperty.name); | 157 var canonicalName = WebInspector.CSSMetadata.canonicalPropertyName(p
ropertyName); |
157 if (property.name !== canonicalName && property.value === nodeStyle.
computedStyle.getPropertyValue(canonicalName)) | 158 if (propertyName !== canonicalName && propertyValue === nodeStyle.co
mputedStyle.get(canonicalName)) |
158 continue; | 159 continue; |
159 var item = this._propertiesContainer.createChild("div", "computed-st
yle-property"); | 160 var item = this._propertiesContainer.createChild("div", "computed-st
yle-property"); |
160 item[WebInspector.ComputedStyleWidget._propertySymbol] = property; | 161 item[WebInspector.ComputedStyleWidget._propertySymbol] = { |
| 162 name: propertyName, |
| 163 value: propertyValue |
| 164 }; |
161 item.classList.toggle("computed-style-property-inherited", inherited
); | 165 item.classList.toggle("computed-style-property-inherited", inherited
); |
162 var renderer = new WebInspector.StylesSidebarPropertyRenderer(null,
nodeStyle.node, property.name, property.value); | 166 var renderer = new WebInspector.StylesSidebarPropertyRenderer(null,
nodeStyle.node, propertyName, /** @type {string} */(propertyValue)); |
163 renderer.setColorHandler(this._processColor.bind(this)); | 167 renderer.setColorHandler(this._processColor.bind(this)); |
164 | 168 |
165 if (!inherited) { | 169 if (!inherited) { |
166 var traceButton = item.createChild("div", "computed-style-trace-
button"); | 170 var traceButton = item.createChild("div", "computed-style-trace-
button"); |
167 traceButton.createChild("div", "glyph"); | 171 traceButton.createChild("div", "glyph"); |
168 traceButton.addEventListener("click", this._onTracePropertyBound
, false); | 172 traceButton.addEventListener("click", this._onTracePropertyBound
, false); |
169 } | 173 } |
170 item.appendChild(renderer.renderName()); | 174 item.appendChild(renderer.renderName()); |
171 item.appendChild(createTextNode(": ")); | 175 item.appendChild(createTextNode(": ")); |
172 item.appendChild(renderer.renderValue()); | 176 item.appendChild(renderer.renderValue()); |
173 item.appendChild(createTextNode(";")); | 177 item.appendChild(createTextNode(";")); |
174 this._propertiesContainer.appendChild(item); | 178 this._propertiesContainer.appendChild(item); |
175 } | 179 } |
176 | 180 |
177 this._updateFilter(this._filterRegex); | 181 this._updateFilter(this._filterRegex); |
178 | 182 |
179 /** | 183 /** |
180 * @param {!WebInspector.CSSProperty} a | 184 * @param {string} a |
181 * @param {!WebInspector.CSSProperty} b | 185 * @param {string} b |
182 */ | 186 */ |
183 function propertySorter(a, b) | 187 function propertySorter(a, b) |
184 { | 188 { |
185 var canonicalName = WebInspector.CSSMetadata.canonicalPropertyName; | 189 var canonicalName = WebInspector.CSSMetadata.canonicalPropertyName; |
186 return canonicalName(a.name).compareTo(canonicalName(b.name)); | 190 return canonicalName(a).compareTo(canonicalName(b)); |
187 } | 191 } |
188 }, | 192 }, |
189 | 193 |
190 /** | 194 /** |
191 * @param {!WebInspector.SectionCascade} matchedCascade | 195 * @param {!WebInspector.SectionCascade} matchedCascade |
192 * @param {string} propertyName | 196 * @param {string} propertyName |
193 */ | 197 */ |
194 _isPropertyInherited: function(matchedCascade, propertyName) | 198 _isPropertyInherited: function(matchedCascade, propertyName) |
195 { | 199 { |
196 var canonicalName = WebInspector.CSSMetadata.canonicalPropertyName(prope
rtyName); | 200 var canonicalName = WebInspector.CSSMetadata.canonicalPropertyName(prope
rtyName); |
197 return !matchedCascade.allUsedProperties().has(canonicalName); | 201 return !matchedCascade.allUsedProperties().has(canonicalName); |
198 }, | 202 }, |
199 | 203 |
200 /** | 204 /** |
201 * @param {?RegExp} regex | 205 * @param {?RegExp} regex |
202 */ | 206 */ |
203 _updateFilter: function(regex) | 207 _updateFilter: function(regex) |
204 { | 208 { |
205 for (var i = 0; i < this._propertiesContainer.children.length; ++i) { | 209 for (var i = 0; i < this._propertiesContainer.children.length; ++i) { |
206 var item = this._propertiesContainer.children[i]; | 210 var item = this._propertiesContainer.children[i]; |
207 var property = item[WebInspector.ComputedStyleWidget._propertySymbol
]; | 211 var property = item[WebInspector.ComputedStyleWidget._propertySymbol
]; |
208 var matched = !regex || regex.test(property.name) || regex.test(prop
erty.value); | 212 var matched = !regex || regex.test(property.name) || regex.test(prop
erty.value); |
209 item.classList.toggle("hidden", !matched); | 213 item.classList.toggle("hidden", !matched); |
210 } | 214 } |
211 }, | 215 }, |
212 | 216 |
213 __proto__: WebInspector.ThrottledWidget.prototype | 217 __proto__: WebInspector.ThrottledWidget.prototype |
214 } | 218 } |
OLD | NEW |