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

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

Issue 2310633002: DevTools: Reduce color parsing by passing in Color to ColorSwatch (Closed)
Patch Set: Get color from model Created 4 years, 3 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
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 159 }
160 } 160 }
161 }, 161 },
162 162
163 /** 163 /**
164 * @param {string} text 164 * @param {string} text
165 * @return {?WebInspector.ColorSwatch} 165 * @return {?WebInspector.ColorSwatch}
166 */ 166 */
167 _createColorSwatch: function(text) 167 _createColorSwatch: function(text)
168 { 168 {
169 if (!WebInspector.Color.parse(text)) 169 var color = WebInspector.Color.parse(text);
170 if (!color)
170 return null; 171 return null;
171 var swatch = WebInspector.ColorSwatch.create(); 172 var swatch = WebInspector.ColorSwatch.create();
172 swatch.setColorText(text); 173 swatch.setColor(color);
173 swatch.iconElement().title = WebInspector.UIString("Open color picker.") ; 174 swatch.iconElement().title = WebInspector.UIString("Open color picker.") ;
174 swatch.iconElement().addEventListener("click", this._swatchIconClicked.b ind(this, swatch), false); 175 swatch.iconElement().addEventListener("click", this._swatchIconClicked.b ind(this, swatch), false);
175 swatch.hideText(true); 176 swatch.hideText(true);
176 return swatch; 177 return swatch;
177 }, 178 },
178 179
179 /** 180 /**
180 * @param {string} text 181 * @param {string} text
181 * @return {?WebInspector.BezierSwatch} 182 * @return {?WebInspector.BezierSwatch}
182 */ 183 */
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 _spectrumResized: function(event) 234 _spectrumResized: function(event)
234 { 235 {
235 this._swatchPopoverHelper.reposition(); 236 this._swatchPopoverHelper.reposition();
236 }, 237 },
237 238
238 /** 239 /**
239 * @param {!WebInspector.Event} event 240 * @param {!WebInspector.Event} event
240 */ 241 */
241 _spectrumChanged: function(event) 242 _spectrumChanged: function(event)
242 { 243 {
243 var colorString = /** @type {string} */ (event.data); 244 var colorString = /** @type {string} */ (event.data);
lushnikov 2016/09/09 00:16:42 spectrm should've fired a Color objects here, but
244 this._currentSwatch.setColorText(colorString); 245 var color = WebInspector.Color.parse(colorString);
246 if (!color)
247 return;
248 this._currentSwatch.setColor(color);
245 this._changeSwatchText(colorString); 249 this._changeSwatchText(colorString);
246 }, 250 },
247 251
248 /** 252 /**
249 * @param {!WebInspector.BezierSwatch} swatch 253 * @param {!WebInspector.BezierSwatch} swatch
250 */ 254 */
251 _showBezierEditor: function(swatch) 255 _showBezierEditor: function(swatch)
252 { 256 {
253 if (!this._bezierEditor) { 257 if (!this._bezierEditor) {
254 this._bezierEditor = new WebInspector.BezierEditor(); 258 this._bezierEditor = new WebInspector.BezierEditor();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 else 385 else
382 return null; 386 return null;
383 } 387 }
384 tokenPosition = token.startColumn - 1; 388 tokenPosition = token.startColumn - 1;
385 } 389 }
386 return null; 390 return null;
387 }, 391 },
388 392
389 __proto__: WebInspector.UISourceCodeFrame.prototype 393 __proto__: WebInspector.UISourceCodeFrame.prototype
390 } 394 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698