| 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 SDK.CSSStyleDeclaration = class { | 4 SDK.CSSStyleDeclaration = class { |
| 5 /** | 5 /** |
| 6 * @param {!SDK.CSSModel} cssModel | 6 * @param {!SDK.CSSModel} cssModel |
| 7 * @param {?SDK.CSSRule} parentRule | 7 * @param {?SDK.CSSRule} parentRule |
| 8 * @param {!Protocol.CSS.CSSStyle} payload | 8 * @param {!Protocol.CSS.CSSStyle} payload |
| 9 * @param {!SDK.CSSStyleDeclaration.Type} type | 9 * @param {!SDK.CSSStyleDeclaration.Type} type |
| 10 */ | 10 */ |
| 11 constructor(cssModel, parentRule, payload, type) { | 11 constructor(cssModel, parentRule, payload, type) { |
| 12 this._cssModel = cssModel; | 12 this._cssModel = cssModel; |
| 13 this.parentRule = parentRule; | 13 this.parentRule = parentRule; |
| 14 /** @type {!Array<!SDK.CSSProperty>} */ | 14 /** @type {!Array<!SDK.CSSProperty>} */ |
| 15 this._allProperties; | 15 this._allProperties; |
| 16 /** @type {string|undefined} */ | 16 /** @type {string|undefined} */ |
| 17 this.styleSheetId; | 17 this.styleSheetId; |
| 18 /** @type {?Common.TextRange} */ | 18 /** @type {?TextUtils.TextRange} */ |
| 19 this.range; | 19 this.range; |
| 20 /** @type {string|undefined} */ | 20 /** @type {string|undefined} */ |
| 21 this.cssText; | 21 this.cssText; |
| 22 /** @type {!Map<string, string>} */ | 22 /** @type {!Map<string, string>} */ |
| 23 this._shorthandValues; | 23 this._shorthandValues; |
| 24 /** @type {!Set<string>} */ | 24 /** @type {!Set<string>} */ |
| 25 this._shorthandIsImportant; | 25 this._shorthandIsImportant; |
| 26 /** @type {!Map<string, !SDK.CSSProperty>} */ | 26 /** @type {!Map<string, !SDK.CSSProperty>} */ |
| 27 this._activePropertyMap; | 27 this._activePropertyMap; |
| 28 /** @type {?Array<!SDK.CSSProperty>} */ | 28 /** @type {?Array<!SDK.CSSProperty>} */ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 44 for (var i = 0; i < this._allProperties.length; ++i) | 44 for (var i = 0; i < this._allProperties.length; ++i) |
| 45 this._allProperties[i].rebase(edit); | 45 this._allProperties[i].rebase(edit); |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * @param {!Protocol.CSS.CSSStyle} payload | 50 * @param {!Protocol.CSS.CSSStyle} payload |
| 51 */ | 51 */ |
| 52 _reinitialize(payload) { | 52 _reinitialize(payload) { |
| 53 this.styleSheetId = payload.styleSheetId; | 53 this.styleSheetId = payload.styleSheetId; |
| 54 this.range = payload.range ? Common.TextRange.fromObject(payload.range) : nu
ll; | 54 this.range = payload.range ? TextUtils.TextRange.fromObject(payload.range) :
null; |
| 55 | 55 |
| 56 var shorthandEntries = payload.shorthandEntries; | 56 var shorthandEntries = payload.shorthandEntries; |
| 57 this._shorthandValues = new Map(); | 57 this._shorthandValues = new Map(); |
| 58 this._shorthandIsImportant = new Set(); | 58 this._shorthandIsImportant = new Set(); |
| 59 for (var i = 0; i < shorthandEntries.length; ++i) { | 59 for (var i = 0; i < shorthandEntries.length; ++i) { |
| 60 this._shorthandValues.set(shorthandEntries[i].name, shorthandEntries[i].va
lue); | 60 this._shorthandValues.set(shorthandEntries[i].name, shorthandEntries[i].va
lue); |
| 61 if (shorthandEntries[i].important) | 61 if (shorthandEntries[i].important) |
| 62 this._shorthandIsImportant.add(shorthandEntries[i].name); | 62 this._shorthandIsImportant.add(shorthandEntries[i].name); |
| 63 } | 63 } |
| 64 | 64 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 pastLastSourcePropertyIndex() { | 246 pastLastSourcePropertyIndex() { |
| 247 for (var i = this.allProperties().length - 1; i >= 0; --i) { | 247 for (var i = this.allProperties().length - 1; i >= 0; --i) { |
| 248 if (this.allProperties()[i].range) | 248 if (this.allProperties()[i].range) |
| 249 return i + 1; | 249 return i + 1; |
| 250 } | 250 } |
| 251 return 0; | 251 return 0; |
| 252 } | 252 } |
| 253 | 253 |
| 254 /** | 254 /** |
| 255 * @param {number} index | 255 * @param {number} index |
| 256 * @return {!Common.TextRange} | 256 * @return {!TextUtils.TextRange} |
| 257 */ | 257 */ |
| 258 _insertionRange(index) { | 258 _insertionRange(index) { |
| 259 var property = this.propertyAt(index); | 259 var property = this.propertyAt(index); |
| 260 return property && property.range ? property.range.collapseToStart() : this.
range.collapseToEnd(); | 260 return property && property.range ? property.range.collapseToStart() : this.
range.collapseToEnd(); |
| 261 } | 261 } |
| 262 | 262 |
| 263 /** | 263 /** |
| 264 * @param {number=} index | 264 * @param {number=} index |
| 265 * @return {!SDK.CSSProperty} | 265 * @return {!SDK.CSSProperty} |
| 266 */ | 266 */ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 this.insertPropertyAt(this.allProperties().length, name, value, userCallback
); | 300 this.insertPropertyAt(this.allProperties().length, name, value, userCallback
); |
| 301 } | 301 } |
| 302 }; | 302 }; |
| 303 | 303 |
| 304 /** @enum {string} */ | 304 /** @enum {string} */ |
| 305 SDK.CSSStyleDeclaration.Type = { | 305 SDK.CSSStyleDeclaration.Type = { |
| 306 Regular: 'Regular', | 306 Regular: 'Regular', |
| 307 Inline: 'Inline', | 307 Inline: 'Inline', |
| 308 Attributes: 'Attributes' | 308 Attributes: 'Attributes' |
| 309 }; | 309 }; |
| OLD | NEW |