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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js

Issue 2230183004: DevTools: Add shadow-editor swatch/icon before box-shadows and text-shadows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: New image swatches.png Created 4 years, 4 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) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 */ 2011 */
2012 _processBezier: function(text) 2012 _processBezier: function(text)
2013 { 2013 {
2014 var geometry = WebInspector.Geometry.CubicBezier.parse(text); 2014 var geometry = WebInspector.Geometry.CubicBezier.parse(text);
2015 if (!geometry || !this._editable()) 2015 if (!geometry || !this._editable())
2016 return createTextNode(text); 2016 return createTextNode(text);
2017 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper; 2017 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper;
2018 return new WebInspector.BezierPopoverIcon(this, swatchPopoverHelper, tex t).element(); 2018 return new WebInspector.BezierPopoverIcon(this, swatchPopoverHelper, tex t).element();
2019 }, 2019 },
2020 2020
2021 /**
2022 * @param {string} propertyValue
2023 * @param {string} propertyName
2024 * @return {!Node}
2025 */
2026 _processShadow: function(propertyValue, propertyName)
2027 {
2028 if (!this._editable())
2029 return createTextNode(propertyValue);
2030
2031 var shadowValues = WebInspector.ShadowEditor.Shadow.splitShadows(propert yValue);
2032 var container = createDocumentFragment();
2033 for (var i = 0; i < shadowValues.length; i++) {
2034 if (i !== 0)
2035 container.appendChild(createTextNode(",")); // Add back the remo ved commas.
2036 var shadowPopoverIcon = new WebInspector.ShadowPopoverIcon(this, thi s._parentPane._swatchPopoverHelper, shadowValues[i], propertyName);
2037 container.appendChild(shadowPopoverIcon.element());
2038 }
2039 return container;
2040 },
2041
2021 _updateState: function() 2042 _updateState: function()
2022 { 2043 {
2023 if (!this.listItemElement) 2044 if (!this.listItemElement)
2024 return; 2045 return;
2025 2046
2026 if (this._style.isPropertyImplicit(this.name)) 2047 if (this._style.isPropertyImplicit(this.name))
2027 this.listItemElement.classList.add("implicit"); 2048 this.listItemElement.classList.add("implicit");
2028 else 2049 else
2029 this.listItemElement.classList.remove("implicit"); 2050 this.listItemElement.classList.remove("implicit");
2030 2051
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 updateTitle: function() 2195 updateTitle: function()
2175 { 2196 {
2176 this._updateState(); 2197 this._updateState();
2177 this._expandElement = createElement("span"); 2198 this._expandElement = createElement("span");
2178 this._expandElement.className = "expand-element"; 2199 this._expandElement.className = "expand-element";
2179 2200
2180 var propertyRenderer = new WebInspector.StylesSidebarPropertyRenderer(th is._style.parentRule, this.node(), this.name, this.value); 2201 var propertyRenderer = new WebInspector.StylesSidebarPropertyRenderer(th is._style.parentRule, this.node(), this.name, this.value);
2181 if (this.property.parsedOk) { 2202 if (this.property.parsedOk) {
2182 propertyRenderer.setColorHandler(this._processColor.bind(this)); 2203 propertyRenderer.setColorHandler(this._processColor.bind(this));
2183 propertyRenderer.setBezierHandler(this._processBezier.bind(this)); 2204 propertyRenderer.setBezierHandler(this._processBezier.bind(this));
2205 propertyRenderer.setShadowHandler(this._processShadow.bind(this));
2184 } 2206 }
2185 2207
2186 this.listItemElement.removeChildren(); 2208 this.listItemElement.removeChildren();
2187 this.nameElement = propertyRenderer.renderName(); 2209 this.nameElement = propertyRenderer.renderName();
2188 this.valueElement = propertyRenderer.renderValue(); 2210 this.valueElement = propertyRenderer.renderValue();
2189 if (!this.treeOutline) 2211 if (!this.treeOutline)
2190 return; 2212 return;
2191 2213
2192 var indent = WebInspector.moduleSetting("textEditorIndent").get(); 2214 var indent = WebInspector.moduleSetting("textEditorIndent").get();
2193 this.listItemElement.createChild("span", "styles-clipboard-only").create TextChild(indent + (this.property.disabled ? "/* " : "")); 2215 this.listItemElement.createChild("span", "styles-clipboard-only").create TextChild(indent + (this.property.disabled ? "/* " : ""));
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
2985 3007
2986 /** 3008 /**
2987 * @param {function(string):!Node} handler 3009 * @param {function(string):!Node} handler
2988 */ 3010 */
2989 setBezierHandler: function(handler) 3011 setBezierHandler: function(handler)
2990 { 3012 {
2991 this._bezierHandler = handler; 3013 this._bezierHandler = handler;
2992 }, 3014 },
2993 3015
2994 /** 3016 /**
3017 * @param {function(string, string):!Node} handler
3018 */
3019 setShadowHandler: function(handler)
3020 {
3021 this._shadowHandler = handler;
3022 },
3023
3024 /**
2995 * @return {!Element} 3025 * @return {!Element}
2996 */ 3026 */
2997 renderName: function() 3027 renderName: function()
2998 { 3028 {
2999 var nameElement = createElement("span"); 3029 var nameElement = createElement("span");
3000 nameElement.className = "webkit-css-property"; 3030 nameElement.className = "webkit-css-property";
3001 nameElement.textContent = this._propertyName; 3031 nameElement.textContent = this._propertyName;
3002 nameElement.normalize(); 3032 nameElement.normalize();
3003 return nameElement; 3033 return nameElement;
3004 }, 3034 },
3005 3035
3006 /** 3036 /**
3007 * @return {!Element} 3037 * @return {!Element}
3008 */ 3038 */
3009 renderValue: function() 3039 renderValue: function()
3010 { 3040 {
3011 var valueElement = createElement("span"); 3041 var valueElement = createElement("span");
3012 valueElement.className = "value"; 3042 valueElement.className = "value";
3013 if (!this._propertyValue) 3043 if (!this._propertyValue)
3014 return valueElement; 3044 return valueElement;
3015 3045
3046 if (this._shadowHandler && (this._propertyName === "box-shadow" || this. _propertyName === "text-shadow")
3047 && !WebInspector.CSSMetadata.VariableRegex.test(this._propertyVa lue) && Runtime.experiments.isEnabled("shadowEditor")) {
3048 valueElement.appendChild(this._shadowHandler(this._propertyValue, th is._propertyName));
3049 valueElement.normalize();
3050 return valueElement;
3051 }
3052
3016 var regexes = [WebInspector.CSSMetadata.VariableRegex, WebInspector.CSSM etadata.URLRegex]; 3053 var regexes = [WebInspector.CSSMetadata.VariableRegex, WebInspector.CSSM etadata.URLRegex];
3017 var processors = [createTextNode, this._processURL.bind(this)]; 3054 var processors = [createTextNode, this._processURL.bind(this)];
3018 if (this._bezierHandler && WebInspector.cssMetadata().isBezierAwarePrope rty(this._propertyName)) { 3055 if (this._bezierHandler && WebInspector.cssMetadata().isBezierAwarePrope rty(this._propertyName)) {
3019 regexes.push(WebInspector.Geometry.CubicBezier.Regex); 3056 regexes.push(WebInspector.Geometry.CubicBezier.Regex);
3020 processors.push(this._bezierHandler); 3057 processors.push(this._bezierHandler);
3021 } 3058 }
3022 if (this._colorHandler && WebInspector.cssMetadata().isColorAwarePropert y(this._propertyName)) { 3059 if (this._colorHandler && WebInspector.cssMetadata().isColorAwarePropert y(this._propertyName)) {
3023 regexes.push(WebInspector.Color.Regex); 3060 regexes.push(WebInspector.Color.Regex);
3024 processors.push(this._colorHandler); 3061 processors.push(this._colorHandler);
3025 } 3062 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
3099 3136
3100 /** 3137 /**
3101 * @override 3138 * @override
3102 * @return {!WebInspector.ToolbarItem} 3139 * @return {!WebInspector.ToolbarItem}
3103 */ 3140 */
3104 item: function() 3141 item: function()
3105 { 3142 {
3106 return this._button; 3143 return this._button;
3107 } 3144 }
3108 } 3145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698