Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/CSSSourceFrame.js

Issue 2171003002: DevTools: Allow ESC for source color picker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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._hadSpectrumChange = false;
188 this._currentSwatch = swatch; 189 this._currentSwatch = swatch;
189 this._currentColorPosition = colorPosition; 190 this._currentColorPosition = colorPosition;
190 this.textEditor.setSelection(WebInspector.TextRange.createFromLocation(c olorPosition.textRange.startLine, colorPosition.textRange.startColumn)); 191 this.textEditor.setSelection(WebInspector.TextRange.createFromLocation(c olorPosition.textRange.startLine, colorPosition.textRange.startColumn));
191 this._spectrum = new WebInspector.Spectrum(); 192 this._spectrum = new WebInspector.Spectrum();
192 this._spectrum.setColor(swatch.color(), swatch.format()); 193 this._spectrum.setColor(swatch.color(), swatch.format());
193 this._spectrum.addEventListener(WebInspector.Spectrum.Events.SizeChanged , this._spectrumResized, this); 194 this._spectrum.addEventListener(WebInspector.Spectrum.Events.SizeChanged , this._spectrumResized, this);
194 this._spectrum.addEventListener(WebInspector.Spectrum.Events.ColorChange d, this._spectrumChanged, this); 195 this._spectrum.addEventListener(WebInspector.Spectrum.Events.ColorChange d, this._spectrumChanged, this);
195 this._swatchPopoverHelper.show(this._spectrum, swatch.iconElement(), thi s._spectrumHidden.bind(this)); 196 this._swatchPopoverHelper.show(this._spectrum, swatch.iconElement(), thi s._spectrumHidden.bind(this));
196 }, 197 },
197 198
198 /** 199 /**
199 * @param {!WebInspector.Event} event 200 * @param {!WebInspector.Event} event
200 */ 201 */
201 _spectrumResized: function(event) 202 _spectrumResized: function(event)
202 { 203 {
203 this._swatchPopoverHelper.reposition(); 204 this._swatchPopoverHelper.reposition();
204 }, 205 },
205 206
206 /** 207 /**
207 * @param {!WebInspector.Event} event 208 * @param {!WebInspector.Event} event
208 */ 209 */
209 _spectrumChanged: function(event) 210 _spectrumChanged: function(event)
210 { 211 {
211 this._muteColorProcessing = true; 212 this._muteColorProcessing = true;
213 this._hadSpectrumChange = true;
212 var colorString = /** @type {string} */ (event.data); 214 var colorString = /** @type {string} */ (event.data);
213 this._currentSwatch.setColorText(colorString); 215 this._currentSwatch.setColorText(colorString);
214 this._textEditor.editRange(this._currentColorPosition.textRange, colorSt ring, "*color-text-changed"); 216 this.textEditor.editRange(this._currentColorPosition.textRange, colorStr ing, "*color-text-changed");
215 this._currentColorPosition.color = WebInspector.Color.parse(colorString) ; 217 this._currentColorPosition.color = WebInspector.Color.parse(colorString) ;
216 this._currentColorPosition.textRange.endColumn = this._currentColorPosit ion.textRange.startColumn + colorString.length; 218 this._currentColorPosition.textRange.endColumn = this._currentColorPosit ion.textRange.startColumn + colorString.length;
217 }, 219 },
218 220
219 _spectrumHidden: function() 221 /**
222 * @param {boolean} commitEdit
223 */
224 _spectrumHidden: function(commitEdit)
220 { 225 {
221 this._muteColorProcessing = false;
222 this._spectrum.removeEventListener(WebInspector.Spectrum.Events.SizeChan ged, this._spectrumResized, this); 226 this._spectrum.removeEventListener(WebInspector.Spectrum.Events.SizeChan ged, this._spectrumResized, this);
223 this._spectrum.removeEventListener(WebInspector.Spectrum.Events.ColorCha nged, this._spectrumChanged, this); 227 this._spectrum.removeEventListener(WebInspector.Spectrum.Events.ColorCha nged, this._spectrumChanged, this);
228 if (!commitEdit && this._hadSpectrumChange)
229 this.textEditor.undo();
224 delete this._spectrum; 230 delete this._spectrum;
231 delete this._currentSwatch;
232 delete this._currentColorPosition;
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698