OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 */ | 180 */ |
181 _showSpectrum: function(swatch, colorPosition, event) | 181 _showSpectrum: function(swatch, colorPosition, event) |
182 { | 182 { |
183 event.consume(true); | 183 event.consume(true); |
184 if (this._swatchPopoverHelper.isShowing()) { | 184 if (this._swatchPopoverHelper.isShowing()) { |
185 this._swatchPopoverHelper.hide(); | 185 this._swatchPopoverHelper.hide(); |
186 return; | 186 return; |
187 } | 187 } |
188 this._currentSwatch = swatch; | 188 this._currentSwatch = swatch; |
189 this._currentColorPosition = colorPosition; | 189 this._currentColorPosition = colorPosition; |
190 this.textEditor.setSelection(WebInspector.TextRange.createFromLocation(c olorPosition.textRange.startLine, colorPosition.textRange.startColumn)); | |
190 this._spectrum = new WebInspector.Spectrum(); | 191 this._spectrum = new WebInspector.Spectrum(); |
191 this._spectrum.setColor(swatch.color(), swatch.format()); | 192 this._spectrum.setColor(swatch.color(), swatch.format()); |
192 this._spectrum.addEventListener(WebInspector.Spectrum.Events.SizeChanged , this._spectrumResized, this); | 193 this._spectrum.addEventListener(WebInspector.Spectrum.Events.SizeChanged , this._spectrumResized, this); |
193 this._spectrum.addEventListener(WebInspector.Spectrum.Events.ColorChange d, this._spectrumChanged, this); | 194 this._spectrum.addEventListener(WebInspector.Spectrum.Events.ColorChange d, this._spectrumChanged, this); |
194 this._swatchPopoverHelper.show(this._spectrum, swatch.iconElement(), thi s._spectrumHidden.bind(this)); | 195 this._swatchPopoverHelper.show(this._spectrum, swatch.iconElement(), thi s._spectrumHidden.bind(this)); |
195 }, | 196 }, |
196 | 197 |
197 /** | 198 /** |
198 * @param {!WebInspector.Event} event | 199 * @param {!WebInspector.Event} event |
199 */ | 200 */ |
200 _spectrumResized: function(event) | 201 _spectrumResized: function(event) |
201 { | 202 { |
202 this._swatchPopoverHelper.reposition(); | 203 this._swatchPopoverHelper.reposition(); |
203 }, | 204 }, |
204 | 205 |
205 /** | 206 /** |
206 * @param {!WebInspector.Event} event | 207 * @param {!WebInspector.Event} event |
207 */ | 208 */ |
208 _spectrumChanged: function(event) | 209 _spectrumChanged: function(event) |
209 { | 210 { |
210 this._muteColorProcessing = true; | 211 this._muteColorProcessing = true; |
211 var colorString = /** @type {string} */ (event.data); | 212 var colorString = /** @type {string} */ (event.data); |
212 this._currentSwatch.setColorText(colorString); | 213 this._currentSwatch.setColorText(colorString); |
213 this._textEditor.editRange(this._currentColorPosition.textRange, colorSt ring); | 214 this._textEditor.editRange(this._currentColorPosition.textRange, colorSt ring, "*color-text-changed"); |
lushnikov
2016/07/21 17:55:39
what is "*" in the beginning? Can me remove it unl
flandy
2016/07/21 18:00:52
The star is necessary as it is used by CodeMirror
flandy
2016/07/21 20:01:51
*change history event
| |
214 this._currentColorPosition.color = WebInspector.Color.parse(colorString) ; | 215 this._currentColorPosition.color = WebInspector.Color.parse(colorString) ; |
215 this._currentColorPosition.textRange.endColumn = this._currentColorPosit ion.textRange.startColumn + colorString.length; | 216 this._currentColorPosition.textRange.endColumn = this._currentColorPosit ion.textRange.startColumn + colorString.length; |
216 }, | 217 }, |
217 | 218 |
218 _spectrumHidden: function() | 219 _spectrumHidden: function() |
219 { | 220 { |
220 this._muteColorProcessing = false; | 221 this._muteColorProcessing = false; |
221 this._spectrum.removeEventListener(WebInspector.Spectrum.Events.SizeChan ged, this._spectrumResized, this); | 222 this._spectrum.removeEventListener(WebInspector.Spectrum.Events.SizeChan ged, this._spectrumResized, this); |
222 this._spectrum.removeEventListener(WebInspector.Spectrum.Events.ColorCha nged, this._spectrumChanged, this); | 223 this._spectrum.removeEventListener(WebInspector.Spectrum.Events.ColorCha nged, this._spectrumChanged, this); |
223 delete this._spectrum; | 224 delete this._spectrum; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 var propertyToken = this._backtrackPropertyToken(editor, prefixRange.sta rtLine, prefixRange.startColumn - 1); | 365 var propertyToken = this._backtrackPropertyToken(editor, prefixRange.sta rtLine, prefixRange.startColumn - 1); |
365 if (!propertyToken) | 366 if (!propertyToken) |
366 return this._simpleDelegate.wordsWithPrefix(editor, prefixRange, sub stituteRange); | 367 return this._simpleDelegate.wordsWithPrefix(editor, prefixRange, sub stituteRange); |
367 | 368 |
368 var line = editor.line(prefixRange.startLine); | 369 var line = editor.line(prefixRange.startLine); |
369 var tokenContent = line.substring(propertyToken.startColumn, propertyTok en.endColumn); | 370 var tokenContent = line.substring(propertyToken.startColumn, propertyTok en.endColumn); |
370 var keywords = WebInspector.CSSMetadata.keywordsForProperty(tokenContent ); | 371 var keywords = WebInspector.CSSMetadata.keywordsForProperty(tokenContent ); |
371 return keywords.startsWith(prefix); | 372 return keywords.startsWith(prefix); |
372 }, | 373 }, |
373 } | 374 } |
OLD | NEW |