Update V8 to version 4.7.45.
[chromium-blink-merge.git] / ui / native_theme / fallback_theme.cc
blob92be98edb87aeb3467557c7cf21746d64e947297
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/native_theme/fallback_theme.h"
7 #include "base/basictypes.h"
8 #include "base/logging.h"
9 #include "ui/base/resource/material_design/material_design_controller.h"
10 #include "ui/gfx/color_utils.h"
11 #include "ui/native_theme/common_theme.h"
13 namespace ui {
15 FallbackTheme::FallbackTheme() {
18 FallbackTheme::~FallbackTheme() {
21 // This implementation returns hardcoded colors.
22 SkColor FallbackTheme::GetSystemColor(ColorId color_id) const {
23 SkColor color;
24 if (CommonThemeGetSystemColor(color_id, &color))
25 return color;
27 // Shared colors.
28 static const SkColor kTextfieldDefaultBackground = SK_ColorWHITE;
29 static const SkColor kTextfieldSelectionBackgroundFocused =
30 SkColorSetARGB(0x54, 0x60, 0xA8, 0xEB);
32 // MD colors.
33 if (ui::MaterialDesignController::IsModeMaterial()) {
34 // Dialogs:
35 static const SkColor kDialogBackgroundColorMd = SK_ColorWHITE;
36 // Results tables:
37 static const SkColor kResultsTableSelectedBackgroundMd =
38 SkColorSetARGB(0x15, 0x00, 0x00, 0x00);
39 static const SkColor kResultsTableTextMd = SK_ColorBLACK;
40 static const SkColor kResultsTableDimmedTextMd =
41 SkColorSetRGB(0x64, 0x64, 0x64);
42 static const SkColor kResultsTableUrlMd = SkColorSetRGB(0x33, 0x67, 0xD6);
43 static const SkColor kResultsTableHoveredBackgroundMd =
44 SkColorSetARGB(0x0D, 0x00, 0x00, 0x00);
45 static const SkColor kResultsTableDividerMd = color_utils::AlphaBlend(
46 kResultsTableTextMd, kTextfieldDefaultBackground, 0x34);
47 static const SkColor kResultsTableSelectedDividerMd =
48 color_utils::AlphaBlend(kResultsTableTextMd,
49 kTextfieldSelectionBackgroundFocused, 0x34);
50 static const SkColor kPositiveTextColorMd = SkColorSetRGB(0x0b, 0x80, 0x43);
51 static const SkColor kNegativeTextColorMd = SkColorSetRGB(0xc5, 0x39, 0x29);
53 switch (color_id) {
54 // Dialogs
55 case kColorId_DialogBackground:
56 return kDialogBackgroundColorMd;
58 // Results Tables
59 case kColorId_ResultsTableHoveredBackground:
60 return kResultsTableHoveredBackgroundMd;
61 case kColorId_ResultsTableSelectedBackground:
62 return kResultsTableSelectedBackgroundMd;
63 case kColorId_ResultsTableNormalText:
64 case kColorId_ResultsTableHoveredText:
65 case kColorId_ResultsTableSelectedText:
66 return kResultsTableTextMd;
67 case kColorId_ResultsTableNormalDimmedText:
68 case kColorId_ResultsTableHoveredDimmedText:
69 case kColorId_ResultsTableSelectedDimmedText:
70 return kResultsTableDimmedTextMd;
71 case kColorId_ResultsTableNormalUrl:
72 case kColorId_ResultsTableHoveredUrl:
73 case kColorId_ResultsTableSelectedUrl:
74 return kResultsTableUrlMd;
75 case kColorId_ResultsTableNormalDivider:
76 case kColorId_ResultsTableHoveredDivider:
77 return kResultsTableDividerMd;
78 case kColorId_ResultsTableSelectedDivider:
79 return kResultsTableSelectedDividerMd;
80 case kColorId_ResultsTablePositiveText:
81 case kColorId_ResultsTablePositiveHoveredText:
82 case kColorId_ResultsTablePositiveSelectedText:
83 return kPositiveTextColorMd;
84 case kColorId_ResultsTableNegativeText:
85 case kColorId_ResultsTableNegativeHoveredText:
86 case kColorId_ResultsTableNegativeSelectedText:
87 return kNegativeTextColorMd;
89 default:
90 break;
94 // Pre-MD colors.
95 static const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128);
96 // Windows:
97 static const SkColor kWindowBackgroundColor = SK_ColorWHITE;
98 // Dialogs:
99 static const SkColor kDialogBackgroundColor = SkColorSetRGB(251, 251, 251);
100 // FocusableBorder:
101 static const SkColor kFocusedBorderColor = SkColorSetRGB(0x4D, 0x90, 0xFE);
102 static const SkColor kUnfocusedBorderColor = SkColorSetRGB(0xD9, 0xD9, 0xD9);
103 // Button:
104 static const SkColor kButtonBackgroundColor = SkColorSetRGB(0xDE, 0xDE, 0xDE);
105 static const SkColor kButtonEnabledColor = SkColorSetRGB(0x22, 0x22, 0x22);
106 static const SkColor kButtonHighlightColor = SkColorSetRGB(0, 0, 0);
107 static const SkColor kButtonHoverColor = kButtonEnabledColor;
108 // Label:
109 static const SkColor kLabelEnabledColor = kButtonEnabledColor;
110 static const SkColor kLabelBackgroundColor = SK_ColorWHITE;
111 // Textfield:
112 static const SkColor kTextfieldDefaultColor = SK_ColorBLACK;
113 static const SkColor kTextfieldReadOnlyColor = SK_ColorDKGRAY;
114 static const SkColor kTextfieldReadOnlyBackground = SK_ColorWHITE;
115 static const SkColor kTextfieldSelectionColor =
116 color_utils::AlphaBlend(SK_ColorBLACK,
117 kTextfieldSelectionBackgroundFocused, 0xdd);
118 // Tooltip
119 static const SkColor kTooltipBackground = 0xFFFFFFCC;
120 static const SkColor kTooltipTextColor = kLabelEnabledColor;
121 // Tree
122 static const SkColor kTreeBackground = SK_ColorWHITE;
123 static const SkColor kTreeTextColor = SK_ColorBLACK;
124 static const SkColor kTreeSelectedTextColor = SK_ColorBLACK;
125 static const SkColor kTreeSelectionBackgroundColor =
126 SkColorSetRGB(0xEE, 0xEE, 0xEE);
127 static const SkColor kTreeArrowColor = SkColorSetRGB(0x7A, 0x7A, 0x7A);
128 // Table
129 static const SkColor kTableBackground = SK_ColorWHITE;
130 static const SkColor kTableTextColor = SK_ColorBLACK;
131 static const SkColor kTableSelectedTextColor = SK_ColorBLACK;
132 static const SkColor kTableSelectionBackgroundColor =
133 SkColorSetRGB(0xEE, 0xEE, 0xEE);
134 static const SkColor kTableGroupingIndicatorColor =
135 SkColorSetRGB(0xCC, 0xCC, 0xCC);
136 // Results Tables
137 static const SkColor kResultsTableSelectedBackground =
138 kTextfieldSelectionBackgroundFocused;
139 static const SkColor kResultsTableNormalText =
140 color_utils::AlphaBlend(SK_ColorBLACK, kTextfieldDefaultBackground, 0xDD);
141 static const SkColor kResultsTableHoveredBackground = color_utils::AlphaBlend(
142 kTextfieldSelectionBackgroundFocused, kTextfieldDefaultBackground, 0x40);
143 static const SkColor kResultsTableHoveredText = color_utils::AlphaBlend(
144 SK_ColorBLACK, kResultsTableHoveredBackground, 0xDD);
145 static const SkColor kResultsTableSelectedText = color_utils::AlphaBlend(
146 SK_ColorBLACK, kTextfieldSelectionBackgroundFocused, 0xDD);
147 static const SkColor kResultsTableNormalDimmedText =
148 color_utils::AlphaBlend(SK_ColorBLACK, kTextfieldDefaultBackground, 0xBB);
149 static const SkColor kResultsTableHoveredDimmedText = color_utils::AlphaBlend(
150 SK_ColorBLACK, kResultsTableHoveredBackground, 0xBB);
151 static const SkColor kResultsTableSelectedDimmedText =
152 color_utils::AlphaBlend(SK_ColorBLACK,
153 kTextfieldSelectionBackgroundFocused, 0xBB);
154 static const SkColor kResultsTableNormalUrl = kTextfieldSelectionColor;
155 static const SkColor kResultsTableSelectedOrHoveredUrl =
156 SkColorSetARGB(0xff, 0x0b, 0x80, 0x43);
157 static const SkColor kResultsTableNormalDivider = color_utils::AlphaBlend(
158 kResultsTableNormalText, kTextfieldDefaultBackground, 0x34);
159 static const SkColor kResultsTableHoveredDivider = color_utils::AlphaBlend(
160 kResultsTableHoveredText, kResultsTableHoveredBackground, 0x34);
161 static const SkColor kResultsTableSelectedDivider = color_utils::AlphaBlend(
162 kResultsTableSelectedText, kTextfieldSelectionBackgroundFocused, 0x34);
163 const SkColor kPositiveTextColor = SkColorSetRGB(0x0b, 0x80, 0x43);
164 const SkColor kNegativeTextColor = SkColorSetRGB(0xc5, 0x39, 0x29);
165 static const SkColor kResultsTablePositiveText = color_utils::AlphaBlend(
166 kPositiveTextColor, kTextfieldDefaultBackground, 0xDD);
167 static const SkColor kResultsTablePositiveHoveredText =
168 color_utils::AlphaBlend(kPositiveTextColor,
169 kResultsTableHoveredBackground, 0xDD);
170 static const SkColor kResultsTablePositiveSelectedText =
171 color_utils::AlphaBlend(kPositiveTextColor,
172 kTextfieldSelectionBackgroundFocused, 0xDD);
173 static const SkColor kResultsTableNegativeText = color_utils::AlphaBlend(
174 kNegativeTextColor, kTextfieldDefaultBackground, 0xDD);
175 static const SkColor kResultsTableNegativeHoveredText =
176 color_utils::AlphaBlend(kNegativeTextColor,
177 kResultsTableHoveredBackground, 0xDD);
178 static const SkColor kResultsTableNegativeSelectedText =
179 color_utils::AlphaBlend(kNegativeTextColor,
180 kTextfieldSelectionBackgroundFocused, 0xDD);
182 switch (color_id) {
183 // Windows
184 case kColorId_WindowBackground:
185 return kWindowBackgroundColor;
187 // Dialogs
188 case kColorId_DialogBackground:
189 return kDialogBackgroundColor;
191 // FocusableBorder
192 case kColorId_FocusedBorderColor:
193 return kFocusedBorderColor;
194 case kColorId_UnfocusedBorderColor:
195 return kUnfocusedBorderColor;
197 // Button
198 case kColorId_ButtonBackgroundColor:
199 return kButtonBackgroundColor;
200 case kColorId_ButtonEnabledColor:
201 return kButtonEnabledColor;
202 case kColorId_ButtonHighlightColor:
203 return kButtonHighlightColor;
204 case kColorId_ButtonHoverColor:
205 return kButtonHoverColor;
207 // Label
208 case kColorId_LabelEnabledColor:
209 return kLabelEnabledColor;
210 case kColorId_LabelDisabledColor:
211 return GetSystemColor(kColorId_ButtonDisabledColor);
212 case kColorId_LabelBackgroundColor:
213 return kLabelBackgroundColor;
215 // Textfield
216 case kColorId_TextfieldDefaultColor:
217 return kTextfieldDefaultColor;
218 case kColorId_TextfieldDefaultBackground:
219 return kTextfieldDefaultBackground;
220 case kColorId_TextfieldReadOnlyColor:
221 return kTextfieldReadOnlyColor;
222 case kColorId_TextfieldReadOnlyBackground:
223 return kTextfieldReadOnlyBackground;
224 case kColorId_TextfieldSelectionColor:
225 return kTextfieldSelectionColor;
226 case kColorId_TextfieldSelectionBackgroundFocused:
227 return kTextfieldSelectionBackgroundFocused;
229 // Tooltip
230 case kColorId_TooltipBackground:
231 return kTooltipBackground;
232 case kColorId_TooltipText:
233 return kTooltipTextColor;
235 // Tree
236 case kColorId_TreeBackground:
237 return kTreeBackground;
238 case kColorId_TreeText:
239 return kTreeTextColor;
240 case kColorId_TreeSelectedText:
241 case kColorId_TreeSelectedTextUnfocused:
242 return kTreeSelectedTextColor;
243 case kColorId_TreeSelectionBackgroundFocused:
244 case kColorId_TreeSelectionBackgroundUnfocused:
245 return kTreeSelectionBackgroundColor;
246 case kColorId_TreeArrow:
247 return kTreeArrowColor;
249 // Table
250 case kColorId_TableBackground:
251 return kTableBackground;
252 case kColorId_TableText:
253 return kTableTextColor;
254 case kColorId_TableSelectedText:
255 case kColorId_TableSelectedTextUnfocused:
256 return kTableSelectedTextColor;
257 case kColorId_TableSelectionBackgroundFocused:
258 case kColorId_TableSelectionBackgroundUnfocused:
259 return kTableSelectionBackgroundColor;
260 case kColorId_TableGroupingIndicatorColor:
261 return kTableGroupingIndicatorColor;
263 // Results Tables
264 case kColorId_ResultsTableNormalBackground:
265 return kTextfieldDefaultBackground;
266 case kColorId_ResultsTableHoveredBackground:
267 return kResultsTableHoveredBackground;
268 case kColorId_ResultsTableSelectedBackground:
269 return kResultsTableSelectedBackground;
270 case kColorId_ResultsTableNormalText:
271 return kResultsTableNormalText;
272 case kColorId_ResultsTableHoveredText:
273 return kResultsTableHoveredText;
274 case kColorId_ResultsTableSelectedText:
275 return kResultsTableSelectedText;
276 case kColorId_ResultsTableNormalDimmedText:
277 return kResultsTableNormalDimmedText;
278 case kColorId_ResultsTableHoveredDimmedText:
279 return kResultsTableHoveredDimmedText;
280 case kColorId_ResultsTableSelectedDimmedText:
281 return kResultsTableSelectedDimmedText;
282 case kColorId_ResultsTableNormalUrl:
283 return kResultsTableNormalUrl;
284 case kColorId_ResultsTableHoveredUrl:
285 case kColorId_ResultsTableSelectedUrl:
286 return kResultsTableSelectedOrHoveredUrl;
287 case kColorId_ResultsTableNormalDivider:
288 return kResultsTableNormalDivider;
289 case kColorId_ResultsTableHoveredDivider:
290 return kResultsTableHoveredDivider;
291 case kColorId_ResultsTableSelectedDivider:
292 return kResultsTableSelectedDivider;
293 case kColorId_ResultsTablePositiveText:
294 return kResultsTablePositiveText;
295 case kColorId_ResultsTablePositiveHoveredText:
296 return kResultsTablePositiveHoveredText;
297 case kColorId_ResultsTablePositiveSelectedText:
298 return kResultsTablePositiveSelectedText;
299 case kColorId_ResultsTableNegativeText:
300 return kResultsTableNegativeText;
301 case kColorId_ResultsTableNegativeHoveredText:
302 return kResultsTableNegativeHoveredText;
303 case kColorId_ResultsTableNegativeSelectedText:
304 return kResultsTableNegativeSelectedText;
306 default:
307 NOTREACHED();
308 break;
311 return kInvalidColorIdColor;
314 } // namespace ui