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

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: Move model to another patch 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 var shadows;
2029 if (propertyName === "box-shadow")
2030 shadows = WebInspector.CSSShadowModel.parseBoxShadow(propertyValue);
2031 else
2032 shadows = WebInspector.CSSShadowModel.parseTextShadow(propertyValue) ;
2033 if (!shadows.length || !this._editable())
dgozman 2016/08/23 17:40:56 Let's not even parse if value is not editable.
flandy 2016/08/23 19:27:15 Done.
2034 return createTextNode(propertyValue);
2035 var container = createDocumentFragment();
2036 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper;
2037 for (var i = 0; i < shadows.length; i++) {
2038 if (i !== 0)
2039 container.appendChild(createTextNode(", ")); // Add back commas and spaces between each shadow.
dgozman 2016/08/23 17:40:57 This removes original formatting. Do we do this ev
flandy 2016/08/23 19:27:15 Andrey says it is okay right now.
dgozman 2016/08/23 19:29:47 Let's have a TODO then.
2040 var cssShadowSwatch = WebInspector.CSSShadowSwatch.create();
2041 cssShadowSwatch.setCSSShadow(shadows[i]);
2042 container.appendChild(cssShadowSwatch);
2043 }
2044 return container;
2045 },
2046
2021 _updateState: function() 2047 _updateState: function()
2022 { 2048 {
2023 if (!this.listItemElement) 2049 if (!this.listItemElement)
2024 return; 2050 return;
2025 2051
2026 if (this._style.isPropertyImplicit(this.name)) 2052 if (this._style.isPropertyImplicit(this.name))
2027 this.listItemElement.classList.add("implicit"); 2053 this.listItemElement.classList.add("implicit");
2028 else 2054 else
2029 this.listItemElement.classList.remove("implicit"); 2055 this.listItemElement.classList.remove("implicit");
2030 2056
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 updateTitle: function() 2200 updateTitle: function()
2175 { 2201 {
2176 this._updateState(); 2202 this._updateState();
2177 this._expandElement = createElement("span"); 2203 this._expandElement = createElement("span");
2178 this._expandElement.className = "expand-element"; 2204 this._expandElement.className = "expand-element";
2179 2205
2180 var propertyRenderer = new WebInspector.StylesSidebarPropertyRenderer(th is._style.parentRule, this.node(), this.name, this.value); 2206 var propertyRenderer = new WebInspector.StylesSidebarPropertyRenderer(th is._style.parentRule, this.node(), this.name, this.value);
2181 if (this.property.parsedOk) { 2207 if (this.property.parsedOk) {
2182 propertyRenderer.setColorHandler(this._processColor.bind(this)); 2208 propertyRenderer.setColorHandler(this._processColor.bind(this));
2183 propertyRenderer.setBezierHandler(this._processBezier.bind(this)); 2209 propertyRenderer.setBezierHandler(this._processBezier.bind(this));
2210 propertyRenderer.setShadowHandler(this._processShadow.bind(this));
2184 } 2211 }
2185 2212
2186 this.listItemElement.removeChildren(); 2213 this.listItemElement.removeChildren();
2187 this.nameElement = propertyRenderer.renderName(); 2214 this.nameElement = propertyRenderer.renderName();
2188 this.valueElement = propertyRenderer.renderValue(); 2215 this.valueElement = propertyRenderer.renderValue();
2189 if (!this.treeOutline) 2216 if (!this.treeOutline)
2190 return; 2217 return;
2191 2218
2192 var indent = WebInspector.moduleSetting("textEditorIndent").get(); 2219 var indent = WebInspector.moduleSetting("textEditorIndent").get();
2193 this.listItemElement.createChild("span", "styles-clipboard-only").create TextChild(indent + (this.property.disabled ? "/* " : "")); 2220 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 3012
2986 /** 3013 /**
2987 * @param {function(string):!Node} handler 3014 * @param {function(string):!Node} handler
2988 */ 3015 */
2989 setBezierHandler: function(handler) 3016 setBezierHandler: function(handler)
2990 { 3017 {
2991 this._bezierHandler = handler; 3018 this._bezierHandler = handler;
2992 }, 3019 },
2993 3020
2994 /** 3021 /**
3022 * @param {function(string, string):!Node} handler
3023 */
3024 setShadowHandler: function(handler)
3025 {
3026 this._shadowHandler = handler;
3027 },
3028
3029 /**
2995 * @return {!Element} 3030 * @return {!Element}
2996 */ 3031 */
2997 renderName: function() 3032 renderName: function()
2998 { 3033 {
2999 var nameElement = createElement("span"); 3034 var nameElement = createElement("span");
3000 nameElement.className = "webkit-css-property"; 3035 nameElement.className = "webkit-css-property";
3001 nameElement.textContent = this._propertyName; 3036 nameElement.textContent = this._propertyName;
3002 nameElement.normalize(); 3037 nameElement.normalize();
3003 return nameElement; 3038 return nameElement;
3004 }, 3039 },
3005 3040
3006 /** 3041 /**
3007 * @return {!Element} 3042 * @return {!Element}
3008 */ 3043 */
3009 renderValue: function() 3044 renderValue: function()
3010 { 3045 {
3011 var valueElement = createElement("span"); 3046 var valueElement = createElement("span");
3012 valueElement.className = "value"; 3047 valueElement.className = "value";
3013 if (!this._propertyValue) 3048 if (!this._propertyValue)
3014 return valueElement; 3049 return valueElement;
3015 3050
3051 if (this._shadowHandler && (this._propertyName === "box-shadow" || this. _propertyName === "text-shadow")
dgozman 2016/08/23 17:40:57 Are there any -webkit aliases we should support as
flandy 2016/08/23 19:27:14 Yes, thanks. There is -webkit-box-shadow but not -
3052 && !WebInspector.CSSMetadata.VariableRegex.test(this._propertyVa lue) && Runtime.experiments.isEnabled("shadowEditor")) {
3053 valueElement.appendChild(this._shadowHandler(this._propertyValue, th is._propertyName));
3054 valueElement.normalize();
3055 return valueElement;
3056 }
3057
3016 var regexes = [WebInspector.CSSMetadata.VariableRegex, WebInspector.CSSM etadata.URLRegex]; 3058 var regexes = [WebInspector.CSSMetadata.VariableRegex, WebInspector.CSSM etadata.URLRegex];
3017 var processors = [createTextNode, this._processURL.bind(this)]; 3059 var processors = [createTextNode, this._processURL.bind(this)];
3018 if (this._bezierHandler && WebInspector.cssMetadata().isBezierAwarePrope rty(this._propertyName)) { 3060 if (this._bezierHandler && WebInspector.cssMetadata().isBezierAwarePrope rty(this._propertyName)) {
3019 regexes.push(WebInspector.Geometry.CubicBezier.Regex); 3061 regexes.push(WebInspector.Geometry.CubicBezier.Regex);
3020 processors.push(this._bezierHandler); 3062 processors.push(this._bezierHandler);
3021 } 3063 }
3022 if (this._colorHandler && WebInspector.cssMetadata().isColorAwarePropert y(this._propertyName)) { 3064 if (this._colorHandler && WebInspector.cssMetadata().isColorAwarePropert y(this._propertyName)) {
3023 regexes.push(WebInspector.Color.Regex); 3065 regexes.push(WebInspector.Color.Regex);
3024 processors.push(this._colorHandler); 3066 processors.push(this._colorHandler);
3025 } 3067 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
3099 3141
3100 /** 3142 /**
3101 * @override 3143 * @override
3102 * @return {!WebInspector.ToolbarItem} 3144 * @return {!WebInspector.ToolbarItem}
3103 */ 3145 */
3104 item: function() 3146 item: function()
3105 { 3147 {
3106 return this._button; 3148 return this._button;
3107 } 3149 }
3108 } 3150 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698