Chromium Code Reviews| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 | 175 |
| 176 /** | 176 /** |
| 177 * @param {!WebInspector.ColorSwatch} swatch | 177 * @param {!WebInspector.ColorSwatch} swatch |
| 178 * @param {!WebInspector.CSSSourceFrame.ColorPosition} colorPosition | 178 * @param {!WebInspector.CSSSourceFrame.ColorPosition} colorPosition |
| 179 * @param {!Event} event | 179 * @param {!Event} event |
| 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(true); |
| 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.textEditor.setSelection(WebInspector.TextRange.createFromLocation(c olorPosition.textRange.startLine, colorPosition.textRange.startColumn)); |
| 191 this._spectrum = new WebInspector.Spectrum(); | 191 this._spectrum = new WebInspector.Spectrum(); |
| 192 this._spectrum.setColor(swatch.color(), swatch.format()); | 192 this._spectrum.setColor(swatch.color(), swatch.format()); |
| 193 this._spectrum.addEventListener(WebInspector.Spectrum.Events.SizeChanged , this._spectrumResized, this); | 193 this._spectrum.addEventListener(WebInspector.Spectrum.Events.SizeChanged , this._spectrumResized, this); |
| 194 this._spectrum.addEventListener(WebInspector.Spectrum.Events.ColorChange d, this._spectrumChanged, this); | 194 this._spectrum.addEventListener(WebInspector.Spectrum.Events.ColorChange d, this._spectrumChanged, this); |
| 195 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)); |
| 196 }, | 196 }, |
| 197 | 197 |
| 198 /** | 198 /** |
| 199 * @param {!WebInspector.Event} event | 199 * @param {!WebInspector.Event} event |
| 200 */ | 200 */ |
| 201 _spectrumResized: function(event) | 201 _spectrumResized: function(event) |
| 202 { | 202 { |
| 203 this._swatchPopoverHelper.reposition(); | 203 this._swatchPopoverHelper.reposition(); |
| 204 }, | 204 }, |
| 205 | 205 |
| 206 /** | 206 /** |
| 207 * @param {!WebInspector.Event} event | 207 * @param {!WebInspector.Event} event |
| 208 */ | 208 */ |
| 209 _spectrumChanged: function(event) | 209 _spectrumChanged: function(event) |
| 210 { | 210 { |
| 211 this._muteColorProcessing = true; | 211 this._muteColorProcessing = true; |
| 212 this._spectrumChangeOccurred = true; | |
|
lushnikov
2016/07/22 04:58:17
this._hadSpectrumChange = true;
flandy
2016/07/22 15:56:09
Done.
| |
| 212 var colorString = /** @type {string} */ (event.data); | 213 var colorString = /** @type {string} */ (event.data); |
| 213 this._currentSwatch.setColorText(colorString); | 214 this._currentSwatch.setColorText(colorString); |
| 214 this._textEditor.editRange(this._currentColorPosition.textRange, colorSt ring, "*color-text-changed"); | 215 this.textEditor.editRange(this._currentColorPosition.textRange, colorStr ing, "*color-text-changed"); |
| 215 this._currentColorPosition.color = WebInspector.Color.parse(colorString) ; | 216 this._currentColorPosition.color = WebInspector.Color.parse(colorString) ; |
| 216 this._currentColorPosition.textRange.endColumn = this._currentColorPosit ion.textRange.startColumn + colorString.length; | 217 this._currentColorPosition.textRange.endColumn = this._currentColorPosit ion.textRange.startColumn + colorString.length; |
| 217 }, | 218 }, |
| 218 | 219 |
| 219 _spectrumHidden: function() | 220 /** |
| 221 * @param {boolean} commitEdit | |
| 222 */ | |
| 223 _spectrumHidden: function(commitEdit) | |
| 220 { | 224 { |
| 221 this._muteColorProcessing = false; | |
| 222 this._spectrum.removeEventListener(WebInspector.Spectrum.Events.SizeChan ged, this._spectrumResized, this); | 225 this._spectrum.removeEventListener(WebInspector.Spectrum.Events.SizeChan ged, this._spectrumResized, this); |
| 223 this._spectrum.removeEventListener(WebInspector.Spectrum.Events.ColorCha nged, this._spectrumChanged, this); | 226 this._spectrum.removeEventListener(WebInspector.Spectrum.Events.ColorCha nged, this._spectrumChanged, this); |
| 227 if (!commitEdit && this._spectrumChangeOccurred) | |
| 228 this.textEditor.undo(); | |
| 224 delete this._spectrum; | 229 delete this._spectrum; |
| 230 delete this._currentSwatch; | |
| 231 delete this._currentColorPosition; | |
| 232 delete this._spectrumChangeOccurred; | |
|
lushnikov
2016/07/22 04:58:17
i'd rather initialize spectrumChangeOccured in _sh
flandy
2016/07/22 15:56:08
Done.
| |
| 233 this._muteColorProcessing = false; | |
| 225 this._updateColorSwatches(); | 234 this._updateColorSwatches(); |
| 226 }, | 235 }, |
| 227 | 236 |
| 228 /** | 237 /** |
| 229 * @override | 238 * @override |
| 230 */ | 239 */ |
| 231 onTextEditorContentSet: function() | 240 onTextEditorContentSet: function() |
| 232 { | 241 { |
| 233 WebInspector.UISourceCodeFrame.prototype.onTextEditorContentSet.call(thi s); | 242 WebInspector.UISourceCodeFrame.prototype.onTextEditorContentSet.call(thi s); |
| 234 if (!this._muteColorProcessing && Runtime.experiments.isEnabled("sourceC olorPicker")) | 243 if (!this._muteColorProcessing && Runtime.experiments.isEnabled("sourceC olorPicker")) |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 251 }, | 260 }, |
| 252 | 261 |
| 253 /** | 262 /** |
| 254 * @override | 263 * @override |
| 255 * @param {number} lineNumber | 264 * @param {number} lineNumber |
| 256 */ | 265 */ |
| 257 scrollChanged: function(lineNumber) | 266 scrollChanged: function(lineNumber) |
| 258 { | 267 { |
| 259 WebInspector.UISourceCodeFrame.prototype.scrollChanged.call(this, lineNu mber); | 268 WebInspector.UISourceCodeFrame.prototype.scrollChanged.call(this, lineNu mber); |
| 260 if (this._swatchPopoverHelper.isShowing()) | 269 if (this._swatchPopoverHelper.isShowing()) |
| 261 this._swatchPopoverHelper.hide(); | 270 this._swatchPopoverHelper.hide(true); |
| 262 }, | 271 }, |
| 263 | 272 |
| 264 __proto__: WebInspector.UISourceCodeFrame.prototype | 273 __proto__: WebInspector.UISourceCodeFrame.prototype |
| 265 } | 274 } |
| 266 | 275 |
| 267 /** | 276 /** |
| 268 * @constructor | 277 * @constructor |
| 269 * @param {!WebInspector.Color} color | 278 * @param {!WebInspector.Color} color |
| 270 * @param {number} lineNumber | 279 * @param {number} lineNumber |
| 271 * @param {number} startColumn | 280 * @param {number} startColumn |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 var propertyToken = this._backtrackPropertyToken(editor, prefixRange.sta rtLine, prefixRange.startColumn - 1); | 374 var propertyToken = this._backtrackPropertyToken(editor, prefixRange.sta rtLine, prefixRange.startColumn - 1); |
| 366 if (!propertyToken) | 375 if (!propertyToken) |
| 367 return this._simpleDelegate.wordsWithPrefix(editor, prefixRange, sub stituteRange); | 376 return this._simpleDelegate.wordsWithPrefix(editor, prefixRange, sub stituteRange); |
| 368 | 377 |
| 369 var line = editor.line(prefixRange.startLine); | 378 var line = editor.line(prefixRange.startLine); |
| 370 var tokenContent = line.substring(propertyToken.startColumn, propertyTok en.endColumn); | 379 var tokenContent = line.substring(propertyToken.startColumn, propertyTok en.endColumn); |
| 371 var keywords = WebInspector.CSSMetadata.keywordsForProperty(tokenContent ); | 380 var keywords = WebInspector.CSSMetadata.keywordsForProperty(tokenContent ); |
| 372 return keywords.startsWith(prefix); | 381 return keywords.startsWith(prefix); |
| 373 }, | 382 }, |
| 374 } | 383 } |
| OLD | NEW |