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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sources/CSSSourceFrame.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sources/CSSSourceFrame.js b/third_party/WebKit/Source/devtools/front_end/sources/CSSSourceFrame.js
index b05b027e29361ea41dbbb255169864db87e21ffa..4934e7b084785ca274f7a92a0620dd4dc85e4397 100644
--- a/third_party/WebKit/Source/devtools/front_end/sources/CSSSourceFrame.js
+++ b/third_party/WebKit/Source/devtools/front_end/sources/CSSSourceFrame.js
@@ -166,10 +166,11 @@ WebInspector.CSSSourceFrame.prototype = {
*/
_createColorSwatch: function(text)
{
- if (!WebInspector.Color.parse(text))
+ var color = WebInspector.Color.parse(text);
+ if (!color)
return null;
var swatch = WebInspector.ColorSwatch.create();
- swatch.setColorText(text);
+ swatch.setColor(color);
swatch.iconElement().title = WebInspector.UIString("Open color picker.");
swatch.iconElement().addEventListener("click", this._swatchIconClicked.bind(this, swatch), false);
swatch.hideText(true);
@@ -241,7 +242,10 @@ WebInspector.CSSSourceFrame.prototype = {
_spectrumChanged: function(event)
{
var colorString = /** @type {string} */ (event.data);
lushnikov 2016/09/09 00:16:42 spectrm should've fired a Color objects here, but
- this._currentSwatch.setColorText(colorString);
+ var color = WebInspector.Color.parse(colorString);
+ if (!color)
+ return;
+ this._currentSwatch.setColor(color);
this._changeSwatchText(colorString);
},

Powered by Google App Engine
This is Rietveld 408576698