Index: third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js b/third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js |
index da94dcc7ded3ed81af9008d31ac1751125d0717a..43501e32f47d307a8860ec6be7106a63a38bf1c5 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js |
+++ b/third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js |
@@ -1960,7 +1960,10 @@ WebInspector.StylePropertyTreeElement.prototype = { |
} |
var swatchPopoverHelper = this._parentPane._swatchPopoverHelper; |
- var swatchIcon = new WebInspector.ColorSwatchPopoverIcon(this, swatchPopoverHelper, text); |
+ var colorSwatch = WebInspector.ColorSwatch.create(); |
+ colorSwatch.setColorText(text); |
+ colorSwatch.setFormat(WebInspector.Color.detectColorFormat(colorSwatch.color())); |
+ var swatchPopoverIcon = new WebInspector.ColorSwatchPopoverIcon(this, swatchPopoverHelper, colorSwatch); |
/** |
* @param {?Array<string>} backgroundColors |
@@ -1986,7 +1989,7 @@ WebInspector.StylePropertyTreeElement.prototype = { |
bgColor = new WebInspector.Color(blendedRGBA, WebInspector.Color.Format.RGBA); |
} |
- swatchIcon.setContrastColor(bgColor); |
+ swatchPopoverIcon.setContrastColor(bgColor); |
} |
if (this.property.name === "color" && this._parentPane.cssModel() && this.node()) { |
@@ -1994,7 +1997,7 @@ WebInspector.StylePropertyTreeElement.prototype = { |
cssModel.backgroundColorsPromise(this.node().id).then(computedCallback); |
} |
- return swatchIcon.element(); |
+ return colorSwatch; |
}, |
/** |
@@ -2018,6 +2021,33 @@ WebInspector.StylePropertyTreeElement.prototype = { |
return new WebInspector.BezierPopoverIcon(this, swatchPopoverHelper, text).element(); |
}, |
+ /** |
+ * @param {string} propertyValue |
+ * @param {string} propertyName |
+ * @return {!Node} |
+ */ |
+ _processShadow: function(propertyValue, propertyName) |
+ { |
+ var shadows; |
+ if (propertyName === "box-shadow") |
+ shadows = WebInspector.CSSShadowModel.parseBoxShadow(propertyValue); |
+ else |
+ shadows = WebInspector.CSSShadowModel.parseTextShadow(propertyValue); |
+ if (!shadows || !this._editable()) |
+ return createTextNode(propertyValue); |
+ var container = createDocumentFragment(); |
+ var swatchPopoverHelper = this._parentPane._swatchPopoverHelper; |
+ for (var i = 0; i < shadows.length; i++) { |
+ if (i !== 0) |
+ container.appendChild(createTextNode(", ")); // Add back commas and spaces between each shadow. |
+ var cssShadowSwatch = WebInspector.CSSShadowSwatch.create(); |
+ cssShadowSwatch.setCSSShadow(shadows[i]); |
+ new WebInspector.ColorSwatchPopoverIcon(this, swatchPopoverHelper, cssShadowSwatch.colorSwatch()); |
+ container.appendChild(cssShadowSwatch); |
+ } |
+ return container; |
+ }, |
+ |
_updateState: function() |
{ |
if (!this.listItemElement) |
@@ -2181,6 +2211,7 @@ WebInspector.StylePropertyTreeElement.prototype = { |
if (this.property.parsedOk) { |
propertyRenderer.setColorHandler(this._processColor.bind(this)); |
propertyRenderer.setBezierHandler(this._processBezier.bind(this)); |
+ propertyRenderer.setShadowHandler(this._processShadow.bind(this)); |
} |
this.listItemElement.removeChildren(); |
@@ -2992,6 +3023,14 @@ WebInspector.StylesSidebarPropertyRenderer.prototype = { |
}, |
/** |
+ * @param {function(string, string):!Node} handler |
+ */ |
+ setShadowHandler: function(handler) |
+ { |
+ this._shadowHandler = handler; |
+ }, |
+ |
+ /** |
* @return {!Element} |
*/ |
renderName: function() |
@@ -3013,6 +3052,13 @@ WebInspector.StylesSidebarPropertyRenderer.prototype = { |
if (!this._propertyValue) |
return valueElement; |
+ if (this._shadowHandler && (this._propertyName === "box-shadow" || this._propertyName === "text-shadow") |
+ && !WebInspector.CSSMetadata.VariableRegex.test(this._propertyValue) && Runtime.experiments.isEnabled("shadowEditor")) { |
+ valueElement.appendChild(this._shadowHandler(this._propertyValue, this._propertyName)); |
+ valueElement.normalize(); |
+ return valueElement; |
+ } |
+ |
var regexes = [WebInspector.CSSMetadata.VariableRegex, WebInspector.CSSMetadata.URLRegex]; |
var processors = [createTextNode, this._processURL.bind(this)]; |
if (this._bezierHandler && WebInspector.cssMetadata().isBezierAwareProperty(this._propertyName)) { |