| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @param {!WebInspector.CSSModel} cssModel | 7 * @param {!WebInspector.CSSModel} cssModel |
| 8 * @param {?WebInspector.CSSRule} parentRule | 8 * @param {?WebInspector.CSSRule} parentRule |
| 9 * @param {!CSSAgent.CSSStyle} payload | 9 * @param {!CSSAgent.CSSStyle} payload |
| 10 * @param {!WebInspector.CSSStyleDeclaration.Type} type | 10 * @param {!WebInspector.CSSStyleDeclaration.Type} type |
| 11 */ | 11 */ |
| 12 WebInspector.CSSStyleDeclaration = function(cssModel, parentRule, payload, type) | 12 WebInspector.CSSStyleDeclaration = function(cssModel, parentRule, payload, type) |
| 13 { | 13 { |
| 14 this._cssModel = cssModel; | 14 this._cssModel = cssModel; |
| 15 this.parentRule = parentRule; | 15 this.parentRule = parentRule; |
| 16 this._reinitialize(payload); | 16 this._reinitialize(payload); |
| 17 this.type = type; | 17 this.type = type; |
| 18 } | 18 }; |
| 19 | 19 |
| 20 /** @enum {string} */ | 20 /** @enum {string} */ |
| 21 WebInspector.CSSStyleDeclaration.Type = { | 21 WebInspector.CSSStyleDeclaration.Type = { |
| 22 Regular: "Regular", | 22 Regular: "Regular", |
| 23 Inline: "Inline", | 23 Inline: "Inline", |
| 24 Attributes: "Attributes" | 24 Attributes: "Attributes" |
| 25 } | 25 }; |
| 26 | 26 |
| 27 WebInspector.CSSStyleDeclaration.prototype = { | 27 WebInspector.CSSStyleDeclaration.prototype = { |
| 28 /** | 28 /** |
| 29 * @param {!WebInspector.CSSModel.Edit} edit | 29 * @param {!WebInspector.CSSModel.Edit} edit |
| 30 */ | 30 */ |
| 31 rebase: function(edit) | 31 rebase: function(edit) |
| 32 { | 32 { |
| 33 if (this.styleSheetId !== edit.styleSheetId || !this.range) | 33 if (this.styleSheetId !== edit.styleSheetId || !this.range) |
| 34 return; | 34 return; |
| 35 if (edit.oldRange.equal(this.range)) { | 35 if (edit.oldRange.equal(this.range)) { |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 return property; | 279 return property; |
| 280 }, | 280 }, |
| 281 | 281 |
| 282 /** | 282 /** |
| 283 * @param {string} text | 283 * @param {string} text |
| 284 * @param {boolean} majorChange | 284 * @param {boolean} majorChange |
| 285 * @return {!Promise.<boolean>} | 285 * @return {!Promise.<boolean>} |
| 286 */ | 286 */ |
| 287 setText: function(text, majorChange) | 287 setText: function(text, majorChange) |
| 288 { | 288 { |
| 289 return this._cssModel.setStyleText(this.styleSheetId, this.range, text,
majorChange) | 289 return this._cssModel.setStyleText(this.styleSheetId, this.range, text,
majorChange); |
| 290 }, | 290 }, |
| 291 | 291 |
| 292 /** | 292 /** |
| 293 * @param {number} index | 293 * @param {number} index |
| 294 * @param {string} name | 294 * @param {string} name |
| 295 * @param {string} value | 295 * @param {string} value |
| 296 * @param {function(boolean)=} userCallback | 296 * @param {function(boolean)=} userCallback |
| 297 */ | 297 */ |
| 298 insertPropertyAt: function(index, name, value, userCallback) | 298 insertPropertyAt: function(index, name, value, userCallback) |
| 299 { | 299 { |
| 300 this.newBlankProperty(index).setText(name + ": " + value + ";", false, t
rue) | 300 this.newBlankProperty(index).setText(name + ": " + value + ";", false, t
rue) |
| 301 .then(userCallback); | 301 .then(userCallback); |
| 302 }, | 302 }, |
| 303 | 303 |
| 304 /** | 304 /** |
| 305 * @param {string} name | 305 * @param {string} name |
| 306 * @param {string} value | 306 * @param {string} value |
| 307 * @param {function(boolean)=} userCallback | 307 * @param {function(boolean)=} userCallback |
| 308 */ | 308 */ |
| 309 appendProperty: function(name, value, userCallback) | 309 appendProperty: function(name, value, userCallback) |
| 310 { | 310 { |
| 311 this.insertPropertyAt(this.allProperties.length, name, value, userCallba
ck); | 311 this.insertPropertyAt(this.allProperties.length, name, value, userCallba
ck); |
| 312 } | 312 } |
| 313 } | 313 }; |
| OLD | NEW |