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

Side by Side Diff: Source/platform/graphics/Color.cpp

Issue 285643006: Kill WTF::DecimalNumber class (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Inline single-line function Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/JSONValues.cpp ('k') | Source/wtf/DecimalNumber.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "platform/graphics/Color.h" 27 #include "platform/graphics/Color.h"
28 28
29 #include "platform/Decimal.h"
29 #include "wtf/Assertions.h" 30 #include "wtf/Assertions.h"
30 #include "wtf/DecimalNumber.h"
31 #include "wtf/HexNumber.h" 31 #include "wtf/HexNumber.h"
32 #include "wtf/MathExtras.h" 32 #include "wtf/MathExtras.h"
33 #include "wtf/dtoa.h"
33 #include "wtf/text/StringBuilder.h" 34 #include "wtf/text/StringBuilder.h"
34 35
35 using namespace std; 36 using namespace std;
36 37
37 namespace WebCore { 38 namespace WebCore {
38 39
39 #if !COMPILER(MSVC) 40 #if !COMPILER(MSVC)
40 const RGBA32 Color::black; 41 const RGBA32 Color::black;
41 const RGBA32 Color::white; 42 const RGBA32 Color::white;
42 const RGBA32 Color::darkGray; 43 const RGBA32 Color::darkGray;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 result.appendNumber(red()); 237 result.appendNumber(red());
237 result.append(commaSpace, 2); 238 result.append(commaSpace, 2);
238 result.appendNumber(green()); 239 result.appendNumber(green());
239 result.append(commaSpace, 2); 240 result.append(commaSpace, 2);
240 result.appendNumber(blue()); 241 result.appendNumber(blue());
241 result.append(commaSpace, 2); 242 result.append(commaSpace, 2);
242 243
243 if (!alpha()) 244 if (!alpha())
244 result.append('0'); 245 result.append('0');
245 else { 246 else {
246 NumberToLStringBuffer buffer; 247 result.append(Decimal::fromDouble(alpha() / 255.0).toString());
247 unsigned length = DecimalNumber(alpha() / 255.0).toStringDecimal(buffer, WTF::NumberToStringBufferLength);
248 result.append(buffer, length);
249 } 248 }
250 249
251 result.append(')'); 250 result.append(')');
252 return result.toString(); 251 return result.toString();
253 } 252 }
254 253
255 String Color::nameForRenderTreeAsText() const 254 String Color::nameForRenderTreeAsText() const
256 { 255 {
257 if (alpha() < 0xFF) 256 if (alpha() < 0xFF)
258 return String::format("#%02X%02X%02X%02X", red(), green(), blue(), alpha ()); 257 return String::format("#%02X%02X%02X%02X", red(), green(), blue(), alpha ());
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 (color.green() * alpha + 254) / 255, 457 (color.green() * alpha + 254) / 255,
459 (color.blue() * alpha + 254) / 255, 458 (color.blue() * alpha + 254) / 255,
460 alpha).rgb(); 459 alpha).rgb();
461 } else 460 } else
462 pixelColor = color.rgb(); 461 pixelColor = color.rgb();
463 462
464 return pixelColor; 463 return pixelColor;
465 } 464 }
466 465
467 } // namespace WebCore 466 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/JSONValues.cpp ('k') | Source/wtf/DecimalNumber.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698