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

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

Powered by Google App Engine
This is Rietveld 408576698