2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include "public/web/WebColorName.h"
34 #include "CSSValueKeywords.h"
35 #include "core/rendering/RenderTheme.h"
36 #include "platform/graphics/Color.h"
37 #include "public/platform/WebColor.h"
39 using namespace::WebCore;
43 static int toCSSValueKeyword(WebColorName name)
46 case WebColorActiveBorder:
47 return CSSValueActiveborder;
48 case WebColorActiveCaption:
49 return CSSValueActivecaption;
50 case WebColorAppworkspace:
51 return CSSValueAppworkspace;
52 case WebColorBackground:
53 return CSSValueBackground;
54 case WebColorButtonFace:
55 return CSSValueButtonface;
56 case WebColorButtonHighlight:
57 return CSSValueButtonhighlight;
58 case WebColorButtonShadow:
59 return CSSValueButtonshadow;
60 case WebColorButtonText:
61 return CSSValueButtontext;
62 case WebColorCaptionText:
63 return CSSValueCaptiontext;
64 case WebColorGrayText:
65 return CSSValueGraytext;
66 case WebColorHighlight:
67 return CSSValueHighlight;
68 case WebColorHighlightText:
69 return CSSValueHighlighttext;
70 case WebColorInactiveBorder:
71 return CSSValueInactiveborder;
72 case WebColorInactiveCaption:
73 return CSSValueInactivecaption;
74 case WebColorInactiveCaptionText:
75 return CSSValueInactivecaptiontext;
76 case WebColorInfoBackground:
77 return CSSValueInfobackground;
78 case WebColorInfoText:
79 return CSSValueInfotext;
82 case WebColorMenuText:
83 return CSSValueMenutext;
84 case WebColorScrollbar:
85 return CSSValueScrollbar;
88 case WebColorThreedDarkShadow:
89 return CSSValueThreeddarkshadow;
90 case WebColorThreedShadow:
91 return CSSValueThreedshadow;
92 case WebColorThreedFace:
93 return CSSValueThreedface;
94 case WebColorThreedHighlight:
95 return CSSValueThreedhighlight;
96 case WebColorThreedLightShadow:
97 return CSSValueThreedlightshadow;
98 case WebColorWebkitFocusRingColor:
99 return CSSValueWebkitFocusRingColor;
101 return CSSValueWindow;
102 case WebColorWindowFrame:
103 return CSSValueWindowframe;
104 case WebColorWindowText:
105 return CSSValueWindowtext;
107 return CSSValueInvalid;
111 void setNamedColors(const WebColorName* colorNames, const WebColor* colors, size_t length)
113 for (size_t i = 0; i < length; ++i) {
114 WebColorName colorName = colorNames[i];
115 WebColor color = colors[i];
117 // Convert color to internal value identifier.
118 int internalColorName = toCSSValueKeyword(colorName);
119 if (internalColorName == CSSValueWebkitFocusRingColor) {
120 RenderTheme::theme().setCustomFocusRingColor(color);
125 // TODO(jeremy): Tell RenderTheme to update colors.