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 "core/CSSValueKeywords.h"
35 #include "core/layout/LayoutTheme.h"
36 #include "platform/graphics/Color.h"
37 #include "public/platform/WebColor.h"
41 static int toCSSValueKeyword(WebColorName name
)
44 case WebColorActiveBorder
:
45 return CSSValueActiveborder
;
46 case WebColorActiveCaption
:
47 return CSSValueActivecaption
;
48 case WebColorAppworkspace
:
49 return CSSValueAppworkspace
;
50 case WebColorBackground
:
51 return CSSValueBackground
;
52 case WebColorButtonFace
:
53 return CSSValueButtonface
;
54 case WebColorButtonHighlight
:
55 return CSSValueButtonhighlight
;
56 case WebColorButtonShadow
:
57 return CSSValueButtonshadow
;
58 case WebColorButtonText
:
59 return CSSValueButtontext
;
60 case WebColorCaptionText
:
61 return CSSValueCaptiontext
;
62 case WebColorGrayText
:
63 return CSSValueGraytext
;
64 case WebColorHighlight
:
65 return CSSValueHighlight
;
66 case WebColorHighlightText
:
67 return CSSValueHighlighttext
;
68 case WebColorInactiveBorder
:
69 return CSSValueInactiveborder
;
70 case WebColorInactiveCaption
:
71 return CSSValueInactivecaption
;
72 case WebColorInactiveCaptionText
:
73 return CSSValueInactivecaptiontext
;
74 case WebColorInfoBackground
:
75 return CSSValueInfobackground
;
76 case WebColorInfoText
:
77 return CSSValueInfotext
;
80 case WebColorMenuText
:
81 return CSSValueMenutext
;
82 case WebColorScrollbar
:
83 return CSSValueScrollbar
;
86 case WebColorThreedDarkShadow
:
87 return CSSValueThreeddarkshadow
;
88 case WebColorThreedShadow
:
89 return CSSValueThreedshadow
;
90 case WebColorThreedFace
:
91 return CSSValueThreedface
;
92 case WebColorThreedHighlight
:
93 return CSSValueThreedhighlight
;
94 case WebColorThreedLightShadow
:
95 return CSSValueThreedlightshadow
;
96 case WebColorWebkitFocusRingColor
:
97 return CSSValueWebkitFocusRingColor
;
99 return CSSValueWindow
;
100 case WebColorWindowFrame
:
101 return CSSValueWindowframe
;
102 case WebColorWindowText
:
103 return CSSValueWindowtext
;
105 return CSSValueInvalid
;
109 void setNamedColors(const WebColorName
* colorNames
, const WebColor
* colors
, size_t length
)
111 for (size_t i
= 0; i
< length
; ++i
) {
112 WebColorName colorName
= colorNames
[i
];
113 WebColor color
= colors
[i
];
115 // Convert color to internal value identifier.
116 int internalColorName
= toCSSValueKeyword(colorName
);
117 if (internalColorName
== CSSValueWebkitFocusRingColor
) {
118 LayoutTheme::theme().setCustomFocusRingColor(color
);
123 // TODO(jeremy): Tell LayoutTheme to update colors.