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

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/ColorSwatch.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/ui/ColorSwatch.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/ColorSwatch.js b/third_party/WebKit/Source/devtools/front_end/ui/ColorSwatch.js
index 1665dc731302450d80a868f536c87612d126b59d..fc5a8e12ba30bf29a1349c4d264fd6f22bc19008 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/ColorSwatch.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/ColorSwatch.js
@@ -31,15 +31,15 @@ WebInspector.ColorSwatch.prototype = {
},
/**
- * @param {string} colorText
+ * @param {!WebInspector.Color} color
*/
- setColorText: function(colorText)
+ setColor: function(color)
{
- this._color = WebInspector.Color.parse(colorText);
- console.assert(this._color, "Color text could not be parsed.");
+ this._color = color;
this._format = this._color.format();
- this._colorValueElement.textContent = this._color.asString(this._format);
- this._swatchInner.style.backgroundColor = colorText;
+ var colorString = this._color.asString(this._format);
+ this._colorValueElement.textContent = colorString;
+ this._swatchInner.style.backgroundColor = colorString;
},
/**
@@ -97,8 +97,6 @@ WebInspector.ColorSwatch.prototype = {
root.createChild("content");
this._colorValueElement = this.createChild("span");
-
- this.setColorText("white");
},
/**
@@ -261,14 +259,14 @@ WebInspector.CSSShadowSwatch.prototype = {
setCSSShadow: function(model)
{
this._model = model;
- this._colorSwatch = null;
this._contentElement.removeChildren();
var results = WebInspector.TextUtils.splitStringByRegexes(model.asCSSText(), [/inset/g, WebInspector.Color.Regex]);
for (var i = 0; i < results.length; i++) {
var result = results[i];
if (result.regexIndex === 1) {
- this._colorSwatch = WebInspector.ColorSwatch.create();
- this._colorSwatch.setColorText(result.value);
+ if (!this._colorSwatch)
+ this._colorSwatch = WebInspector.ColorSwatch.create();
+ this._colorSwatch.setColor(model.color());
this._contentElement.appendChild(this._colorSwatch);
} else {
this._contentElement.appendChild(createTextNode(result.value));
@@ -293,7 +291,7 @@ WebInspector.CSSShadowSwatch.prototype = {
},
/**
- * @return {!WebInspector.ColorSwatch}
+ * @return {?WebInspector.ColorSwatch}
*/
colorSwatch: function()
{

Powered by Google App Engine
This is Rietveld 408576698