| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 this.type = type; | 645 this.type = type; |
| 646 } | 646 } |
| 647 | 647 |
| 648 /** @enum {string} */ | 648 /** @enum {string} */ |
| 649 WebInspector.CSSStyleDeclaration.Type = { | 649 WebInspector.CSSStyleDeclaration.Type = { |
| 650 Regular: "Regular", | 650 Regular: "Regular", |
| 651 Inline: "Inline", | 651 Inline: "Inline", |
| 652 Attributes: "Attributes" | 652 Attributes: "Attributes" |
| 653 } | 653 } |
| 654 | 654 |
| 655 /** | |
| 656 * @param {!WebInspector.CSSStyleModel} cssModel | |
| 657 * @return {!WebInspector.CSSStyleDeclaration} | |
| 658 */ | |
| 659 WebInspector.CSSStyleDeclaration.createDummyStyle = function(cssModel) | |
| 660 { | |
| 661 var dummyPayload = { | |
| 662 shorthandEntries: [], | |
| 663 cssProperties: [] | |
| 664 }; | |
| 665 return new WebInspector.CSSStyleDeclaration(cssModel, null, dummyPayload, We
bInspector.CSSStyleDeclaration.Type.Regular); | |
| 666 } | |
| 667 | |
| 668 WebInspector.CSSStyleDeclaration.prototype = { | 655 WebInspector.CSSStyleDeclaration.prototype = { |
| 669 /** | 656 /** |
| 670 * @param {!CSSAgent.CSSStyle} payload | 657 * @param {!CSSAgent.CSSStyle} payload |
| 671 */ | 658 */ |
| 672 _reinitialize: function(payload) | 659 _reinitialize: function(payload) |
| 673 { | 660 { |
| 674 this.styleSheetId = payload.styleSheetId; | 661 this.styleSheetId = payload.styleSheetId; |
| 675 this.range = payload.range ? WebInspector.TextRange.fromObject(payload.r
ange) : null; | 662 this.range = payload.range ? WebInspector.TextRange.fromObject(payload.r
ange) : null; |
| 676 | 663 |
| 677 var shorthandEntries = payload.shorthandEntries; | 664 var shorthandEntries = payload.shorthandEntries; |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 if (this.styleSheetId) { | 1018 if (this.styleSheetId) { |
| 1032 var styleSheetHeader = cssModel.styleSheetHeaderForId(this.styleSheetId)
; | 1019 var styleSheetHeader = cssModel.styleSheetHeaderForId(this.styleSheetId)
; |
| 1033 this.sourceURL = styleSheetHeader.sourceURL; | 1020 this.sourceURL = styleSheetHeader.sourceURL; |
| 1034 } | 1021 } |
| 1035 this.origin = payload.origin; | 1022 this.origin = payload.origin; |
| 1036 this.style = new WebInspector.CSSStyleDeclaration(this._cssModel, this, payl
oad.style, WebInspector.CSSStyleDeclaration.Type.Regular); | 1023 this.style = new WebInspector.CSSStyleDeclaration(this._cssModel, this, payl
oad.style, WebInspector.CSSStyleDeclaration.Type.Regular); |
| 1037 if (payload.media) | 1024 if (payload.media) |
| 1038 this.media = WebInspector.CSSMedia.parseMediaArrayPayload(cssModel, payl
oad.media); | 1025 this.media = WebInspector.CSSMedia.parseMediaArrayPayload(cssModel, payl
oad.media); |
| 1039 } | 1026 } |
| 1040 | 1027 |
| 1028 /** |
| 1029 * @param {!WebInspector.CSSStyleModel} cssModel |
| 1030 * @param {string} selectorText |
| 1031 * @return {!WebInspector.CSSRule} |
| 1032 */ |
| 1033 WebInspector.CSSRule.createDummyRule = function(cssModel, selectorText) |
| 1034 { |
| 1035 var dummyPayload = { |
| 1036 selectorList: { |
| 1037 selectors: [{ value: selectorText}], |
| 1038 }, |
| 1039 style: { |
| 1040 styleSheetId: "0", |
| 1041 range: new WebInspector.TextRange(0, 0, 0, 0), |
| 1042 shorthandEntries: [], |
| 1043 cssProperties: [] |
| 1044 } |
| 1045 }; |
| 1046 return new WebInspector.CSSRule(cssModel, /** @type {!CSSAgent.CSSRule} */(d
ummyPayload)); |
| 1047 } |
| 1048 |
| 1041 WebInspector.CSSRule.prototype = { | 1049 WebInspector.CSSRule.prototype = { |
| 1042 /** | 1050 /** |
| 1043 * @param {!DOMAgent.NodeId} nodeId | 1051 * @param {!DOMAgent.NodeId} nodeId |
| 1044 * @param {string} newSelector | 1052 * @param {string} newSelector |
| 1045 * @param {function(boolean)} userCallback | 1053 * @param {function(boolean)} userCallback |
| 1046 */ | 1054 */ |
| 1047 setSelectorText: function(nodeId, newSelector, userCallback) | 1055 setSelectorText: function(nodeId, newSelector, userCallback) |
| 1048 { | 1056 { |
| 1049 /** | 1057 /** |
| 1050 * @param {?Protocol.Error} error | 1058 * @param {?Protocol.Error} error |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 * @return {boolean} | 1239 * @return {boolean} |
| 1232 */ | 1240 */ |
| 1233 isRegular: function() | 1241 isRegular: function() |
| 1234 { | 1242 { |
| 1235 return this.origin === CSSAgent.StyleSheetOrigin.Regular; | 1243 return this.origin === CSSAgent.StyleSheetOrigin.Regular; |
| 1236 } | 1244 } |
| 1237 } | 1245 } |
| 1238 | 1246 |
| 1239 /** | 1247 /** |
| 1240 * @constructor | 1248 * @constructor |
| 1241 * @param {?WebInspector.CSSStyleDeclaration} ownerStyle | 1249 * @param {!WebInspector.CSSStyleDeclaration} ownerStyle |
| 1242 * @param {number} index | 1250 * @param {number} index |
| 1243 * @param {string} name | 1251 * @param {string} name |
| 1244 * @param {string} value | 1252 * @param {string} value |
| 1245 * @param {boolean} important | 1253 * @param {boolean} important |
| 1246 * @param {boolean} disabled | 1254 * @param {boolean} disabled |
| 1247 * @param {boolean} parsedOk | 1255 * @param {boolean} parsedOk |
| 1248 * @param {boolean} implicit | 1256 * @param {boolean} implicit |
| 1249 * @param {?string=} text | 1257 * @param {?string=} text |
| 1250 * @param {!CSSAgent.SourceRange=} range | 1258 * @param {!CSSAgent.SourceRange=} range |
| 1251 */ | 1259 */ |
| 1252 WebInspector.CSSProperty = function(ownerStyle, index, name, value, important, d
isabled, parsedOk, implicit, text, range) | 1260 WebInspector.CSSProperty = function(ownerStyle, index, name, value, important, d
isabled, parsedOk, implicit, text, range) |
| 1253 { | 1261 { |
| 1254 this.ownerStyle = ownerStyle; | 1262 this.ownerStyle = ownerStyle; |
| 1255 this.index = index; | 1263 this.index = index; |
| 1256 this.name = name; | 1264 this.name = name; |
| 1257 this.value = value; | 1265 this.value = value; |
| 1258 this.important = important; | 1266 this.important = important; |
| 1259 this.disabled = disabled; | 1267 this.disabled = disabled; |
| 1260 this.parsedOk = parsedOk; | 1268 this.parsedOk = parsedOk; |
| 1261 this.implicit = implicit; // A longhand, implicitly set by missing values of
shorthand. | 1269 this.implicit = implicit; // A longhand, implicitly set by missing values of
shorthand. |
| 1262 this.text = text; | 1270 this.text = text; |
| 1263 this.range = range ? WebInspector.TextRange.fromObject(range) : null; | 1271 this.range = range ? WebInspector.TextRange.fromObject(range) : null; |
| 1264 this._active = true; | 1272 this._active = true; |
| 1265 } | 1273 } |
| 1266 | 1274 |
| 1267 /** | 1275 /** |
| 1268 * @param {?WebInspector.CSSStyleDeclaration} ownerStyle | 1276 * @param {!WebInspector.CSSStyleDeclaration} ownerStyle |
| 1269 * @param {number} index | 1277 * @param {number} index |
| 1270 * @param {!CSSAgent.CSSProperty} payload | 1278 * @param {!CSSAgent.CSSProperty} payload |
| 1271 * @return {!WebInspector.CSSProperty} | 1279 * @return {!WebInspector.CSSProperty} |
| 1272 */ | 1280 */ |
| 1273 WebInspector.CSSProperty.parsePayload = function(ownerStyle, index, payload) | 1281 WebInspector.CSSProperty.parsePayload = function(ownerStyle, index, payload) |
| 1274 { | 1282 { |
| 1275 // The following default field values are used in the payload: | 1283 // The following default field values are used in the payload: |
| 1276 // important: false | 1284 // important: false |
| 1277 // parsedOk: true | 1285 // parsedOk: true |
| 1278 // implicit: false | 1286 // implicit: false |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2045 * @param {!Array.<!CSSAgent.PseudoElementMatches>=} pseudoPayload | 2053 * @param {!Array.<!CSSAgent.PseudoElementMatches>=} pseudoPayload |
| 2046 * @param {!Array.<!CSSAgent.InheritedStyleEntry>=} inheritedPayload | 2054 * @param {!Array.<!CSSAgent.InheritedStyleEntry>=} inheritedPayload |
| 2047 */ | 2055 */ |
| 2048 WebInspector.CSSStyleModel.MatchedStyleResult = function(cssModel, nodeId, inlin
ePayload, attributesPayload, matchedPayload, pseudoPayload, inheritedPayload) | 2056 WebInspector.CSSStyleModel.MatchedStyleResult = function(cssModel, nodeId, inlin
ePayload, attributesPayload, matchedPayload, pseudoPayload, inheritedPayload) |
| 2049 { | 2057 { |
| 2050 this._cssModel = cssModel; | 2058 this._cssModel = cssModel; |
| 2051 this._node = this._cssModel._domModel.nodeForId(nodeId); | 2059 this._node = this._cssModel._domModel.nodeForId(nodeId); |
| 2052 | 2060 |
| 2053 this._nodeStyles = []; | 2061 this._nodeStyles = []; |
| 2054 this._nodeForStyle = new Map(); | 2062 this._nodeForStyle = new Map(); |
| 2063 this._inheritedStyles = new Set(); |
| 2055 | 2064 |
| 2056 /** | 2065 /** |
| 2057 * @this {WebInspector.CSSStyleModel.MatchedStyleResult} | 2066 * @this {WebInspector.CSSStyleModel.MatchedStyleResult} |
| 2058 */ | 2067 */ |
| 2059 function addAttributesStyle() | 2068 function addAttributesStyle() |
| 2060 { | 2069 { |
| 2061 if (!attributesPayload) | 2070 if (!attributesPayload) |
| 2062 return; | 2071 return; |
| 2063 var style = new WebInspector.CSSStyleDeclaration(cssModel, null, attribu
tesPayload, WebInspector.CSSStyleDeclaration.Type.Attributes); | 2072 var style = new WebInspector.CSSStyleDeclaration(cssModel, null, attribu
tesPayload, WebInspector.CSSStyleDeclaration.Type.Attributes); |
| 2064 this._nodeForStyle.set(style, this._node); | 2073 this._nodeForStyle.set(style, this._node); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2091 | 2100 |
| 2092 // Walk the node structure and identify styles with inherited properties. | 2101 // Walk the node structure and identify styles with inherited properties. |
| 2093 var parentNode = this._node.parentNode; | 2102 var parentNode = this._node.parentNode; |
| 2094 for (var i = 0; inheritedPayload && i < inheritedPayload.length; ++i) { | 2103 for (var i = 0; inheritedPayload && i < inheritedPayload.length; ++i) { |
| 2095 var entryPayload = inheritedPayload[i]; | 2104 var entryPayload = inheritedPayload[i]; |
| 2096 var inheritedInlineStyle = entryPayload.inlineStyle ? new WebInspector.C
SSStyleDeclaration(cssModel, null, entryPayload.inlineStyle, WebInspector.CSSSty
leDeclaration.Type.Inline) : null; | 2105 var inheritedInlineStyle = entryPayload.inlineStyle ? new WebInspector.C
SSStyleDeclaration(cssModel, null, entryPayload.inlineStyle, WebInspector.CSSSty
leDeclaration.Type.Inline) : null; |
| 2097 var inheritedMatchedCSSRules = entryPayload.matchedCSSRules ? WebInspect
or.CSSStyleModel.parseRuleMatchArrayPayload(cssModel, entryPayload.matchedCSSRul
es) : null; | 2106 var inheritedMatchedCSSRules = entryPayload.matchedCSSRules ? WebInspect
or.CSSStyleModel.parseRuleMatchArrayPayload(cssModel, entryPayload.matchedCSSRul
es) : null; |
| 2098 if (inheritedInlineStyle && this._containsInherited(inheritedInlineStyle
)) { | 2107 if (inheritedInlineStyle && this._containsInherited(inheritedInlineStyle
)) { |
| 2099 this._nodeForStyle.set(inheritedInlineStyle, parentNode); | 2108 this._nodeForStyle.set(inheritedInlineStyle, parentNode); |
| 2100 this._nodeStyles.push(inheritedInlineStyle); | 2109 this._nodeStyles.push(inheritedInlineStyle); |
| 2110 this._inheritedStyles.add(inheritedInlineStyle); |
| 2101 } | 2111 } |
| 2102 | 2112 |
| 2103 for (var j = inheritedMatchedCSSRules.length - 1; j >= 0; --j) { | 2113 for (var j = inheritedMatchedCSSRules.length - 1; j >= 0; --j) { |
| 2104 var inheritedRule = inheritedMatchedCSSRules[j]; | 2114 var inheritedRule = inheritedMatchedCSSRules[j]; |
| 2105 if (!this._containsInherited(inheritedRule.style)) | 2115 if (!this._containsInherited(inheritedRule.style)) |
| 2106 continue; | 2116 continue; |
| 2107 this._nodeForStyle.set(inheritedRule.style, parentNode); | 2117 this._nodeForStyle.set(inheritedRule.style, parentNode); |
| 2108 this._nodeStyles.push(inheritedRule.style); | 2118 this._nodeStyles.push(inheritedRule.style); |
| 2119 this._inheritedStyles.add(inheritedRule.style); |
| 2109 } | 2120 } |
| 2110 parentNode = parentNode.parentNode; | 2121 parentNode = parentNode.parentNode; |
| 2111 } | 2122 } |
| 2112 | 2123 |
| 2113 // Set up pseudo styles map. | 2124 // Set up pseudo styles map. |
| 2114 this._pseudoStyles = new Map(); | 2125 this._pseudoStyles = new Map(); |
| 2115 if (pseudoPayload) { | 2126 if (pseudoPayload) { |
| 2116 for (var i = 0; i < pseudoPayload.length; ++i) { | 2127 for (var i = 0; i < pseudoPayload.length; ++i) { |
| 2117 var entryPayload = pseudoPayload[i]; | 2128 var entryPayload = pseudoPayload[i]; |
| 2118 var pseudoElement = this._node.pseudoElements().get(entryPayload.pse
udoType); | 2129 var pseudoElement = this._node.pseudoElements().get(entryPayload.pse
udoType); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2169 { | 2180 { |
| 2170 return this._nodeForStyle.get(style) || null; | 2181 return this._nodeForStyle.get(style) || null; |
| 2171 }, | 2182 }, |
| 2172 | 2183 |
| 2173 /** | 2184 /** |
| 2174 * @param {!WebInspector.CSSStyleDeclaration} style | 2185 * @param {!WebInspector.CSSStyleDeclaration} style |
| 2175 * @return {boolean} | 2186 * @return {boolean} |
| 2176 */ | 2187 */ |
| 2177 isInherited: function(style) | 2188 isInherited: function(style) |
| 2178 { | 2189 { |
| 2179 return this.nodeForStyle(style) !== this._node; | 2190 return this._inheritedStyles.has(style); |
| 2180 } | 2191 } |
| 2181 } | 2192 } |
| 2182 | 2193 |
| 2183 /** | 2194 /** |
| 2184 * @constructor | 2195 * @constructor |
| 2185 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle | 2196 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle |
| 2186 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle | 2197 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle |
| 2187 */ | 2198 */ |
| 2188 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS
tyle) | 2199 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS
tyle) |
| 2189 { | 2200 { |
| 2190 this.inlineStyle = inlineStyle; | 2201 this.inlineStyle = inlineStyle; |
| 2191 this.attributesStyle = attributesStyle; | 2202 this.attributesStyle = attributesStyle; |
| 2192 } | 2203 } |
| 2193 | 2204 |
| OLD | NEW |