Chromium Code Reviews| 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 27 matching lines...) Expand all Loading... | |
| 38 WebInspector.SDKModel.call(this, WebInspector.CSSStyleModel, target); | 38 WebInspector.SDKModel.call(this, WebInspector.CSSStyleModel, target); |
| 39 this._domModel = WebInspector.DOMModel.fromTarget(target); | 39 this._domModel = WebInspector.DOMModel.fromTarget(target); |
| 40 this._agent = target.cssAgent(); | 40 this._agent = target.cssAgent(); |
| 41 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.SuspendStateChanged, this._suspendStateChanged, this); | 41 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.SuspendStateChanged, this._suspendStateChanged, this); |
| 42 this._pendingCommandsMajorState = []; | 42 this._pendingCommandsMajorState = []; |
| 43 this._styleLoader = new WebInspector.CSSStyleModel.ComputedStyleLoader(this) ; | 43 this._styleLoader = new WebInspector.CSSStyleModel.ComputedStyleLoader(this) ; |
| 44 this._domModel.addEventListener(WebInspector.DOMModel.Events.UndoRedoRequest ed, this._undoRedoRequested, this); | 44 this._domModel.addEventListener(WebInspector.DOMModel.Events.UndoRedoRequest ed, this._undoRedoRequested, this); |
| 45 this._domModel.addEventListener(WebInspector.DOMModel.Events.UndoRedoComplet ed, this._undoRedoCompleted, this); | 45 this._domModel.addEventListener(WebInspector.DOMModel.Events.UndoRedoComplet ed, this._undoRedoCompleted, this); |
| 46 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.MainFrameNavigated, this._mainFrameNavigated, this); | 46 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.MainFrameNavigated, this._mainFrameNavigated, this); |
| 47 target.registerCSSDispatcher(new WebInspector.CSSDispatcher(this)); | 47 target.registerCSSDispatcher(new WebInspector.CSSDispatcher(this)); |
| 48 this._agent.enable(this._wasEnabled.bind(this)); | 48 this._agent.enable().spread(this._wasEnabled.bind(this)); |
|
pfeldman
2015/06/24 16:38:12
Why spread?
lushnikov
2015/06/24 16:45:25
Oops. Accidental.
| |
| 49 /** @type {!Map.<string, !WebInspector.CSSStyleSheetHeader>} */ | 49 /** @type {!Map.<string, !WebInspector.CSSStyleSheetHeader>} */ |
| 50 this._styleSheetIdToHeader = new Map(); | 50 this._styleSheetIdToHeader = new Map(); |
| 51 /** @type {!Map.<string, !Object.<!PageAgent.FrameId, !Array.<!CSSAgent.Styl eSheetId>>>} */ | 51 /** @type {!Map.<string, !Object.<!PageAgent.FrameId, !Array.<!CSSAgent.Styl eSheetId>>>} */ |
| 52 this._styleSheetIdsForURL = new Map(); | 52 this._styleSheetIdsForURL = new Map(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 WebInspector.CSSStyleModel.PseudoStatePropertyName = "pseudoState"; | 55 WebInspector.CSSStyleModel.PseudoStatePropertyName = "pseudoState"; |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * @param {!WebInspector.CSSStyleModel} cssModel | 58 * @param {!WebInspector.CSSStyleModel} cssModel |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 83 | 83 |
| 84 WebInspector.CSSStyleModel.prototype = { | 84 WebInspector.CSSStyleModel.prototype = { |
| 85 /** | 85 /** |
| 86 * @param {function(!Array.<!WebInspector.CSSMedia>)} userCallback | 86 * @param {function(!Array.<!WebInspector.CSSMedia>)} userCallback |
| 87 */ | 87 */ |
| 88 getMediaQueries: function(userCallback) | 88 getMediaQueries: function(userCallback) |
| 89 { | 89 { |
| 90 /** | 90 /** |
| 91 * @param {?Protocol.Error} error | 91 * @param {?Protocol.Error} error |
| 92 * @param {?Array.<!CSSAgent.CSSMedia>} payload | 92 * @param {?Array.<!CSSAgent.CSSMedia>} payload |
| 93 * @return {!Array.<!WebInspector.CSSMedia>} | |
| 93 * @this {!WebInspector.CSSStyleModel} | 94 * @this {!WebInspector.CSSStyleModel} |
| 94 */ | 95 */ |
| 95 function callback(error, payload) | 96 function parsePayload(error, payload) |
| 96 { | 97 { |
| 97 var models = []; | 98 return !error && payload ? WebInspector.CSSMedia.parseMediaArrayPayl oad(this, payload) : []; |
| 98 if (!error && payload) | |
| 99 models = WebInspector.CSSMedia.parseMediaArrayPayload(this, payl oad); | |
| 100 userCallback(models); | |
| 101 } | 99 } |
| 102 this._agent.getMediaQueries(callback.bind(this)); | 100 |
| 101 this._agent.getMediaQueries(parsePayload.bind(this)) | |
| 102 .catchException([]) | |
|
pfeldman
2015/06/24 16:38:12
1. It is not checking whether [] matcher the signa
lushnikov
2015/06/24 16:45:25
Thats minor, but ill fix it
| |
| 103 .then(userCallback); | |
|
pfeldman
2015/06/24 16:38:12
So any error in the user callback is ignored? What
lushnikov
2015/06/24 16:45:25
It gets reported in the devtools console.
| |
| 103 }, | 104 }, |
| 104 | 105 |
| 105 /** | 106 /** |
| 106 * @return {boolean} | 107 * @return {boolean} |
| 107 */ | 108 */ |
| 108 isEnabled: function() | 109 isEnabled: function() |
| 109 { | 110 { |
| 110 return this._isEnabled; | 111 return this._isEnabled; |
| 111 }, | 112 }, |
| 112 | 113 |
| 113 _wasEnabled: function() | 114 /** |
| 115 * @param {?Protocol.Error} error | |
| 116 */ | |
| 117 _wasEnabled: function(error) | |
| 114 { | 118 { |
| 119 if (error) { | |
| 120 console.error("Failed to enabled CSS agent: " + error); | |
| 121 return; | |
| 122 } | |
| 115 this._isEnabled = true; | 123 this._isEnabled = true; |
| 116 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.ModelWas Enabled); | 124 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.ModelWas Enabled); |
| 117 }, | 125 }, |
| 118 | 126 |
| 119 /** | 127 /** |
| 120 * @param {!DOMAgent.NodeId} nodeId | 128 * @param {!DOMAgent.NodeId} nodeId |
| 121 * @param {boolean} excludePseudo | 129 * @param {boolean} excludePseudo |
| 122 * @param {boolean} excludeInherited | 130 * @param {boolean} excludeInherited |
| 123 * @param {function(?*)} userCallback | 131 * @param {function(?*)} userCallback |
| 124 */ | 132 */ |
| 125 getMatchedStylesAsync: function(nodeId, excludePseudo, excludeInherited, use rCallback) | 133 getMatchedStylesAsync: function(nodeId, excludePseudo, excludeInherited, use rCallback) |
| 126 { | 134 { |
| 127 /** | 135 /** |
| 128 * @param {function(?*)} userCallback | |
| 129 * @param {?Protocol.Error} error | 136 * @param {?Protocol.Error} error |
| 130 * @param {!Array.<!CSSAgent.RuleMatch>=} matchedPayload | 137 * @param {!Array.<!CSSAgent.RuleMatch>=} matchedPayload |
| 131 * @param {!Array.<!CSSAgent.PseudoIdMatches>=} pseudoPayload | 138 * @param {!Array.<!CSSAgent.PseudoIdMatches>=} pseudoPayload |
| 132 * @param {!Array.<!CSSAgent.InheritedStyleEntry>=} inheritedPayload | 139 * @param {!Array.<!CSSAgent.InheritedStyleEntry>=} inheritedPayload |
| 140 * @return {?*} | |
| 133 * @this {WebInspector.CSSStyleModel} | 141 * @this {WebInspector.CSSStyleModel} |
| 134 */ | 142 */ |
| 135 function callback(userCallback, error, matchedPayload, pseudoPayload, in heritedPayload) | 143 function parsePayload(error, matchedPayload, pseudoPayload, inheritedPay load) |
| 136 { | 144 { |
| 137 if (error) { | 145 if (error) |
| 138 if (userCallback) | 146 return null; |
| 139 userCallback(null); | 147 var result = {}; |
| 140 return; | 148 result.matchedCSSRules = WebInspector.CSSStyleModel.parseRuleMatchAr rayPayload(this, matchedPayload); |
| 149 | |
| 150 result.pseudoElements = []; | |
| 151 if (pseudoPayload) { | |
| 152 for (var i = 0; i < pseudoPayload.length; ++i) { | |
| 153 var entryPayload = pseudoPayload[i]; | |
| 154 result.pseudoElements.push({ pseudoId: entryPayload.pseudoId , rules: WebInspector.CSSStyleModel.parseRuleMatchArrayPayload(this, entryPayloa d.matches) }); | |
| 155 } | |
| 141 } | 156 } |
| 142 | 157 |
| 143 var result = {}; | 158 result.inherited = []; |
| 144 // Due to CSSOM inconsistencies, backend might send us illegal data. @see crbug.com/178410 | 159 if (inheritedPayload) { |
| 145 try { | 160 for (var i = 0; i < inheritedPayload.length; ++i) { |
| 146 result.matchedCSSRules = WebInspector.CSSStyleModel.parseRuleMat chArrayPayload(this, matchedPayload); | 161 var entryPayload = inheritedPayload[i]; |
| 147 | 162 var entry = {}; |
| 148 result.pseudoElements = []; | 163 if (entryPayload.inlineStyle) |
| 149 if (pseudoPayload) { | 164 entry.inlineStyle = WebInspector.CSSStyleDeclaration.par sePayload(this, entryPayload.inlineStyle); |
| 150 for (var i = 0; i < pseudoPayload.length; ++i) { | 165 if (entryPayload.matchedCSSRules) |
| 151 var entryPayload = pseudoPayload[i]; | 166 entry.matchedCSSRules = WebInspector.CSSStyleModel.parse RuleMatchArrayPayload(this, entryPayload.matchedCSSRules); |
| 152 result.pseudoElements.push({ pseudoId: entryPayload.pseu doId, rules: WebInspector.CSSStyleModel.parseRuleMatchArrayPayload(this, entryPa yload.matches) }); | 167 result.inherited.push(entry); |
| 153 } | |
| 154 } | 168 } |
| 155 | |
| 156 result.inherited = []; | |
| 157 if (inheritedPayload) { | |
| 158 for (var i = 0; i < inheritedPayload.length; ++i) { | |
| 159 var entryPayload = inheritedPayload[i]; | |
| 160 var entry = {}; | |
| 161 if (entryPayload.inlineStyle) | |
| 162 entry.inlineStyle = WebInspector.CSSStyleDeclaration .parsePayload(this, entryPayload.inlineStyle); | |
| 163 if (entryPayload.matchedCSSRules) | |
| 164 entry.matchedCSSRules = WebInspector.CSSStyleModel.p arseRuleMatchArrayPayload(this, entryPayload.matchedCSSRules); | |
| 165 result.inherited.push(entry); | |
| 166 } | |
| 167 } | |
| 168 } catch (e) { | |
| 169 console.error(e); | |
| 170 result = null; | |
| 171 } | 169 } |
| 172 | 170 return result; |
| 173 if (userCallback) | |
| 174 userCallback(result); | |
| 175 } | 171 } |
| 176 | 172 |
| 177 this._agent.getMatchedStylesForNode(nodeId, excludePseudo, excludeInheri ted, callback.bind(this, userCallback)); | 173 this._agent.getMatchedStylesForNode(nodeId, excludePseudo, excludeInheri ted, parsePayload.bind(this)) |
| 174 .catchException(null) | |
| 175 .then(userCallback); | |
| 178 }, | 176 }, |
| 179 | 177 |
| 180 /** | 178 /** |
| 181 * @param {!DOMAgent.NodeId} nodeId | 179 * @param {!DOMAgent.NodeId} nodeId |
| 182 * @param {function(?WebInspector.CSSStyleDeclaration)} userCallback | 180 * @param {function(?WebInspector.CSSStyleDeclaration)} userCallback |
| 183 */ | 181 */ |
| 184 getComputedStyleAsync: function(nodeId, userCallback) | 182 getComputedStyleAsync: function(nodeId, userCallback) |
| 185 { | 183 { |
| 186 this._styleLoader.getComputedStyle(nodeId, userCallback); | 184 this._styleLoader.getComputedStyle(nodeId, userCallback); |
| 187 }, | 185 }, |
| 188 | 186 |
| 189 /** | 187 /** |
| 190 * @param {number} nodeId | 188 * @param {number} nodeId |
| 191 * @param {function(?string, ?Array.<!CSSAgent.PlatformFontUsage>)} callback | 189 * @param {function(?string, ?Array.<!CSSAgent.PlatformFontUsage>)} callback |
| 192 */ | 190 */ |
| 193 getPlatformFontsForNode: function(nodeId, callback) | 191 getPlatformFontsForNode: function(nodeId, callback) |
| 194 { | 192 { |
| 193 /** | |
| 194 * @param {?Protocol.Error} error | |
| 195 * @param {?string} cssFamilyName | |
| 196 * @param {?Array.<!CSSAgent.PlatformFontUsage>} fonts | |
| 197 * @return {!Array.<?>} | |
| 198 */ | |
| 195 function platformFontsCallback(error, cssFamilyName, fonts) | 199 function platformFontsCallback(error, cssFamilyName, fonts) |
| 196 { | 200 { |
| 197 if (error) | 201 return error ? [null, null] : [cssFamilyName, fonts]; |
| 198 callback(null, null); | |
| 199 else | |
| 200 callback(cssFamilyName, fonts); | |
| 201 } | 202 } |
| 202 this._agent.getPlatformFontsForNode(nodeId, platformFontsCallback); | 203 this._agent.getPlatformFontsForNode(nodeId, platformFontsCallback) |
| 204 .catchException([null, null]) | |
| 205 .spread(callback) | |
| 203 }, | 206 }, |
| 204 | 207 |
| 205 /** | 208 /** |
| 206 * @return {!Array.<!WebInspector.CSSStyleSheetHeader>} | 209 * @return {!Array.<!WebInspector.CSSStyleSheetHeader>} |
| 207 */ | 210 */ |
| 208 allStyleSheets: function() | 211 allStyleSheets: function() |
| 209 { | 212 { |
| 210 var values = this._styleSheetIdToHeader.valuesArray(); | 213 var values = this._styleSheetIdToHeader.valuesArray(); |
| 211 /** | 214 /** |
| 212 * @param {!WebInspector.CSSStyleSheetHeader} a | 215 * @param {!WebInspector.CSSStyleSheetHeader} a |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 226 return values; | 229 return values; |
| 227 }, | 230 }, |
| 228 | 231 |
| 229 /** | 232 /** |
| 230 * @param {!DOMAgent.NodeId} nodeId | 233 * @param {!DOMAgent.NodeId} nodeId |
| 231 * @param {function(?WebInspector.CSSStyleDeclaration, ?WebInspector.CSSStyl eDeclaration)} userCallback | 234 * @param {function(?WebInspector.CSSStyleDeclaration, ?WebInspector.CSSStyl eDeclaration)} userCallback |
| 232 */ | 235 */ |
| 233 getInlineStylesAsync: function(nodeId, userCallback) | 236 getInlineStylesAsync: function(nodeId, userCallback) |
| 234 { | 237 { |
| 235 /** | 238 /** |
| 236 * @param {function(?WebInspector.CSSStyleDeclaration, ?WebInspector.CSS StyleDeclaration)} userCallback | |
| 237 * @param {?Protocol.Error} error | 239 * @param {?Protocol.Error} error |
| 238 * @param {?CSSAgent.CSSStyle=} inlinePayload | 240 * @param {?CSSAgent.CSSStyle=} inlinePayload |
| 239 * @param {?CSSAgent.CSSStyle=} attributesStylePayload | 241 * @param {?CSSAgent.CSSStyle=} attributesStylePayload |
| 242 * @return {!Array.<?CSSStyleDeclaration>} | |
| 240 * @this {WebInspector.CSSStyleModel} | 243 * @this {WebInspector.CSSStyleModel} |
| 241 */ | 244 */ |
| 242 function callback(userCallback, error, inlinePayload, attributesStylePay load) | 245 function parsePayload(error, inlinePayload, attributesStylePayload) |
| 243 { | 246 { |
| 244 if (error || !inlinePayload) | 247 var result = [null, null]; |
| 245 userCallback(null, null); | 248 if (error) |
| 246 else | 249 return result; |
| 247 userCallback(WebInspector.CSSStyleDeclaration.parsePayload(this, inlinePayload), attributesStylePayload ? WebInspector.CSSStyleDeclaration.parse Payload(this, attributesStylePayload) : null); | 250 if (inlinePayload) |
| 251 result[0] = WebInspector.CSSStyleDeclaration.parsePayload(this, inlinePayload); | |
| 252 if (attributesStylePayload) | |
| 253 result[1] = WebInspector.CSSStyleDeclaration.parsePayload(this, attributesStylePayload); | |
| 254 return result; | |
| 248 } | 255 } |
| 249 | 256 |
| 250 this._agent.getInlineStylesForNode(nodeId, callback.bind(this, userCallb ack)); | 257 this._agent.getInlineStylesForNode(nodeId, parsePayload.bind(this)) |
| 258 .catchException([null, null]) | |
| 259 .spread(userCallback); | |
| 251 }, | 260 }, |
| 252 | 261 |
| 253 /** | 262 /** |
| 254 * @param {!WebInspector.DOMNode} node | 263 * @param {!WebInspector.DOMNode} node |
| 255 * @param {string} pseudoClass | 264 * @param {string} pseudoClass |
| 256 * @param {boolean} enable | 265 * @param {boolean} enable |
| 257 * @return {boolean} | 266 * @return {boolean} |
| 258 */ | 267 */ |
| 259 forcePseudoState: function(node, pseudoClass, enable) | 268 forcePseudoState: function(node, pseudoClass, enable) |
| 260 { | 269 { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 274 | 283 |
| 275 this._agent.forcePseudoState(node.id, pseudoClasses); | 284 this._agent.forcePseudoState(node.id, pseudoClasses); |
| 276 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.PseudoSt ateForced, { node: node, pseudoClass: pseudoClass, enable: enable }); | 285 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.PseudoSt ateForced, { node: node, pseudoClass: pseudoClass, enable: enable }); |
| 277 return true; | 286 return true; |
| 278 }, | 287 }, |
| 279 | 288 |
| 280 /** | 289 /** |
| 281 * @param {!CSSAgent.CSSRule} rule | 290 * @param {!CSSAgent.CSSRule} rule |
| 282 * @param {!DOMAgent.NodeId} nodeId | 291 * @param {!DOMAgent.NodeId} nodeId |
| 283 * @param {string} newSelector | 292 * @param {string} newSelector |
| 284 * @param {function(!WebInspector.CSSRule)} successCallback | 293 * @param {function(?WebInspector.CSSRule)} userCallback |
| 285 * @param {function()} failureCallback | |
| 286 */ | 294 */ |
| 287 setRuleSelector: function(rule, nodeId, newSelector, successCallback, failur eCallback) | 295 setRuleSelector: function(rule, nodeId, newSelector, userCallback) |
| 288 { | 296 { |
| 289 /** | 297 /** |
| 290 * @param {!DOMAgent.NodeId} nodeId | |
| 291 * @param {function(!WebInspector.CSSRule)} successCallback | |
| 292 * @param {function()} failureCallback | |
| 293 * @param {?Protocol.Error} error | 298 * @param {?Protocol.Error} error |
| 294 * @param {string} newSelector | 299 * @param {?CSSAgent.CSSRule} rulePayload |
| 295 * @param {!CSSAgent.CSSRule} rulePayload | 300 * @return {?CSSAgent.CSSRule} |
| 296 * @this {WebInspector.CSSStyleModel} | 301 * @this {WebInspector.CSSStyleModel} |
| 297 */ | 302 */ |
| 298 function callback(nodeId, successCallback, failureCallback, newSelector, error, rulePayload) | 303 function callback(error, rulePayload) |
| 299 { | 304 { |
| 300 this._pendingCommandsMajorState.pop(); | 305 this._pendingCommandsMajorState.pop(); |
| 301 if (error) { | 306 if (error || !rulePayload) |
| 302 failureCallback(); | 307 return null; |
| 303 return; | |
| 304 } | |
| 305 this._domModel.markUndoableState(); | 308 this._domModel.markUndoableState(); |
| 306 this._computeMatchingSelectors(rulePayload, nodeId, successCallback, failureCallback); | 309 return rulePayload; |
| 307 } | 310 } |
| 308 | 311 |
| 309 if (!rule.styleSheetId) | 312 if (!rule.styleSheetId) |
| 310 throw "No rule stylesheet id"; | 313 throw "No rule stylesheet id"; |
| 311 WebInspector.userMetrics.StyleRuleEdited.record(); | 314 WebInspector.userMetrics.StyleRuleEdited.record(); |
| 312 this._pendingCommandsMajorState.push(true); | 315 this._pendingCommandsMajorState.push(true); |
| 313 this._agent.setRuleSelector(rule.styleSheetId, rule.selectorRange, newSe lector, callback.bind(this, nodeId, successCallback, failureCallback, newSelecto r)); | 316 this._agent.setRuleSelector(rule.styleSheetId, rule.selectorRange, newSe lector, callback.bind(this)) |
| 317 .then(this._computeMatchingSelectors.bind(this, nodeId)) | |
| 318 .catchException(null) | |
| 319 .then(userCallback); | |
| 314 }, | 320 }, |
| 315 | 321 |
| 316 /** | 322 /** |
| 317 * @param {!WebInspector.CSSMedia} media | 323 * @param {!WebInspector.CSSMedia} media |
| 318 * @param {string} newMediaText | 324 * @param {string} newMediaText |
| 319 * @param {function(!WebInspector.CSSMedia)} successCallback | 325 * @param {function(?WebInspector.CSSMedia)} userCallback |
| 320 * @param {function()} failureCallback | |
| 321 */ | 326 */ |
| 322 setMediaText: function(media, newMediaText, successCallback, failureCallback ) | 327 setMediaText: function(media, newMediaText, userCallback) |
| 323 { | 328 { |
| 324 /** | 329 /** |
| 325 * @param {function(!WebInspector.CSSMedia)} successCallback | |
| 326 * @param {function()} failureCallback | |
| 327 * @param {?Protocol.Error} error | 330 * @param {?Protocol.Error} error |
| 328 * @param {!CSSAgent.CSSMedia} mediaPayload | 331 * @param {!CSSAgent.CSSMedia} mediaPayload |
| 332 * @return {?WebInspector.CSSMedia} | |
| 329 * @this {WebInspector.CSSStyleModel} | 333 * @this {WebInspector.CSSStyleModel} |
| 330 */ | 334 */ |
| 331 function callback(successCallback, failureCallback, error, mediaPayload) | 335 function parsePayload(error, mediaPayload) |
| 332 { | 336 { |
| 333 this._pendingCommandsMajorState.pop(); | 337 this._pendingCommandsMajorState.pop(); |
| 334 if (error) { | 338 if (!mediaPayload) |
| 335 failureCallback(); | 339 return null; |
| 336 return; | |
| 337 } | |
| 338 this._domModel.markUndoableState(); | 340 this._domModel.markUndoableState(); |
| 339 successCallback(WebInspector.CSSMedia.parsePayload(this, mediaPayloa d)); | 341 return WebInspector.CSSMedia.parsePayload(this, mediaPayload); |
| 340 } | 342 } |
| 341 | 343 |
| 342 console.assert(!!media.parentStyleSheetId); | 344 console.assert(!!media.parentStyleSheetId); |
| 343 WebInspector.userMetrics.StyleRuleEdited.record(); | 345 WebInspector.userMetrics.StyleRuleEdited.record(); |
| 344 this._pendingCommandsMajorState.push(true); | 346 this._pendingCommandsMajorState.push(true); |
| 345 this._agent.setMediaText(media.parentStyleSheetId, media.range, newMedia Text, callback.bind(this, successCallback, failureCallback)); | 347 this._agent.setMediaText(media.parentStyleSheetId, media.range, newMedia Text, parsePayload.bind(this)) |
| 348 .catchException(null) | |
| 349 .then(userCallback); | |
| 346 }, | 350 }, |
| 347 | 351 |
| 348 /** | 352 /** |
| 349 * @param {!CSSAgent.CSSRule} rulePayload | |
| 350 * @param {!DOMAgent.NodeId} nodeId | 353 * @param {!DOMAgent.NodeId} nodeId |
| 351 * @param {function(!WebInspector.CSSRule)} successCallback | 354 * @param {?CSSAgent.CSSRule} rulePayload |
| 352 * @param {function()} failureCallback | 355 * @return {!Promise.<?WebInspector.CSSRule>} |
| 353 */ | 356 */ |
| 354 _computeMatchingSelectors: function(rulePayload, nodeId, successCallback, fa ilureCallback) | 357 _computeMatchingSelectors: function(nodeId, rulePayload) |
| 355 { | 358 { |
| 356 var ownerDocumentId = this._ownerDocumentId(nodeId); | 359 var ownerDocumentId = this._ownerDocumentId(nodeId); |
| 357 if (!ownerDocumentId) { | 360 if (!ownerDocumentId || !rulePayload) |
| 358 failureCallback(); | 361 return Promise.resolve(/** @type {?WebInspector.CSSRule} */(null)); |
| 359 return; | |
| 360 } | |
| 361 var rule = WebInspector.CSSRule.parsePayload(this, rulePayload); | 362 var rule = WebInspector.CSSRule.parsePayload(this, rulePayload); |
| 362 var matchingSelectors = []; | 363 var matchingSelectors = []; |
| 363 var allSelectorsBarrier = new CallbackBarrier(); | 364 var allSelectorsBarrier = new CallbackBarrier(); |
| 364 for (var i = 0; i < rule.selectors.length; ++i) { | 365 for (var i = 0; i < rule.selectors.length; ++i) { |
| 365 var selector = rule.selectors[i]; | 366 var selector = rule.selectors[i]; |
| 366 var boundCallback = allSelectorsBarrier.createCallback(selectorQueri ed.bind(null, i, nodeId, matchingSelectors)); | 367 var boundCallback = allSelectorsBarrier.createCallback(selectorQueri ed.bind(null, i, nodeId, matchingSelectors)); |
| 367 this._domModel.querySelectorAll(ownerDocumentId, selector.value, bou ndCallback); | 368 this._domModel.querySelectorAll(ownerDocumentId, selector.value, bou ndCallback); |
| 368 } | 369 } |
| 369 allSelectorsBarrier.callWhenDone(function() { | 370 return new Promise(function(resolve) { |
| 370 rule.matchingSelectors = matchingSelectors; | 371 allSelectorsBarrier.callWhenDone(function() { |
| 371 successCallback(rule); | 372 rule.matchingSelectors = matchingSelectors; |
| 373 resolve(rule); | |
| 374 }); | |
| 372 }); | 375 }); |
| 373 | 376 |
| 374 /** | 377 /** |
| 375 * @param {number} index | 378 * @param {number} index |
| 376 * @param {!DOMAgent.NodeId} nodeId | 379 * @param {!DOMAgent.NodeId} nodeId |
| 377 * @param {!Array.<number>} matchingSelectors | 380 * @param {!Array.<number>} matchingSelectors |
| 378 * @param {!Array.<!DOMAgent.NodeId>=} matchingNodeIds | 381 * @param {!Array.<!DOMAgent.NodeId>=} matchingNodeIds |
| 379 */ | 382 */ |
| 380 function selectorQueried(index, nodeId, matchingSelectors, matchingNodeI ds) | 383 function selectorQueried(index, nodeId, matchingSelectors, matchingNodeI ds) |
| 381 { | 384 { |
| 382 if (!matchingNodeIds) | 385 if (!matchingNodeIds) |
| 383 return; | 386 return; |
| 384 if (matchingNodeIds.indexOf(nodeId) !== -1) | 387 if (matchingNodeIds.indexOf(nodeId) !== -1) |
| 385 matchingSelectors.push(index); | 388 matchingSelectors.push(index); |
| 386 } | 389 } |
| 387 }, | 390 }, |
| 388 | 391 |
| 389 /** | 392 /** |
| 390 * @param {!CSSAgent.StyleSheetId} styleSheetId | 393 * @param {!CSSAgent.StyleSheetId} styleSheetId |
| 391 * @param {!WebInspector.DOMNode} node | 394 * @param {!WebInspector.DOMNode} node |
| 392 * @param {string} ruleText | 395 * @param {string} ruleText |
| 393 * @param {!WebInspector.TextRange} ruleLocation | 396 * @param {!WebInspector.TextRange} ruleLocation |
| 394 * @param {function(!WebInspector.CSSRule)} successCallback | 397 * @param {function(?WebInspector.CSSRule)} userCallback |
| 395 * @param {function()} failureCallback | |
| 396 */ | 398 */ |
| 397 addRule: function(styleSheetId, node, ruleText, ruleLocation, successCallbac k, failureCallback) | 399 addRule: function(styleSheetId, node, ruleText, ruleLocation, userCallback) |
| 398 { | 400 { |
| 399 this._pendingCommandsMajorState.push(true); | 401 this._pendingCommandsMajorState.push(true); |
| 400 this._agent.addRule(styleSheetId, ruleText, ruleLocation, callback.bind( this)); | 402 this._agent.addRule(styleSheetId, ruleText, ruleLocation, parsePayload.b ind(this)) |
| 403 .then(this._computeMatchingSelectors.bind(this, node.id)) | |
| 404 .catchException(null) | |
| 405 .then(userCallback); | |
| 401 | 406 |
| 402 /** | 407 /** |
| 403 * @param {?Protocol.Error} error | 408 * @param {?Protocol.Error} error |
| 404 * @param {!CSSAgent.CSSRule} rulePayload | 409 * @param {?CSSAgent.CSSRule} rulePayload |
| 410 * @return {?CSSAgent.CSSRule} | |
| 405 * @this {WebInspector.CSSStyleModel} | 411 * @this {WebInspector.CSSStyleModel} |
| 406 */ | 412 */ |
| 407 function callback(error, rulePayload) | 413 function parsePayload(error, rulePayload) |
| 408 { | 414 { |
| 409 this._pendingCommandsMajorState.pop(); | 415 this._pendingCommandsMajorState.pop(); |
| 410 if (error) { | 416 if (error || !rulePayload) |
| 411 // Invalid syntax for a selector | 417 return null; |
| 412 failureCallback(); | 418 this._domModel.markUndoableState(); |
| 413 } else { | 419 return rulePayload; |
| 414 this._domModel.markUndoableState(); | |
| 415 this._computeMatchingSelectors(rulePayload, node.id, successCall back, failureCallback); | |
| 416 } | |
| 417 } | 420 } |
| 418 }, | 421 }, |
| 419 | 422 |
| 420 /** | 423 /** |
| 421 * @param {!WebInspector.DOMNode} node | 424 * @param {!WebInspector.DOMNode} node |
| 422 * @param {function(?WebInspector.CSSStyleSheetHeader)} callback | 425 * @param {function(?WebInspector.CSSStyleSheetHeader)} userCallback |
| 423 */ | 426 */ |
| 424 requestViaInspectorStylesheet: function(node, callback) | 427 requestViaInspectorStylesheet: function(node, userCallback) |
| 425 { | 428 { |
| 426 var frameId = node.frameId() || this.target().resourceTreeModel.mainFram e.id; | 429 var frameId = node.frameId() || this.target().resourceTreeModel.mainFram e.id; |
| 427 var headers = this._styleSheetIdToHeader.valuesArray(); | 430 var headers = this._styleSheetIdToHeader.valuesArray(); |
| 428 for (var i = 0; i < headers.length; ++i) { | 431 for (var i = 0; i < headers.length; ++i) { |
| 429 var styleSheetHeader = headers[i]; | 432 var styleSheetHeader = headers[i]; |
| 430 if (styleSheetHeader.frameId === frameId && styleSheetHeader.isViaIn spector()) { | 433 if (styleSheetHeader.frameId === frameId && styleSheetHeader.isViaIn spector()) { |
| 431 callback(styleSheetHeader); | 434 userCallback(styleSheetHeader); |
| 432 return; | 435 return; |
| 433 } | 436 } |
| 434 } | 437 } |
| 435 | 438 |
| 436 /** | 439 /** |
| 440 * @param {?Protocol.Error} error | |
| 441 * @param {?CSSAgent.StyleSheetId} styleSheetId | |
| 442 * @return {?WebInspector.CSSStyleSheetHeader} | |
| 437 * @this {WebInspector.CSSStyleModel} | 443 * @this {WebInspector.CSSStyleModel} |
| 438 * @param {?Protocol.Error} error | |
| 439 * @param {!CSSAgent.StyleSheetId} styleSheetId | |
| 440 */ | 444 */ |
| 441 function innerCallback(error, styleSheetId) | 445 function innerCallback(error, styleSheetId) |
| 442 { | 446 { |
| 443 if (error) { | 447 return !error && styleSheetId ? this._styleSheetIdToHeader.get(style SheetId) || null : null; |
| 444 console.error(error); | |
| 445 callback(null); | |
| 446 } | |
| 447 | |
| 448 callback(this._styleSheetIdToHeader.get(styleSheetId) || null); | |
| 449 } | 448 } |
| 450 | 449 |
| 451 this._agent.createStyleSheet(frameId, innerCallback.bind(this)); | 450 this._agent.createStyleSheet(frameId, innerCallback.bind(this)) |
| 451 .catchException(null) | |
| 452 .then(userCallback) | |
| 452 }, | 453 }, |
| 453 | 454 |
| 454 mediaQueryResultChanged: function() | 455 mediaQueryResultChanged: function() |
| 455 { | 456 { |
| 456 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.MediaQue ryResultChanged); | 457 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.MediaQue ryResultChanged); |
| 457 }, | 458 }, |
| 458 | 459 |
| 459 /** | 460 /** |
| 460 * @param {!CSSAgent.StyleSheetId} id | 461 * @param {!CSSAgent.StyleSheetId} id |
| 461 * @return {?WebInspector.CSSStyleSheetHeader} | 462 * @return {?WebInspector.CSSStyleSheetHeader} |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.Styl eSheetRemoved, headers[i]); | 613 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.Styl eSheetRemoved, headers[i]); |
| 613 }, | 614 }, |
| 614 | 615 |
| 615 _suspendStateChanged: function() | 616 _suspendStateChanged: function() |
| 616 { | 617 { |
| 617 if (WebInspector.targetManager.allTargetsSuspended()) { | 618 if (WebInspector.targetManager.allTargetsSuspended()) { |
| 618 this._agent.disable(); | 619 this._agent.disable(); |
| 619 this._isEnabled = false; | 620 this._isEnabled = false; |
| 620 } else { | 621 } else { |
| 621 this._resetStyleSheets(); | 622 this._resetStyleSheets(); |
| 622 this._agent.enable(this._wasEnabled.bind(this)); | 623 this._agent.enable().spread(this._wasEnabled.bind(this)); |
| 623 } | 624 } |
| 624 }, | 625 }, |
| 625 | 626 |
| 626 __proto__: WebInspector.SDKModel.prototype | 627 __proto__: WebInspector.SDKModel.prototype |
| 627 } | 628 } |
| 628 | 629 |
| 629 /** | 630 /** |
| 630 * @constructor | 631 * @constructor |
| 631 * @extends {WebInspector.SDKObject} | 632 * @extends {WebInspector.SDKObject} |
| 632 * @param {!WebInspector.CSSStyleModel} cssModel | 633 * @param {!WebInspector.CSSStyleModel} cssModel |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 897 { | 898 { |
| 898 index = (typeof index === "undefined") ? this.pastLastSourcePropertyInde x() : index; | 899 index = (typeof index === "undefined") ? this.pastLastSourcePropertyInde x() : index; |
| 899 var property = new WebInspector.CSSProperty(this, index, "", "", false, false, true, false, "", this._insertionRange(index)); | 900 var property = new WebInspector.CSSProperty(this, index, "", "", false, false, true, false, "", this._insertionRange(index)); |
| 900 property._setActive(true); | 901 property._setActive(true); |
| 901 return property; | 902 return property; |
| 902 }, | 903 }, |
| 903 | 904 |
| 904 /** | 905 /** |
| 905 * @param {string} text | 906 * @param {string} text |
| 906 * @param {boolean} majorChange | 907 * @param {boolean} majorChange |
| 907 * @param {function(?WebInspector.CSSStyleDeclaration)} callback | 908 * @param {function(?WebInspector.CSSStyleDeclaration)} userCallback |
| 908 */ | 909 */ |
| 909 setText: function(text, majorChange, callback) | 910 setText: function(text, majorChange, userCallback) |
| 910 { | 911 { |
| 911 if (!this.styleSheetId) { | 912 if (!this.styleSheetId) { |
| 912 callback(null); | 913 userCallback(null); |
| 913 return; | 914 return; |
| 914 } | 915 } |
| 915 | 916 |
| 916 /** | 917 /** |
| 917 * @param {?Protocol.Error} error | 918 * @param {?Protocol.Error} error |
| 918 * @param {!CSSAgent.CSSStyle} stylePayload | 919 * @param {?CSSAgent.CSSStyle} stylePayload |
| 920 * @return {?WebInspector.CSSStyleDeclaration} | |
| 919 * @this {WebInspector.CSSStyleDeclaration} | 921 * @this {WebInspector.CSSStyleDeclaration} |
| 920 */ | 922 */ |
| 921 function mycallback(error, stylePayload) | 923 function parsePayload(error, stylePayload) |
| 922 { | 924 { |
| 923 this._cssModel._pendingCommandsMajorState.pop(); | 925 this._cssModel._pendingCommandsMajorState.pop(); |
| 924 if (!error) { | 926 if (error || !stylePayload) |
| 925 if (majorChange) | 927 return null; |
| 926 this._cssModel._domModel.markUndoableState(); | 928 |
| 927 callback(WebInspector.CSSStyleDeclaration.parsePayload(this._css Model, stylePayload)); | 929 if (majorChange) |
| 928 return; | 930 this._cssModel._domModel.markUndoableState(); |
| 929 } | 931 return WebInspector.CSSStyleDeclaration.parsePayload(this._cssModel, stylePayload); |
| 930 callback(null); | |
| 931 } | 932 } |
| 932 | 933 |
| 933 this._cssModel._pendingCommandsMajorState.push(majorChange); | 934 this._cssModel._pendingCommandsMajorState.push(majorChange); |
| 934 this._cssModel._agent.setStyleText(this.styleSheetId, this.range.seriali zeToObject(), text, mycallback.bind(this)); | 935 this._cssModel._agent.setStyleText(this.styleSheetId, this.range.seriali zeToObject(), text, parsePayload.bind(this)) |
| 936 .catchException(null) | |
| 937 .then(userCallback) | |
| 935 }, | 938 }, |
| 936 | 939 |
| 937 /** | 940 /** |
| 938 * @param {number} index | 941 * @param {number} index |
| 939 * @param {string} name | 942 * @param {string} name |
| 940 * @param {string} value | 943 * @param {string} value |
| 941 * @param {function(?WebInspector.CSSStyleDeclaration)=} userCallback | 944 * @param {function(?WebInspector.CSSStyleDeclaration)=} userCallback |
| 942 */ | 945 */ |
| 943 insertPropertyAt: function(index, name, value, userCallback) | 946 insertPropertyAt: function(index, name, value, userCallback) |
| 944 { | 947 { |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1764 * @return {string} | 1767 * @return {string} |
| 1765 */ | 1768 */ |
| 1766 _trimSourceURL: function(text) | 1769 _trimSourceURL: function(text) |
| 1767 { | 1770 { |
| 1768 var sourceURLRegex = /\n[\040\t]*\/\*[#@][\040\t]sourceURL=[\040\t]*([^\ s]*)[\040\t]*\*\/[\040\t]*$/mg; | 1771 var sourceURLRegex = /\n[\040\t]*\/\*[#@][\040\t]sourceURL=[\040\t]*([^\ s]*)[\040\t]*\*\/[\040\t]*$/mg; |
| 1769 return text.replace(sourceURLRegex, ""); | 1772 return text.replace(sourceURLRegex, ""); |
| 1770 }, | 1773 }, |
| 1771 | 1774 |
| 1772 /** | 1775 /** |
| 1773 * @override | 1776 * @override |
| 1774 * @param {function(string)} callback | 1777 * @param {function(string)} userCallback |
| 1775 */ | 1778 */ |
| 1776 requestContent: function(callback) | 1779 requestContent: function(userCallback) |
| 1777 { | 1780 { |
| 1778 this._cssModel._agent.getStyleSheetText(this.id, textCallback.bind(this) ); | 1781 this._cssModel._agent.getStyleSheetText(this.id, textCallback.bind(this) ) |
| 1782 .catchException("") | |
| 1783 .then(userCallback) | |
| 1779 | 1784 |
| 1780 /** | 1785 /** |
| 1786 * @param {?Protocol.Error} error | |
| 1787 * @param {?string} text | |
| 1788 * @return {string} | |
| 1781 * @this {WebInspector.CSSStyleSheetHeader} | 1789 * @this {WebInspector.CSSStyleSheetHeader} |
| 1782 */ | 1790 */ |
| 1783 function textCallback(error, text) | 1791 function textCallback(error, text) |
| 1784 { | 1792 { |
| 1785 if (error) { | 1793 if (error || !text) { |
| 1786 WebInspector.console.error("Failed to get text for stylesheet " + this.id + ": " + error); | 1794 WebInspector.console.error("Failed to get text for stylesheet " + this.id + ": " + error) |
| 1787 text = ""; | 1795 text = ""; |
| 1788 // Fall through. | 1796 // Fall through. |
| 1789 } | 1797 } |
| 1790 text = this._trimSourceURL(text); | 1798 return this._trimSourceURL(text); |
| 1791 callback(text); | |
| 1792 } | 1799 } |
| 1793 }, | 1800 }, |
| 1794 | 1801 |
| 1795 /** | 1802 /** |
| 1796 * @override | 1803 * @override |
| 1797 */ | 1804 */ |
| 1798 searchInContent: function(query, caseSensitive, isRegex, callback) | 1805 searchInContent: function(query, caseSensitive, isRegex, callback) |
| 1799 { | 1806 { |
| 1800 function performSearch(content) | 1807 function performSearch(content) |
| 1801 { | 1808 { |
| 1802 callback(WebInspector.ContentProvider.performSearchInContent(content , query, caseSensitive, isRegex)); | 1809 callback(WebInspector.ContentProvider.performSearchInContent(content , query, caseSensitive, isRegex)); |
| 1803 } | 1810 } |
| 1804 | 1811 |
| 1805 // searchInContent should call back later. | 1812 // searchInContent should call back later. |
| 1806 this.requestContent(performSearch); | 1813 this.requestContent(performSearch); |
| 1807 }, | 1814 }, |
| 1808 | 1815 |
| 1809 /** | 1816 /** |
| 1810 * @param {string} newText | 1817 * @param {string} newText |
| 1811 * @param {function(?Protocol.Error)} callback | 1818 * @param {function(?Protocol.Error)} callback |
| 1812 */ | 1819 */ |
| 1813 setContent: function(newText, callback) | 1820 setContent: function(newText, callback) |
| 1814 { | 1821 { |
| 1815 newText = this._trimSourceURL(newText); | 1822 newText = this._trimSourceURL(newText); |
| 1816 if (this.hasSourceURL) | 1823 if (this.hasSourceURL) |
| 1817 newText += "\n/*# sourceURL=" + this.sourceURL + " */"; | 1824 newText += "\n/*# sourceURL=" + this.sourceURL + " */"; |
| 1818 this._cssModel._agent.setStyleSheetText(this.id, newText, callback); | 1825 this._cssModel._agent.setStyleSheetText(this.id, newText) |
| 1826 .spread(callback); | |
| 1819 }, | 1827 }, |
| 1820 | 1828 |
| 1821 /** | 1829 /** |
| 1822 * @return {boolean} | 1830 * @return {boolean} |
| 1823 */ | 1831 */ |
| 1824 isViaInspector: function() | 1832 isViaInspector: function() |
| 1825 { | 1833 { |
| 1826 return this.origin === "inspector"; | 1834 return this.origin === "inspector"; |
| 1827 } | 1835 } |
| 1828 } | 1836 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1892 */ | 1900 */ |
| 1893 getComputedStyle: function(nodeId, userCallback) | 1901 getComputedStyle: function(nodeId, userCallback) |
| 1894 { | 1902 { |
| 1895 if (this._nodeIdToCallbackData[nodeId]) { | 1903 if (this._nodeIdToCallbackData[nodeId]) { |
| 1896 this._nodeIdToCallbackData[nodeId].push(userCallback); | 1904 this._nodeIdToCallbackData[nodeId].push(userCallback); |
| 1897 return; | 1905 return; |
| 1898 } | 1906 } |
| 1899 | 1907 |
| 1900 this._nodeIdToCallbackData[nodeId] = [userCallback]; | 1908 this._nodeIdToCallbackData[nodeId] = [userCallback]; |
| 1901 | 1909 |
| 1902 this._cssModel._agent.getComputedStyleForNode(nodeId, resultCallback.bin d(this, nodeId)); | 1910 this._cssModel._agent.getComputedStyleForNode(nodeId, parsePayload.bind( this)) |
| 1911 .catchException(null) | |
| 1912 .then(broadcast.bind(this, nodeId)) | |
| 1913 | |
| 1914 /** | |
| 1915 * @param {?Protocol.Error} error | |
| 1916 * @param {!Array.<!CSSAgent.CSSComputedStyleProperty>} computedPayload | |
| 1917 * @return {?WebInspector.CSSStyleDeclaration} | |
| 1918 * @this {WebInspector.CSSStyleModel.ComputedStyleLoader} | |
| 1919 */ | |
| 1920 function parsePayload(error, computedPayload) | |
| 1921 { | |
| 1922 return !error && computedPayload ? WebInspector.CSSStyleDeclaration. parseComputedStylePayload(this._cssModel, computedPayload) : null; | |
| 1923 } | |
| 1903 | 1924 |
| 1904 /** | 1925 /** |
| 1905 * @param {!DOMAgent.NodeId} nodeId | 1926 * @param {!DOMAgent.NodeId} nodeId |
| 1906 * @param {?Protocol.Error} error | 1927 * @param {?WebInspector.CSSStyleDeclaration} computedStyle |
| 1907 * @param {!Array.<!CSSAgent.CSSComputedStyleProperty>} computedPayload | |
| 1908 * @this {WebInspector.CSSStyleModel.ComputedStyleLoader} | 1928 * @this {WebInspector.CSSStyleModel.ComputedStyleLoader} |
| 1909 */ | 1929 */ |
| 1910 function resultCallback(nodeId, error, computedPayload) | 1930 function broadcast(nodeId, computedStyle) |
| 1911 { | 1931 { |
| 1912 var computedStyle = (error || !computedPayload) ? null : WebInspecto r.CSSStyleDeclaration.parseComputedStylePayload(this._cssModel, computedPayload) ; | |
| 1913 var callbacks = this._nodeIdToCallbackData[nodeId]; | 1932 var callbacks = this._nodeIdToCallbackData[nodeId]; |
| 1914 | 1933 |
| 1915 // The loader has been reset. | 1934 // The loader has been reset. |
| 1916 if (!callbacks) | 1935 if (!callbacks) |
| 1917 return; | 1936 return; |
| 1918 | 1937 |
| 1919 delete this._nodeIdToCallbackData[nodeId]; | 1938 delete this._nodeIdToCallbackData[nodeId]; |
| 1920 for (var i = 0; i < callbacks.length; ++i) | 1939 for (var i = 0; i < callbacks.length; ++i) |
| 1921 callbacks[i](computedStyle); | 1940 callbacks[i](computedStyle); |
| 1922 } | 1941 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1935 } | 1954 } |
| 1936 | 1955 |
| 1937 /** | 1956 /** |
| 1938 * @param {!WebInspector.DOMNode} node | 1957 * @param {!WebInspector.DOMNode} node |
| 1939 * @return {!WebInspector.CSSStyleModel} | 1958 * @return {!WebInspector.CSSStyleModel} |
| 1940 */ | 1959 */ |
| 1941 WebInspector.CSSStyleModel.fromNode = function(node) | 1960 WebInspector.CSSStyleModel.fromNode = function(node) |
| 1942 { | 1961 { |
| 1943 return /** @type {!WebInspector.CSSStyleModel} */ (WebInspector.CSSStyleMode l.fromTarget(node.target())); | 1962 return /** @type {!WebInspector.CSSStyleModel} */ (WebInspector.CSSStyleMode l.fromTarget(node.target())); |
| 1944 } | 1963 } |
| OLD | NEW |