| 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 {!CSSAgent.Value} payload | 7 * @param {!CSSAgent.Value} payload |
| 8 */ | 8 */ |
| 9 WebInspector.CSSValue = function(payload) | 9 WebInspector.CSSValue = function(payload) |
| 10 { | 10 { |
| 11 this.text = payload.text; | 11 this.text = payload.text; |
| 12 if (payload.range) | 12 if (payload.range) |
| 13 this.range = WebInspector.TextRange.fromObject(payload.range); | 13 this.range = WebInspector.TextRange.fromObject(payload.range); |
| 14 } | 14 }; |
| 15 | 15 |
| 16 WebInspector.CSSValue.prototype = { | 16 WebInspector.CSSValue.prototype = { |
| 17 /** | 17 /** |
| 18 * @param {!WebInspector.CSSModel.Edit} edit | 18 * @param {!WebInspector.CSSModel.Edit} edit |
| 19 */ | 19 */ |
| 20 rebase: function(edit) | 20 rebase: function(edit) |
| 21 { | 21 { |
| 22 if (!this.range) | 22 if (!this.range) |
| 23 return; | 23 return; |
| 24 this.range = this.range.rebaseAfterTextEdit(edit.oldRange, edit.newRange
); | 24 this.range = this.range.rebaseAfterTextEdit(edit.oldRange, edit.newRange
); |
| 25 } | 25 } |
| 26 } | 26 }; |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * @constructor | 29 * @constructor |
| 30 * @param {!WebInspector.CSSModel} cssModel | 30 * @param {!WebInspector.CSSModel} cssModel |
| 31 * @param {{style: !CSSAgent.CSSStyle, styleSheetId: (string|undefined), origin:
!CSSAgent.StyleSheetOrigin}} payload | 31 * @param {{style: !CSSAgent.CSSStyle, styleSheetId: (string|undefined), origin:
!CSSAgent.StyleSheetOrigin}} payload |
| 32 */ | 32 */ |
| 33 WebInspector.CSSRule = function(cssModel, payload) | 33 WebInspector.CSSRule = function(cssModel, payload) |
| 34 { | 34 { |
| 35 this._cssModel = cssModel; | 35 this._cssModel = cssModel; |
| 36 this.styleSheetId = payload.styleSheetId; | 36 this.styleSheetId = payload.styleSheetId; |
| 37 | 37 |
| 38 if (this.styleSheetId) { | 38 if (this.styleSheetId) { |
| 39 var styleSheetHeader = cssModel.styleSheetHeaderForId(this.styleSheetId)
; | 39 var styleSheetHeader = cssModel.styleSheetHeaderForId(this.styleSheetId)
; |
| 40 this.sourceURL = styleSheetHeader.sourceURL; | 40 this.sourceURL = styleSheetHeader.sourceURL; |
| 41 } | 41 } |
| 42 this.origin = payload.origin; | 42 this.origin = payload.origin; |
| 43 this.style = new WebInspector.CSSStyleDeclaration(this._cssModel, this, payl
oad.style, WebInspector.CSSStyleDeclaration.Type.Regular); | 43 this.style = new WebInspector.CSSStyleDeclaration(this._cssModel, this, payl
oad.style, WebInspector.CSSStyleDeclaration.Type.Regular); |
| 44 } | 44 }; |
| 45 | 45 |
| 46 WebInspector.CSSRule.prototype = { | 46 WebInspector.CSSRule.prototype = { |
| 47 /** | 47 /** |
| 48 * @param {!WebInspector.CSSModel.Edit} edit | 48 * @param {!WebInspector.CSSModel.Edit} edit |
| 49 */ | 49 */ |
| 50 rebase: function(edit) | 50 rebase: function(edit) |
| 51 { | 51 { |
| 52 if (this.styleSheetId !== edit.styleSheetId) | 52 if (this.styleSheetId !== edit.styleSheetId) |
| 53 return; | 53 return; |
| 54 this.style.rebase(edit); | 54 this.style.rebase(edit); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 return this.origin === CSSAgent.StyleSheetOrigin.Inspector; | 89 return this.origin === CSSAgent.StyleSheetOrigin.Inspector; |
| 90 }, | 90 }, |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * @return {boolean} | 93 * @return {boolean} |
| 94 */ | 94 */ |
| 95 isRegular: function() | 95 isRegular: function() |
| 96 { | 96 { |
| 97 return this.origin === CSSAgent.StyleSheetOrigin.Regular; | 97 return this.origin === CSSAgent.StyleSheetOrigin.Regular; |
| 98 } | 98 } |
| 99 } | 99 }; |
| 100 | 100 |
| 101 /** | 101 /** |
| 102 * @constructor | 102 * @constructor |
| 103 * @extends {WebInspector.CSSRule} | 103 * @extends {WebInspector.CSSRule} |
| 104 * @param {!WebInspector.CSSModel} cssModel | 104 * @param {!WebInspector.CSSModel} cssModel |
| 105 * @param {!CSSAgent.CSSRule} payload | 105 * @param {!CSSAgent.CSSRule} payload |
| 106 */ | 106 */ |
| 107 WebInspector.CSSStyleRule = function(cssModel, payload) | 107 WebInspector.CSSStyleRule = function(cssModel, payload) |
| 108 { | 108 { |
| 109 WebInspector.CSSRule.call(this, cssModel, payload); | 109 WebInspector.CSSRule.call(this, cssModel, payload); |
| 110 | 110 |
| 111 this._reinitializeSelectors(payload.selectorList); | 111 this._reinitializeSelectors(payload.selectorList); |
| 112 this.media = payload.media ? WebInspector.CSSMedia.parseMediaArrayPayload(cs
sModel, payload.media) : []; | 112 this.media = payload.media ? WebInspector.CSSMedia.parseMediaArrayPayload(cs
sModel, payload.media) : []; |
| 113 } | 113 }; |
| 114 | 114 |
| 115 /** | 115 /** |
| 116 * @param {!WebInspector.CSSModel} cssModel | 116 * @param {!WebInspector.CSSModel} cssModel |
| 117 * @param {string} selectorText | 117 * @param {string} selectorText |
| 118 * @return {!WebInspector.CSSStyleRule} | 118 * @return {!WebInspector.CSSStyleRule} |
| 119 */ | 119 */ |
| 120 WebInspector.CSSStyleRule.createDummyRule = function(cssModel, selectorText) | 120 WebInspector.CSSStyleRule.createDummyRule = function(cssModel, selectorText) |
| 121 { | 121 { |
| 122 var dummyPayload = { | 122 var dummyPayload = { |
| 123 selectorList: { | 123 selectorList: { |
| 124 selectors: [{ text: selectorText}], | 124 selectors: [{ text: selectorText}], |
| 125 }, | 125 }, |
| 126 style: { | 126 style: { |
| 127 styleSheetId: "0", | 127 styleSheetId: "0", |
| 128 range: new WebInspector.TextRange(0, 0, 0, 0), | 128 range: new WebInspector.TextRange(0, 0, 0, 0), |
| 129 shorthandEntries: [], | 129 shorthandEntries: [], |
| 130 cssProperties: [] | 130 cssProperties: [] |
| 131 } | 131 } |
| 132 }; | 132 }; |
| 133 return new WebInspector.CSSStyleRule(cssModel, /** @type {!CSSAgent.CSSRule}
*/(dummyPayload)); | 133 return new WebInspector.CSSStyleRule(cssModel, /** @type {!CSSAgent.CSSRule}
*/(dummyPayload)); |
| 134 } | 134 }; |
| 135 | 135 |
| 136 WebInspector.CSSStyleRule.prototype = { | 136 WebInspector.CSSStyleRule.prototype = { |
| 137 /** | 137 /** |
| 138 * @param {!CSSAgent.SelectorList} selectorList | 138 * @param {!CSSAgent.SelectorList} selectorList |
| 139 */ | 139 */ |
| 140 _reinitializeSelectors: function(selectorList) | 140 _reinitializeSelectors: function(selectorList) |
| 141 { | 141 { |
| 142 /** @type {!Array.<!WebInspector.CSSValue>} */ | 142 /** @type {!Array.<!WebInspector.CSSValue>} */ |
| 143 this.selectors = []; | 143 this.selectors = []; |
| 144 for (var i = 0; i < selectorList.selectors.length; ++i) | 144 for (var i = 0; i < selectorList.selectors.length; ++i) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 for (var i = 0; i < this.selectors.length; ++i) | 221 for (var i = 0; i < this.selectors.length; ++i) |
| 222 this.selectors[i].rebase(edit); | 222 this.selectors[i].rebase(edit); |
| 223 } | 223 } |
| 224 for (var media of this.media) | 224 for (var media of this.media) |
| 225 media.rebase(edit); | 225 media.rebase(edit); |
| 226 | 226 |
| 227 WebInspector.CSSRule.prototype.rebase.call(this, edit); | 227 WebInspector.CSSRule.prototype.rebase.call(this, edit); |
| 228 }, | 228 }, |
| 229 | 229 |
| 230 __proto__: WebInspector.CSSRule.prototype | 230 __proto__: WebInspector.CSSRule.prototype |
| 231 } | 231 }; |
| 232 | 232 |
| 233 /** | 233 /** |
| 234 * @constructor | 234 * @constructor |
| 235 * @param {!WebInspector.CSSModel} cssModel | 235 * @param {!WebInspector.CSSModel} cssModel |
| 236 * @param {!CSSAgent.CSSKeyframesRule} payload | 236 * @param {!CSSAgent.CSSKeyframesRule} payload |
| 237 */ | 237 */ |
| 238 WebInspector.CSSKeyframesRule = function(cssModel, payload) | 238 WebInspector.CSSKeyframesRule = function(cssModel, payload) |
| 239 { | 239 { |
| 240 this._cssModel = cssModel; | 240 this._cssModel = cssModel; |
| 241 this._animationName = new WebInspector.CSSValue(payload.animationName); | 241 this._animationName = new WebInspector.CSSValue(payload.animationName); |
| 242 this._keyframes = payload.keyframes.map(keyframeRule => new WebInspector.CSS
KeyframeRule(cssModel, keyframeRule)); | 242 this._keyframes = payload.keyframes.map(keyframeRule => new WebInspector.CSS
KeyframeRule(cssModel, keyframeRule)); |
| 243 } | 243 }; |
| 244 | 244 |
| 245 WebInspector.CSSKeyframesRule.prototype = { | 245 WebInspector.CSSKeyframesRule.prototype = { |
| 246 /** | 246 /** |
| 247 * @return {!WebInspector.CSSValue} | 247 * @return {!WebInspector.CSSValue} |
| 248 */ | 248 */ |
| 249 name: function() | 249 name: function() |
| 250 { | 250 { |
| 251 return this._animationName; | 251 return this._animationName; |
| 252 }, | 252 }, |
| 253 | 253 |
| 254 /** | 254 /** |
| 255 * @return {!Array.<!WebInspector.CSSKeyframeRule>} | 255 * @return {!Array.<!WebInspector.CSSKeyframeRule>} |
| 256 */ | 256 */ |
| 257 keyframes: function() | 257 keyframes: function() |
| 258 { | 258 { |
| 259 return this._keyframes; | 259 return this._keyframes; |
| 260 } | 260 } |
| 261 } | 261 }; |
| 262 | 262 |
| 263 /** | 263 /** |
| 264 * @constructor | 264 * @constructor |
| 265 * @extends {WebInspector.CSSRule} | 265 * @extends {WebInspector.CSSRule} |
| 266 * @param {!WebInspector.CSSModel} cssModel | 266 * @param {!WebInspector.CSSModel} cssModel |
| 267 * @param {!CSSAgent.CSSKeyframeRule} payload | 267 * @param {!CSSAgent.CSSKeyframeRule} payload |
| 268 */ | 268 */ |
| 269 WebInspector.CSSKeyframeRule = function(cssModel, payload) | 269 WebInspector.CSSKeyframeRule = function(cssModel, payload) |
| 270 { | 270 { |
| 271 WebInspector.CSSRule.call(this, cssModel, payload); | 271 WebInspector.CSSRule.call(this, cssModel, payload); |
| 272 this._reinitializeKey(payload.keyText); | 272 this._reinitializeKey(payload.keyText); |
| 273 } | 273 }; |
| 274 | 274 |
| 275 WebInspector.CSSKeyframeRule.prototype = { | 275 WebInspector.CSSKeyframeRule.prototype = { |
| 276 /** | 276 /** |
| 277 * @return {!WebInspector.CSSValue} | 277 * @return {!WebInspector.CSSValue} |
| 278 */ | 278 */ |
| 279 key: function() | 279 key: function() |
| 280 { | 280 { |
| 281 return this._keyText; | 281 return this._keyText; |
| 282 }, | 282 }, |
| 283 | 283 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 314 var styleSheetId = this.styleSheetId; | 314 var styleSheetId = this.styleSheetId; |
| 315 if (!styleSheetId) | 315 if (!styleSheetId) |
| 316 throw "No rule stylesheet id"; | 316 throw "No rule stylesheet id"; |
| 317 var range = this._keyText.range; | 317 var range = this._keyText.range; |
| 318 if (!range) | 318 if (!range) |
| 319 throw "Keyframe key is not editable"; | 319 throw "Keyframe key is not editable"; |
| 320 return this._cssModel.setKeyframeKey(styleSheetId, range, newKeyText); | 320 return this._cssModel.setKeyframeKey(styleSheetId, range, newKeyText); |
| 321 }, | 321 }, |
| 322 | 322 |
| 323 __proto__: WebInspector.CSSRule.prototype | 323 __proto__: WebInspector.CSSRule.prototype |
| 324 } | 324 }; |
| OLD | NEW |