OLD | NEW |
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 Loading... |
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 = WebInspector.ShadowEditor.Shadow.parse(propertyValue, prop
ertyName); |
| 2029 if (!shadows || !this._editable()) |
| 2030 return createTextNode(propertyValue); |
| 2031 var container = createDocumentFragment(); |
| 2032 for (var i = 0; i < shadows.length; i++) { |
| 2033 if (i !== 0) |
| 2034 container.appendChild(createTextNode(", ")); // Add back commas
and spaces between each shadow. |
| 2035 var shadowPopoverIcon = new WebInspector.ShadowPopoverIcon(this, thi
s._parentPane._swatchPopoverHelper, shadows[i]); |
| 2036 container.appendChild(shadowPopoverIcon.element()); |
| 2037 } |
| 2038 return container; |
| 2039 }, |
| 2040 |
2021 _updateState: function() | 2041 _updateState: function() |
2022 { | 2042 { |
2023 if (!this.listItemElement) | 2043 if (!this.listItemElement) |
2024 return; | 2044 return; |
2025 | 2045 |
2026 if (this._style.isPropertyImplicit(this.name)) | 2046 if (this._style.isPropertyImplicit(this.name)) |
2027 this.listItemElement.classList.add("implicit"); | 2047 this.listItemElement.classList.add("implicit"); |
2028 else | 2048 else |
2029 this.listItemElement.classList.remove("implicit"); | 2049 this.listItemElement.classList.remove("implicit"); |
2030 | 2050 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2174 updateTitle: function() | 2194 updateTitle: function() |
2175 { | 2195 { |
2176 this._updateState(); | 2196 this._updateState(); |
2177 this._expandElement = createElement("span"); | 2197 this._expandElement = createElement("span"); |
2178 this._expandElement.className = "expand-element"; | 2198 this._expandElement.className = "expand-element"; |
2179 | 2199 |
2180 var propertyRenderer = new WebInspector.StylesSidebarPropertyRenderer(th
is._style.parentRule, this.node(), this.name, this.value); | 2200 var propertyRenderer = new WebInspector.StylesSidebarPropertyRenderer(th
is._style.parentRule, this.node(), this.name, this.value); |
2181 if (this.property.parsedOk) { | 2201 if (this.property.parsedOk) { |
2182 propertyRenderer.setColorHandler(this._processColor.bind(this)); | 2202 propertyRenderer.setColorHandler(this._processColor.bind(this)); |
2183 propertyRenderer.setBezierHandler(this._processBezier.bind(this)); | 2203 propertyRenderer.setBezierHandler(this._processBezier.bind(this)); |
| 2204 propertyRenderer.setShadowHandler(this._processShadow.bind(this)); |
2184 } | 2205 } |
2185 | 2206 |
2186 this.listItemElement.removeChildren(); | 2207 this.listItemElement.removeChildren(); |
2187 this.nameElement = propertyRenderer.renderName(); | 2208 this.nameElement = propertyRenderer.renderName(); |
2188 this.valueElement = propertyRenderer.renderValue(); | 2209 this.valueElement = propertyRenderer.renderValue(); |
2189 if (!this.treeOutline) | 2210 if (!this.treeOutline) |
2190 return; | 2211 return; |
2191 | 2212 |
2192 var indent = WebInspector.moduleSetting("textEditorIndent").get(); | 2213 var indent = WebInspector.moduleSetting("textEditorIndent").get(); |
2193 this.listItemElement.createChild("span", "styles-clipboard-only").create
TextChild(indent + (this.property.disabled ? "/* " : "")); | 2214 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 Loading... |
2985 | 3006 |
2986 /** | 3007 /** |
2987 * @param {function(string):!Node} handler | 3008 * @param {function(string):!Node} handler |
2988 */ | 3009 */ |
2989 setBezierHandler: function(handler) | 3010 setBezierHandler: function(handler) |
2990 { | 3011 { |
2991 this._bezierHandler = handler; | 3012 this._bezierHandler = handler; |
2992 }, | 3013 }, |
2993 | 3014 |
2994 /** | 3015 /** |
| 3016 * @param {function(string, string):!Node} handler |
| 3017 */ |
| 3018 setShadowHandler: function(handler) |
| 3019 { |
| 3020 this._shadowHandler = handler; |
| 3021 }, |
| 3022 |
| 3023 /** |
2995 * @return {!Element} | 3024 * @return {!Element} |
2996 */ | 3025 */ |
2997 renderName: function() | 3026 renderName: function() |
2998 { | 3027 { |
2999 var nameElement = createElement("span"); | 3028 var nameElement = createElement("span"); |
3000 nameElement.className = "webkit-css-property"; | 3029 nameElement.className = "webkit-css-property"; |
3001 nameElement.textContent = this._propertyName; | 3030 nameElement.textContent = this._propertyName; |
3002 nameElement.normalize(); | 3031 nameElement.normalize(); |
3003 return nameElement; | 3032 return nameElement; |
3004 }, | 3033 }, |
3005 | 3034 |
3006 /** | 3035 /** |
3007 * @return {!Element} | 3036 * @return {!Element} |
3008 */ | 3037 */ |
3009 renderValue: function() | 3038 renderValue: function() |
3010 { | 3039 { |
3011 var valueElement = createElement("span"); | 3040 var valueElement = createElement("span"); |
3012 valueElement.className = "value"; | 3041 valueElement.className = "value"; |
3013 if (!this._propertyValue) | 3042 if (!this._propertyValue) |
3014 return valueElement; | 3043 return valueElement; |
3015 | 3044 |
| 3045 if (this._shadowHandler && (this._propertyName === "box-shadow" || this.
_propertyName === "text-shadow") |
| 3046 && !WebInspector.CSSMetadata.VariableRegex.test(this._propertyVa
lue) && Runtime.experiments.isEnabled("shadowEditor")) { |
| 3047 valueElement.appendChild(this._shadowHandler(this._propertyValue, th
is._propertyName)); |
| 3048 valueElement.normalize(); |
| 3049 return valueElement; |
| 3050 } |
| 3051 |
3016 var regexes = [WebInspector.CSSMetadata.VariableRegex, WebInspector.CSSM
etadata.URLRegex]; | 3052 var regexes = [WebInspector.CSSMetadata.VariableRegex, WebInspector.CSSM
etadata.URLRegex]; |
3017 var processors = [createTextNode, this._processURL.bind(this)]; | 3053 var processors = [createTextNode, this._processURL.bind(this)]; |
3018 if (this._bezierHandler && WebInspector.cssMetadata().isBezierAwarePrope
rty(this._propertyName)) { | 3054 if (this._bezierHandler && WebInspector.cssMetadata().isBezierAwarePrope
rty(this._propertyName)) { |
3019 regexes.push(WebInspector.Geometry.CubicBezier.Regex); | 3055 regexes.push(WebInspector.Geometry.CubicBezier.Regex); |
3020 processors.push(this._bezierHandler); | 3056 processors.push(this._bezierHandler); |
3021 } | 3057 } |
3022 if (this._colorHandler && WebInspector.cssMetadata().isColorAwarePropert
y(this._propertyName)) { | 3058 if (this._colorHandler && WebInspector.cssMetadata().isColorAwarePropert
y(this._propertyName)) { |
3023 regexes.push(WebInspector.Color.Regex); | 3059 regexes.push(WebInspector.Color.Regex); |
3024 processors.push(this._colorHandler); | 3060 processors.push(this._colorHandler); |
3025 } | 3061 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3099 | 3135 |
3100 /** | 3136 /** |
3101 * @override | 3137 * @override |
3102 * @return {!WebInspector.ToolbarItem} | 3138 * @return {!WebInspector.ToolbarItem} |
3103 */ | 3139 */ |
3104 item: function() | 3140 item: function() |
3105 { | 3141 { |
3106 return this._button; | 3142 return this._button; |
3107 } | 3143 } |
3108 } | 3144 } |
OLD | NEW |