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 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1953 if (!color) | 1953 if (!color) |
1954 return createTextNode(text); | 1954 return createTextNode(text); |
1955 | 1955 |
1956 if (!this._editable()) { | 1956 if (!this._editable()) { |
1957 var swatch = WebInspector.ColorSwatch.create(); | 1957 var swatch = WebInspector.ColorSwatch.create(); |
1958 swatch.setColorText(text); | 1958 swatch.setColorText(text); |
1959 return swatch; | 1959 return swatch; |
1960 } | 1960 } |
1961 | 1961 |
1962 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper; | 1962 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper; |
1963 var swatchIcon = new WebInspector.ColorSwatchPopoverIcon(this, swatchPop
overHelper, text); | 1963 var swatch = WebInspector.ColorSwatch.create(); |
| 1964 swatch.setColorText(text); |
| 1965 swatch.setFormat(WebInspector.Color.detectColorFormat(swatch.color())); |
| 1966 var swatchIcon = new WebInspector.ColorSwatchPopoverIcon(this, swatchPop
overHelper, swatch); |
1964 | 1967 |
1965 /** | 1968 /** |
1966 * @param {?Array<string>} backgroundColors | 1969 * @param {?Array<string>} backgroundColors |
1967 */ | 1970 */ |
1968 function computedCallback(backgroundColors) | 1971 function computedCallback(backgroundColors) |
1969 { | 1972 { |
1970 // TODO(aboxhall): distinguish between !backgroundColors (no text) a
nd | 1973 // TODO(aboxhall): distinguish between !backgroundColors (no text) a
nd |
1971 // !backgroundColors.length (no computed bg color) | 1974 // !backgroundColors.length (no computed bg color) |
1972 if (!backgroundColors || !backgroundColors.length) | 1975 if (!backgroundColors || !backgroundColors.length) |
1973 return; | 1976 return; |
(...skipping 13 matching lines...) Expand all Loading... |
1987 } | 1990 } |
1988 | 1991 |
1989 swatchIcon.setContrastColor(bgColor); | 1992 swatchIcon.setContrastColor(bgColor); |
1990 } | 1993 } |
1991 | 1994 |
1992 if (Runtime.experiments.isEnabled("colorContrastRatio") && this.property
.name === "color" && this._parentPane.cssModel() && this.node()) { | 1995 if (Runtime.experiments.isEnabled("colorContrastRatio") && this.property
.name === "color" && this._parentPane.cssModel() && this.node()) { |
1993 var cssModel = this._parentPane.cssModel(); | 1996 var cssModel = this._parentPane.cssModel(); |
1994 cssModel.backgroundColorsPromise(this.node().id).then(computedCallba
ck); | 1997 cssModel.backgroundColorsPromise(this.node().id).then(computedCallba
ck); |
1995 } | 1998 } |
1996 | 1999 |
1997 return swatchIcon.element(); | 2000 return swatch; |
1998 }, | 2001 }, |
1999 | 2002 |
2000 /** | 2003 /** |
2001 * @return {string} | 2004 * @return {string} |
2002 */ | 2005 */ |
2003 renderedPropertyText: function() | 2006 renderedPropertyText: function() |
2004 { | 2007 { |
2005 return this.nameElement.textContent + ": " + this.valueElement.textConte
nt; | 2008 return this.nameElement.textContent + ": " + this.valueElement.textConte
nt; |
2006 }, | 2009 }, |
2007 | 2010 |
(...skipping 27 matching lines...) Expand all Loading... |
2035 if (!shadows.length) | 2038 if (!shadows.length) |
2036 return createTextNode(propertyValue); | 2039 return createTextNode(propertyValue); |
2037 var container = createDocumentFragment(); | 2040 var container = createDocumentFragment(); |
2038 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper; | 2041 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper; |
2039 for (var i = 0; i < shadows.length; i++) { | 2042 for (var i = 0; i < shadows.length; i++) { |
2040 if (i !== 0) | 2043 if (i !== 0) |
2041 container.appendChild(createTextNode(", ")); // Add back commas
and spaces between each shadow. | 2044 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. | 2045 // TODO(flandy): editing the property value should use the original
value with all spaces. |
2043 var cssShadowSwatch = WebInspector.CSSShadowSwatch.create(); | 2046 var cssShadowSwatch = WebInspector.CSSShadowSwatch.create(); |
2044 cssShadowSwatch.setCSSShadow(shadows[i]); | 2047 cssShadowSwatch.setCSSShadow(shadows[i]); |
| 2048 if (cssShadowSwatch.colorSwatch()) |
| 2049 var colorSwatchIcon = new WebInspector.ColorSwatchPopoverIcon(th
is, swatchPopoverHelper, cssShadowSwatch.colorSwatch()); |
2045 container.appendChild(cssShadowSwatch); | 2050 container.appendChild(cssShadowSwatch); |
2046 } | 2051 } |
2047 return container; | 2052 return container; |
2048 }, | 2053 }, |
2049 | 2054 |
2050 _updateState: function() | 2055 _updateState: function() |
2051 { | 2056 { |
2052 if (!this.listItemElement) | 2057 if (!this.listItemElement) |
2053 return; | 2058 return; |
2054 | 2059 |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3144 | 3149 |
3145 /** | 3150 /** |
3146 * @override | 3151 * @override |
3147 * @return {!WebInspector.ToolbarItem} | 3152 * @return {!WebInspector.ToolbarItem} |
3148 */ | 3153 */ |
3149 item: function() | 3154 item: function() |
3150 { | 3155 { |
3151 return this._button; | 3156 return this._button; |
3152 } | 3157 } |
3153 } | 3158 } |
OLD | NEW |