| 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 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 SDK.CSSValue = class { | 7 SDK.CSSValue = class { |
| 8 /** | 8 /** |
| 9 * @param {!Protocol.CSS.Value} payload | 9 * @param {!Protocol.CSS.Value} payload |
| 10 */ | 10 */ |
| 11 constructor(payload) { | 11 constructor(payload) { |
| 12 this.text = payload.text; | 12 this.text = payload.text; |
| 13 if (payload.range) | 13 if (payload.range) |
| 14 this.range = Common.TextRange.fromObject(payload.range); | 14 this.range = TextUtils.TextRange.fromObject(payload.range); |
| 15 } | 15 } |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * @param {!SDK.CSSModel.Edit} edit | 18 * @param {!SDK.CSSModel.Edit} edit |
| 19 */ | 19 */ |
| 20 rebase(edit) { | 20 rebase(edit) { |
| 21 if (!this.range) | 21 if (!this.range) |
| 22 return; | 22 return; |
| 23 this.range = this.range.rebaseAfterTextEdit(edit.oldRange, edit.newRange); | 23 this.range = this.range.rebaseAfterTextEdit(edit.oldRange, edit.newRange); |
| 24 } | 24 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 /** | 119 /** |
| 120 * @param {!SDK.CSSModel} cssModel | 120 * @param {!SDK.CSSModel} cssModel |
| 121 * @param {string} selectorText | 121 * @param {string} selectorText |
| 122 * @return {!SDK.CSSStyleRule} | 122 * @return {!SDK.CSSStyleRule} |
| 123 */ | 123 */ |
| 124 static createDummyRule(cssModel, selectorText) { | 124 static createDummyRule(cssModel, selectorText) { |
| 125 var dummyPayload = { | 125 var dummyPayload = { |
| 126 selectorList: { | 126 selectorList: { |
| 127 selectors: [{text: selectorText}], | 127 selectors: [{text: selectorText}], |
| 128 }, | 128 }, |
| 129 style: {styleSheetId: '0', range: new Common.TextRange(0, 0, 0, 0), shorth
andEntries: [], cssProperties: []} | 129 style: {styleSheetId: '0', range: new TextUtils.TextRange(0, 0, 0, 0), sho
rthandEntries: [], cssProperties: []} |
| 130 }; | 130 }; |
| 131 return new SDK.CSSStyleRule(cssModel, /** @type {!Protocol.CSS.CSSRule} */ (
dummyPayload)); | 131 return new SDK.CSSStyleRule(cssModel, /** @type {!Protocol.CSS.CSSRule} */ (
dummyPayload)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 /** | 134 /** |
| 135 * @param {!Protocol.CSS.SelectorList} selectorList | 135 * @param {!Protocol.CSS.SelectorList} selectorList |
| 136 */ | 136 */ |
| 137 _reinitializeSelectors(selectorList) { | 137 _reinitializeSelectors(selectorList) { |
| 138 /** @type {!Array.<!SDK.CSSValue>} */ | 138 /** @type {!Array.<!SDK.CSSValue>} */ |
| 139 this.selectors = []; | 139 this.selectors = []; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 156 } | 156 } |
| 157 | 157 |
| 158 /** | 158 /** |
| 159 * @return {string} | 159 * @return {string} |
| 160 */ | 160 */ |
| 161 selectorText() { | 161 selectorText() { |
| 162 return this.selectors.select('text').join(', '); | 162 return this.selectors.select('text').join(', '); |
| 163 } | 163 } |
| 164 | 164 |
| 165 /** | 165 /** |
| 166 * @return {?Common.TextRange} | 166 * @return {?TextUtils.TextRange} |
| 167 */ | 167 */ |
| 168 selectorRange() { | 168 selectorRange() { |
| 169 var firstRange = this.selectors[0].range; | 169 var firstRange = this.selectors[0].range; |
| 170 if (!firstRange) | 170 if (!firstRange) |
| 171 return null; | 171 return null; |
| 172 var lastRange = this.selectors.peekLast().range; | 172 var lastRange = this.selectors.peekLast().range; |
| 173 return new Common.TextRange(firstRange.startLine, firstRange.startColumn, la
stRange.endLine, lastRange.endColumn); | 173 return new TextUtils.TextRange( |
| 174 firstRange.startLine, firstRange.startColumn, lastRange.endLine, lastRan
ge.endColumn); |
| 174 } | 175 } |
| 175 | 176 |
| 176 /** | 177 /** |
| 177 * @param {number} selectorIndex | 178 * @param {number} selectorIndex |
| 178 * @return {number} | 179 * @return {number} |
| 179 */ | 180 */ |
| 180 lineNumberInSource(selectorIndex) { | 181 lineNumberInSource(selectorIndex) { |
| 181 var selector = this.selectors[selectorIndex]; | 182 var selector = this.selectors[selectorIndex]; |
| 182 if (!selector || !selector.range || !this.styleSheetId) | 183 if (!selector || !selector.range || !this.styleSheetId) |
| 183 return 0; | 184 return 0; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 setKeyText(newKeyText) { | 298 setKeyText(newKeyText) { |
| 298 var styleSheetId = this.styleSheetId; | 299 var styleSheetId = this.styleSheetId; |
| 299 if (!styleSheetId) | 300 if (!styleSheetId) |
| 300 throw 'No rule stylesheet id'; | 301 throw 'No rule stylesheet id'; |
| 301 var range = this._keyText.range; | 302 var range = this._keyText.range; |
| 302 if (!range) | 303 if (!range) |
| 303 throw 'Keyframe key is not editable'; | 304 throw 'Keyframe key is not editable'; |
| 304 return this._cssModel.setKeyframeKey(styleSheetId, range, newKeyText); | 305 return this._cssModel.setKeyframeKey(styleSheetId, range, newKeyText); |
| 305 } | 306 } |
| 306 }; | 307 }; |
| OLD | NEW |