| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {HTMLSpanElement} | 7 * @extends {HTMLSpanElement} |
| 8 */ | 8 */ |
| 9 WebInspector.ColorSwatch = function() | 9 WebInspector.ColorSwatch = function() |
| 10 { | 10 { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 * @param {!WebInspector.Color} color | 111 * @param {!WebInspector.Color} color |
| 112 * @param {string} curFormat | 112 * @param {string} curFormat |
| 113 */ | 113 */ |
| 114 WebInspector.ColorSwatch._nextColorFormat = function(color, curFormat) | 114 WebInspector.ColorSwatch._nextColorFormat = function(color, curFormat) |
| 115 { | 115 { |
| 116 // The format loop is as follows: | 116 // The format loop is as follows: |
| 117 // * original | 117 // * original |
| 118 // * rgb(a) | 118 // * rgb(a) |
| 119 // * hsl(a) | 119 // * hsl(a) |
| 120 // * nickname (if the color has a nickname) | 120 // * nickname (if the color has a nickname) |
| 121 // * if the color is simple: | 121 // * shorthex (if has short hex) |
| 122 // - shorthex (if has short hex) | 122 // * hex |
| 123 // - hex | |
| 124 var cf = WebInspector.Color.Format; | 123 var cf = WebInspector.Color.Format; |
| 125 | 124 |
| 126 switch (curFormat) { | 125 switch (curFormat) { |
| 127 case cf.Original: | 126 case cf.Original: |
| 128 return !color.hasAlpha() ? cf.RGB : cf.RGBA; | 127 return !color.hasAlpha() ? cf.RGB : cf.RGBA; |
| 129 | 128 |
| 130 case cf.RGB: | 129 case cf.RGB: |
| 131 case cf.RGBA: | 130 case cf.RGBA: |
| 132 return !color.hasAlpha() ? cf.HSL : cf.HSLA; | 131 return !color.hasAlpha() ? cf.HSL : cf.HSLA; |
| 133 | 132 |
| 134 case cf.HSL: | 133 case cf.HSL: |
| 135 case cf.HSLA: | 134 case cf.HSLA: |
| 136 if (color.nickname()) | 135 if (color.nickname()) |
| 137 return cf.Nickname; | 136 return cf.Nickname; |
| 138 if (!color.hasAlpha()) | 137 return color.detectHEXFormat(); |
| 139 return color.canBeShortHex() ? cf.ShortHEX : cf.HEX; | |
| 140 else | |
| 141 return cf.Original; | |
| 142 | 138 |
| 143 case cf.ShortHEX: | 139 case cf.ShortHEX: |
| 144 return cf.HEX; | 140 return cf.HEX; |
| 145 | 141 |
| 142 case cf.ShortHEXA: |
| 143 return cf.HEXA; |
| 144 |
| 145 case cf.HEXA: |
| 146 case cf.HEX: | 146 case cf.HEX: |
| 147 return cf.Original; | 147 return cf.Original; |
| 148 | 148 |
| 149 case cf.Nickname: | 149 case cf.Nickname: |
| 150 if (!color.hasAlpha()) | 150 return color.detectHEXFormat(); |
| 151 return color.canBeShortHex() ? cf.ShortHEX : cf.HEX; | |
| 152 else | |
| 153 return cf.Original; | |
| 154 | 151 |
| 155 default: | 152 default: |
| 156 return cf.RGBA; | 153 return cf.RGBA; |
| 157 } | 154 } |
| 158 } | 155 } |
| OLD | NEW |