| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 { | 160 { |
| 161 unsigned length = name.length(); | 161 unsigned length = name.length(); |
| 162 | 162 |
| 163 if (!length) | 163 if (!length) |
| 164 return false; | 164 return false; |
| 165 if (name.is8Bit()) | 165 if (name.is8Bit()) |
| 166 return parseHexColor(name.characters8(), name.length(), rgb); | 166 return parseHexColor(name.characters8(), name.length(), rgb); |
| 167 return parseHexColor(name.characters16(), name.length(), rgb); | 167 return parseHexColor(name.characters16(), name.length(), rgb); |
| 168 } | 168 } |
| 169 | 169 |
| 170 int differenceSquared(const Color& c1, const Color& c2) | |
| 171 { | |
| 172 int dR = c1.red() - c2.red(); | |
| 173 int dG = c1.green() - c2.green(); | |
| 174 int dB = c1.blue() - c2.blue(); | |
| 175 return dR * dR + dG * dG + dB * dB; | |
| 176 } | |
| 177 | |
| 178 bool Color::setFromString(const String& name) | 170 bool Color::setFromString(const String& name) |
| 179 { | 171 { |
| 180 if (name[0] != '#') | 172 if (name[0] != '#') |
| 181 return setNamedColor(name); | 173 return setNamedColor(name); |
| 182 if (name.is8Bit()) | 174 if (name.is8Bit()) |
| 183 return parseHexColor(name.characters8() + 1, name.length() - 1, m_color)
; | 175 return parseHexColor(name.characters8() + 1, name.length() - 1, m_color)
; |
| 184 return parseHexColor(name.characters16() + 1, name.length() - 1, m_color); | 176 return parseHexColor(name.characters16() + 1, name.length() - 1, m_color); |
| 185 } | 177 } |
| 186 | 178 |
| 187 String Color::serializedAsCSSComponentValue() const | 179 String Color::serializedAsCSSComponentValue() const |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 (color.green() * alpha + 254) / 255, | 444 (color.green() * alpha + 254) / 255, |
| 453 (color.blue() * alpha + 254) / 255, | 445 (color.blue() * alpha + 254) / 255, |
| 454 alpha).rgb(); | 446 alpha).rgb(); |
| 455 } else | 447 } else |
| 456 pixelColor = color.rgb(); | 448 pixelColor = color.rgb(); |
| 457 | 449 |
| 458 return pixelColor; | 450 return pixelColor; |
| 459 } | 451 } |
| 460 | 452 |
| 461 } // namespace blink | 453 } // namespace blink |
| OLD | NEW |