OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserve
d. | 2 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserve
d. |
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 15 matching lines...) Expand all Loading... |
26 #import "config.h" | 26 #import "config.h" |
27 #import "platform/mac/ColorMac.h" | 27 #import "platform/mac/ColorMac.h" |
28 | 28 |
29 #import <wtf/RetainPtr.h> | 29 #import <wtf/RetainPtr.h> |
30 #import <wtf/StdLibExtras.h> | 30 #import <wtf/StdLibExtras.h> |
31 | 31 |
32 namespace WebCore { | 32 namespace WebCore { |
33 | 33 |
34 // NSColor calls don't throw, so no need to block Cocoa exceptions in this file | 34 // NSColor calls don't throw, so no need to block Cocoa exceptions in this file |
35 | 35 |
36 static bool useOldAquaFocusRingColor; | |
37 | |
38 RGBA32 oldAquaFocusRingColor() | |
39 { | |
40 return 0xFF7DADD9; | |
41 } | |
42 | |
43 void setUsesTestModeFocusRingColor(bool newValue) | |
44 { | |
45 useOldAquaFocusRingColor = newValue; | |
46 } | |
47 | |
48 bool usesTestModeFocusRingColor() | |
49 { | |
50 return useOldAquaFocusRingColor; | |
51 } | |
52 | |
53 static RGBA32 makeRGBAFromNSColor(NSColor *c) | |
54 { | |
55 CGFloat redComponent; | |
56 CGFloat greenComponent; | |
57 CGFloat blueComponent; | |
58 CGFloat alpha; | |
59 [c getRed:&redComponent green:&greenComponent blue:&blueComponent alpha:&alp
ha]; | |
60 | |
61 return makeRGBA(255 * redComponent, 255 * greenComponent, 255 * blueComponen
t, 255 * alpha); | |
62 } | |
63 | |
64 Color colorFromNSColor(NSColor *c) | |
65 { | |
66 return Color(makeRGBAFromNSColor(c)); | |
67 } | |
68 | |
69 NSColor *nsColor(const Color& color) | 36 NSColor *nsColor(const Color& color) |
70 { | 37 { |
71 RGBA32 c = color.rgb(); | 38 RGBA32 c = color.rgb(); |
72 switch (c) { | 39 switch (c) { |
73 case 0: { | 40 case 0: { |
74 // Need this to avoid returning nil because cachedRGBAValues will de
fault to 0. | 41 // Need this to avoid returning nil because cachedRGBAValues will de
fault to 0. |
75 DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, clearColor, ([NSColor colorW
ithDeviceRed:0 green:0 blue:0 alpha:0])); | 42 DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, clearColor, ([NSColor colorW
ithDeviceRed:0 green:0 blue:0 alpha:0])); |
76 return clearColor.get(); | 43 return clearColor.get(); |
77 } | 44 } |
78 case Color::black: { | 45 case Color::black: { |
(...skipping 24 matching lines...) Expand all Loading... |
103 cachedColors[cursor] = result; | 70 cachedColors[cursor] = result; |
104 if (++cursor == cacheSize) | 71 if (++cursor == cacheSize) |
105 cursor = 0; | 72 cursor = 0; |
106 return result; | 73 return result; |
107 } | 74 } |
108 } | 75 } |
109 } | 76 } |
110 | 77 |
111 | 78 |
112 } // namespace WebCore | 79 } // namespace WebCore |
OLD | NEW |