| 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 314 |
| 315 /** | 315 /** |
| 316 * @override | 316 * @override |
| 317 * @return {!Promise.<?>} | 317 * @return {!Promise.<?>} |
| 318 */ | 318 */ |
| 319 doUpdate: function() | 319 doUpdate: function() |
| 320 { | 320 { |
| 321 this._discardElementUnderMouse(); | 321 this._discardElementUnderMouse(); |
| 322 | 322 |
| 323 return this.fetchMatchedCascade() | 323 return this.fetchMatchedCascade() |
| 324 .then(this._innerRebuildUpdate.bind(this)) | 324 .then(this._innerRebuildUpdate.bind(this)); |
| 325 }, | 325 }, |
| 326 | 326 |
| 327 _resetCache: function() | 327 _resetCache: function() |
| 328 { | 328 { |
| 329 delete this._matchedCascadePromise; | 329 delete this._matchedCascadePromise; |
| 330 }, | 330 }, |
| 331 | 331 |
| 332 /** | 332 /** |
| 333 * @return {!Promise.<?{matched: !WebInspector.SectionCascade, pseudo: !Map.
<number, !WebInspector.SectionCascade>}>} | 333 * @return {!Promise.<?{matched: !WebInspector.SectionCascade, pseudo: !Map.
<number, !WebInspector.SectionCascade>}>} |
| 334 */ | 334 */ |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 /** | 619 /** |
| 620 * @param {!WebInspector.CSSStyleDeclaration} style | 620 * @param {!WebInspector.CSSStyleDeclaration} style |
| 621 * @return {boolean} | 621 * @return {boolean} |
| 622 */ | 622 */ |
| 623 _containsInherited: function(style) | 623 _containsInherited: function(style) |
| 624 { | 624 { |
| 625 var properties = style.allProperties; | 625 var properties = style.allProperties; |
| 626 for (var i = 0; i < properties.length; ++i) { | 626 for (var i = 0; i < properties.length; ++i) { |
| 627 var property = properties[i]; | 627 var property = properties[i]; |
| 628 // Does this style contain non-overridden inherited property? | 628 // Does this style contain non-overridden inherited property? |
| 629 if (property.isLive && WebInspector.CSSMetadata.isPropertyInherited(
property.name)) | 629 if (property.activeInStyle() && WebInspector.CSSMetadata.isPropertyI
nherited(property.name)) |
| 630 return true; | 630 return true; |
| 631 } | 631 } |
| 632 return false; | 632 return false; |
| 633 }, | 633 }, |
| 634 | 634 |
| 635 _createNewRuleInViaInspectorStyleSheet: function() | 635 _createNewRuleInViaInspectorStyleSheet: function() |
| 636 { | 636 { |
| 637 var cssModel = this.cssModel(); | 637 var cssModel = this.cssModel(); |
| 638 var node = this.node(); | 638 var node = this.node(); |
| 639 if (!cssModel || !node) | 639 if (!cssModel || !node) |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 } | 1285 } |
| 1286 }, | 1286 }, |
| 1287 | 1287 |
| 1288 _afterUpdateFinishedForTest: function() | 1288 _afterUpdateFinishedForTest: function() |
| 1289 { | 1289 { |
| 1290 }, | 1290 }, |
| 1291 | 1291 |
| 1292 onpopulate: function() | 1292 onpopulate: function() |
| 1293 { | 1293 { |
| 1294 var style = this.styleRule.style(); | 1294 var style = this.styleRule.style(); |
| 1295 var allProperties = style.allProperties; | 1295 for (var property of style.leadingProperties()) { |
| 1296 | |
| 1297 var styleHasEditableSource = this.editable && !!style.range; | |
| 1298 if (styleHasEditableSource) { | |
| 1299 for (var i = 0; i < allProperties.length; ++i) { | |
| 1300 var property = allProperties[i]; | |
| 1301 if (property.styleBased) | |
| 1302 continue; | |
| 1303 | |
| 1304 var isShorthand = !!WebInspector.CSSMetadata.cssPropertiesMetain
fo.longhands(property.name); | |
| 1305 var inherited = this.isPropertyInherited(property.name); | |
| 1306 var overloaded = property.inactive || this.styleRule.isPropertyO
verloaded(property.name); | |
| 1307 var item = new WebInspector.StylePropertyTreeElement(this._paren
tPane, this.styleRule, property, isShorthand, inherited, overloaded); | |
| 1308 this.propertiesTreeOutline.appendChild(item); | |
| 1309 } | |
| 1310 return; | |
| 1311 } | |
| 1312 | |
| 1313 var generatedShorthands = {}; | |
| 1314 // For style-based properties, generate shorthands with values when poss
ible. | |
| 1315 for (var i = 0; i < allProperties.length; ++i) { | |
| 1316 var property = allProperties[i]; | |
| 1317 var isShorthand = !!WebInspector.CSSMetadata.cssPropertiesMetainfo.l
onghands(property.name); | 1296 var isShorthand = !!WebInspector.CSSMetadata.cssPropertiesMetainfo.l
onghands(property.name); |
| 1318 | |
| 1319 // For style-based properties, try generating shorthands. | |
| 1320 var shorthands = isShorthand ? null : WebInspector.CSSMetadata.cssPr
opertiesMetainfo.shorthands(property.name); | |
| 1321 var shorthandPropertyAvailable = false; | |
| 1322 for (var j = 0; shorthands && !shorthandPropertyAvailable && j < sho
rthands.length; ++j) { | |
| 1323 var shorthand = shorthands[j]; | |
| 1324 if (shorthand in generatedShorthands) { | |
| 1325 shorthandPropertyAvailable = true; | |
| 1326 continue; // There already is a shorthand this longhands fa
lls under. | |
| 1327 } | |
| 1328 if (style.getLiveProperty(shorthand)) { | |
| 1329 shorthandPropertyAvailable = true; | |
| 1330 continue; // There is an explict shorthand property this lo
nghands falls under. | |
| 1331 } | |
| 1332 if (!style.shorthandValue(shorthand)) { | |
| 1333 shorthandPropertyAvailable = false; | |
| 1334 continue; // Never generate synthetic shorthands when no va
lue is available. | |
| 1335 } | |
| 1336 | |
| 1337 // Generate synthetic shorthand we have a value for. | |
| 1338 var shorthandProperty = new WebInspector.CSSProperty(style, styl
e.allProperties.length, shorthand, style.shorthandValue(shorthand), style.shorth
andIsImportant(shorthand), false, true, true); | |
| 1339 var overloaded = property.inactive || this.styleRule.isPropertyO
verloaded(property.name, true); | |
| 1340 var item = new WebInspector.StylePropertyTreeElement(this._paren
tPane, this.styleRule, shorthandProperty, /* isShorthand */ true, /* inherited
*/ false, overloaded); | |
| 1341 this.propertiesTreeOutline.appendChild(item); | |
| 1342 generatedShorthands[shorthand] = shorthandProperty; | |
| 1343 shorthandPropertyAvailable = true; | |
| 1344 } | |
| 1345 if (shorthandPropertyAvailable) | |
| 1346 continue; // Shorthand for the property found. | |
| 1347 | |
| 1348 var inherited = this.isPropertyInherited(property.name); | 1297 var inherited = this.isPropertyInherited(property.name); |
| 1349 var overloaded = property.inactive || this.styleRule.isPropertyOverl
oaded(property.name, isShorthand); | 1298 var overloaded = this.styleRule.isPropertyOverloaded(property.name,
isShorthand); |
| 1350 var item = new WebInspector.StylePropertyTreeElement(this._parentPan
e, this.styleRule, property, isShorthand, inherited, overloaded); | 1299 var item = new WebInspector.StylePropertyTreeElement(this._parentPan
e, this.styleRule, property, isShorthand, inherited, overloaded); |
| 1351 this.propertiesTreeOutline.appendChild(item); | 1300 this.propertiesTreeOutline.appendChild(item); |
| 1352 } | 1301 } |
| 1353 }, | 1302 }, |
| 1354 | 1303 |
| 1355 /** | 1304 /** |
| 1356 * @return {boolean} | 1305 * @return {boolean} |
| 1357 */ | 1306 */ |
| 1358 _updateFilter: function() | 1307 _updateFilter: function() |
| 1359 { | 1308 { |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2226 var name = longhandProperties[i].name; | 2175 var name = longhandProperties[i].name; |
| 2227 var inherited = false; | 2176 var inherited = false; |
| 2228 var overloaded = false; | 2177 var overloaded = false; |
| 2229 | 2178 |
| 2230 var section = this.section(); | 2179 var section = this.section(); |
| 2231 if (section) { | 2180 if (section) { |
| 2232 inherited = section.isPropertyInherited(name); | 2181 inherited = section.isPropertyInherited(name); |
| 2233 overloaded = section.styleRule.isPropertyOverloaded(name); | 2182 overloaded = section.styleRule.isPropertyOverloaded(name); |
| 2234 } | 2183 } |
| 2235 | 2184 |
| 2236 var liveProperty = this.style().getLiveProperty(name); | 2185 var item = new WebInspector.StylePropertyTreeElement(this._parentPan
e, this._styleRule, longhandProperties[i], false, inherited, overloaded); |
| 2237 if (!liveProperty) | |
| 2238 continue; | |
| 2239 | |
| 2240 var item = new WebInspector.StylePropertyTreeElement(this._parentPan
e, this._styleRule, liveProperty, false, inherited, overloaded); | |
| 2241 this.appendChild(item); | 2186 this.appendChild(item); |
| 2242 } | 2187 } |
| 2243 }, | 2188 }, |
| 2244 | 2189 |
| 2245 /** | 2190 /** |
| 2246 * @override | 2191 * @override |
| 2247 */ | 2192 */ |
| 2248 onattach: function() | 2193 onattach: function() |
| 2249 { | 2194 { |
| 2250 this.updateTitle(); | 2195 this.updateTitle(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2304 if (this.property.disabled) | 2249 if (this.property.disabled) |
| 2305 this.listItemElement.createChild("span", "styles-clipboard-only").cr
eateTextChild(" */"); | 2250 this.listItemElement.createChild("span", "styles-clipboard-only").cr
eateTextChild(" */"); |
| 2306 | 2251 |
| 2307 if (!this.property.parsedOk) { | 2252 if (!this.property.parsedOk) { |
| 2308 // Avoid having longhands under an invalid shorthand. | 2253 // Avoid having longhands under an invalid shorthand. |
| 2309 this.listItemElement.classList.add("not-parsed-ok"); | 2254 this.listItemElement.classList.add("not-parsed-ok"); |
| 2310 | 2255 |
| 2311 // Add a separate exclamation mark IMG element with a tooltip. | 2256 // Add a separate exclamation mark IMG element with a tooltip. |
| 2312 this.listItemElement.insertBefore(WebInspector.StylesSidebarPane.cre
ateExclamationMark(this.property), this.listItemElement.firstChild); | 2257 this.listItemElement.insertBefore(WebInspector.StylesSidebarPane.cre
ateExclamationMark(this.property), this.listItemElement.firstChild); |
| 2313 } | 2258 } |
| 2314 if (this.property.inactive) | 2259 if (!this.property.activeInStyle()) |
| 2315 this.listItemElement.classList.add("inactive"); | 2260 this.listItemElement.classList.add("inactive"); |
| 2316 this._updateFilter(); | 2261 this._updateFilter(); |
| 2317 | 2262 |
| 2318 if (this.property.parsedOk && this.section() && this.parent.root) { | 2263 if (this.property.parsedOk && this.section() && this.parent.root) { |
| 2319 var enabledCheckboxElement = createElement("input"); | 2264 var enabledCheckboxElement = createElement("input"); |
| 2320 enabledCheckboxElement.className = "enabled-button"; | 2265 enabledCheckboxElement.className = "enabled-button"; |
| 2321 enabledCheckboxElement.type = "checkbox"; | 2266 enabledCheckboxElement.type = "checkbox"; |
| 2322 enabledCheckboxElement.checked = !this.property.disabled; | 2267 enabledCheckboxElement.checked = !this.property.disabled; |
| 2323 enabledCheckboxElement.addEventListener("click", this._toggleEnabled
.bind(this), false); | 2268 enabledCheckboxElement.addEventListener("click", this._toggleEnabled
.bind(this), false); |
| 2324 this.listItemElement.insertBefore(enabledCheckboxElement, this.listI
temElement.firstChild); | 2269 this.listItemElement.insertBefore(enabledCheckboxElement, this.listI
temElement.firstChild); |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3250 | 3195 |
| 3251 /** | 3196 /** |
| 3252 * @override | 3197 * @override |
| 3253 * @return {?WebInspector.ToolbarItem} | 3198 * @return {?WebInspector.ToolbarItem} |
| 3254 */ | 3199 */ |
| 3255 item: function() | 3200 item: function() |
| 3256 { | 3201 { |
| 3257 return this._button; | 3202 return this._button; |
| 3258 } | 3203 } |
| 3259 } | 3204 } |
| OLD | NEW |