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

Side by Side Diff: chrome/browser/ui/libgtkui/native_theme_gtk3.cc

Issue 2683953005: Gtk3: More fixes and refactorings (Closed)
Patch Set: Remove lambda Created 3 years, 10 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
« no previous file with comments | « chrome/browser/ui/libgtkui/gtk_util.cc ('k') | docs/linux_gtk_theme_integration.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/libgtkui/native_theme_gtk3.h" 5 #include "chrome/browser/ui/libgtkui/native_theme_gtk3.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "chrome/browser/ui/libgtkui/chrome_gtk_frame.h" 9 #include "chrome/browser/ui/libgtkui/chrome_gtk_frame.h"
10 #include "chrome/browser/ui/libgtkui/chrome_gtk_menu_subclasses.h" 10 #include "chrome/browser/ui/libgtkui/chrome_gtk_menu_subclasses.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return GetBorderColor("GtkEntry#entry"); 99 return GetBorderColor("GtkEntry#entry");
100 100
101 // Menu 101 // Menu
102 case ui::NativeTheme::kColorId_MenuBackgroundColor: 102 case ui::NativeTheme::kColorId_MenuBackgroundColor:
103 return GetBgColor("GtkMenu#menu"); 103 return GetBgColor("GtkMenu#menu");
104 case ui::NativeTheme::kColorId_MenuBorderColor: 104 case ui::NativeTheme::kColorId_MenuBorderColor:
105 return GetBorderColor("GtkMenu#menu"); 105 return GetBorderColor("GtkMenu#menu");
106 case ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor: 106 case ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor:
107 return GetBgColor("GtkMenu#menu GtkMenuItem#menuitem:hover"); 107 return GetBgColor("GtkMenu#menu GtkMenuItem#menuitem:hover");
108 case ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor: 108 case ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor:
109 return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem GtkLabel#label"); 109 return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem GtkLabel");
110 case ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor: 110 case ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor:
111 return GetFgColor( 111 return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem:hover GtkLabel");
112 "GtkMenu#menu GtkMenuItem#menuitem:hover GtkLabel#label");
113 case ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor: 112 case ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor:
114 return GetFgColor( 113 return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem:disabled GtkLabel");
115 "GtkMenu#menu GtkMenuItem#menuitem:disabled GtkLabel#label");
116 case ui::NativeTheme::kColorId_MenuItemSubtitleColor: 114 case ui::NativeTheme::kColorId_MenuItemSubtitleColor:
117 return GetFgColor( 115 return GetFgColor(
118 "GtkMenu#menu GtkMenuItem#menuitem GtkLabel#label.accelerator"); 116 "GtkMenu#menu GtkMenuItem#menuitem GtkLabel.accelerator");
119 case ui::NativeTheme::kColorId_MenuSeparatorColor: 117 case ui::NativeTheme::kColorId_MenuSeparatorColor:
120 // MenuButton borders are used as vertical menu separators in Chrome. 118 // MenuButton borders are used as vertical menu separators in Chrome.
121 case ui::NativeTheme::kColorId_EnabledMenuButtonBorderColor: 119 case ui::NativeTheme::kColorId_EnabledMenuButtonBorderColor:
122 case ui::NativeTheme::kColorId_FocusedMenuButtonBorderColor: 120 case ui::NativeTheme::kColorId_FocusedMenuButtonBorderColor:
123 case ui::NativeTheme::kColorId_HoverMenuButtonBorderColor: 121 case ui::NativeTheme::kColorId_HoverMenuButtonBorderColor:
124 if (GtkVersionCheck(3, 20)) 122 if (GtkVersionCheck(3, 20)) {
125 return GetBgColor("GtkMenu#menu GtkSeparator#separator"); 123 return GetSeparatorColor(
126 else 124 "GtkMenu#menu GtkSeparator#separator.horizontal");
125 } else {
127 return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem.separator"); 126 return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem.separator");
127 }
128 128
129 // Label 129 // Label
130 case ui::NativeTheme::kColorId_LabelEnabledColor: 130 case ui::NativeTheme::kColorId_LabelEnabledColor:
131 return GetFgColor("GtkLabel#label"); 131 return GetFgColor("GtkLabel");
132 case ui::NativeTheme::kColorId_LabelDisabledColor: 132 case ui::NativeTheme::kColorId_LabelDisabledColor:
133 return GetFgColor("GtkLabel#label:disabled"); 133 return GetFgColor("GtkLabel:disabled");
134 case ui::NativeTheme::kColorId_LabelTextSelectionColor: 134 case ui::NativeTheme::kColorId_LabelTextSelectionColor:
135 return GetFgColor("GtkLabel#label #selection:selected"); 135 return GetSelectedTextColor("GtkLabel");
136 case ui::NativeTheme::kColorId_LabelTextSelectionBackgroundFocused: 136 case ui::NativeTheme::kColorId_LabelTextSelectionBackgroundFocused:
137 return GetBgColor("GtkLabel#label #selection:selected"); 137 return GetSelectedBgColor("GtkLabel");
138 138
139 // Link 139 // Link
140 case ui::NativeTheme::kColorId_LinkDisabled: 140 case ui::NativeTheme::kColorId_LinkDisabled:
141 return SkColorSetA( 141 return SkColorSetA(
142 SkColorFromColorId(ui::NativeTheme::kColorId_LinkEnabled), 0xBB); 142 SkColorFromColorId(ui::NativeTheme::kColorId_LinkEnabled), 0xBB);
143 case ui::NativeTheme::kColorId_LinkPressed: 143 case ui::NativeTheme::kColorId_LinkPressed:
144 if (GtkVersionCheck(3, 12)) 144 if (GtkVersionCheck(3, 12))
145 return GetFgColor("GtkLabel#label.link:link:hover:active"); 145 return GetFgColor("GtkLabel.link:link:hover:active");
146 // fallthrough 146 // fallthrough
147 case ui::NativeTheme::kColorId_LinkEnabled: { 147 case ui::NativeTheme::kColorId_LinkEnabled: {
148 if (GtkVersionCheck(3, 12)) { 148 if (GtkVersionCheck(3, 12)) {
149 return GetFgColor("GtkLabel#label.link:link"); 149 return GetFgColor("GtkLabel.link:link");
150 } 150 }
151 auto link_context = GetStyleContextFromCss("GtkLabel#label.view"); 151 auto link_context = GetStyleContextFromCss("GtkLabel.view");
152 GdkColor* color; 152 GdkColor* color;
153 gtk_style_context_get_style(link_context, "link-color", &color, nullptr); 153 gtk_style_context_get_style(link_context, "link-color", &color, nullptr);
154 if (color) { 154 if (color) {
155 SkColor ret_color = SkColorSetRGB(color->red / 255, color->green / 255, 155 SkColor ret_color = SkColorSetRGB(color->red / 255, color->green / 255,
156 color->blue / 255); 156 color->blue / 255);
157 // gdk_color_free() was deprecated in Gtk3.14. This code path is only 157 // gdk_color_free() was deprecated in Gtk3.14. This code path is only
158 // taken on versions earlier than Gtk3.12, but the compiler doesn't know 158 // taken on versions earlier than Gtk3.12, but the compiler doesn't know
159 // that, so silence the deprecation warnings. 159 // that, so silence the deprecation warnings.
160 G_GNUC_BEGIN_IGNORE_DEPRECATIONS; 160 G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
161 gdk_color_free(color); 161 gdk_color_free(color);
162 G_GNUC_END_IGNORE_DEPRECATIONS; 162 G_GNUC_END_IGNORE_DEPRECATIONS;
163 return ret_color; 163 return ret_color;
164 } 164 }
165 165
166 // Default color comes from gtklinkbutton.c. 166 // Default color comes from gtklinkbutton.c.
167 return SkColorSetRGB(0x00, 0x00, 0xEE); 167 return SkColorSetRGB(0x00, 0x00, 0xEE);
168 } 168 }
169 169
170 // Separator 170 // Separator
171 case ui::NativeTheme::kColorId_SeparatorColor: 171 case ui::NativeTheme::kColorId_SeparatorColor:
172 return GetSeparatorColor("GtkSeparator#separator.horizontal"); 172 return GetSeparatorColor("GtkSeparator#separator.horizontal");
173 173
174 // Button 174 // Button
175 case ui::NativeTheme::kColorId_ButtonEnabledColor: 175 case ui::NativeTheme::kColorId_ButtonEnabledColor:
176 return GetFgColor("GtkButton#button.text-button GtkLabel#label"); 176 return GetFgColor("GtkButton#button.text-button GtkLabel");
177 case ui::NativeTheme::kColorId_ButtonDisabledColor: 177 case ui::NativeTheme::kColorId_ButtonDisabledColor:
178 return GetFgColor("GtkButton#button.text-button:disabled GtkLabel#label"); 178 return GetFgColor("GtkButton#button.text-button:disabled GtkLabel");
179 case ui::NativeTheme::kColorId_ButtonHoverColor: 179 case ui::NativeTheme::kColorId_ButtonHoverColor:
180 return GetFgColor("GtkButton#button.text-button:hover GtkLabel#label"); 180 return GetFgColor("GtkButton#button.text-button:hover GtkLabel");
181 case ui::NativeTheme::kColorId_ButtonPressedShade: 181 case ui::NativeTheme::kColorId_ButtonPressedShade:
182 return SK_ColorTRANSPARENT; 182 return SK_ColorTRANSPARENT;
183 183
184 case ui::NativeTheme::kColorId_BlueButtonEnabledColor: 184 case ui::NativeTheme::kColorId_BlueButtonEnabledColor:
185 return GetFgColor( 185 return GetFgColor(
186 "GtkButton#button.text-button.suggested-action GtkLabel#label"); 186 "GtkButton#button.text-button.suggested-action GtkLabel");
187 case ui::NativeTheme::kColorId_BlueButtonDisabledColor: 187 case ui::NativeTheme::kColorId_BlueButtonDisabledColor:
188 return GetFgColor( 188 return GetFgColor(
189 "GtkButton#button.text-button.suggested-action:disabled " 189 "GtkButton#button.text-button.suggested-action:disabled "
190 "GtkLabel#label"); 190 "GtkLabel");
191 case ui::NativeTheme::kColorId_BlueButtonHoverColor: 191 case ui::NativeTheme::kColorId_BlueButtonHoverColor:
192 return GetFgColor( 192 return GetFgColor(
193 "GtkButton#button.text-button.suggested-action:hover GtkLabel#label"); 193 "GtkButton#button.text-button.suggested-action:hover GtkLabel");
194 case ui::NativeTheme::kColorId_BlueButtonPressedColor: 194 case ui::NativeTheme::kColorId_BlueButtonPressedColor:
195 return GetFgColor( 195 return GetFgColor(
196 "GtkButton#button.text-button.suggested-action:hover:active " 196 "GtkButton#button.text-button.suggested-action:hover:active "
197 "GtkLabel#label"); 197 "GtkLabel");
198 case ui::NativeTheme::kColorId_BlueButtonShadowColor: 198 case ui::NativeTheme::kColorId_BlueButtonShadowColor:
199 return SK_ColorTRANSPARENT; 199 return SK_ColorTRANSPARENT;
200 200
201 case ui::NativeTheme::kColorId_ProminentButtonColor: 201 case ui::NativeTheme::kColorId_ProminentButtonColor:
202 return GetBgColor("GtkButton#button.text-button.destructive-action"); 202 return GetBgColor("GtkButton#button.text-button.destructive-action");
203 case ui::NativeTheme::kColorId_TextOnProminentButtonColor: 203 case ui::NativeTheme::kColorId_TextOnProminentButtonColor:
204 return GetFgColor( 204 return GetFgColor(
205 "GtkButton#button.text-button.destructive-action GtkLabel#label"); 205 "GtkButton#button.text-button.destructive-action GtkLabel");
206 206
207 // Textfield 207 // Textfield
208 case ui::NativeTheme::kColorId_TextfieldDefaultColor: 208 case ui::NativeTheme::kColorId_TextfieldDefaultColor:
209 return GetFgColor("GtkEntry#entry"); 209 return GetFgColor("GtkEntry#entry");
210 case ui::NativeTheme::kColorId_TextfieldDefaultBackground: 210 case ui::NativeTheme::kColorId_TextfieldDefaultBackground:
211 return GetBgColor("GtkEntry#entry"); 211 return GetBgColor("GtkEntry#entry");
212 case ui::NativeTheme::kColorId_TextfieldReadOnlyColor: 212 case ui::NativeTheme::kColorId_TextfieldReadOnlyColor:
213 return GetFgColor("GtkEntry#entry:disabled"); 213 return GetFgColor("GtkEntry#entry:disabled");
214 case ui::NativeTheme::kColorId_TextfieldReadOnlyBackground: 214 case ui::NativeTheme::kColorId_TextfieldReadOnlyBackground:
215 return GetBgColor("GtkEntry#entry:disabled"); 215 return GetBgColor("GtkEntry#entry:disabled");
216 case ui::NativeTheme::kColorId_TextfieldSelectionColor: 216 case ui::NativeTheme::kColorId_TextfieldSelectionColor:
217 return GetFgColor("GtkEntry#entry #selection:selected"); 217 return GetSelectedTextColor("GtkEntry#entry");
218 case ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused: 218 case ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused:
219 return GetBgColor("GtkEntry#entry #selection:selected"); 219 return GetSelectedBgColor("GtkEntry#entry");
220 220
221 // Tooltips 221 // Tooltips
222 case ui::NativeTheme::kColorId_TooltipBackground: 222 case ui::NativeTheme::kColorId_TooltipBackground:
223 return GetBgColor("GtkTooltip#tooltip"); 223 return GetBgColor("GtkTooltip#tooltip");
224 case ui::NativeTheme::kColorId_TooltipText: 224 case ui::NativeTheme::kColorId_TooltipText:
225 return color_utils::GetReadableColor(GetFgColor("GtkTooltip#tooltip"), 225 return color_utils::GetReadableColor(GetFgColor("GtkTooltip#tooltip"),
226 GetBgColor("GtkTooltip#tooltip")); 226 GetBgColor("GtkTooltip#tooltip"));
227 227
228 // Trees and Tables (implemented on GTK using the same class) 228 // Trees and Tables (implemented on GTK using the same class)
229 case ui::NativeTheme::kColorId_TableBackground: 229 case ui::NativeTheme::kColorId_TableBackground:
230 case ui::NativeTheme::kColorId_TreeBackground: 230 case ui::NativeTheme::kColorId_TreeBackground:
231 return GetBgColor("GtkTreeView#treeview.view .view.cell"); 231 return GetBgColor("GtkTreeView#treeview.view .view.cell");
232 case ui::NativeTheme::kColorId_TableText: 232 case ui::NativeTheme::kColorId_TableText:
233 case ui::NativeTheme::kColorId_TreeText: 233 case ui::NativeTheme::kColorId_TreeText:
234 case ui::NativeTheme::kColorId_TreeArrow: 234 case ui::NativeTheme::kColorId_TreeArrow:
235 case ui::NativeTheme::kColorId_TableGroupingIndicatorColor: 235 case ui::NativeTheme::kColorId_TableGroupingIndicatorColor:
236 return GetFgColor("GtkTreeView#treeview.view .view.cell GtkLabel#label"); 236 return GetFgColor("GtkTreeView#treeview.view .view.cell GtkLabel");
237 case ui::NativeTheme::kColorId_TableSelectedText: 237 case ui::NativeTheme::kColorId_TableSelectedText:
238 case ui::NativeTheme::kColorId_TableSelectedTextUnfocused: 238 case ui::NativeTheme::kColorId_TableSelectedTextUnfocused:
239 case ui::NativeTheme::kColorId_TreeSelectedText: 239 case ui::NativeTheme::kColorId_TreeSelectedText:
240 case ui::NativeTheme::kColorId_TreeSelectedTextUnfocused: 240 case ui::NativeTheme::kColorId_TreeSelectedTextUnfocused:
241 return GetFgColor( 241 return GetFgColor(
242 "GtkTreeView#treeview.view .view.cell:selected:focus GtkLabel#label"); 242 "GtkTreeView#treeview.view .view.cell:selected:focus GtkLabel");
243 case ui::NativeTheme::kColorId_TableSelectionBackgroundFocused: 243 case ui::NativeTheme::kColorId_TableSelectionBackgroundFocused:
244 case ui::NativeTheme::kColorId_TableSelectionBackgroundUnfocused: 244 case ui::NativeTheme::kColorId_TableSelectionBackgroundUnfocused:
245 case ui::NativeTheme::kColorId_TreeSelectionBackgroundFocused: 245 case ui::NativeTheme::kColorId_TreeSelectionBackgroundFocused:
246 case ui::NativeTheme::kColorId_TreeSelectionBackgroundUnfocused: 246 case ui::NativeTheme::kColorId_TreeSelectionBackgroundUnfocused:
247 return GetBgColor("GtkTreeView#treeview.view .view.cell:selected:focus"); 247 return GetBgColor("GtkTreeView#treeview.view .view.cell:selected:focus");
248 248
249 // Table Header 249 // Table Header
250 case ui::NativeTheme::kColorId_TableHeaderText: 250 case ui::NativeTheme::kColorId_TableHeaderText:
251 return GetFgColor( 251 return GetFgColor("GtkTreeView#treeview.view GtkButton#button GtkLabel");
252 "GtkTreeView#treeview.view GtkButton#button GtkLabel#label");
253 case ui::NativeTheme::kColorId_TableHeaderBackground: 252 case ui::NativeTheme::kColorId_TableHeaderBackground:
254 return GetBgColor("GtkTreeView#treeview.view GtkButton#button"); 253 return GetBgColor("GtkTreeView#treeview.view GtkButton#button");
255 case ui::NativeTheme::kColorId_TableHeaderSeparator: 254 case ui::NativeTheme::kColorId_TableHeaderSeparator:
256 return GetBorderColor("GtkTreeView#treeview.view GtkButton#button"); 255 return GetBorderColor("GtkTreeView#treeview.view GtkButton#button");
257 256
258 // Results Table 257 // Results Table
259 // TODO(thomasanderson): The GtkEntry selectors was how the gtk2 theme got
260 // these colors. Update this code to use a different widget.
261 case ui::NativeTheme::kColorId_ResultsTableNormalBackground: 258 case ui::NativeTheme::kColorId_ResultsTableNormalBackground:
262 return GetBgColor("GtkEntry#entry"); 259 return GetBgColor("GtkEntry#entry");
263 case ui::NativeTheme::kColorId_ResultsTableHoveredBackground: 260 case ui::NativeTheme::kColorId_ResultsTableHoveredBackground:
264 return color_utils::AlphaBlend( 261 return color_utils::AlphaBlend(GetBgColor("GtkEntry#entry"),
265 GetBgColor("GtkEntry#entry"), 262 GetSelectedBgColor("GtkEntry#entry"),
266 GetBgColor("GtkEntry#entry #selection:selected"), 0x80); 263 0x80);
267 case ui::NativeTheme::kColorId_ResultsTableSelectedBackground: 264 case ui::NativeTheme::kColorId_ResultsTableSelectedBackground:
268 return GetBgColor("GtkEntry#entry #selection:selected"); 265 return GetSelectedBgColor("GtkEntry#entry");
269 case ui::NativeTheme::kColorId_ResultsTableNormalText: 266 case ui::NativeTheme::kColorId_ResultsTableNormalText:
270 case ui::NativeTheme::kColorId_ResultsTableHoveredText: 267 case ui::NativeTheme::kColorId_ResultsTableHoveredText:
271 return GetFgColor("GtkEntry#entry"); 268 return GetFgColor("GtkEntry#entry");
272 case ui::NativeTheme::kColorId_ResultsTableSelectedText: 269 case ui::NativeTheme::kColorId_ResultsTableSelectedText:
273 return GetFgColor("GtkEntry#entry #selection:selected"); 270 return GetSelectedTextColor("GtkEntry#entry");
274 case ui::NativeTheme::kColorId_ResultsTableNormalDimmedText: 271 case ui::NativeTheme::kColorId_ResultsTableNormalDimmedText:
275 case ui::NativeTheme::kColorId_ResultsTableHoveredDimmedText: 272 case ui::NativeTheme::kColorId_ResultsTableHoveredDimmedText:
276 return color_utils::AlphaBlend(GetFgColor("GtkEntry#entry"), 273 return color_utils::AlphaBlend(GetFgColor("GtkEntry#entry"),
277 GetBgColor("GtkEntry#entry"), 0x80); 274 GetBgColor("GtkEntry#entry"), 0x80);
278 case ui::NativeTheme::kColorId_ResultsTableSelectedDimmedText: 275 case ui::NativeTheme::kColorId_ResultsTableSelectedDimmedText:
279 return color_utils::AlphaBlend( 276 return color_utils::AlphaBlend(GetSelectedTextColor("GtkEntry#entry"),
280 GetFgColor("GtkEntry#entry #selection:selected"), 277 GetBgColor("GtkEntry#entry"), 0x80);
281 GetBgColor("GtkEntry#entry"), 0x80);
282 case ui::NativeTheme::kColorId_ResultsTableNormalUrl: 278 case ui::NativeTheme::kColorId_ResultsTableNormalUrl:
283 case ui::NativeTheme::kColorId_ResultsTableHoveredUrl: 279 case ui::NativeTheme::kColorId_ResultsTableHoveredUrl:
284 return NormalURLColor(GetFgColor("GtkEntry#entry")); 280 return NormalURLColor(GetFgColor("GtkEntry#entry"));
285 case ui::NativeTheme::kColorId_ResultsTableSelectedUrl: 281 case ui::NativeTheme::kColorId_ResultsTableSelectedUrl:
286 return SelectedURLColor(GetFgColor("GtkEntry#entry #selection:selected"), 282 return SelectedURLColor(GetSelectedTextColor("GtkEntry#entry"),
287 GetBgColor("GtkEntry#entry #selection:selected")); 283 GetSelectedBgColor("GtkEntry#entry"));
288 284
289 case ui::NativeTheme::kColorId_ResultsTablePositiveText: 285 case ui::NativeTheme::kColorId_ResultsTablePositiveText:
290 return color_utils::GetReadableColor(kPositiveTextColor, 286 return color_utils::GetReadableColor(kPositiveTextColor,
291 GetBgColor("GtkEntry#entry")); 287 GetBgColor("GtkEntry#entry"));
292 case ui::NativeTheme::kColorId_ResultsTablePositiveHoveredText: 288 case ui::NativeTheme::kColorId_ResultsTablePositiveHoveredText:
293 return color_utils::GetReadableColor(kPositiveTextColor, 289 return color_utils::GetReadableColor(kPositiveTextColor,
294 GetBgColor("GtkEntry#entry:hover")); 290 GetBgColor("GtkEntry#entry:hover"));
295 case ui::NativeTheme::kColorId_ResultsTablePositiveSelectedText: 291 case ui::NativeTheme::kColorId_ResultsTablePositiveSelectedText:
296 return color_utils::GetReadableColor( 292 return color_utils::GetReadableColor(
297 kPositiveTextColor, GetBgColor("GtkEntry#entry:selected")); 293 kPositiveTextColor, GetBgColor("GtkEntry#entry:selected"));
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 gtk_style_context_add_class(context, GTK_STYLE_CLASS_BOTTOM); 402 gtk_style_context_add_class(context, GTK_STYLE_CLASS_BOTTOM);
407 break; 403 break;
408 case kScrollbarLeftArrow: 404 case kScrollbarLeftArrow:
409 gtk_style_context_add_class(context, GTK_STYLE_CLASS_LEFT); 405 gtk_style_context_add_class(context, GTK_STYLE_CLASS_LEFT);
410 break; 406 break;
411 default: 407 default:
412 NOTREACHED(); 408 NOTREACHED();
413 } 409 }
414 410
415 PaintWidget(canvas, rect, context, BG_RENDER_NORMAL, true); 411 PaintWidget(canvas, rect, context, BG_RENDER_NORMAL, true);
416 PaintArrow(canvas, rect, direction, SkColorFromStyleContext(context)); 412 PaintArrow(canvas, rect, direction, GetFgColorFromStyleContext(context));
417 } 413 }
418 414
419 void NativeThemeGtk3::PaintScrollbarTrack( 415 void NativeThemeGtk3::PaintScrollbarTrack(
420 SkCanvas* canvas, 416 SkCanvas* canvas,
421 Part part, 417 Part part,
422 State state, 418 State state,
423 const ScrollbarTrackExtraParams& extra_params, 419 const ScrollbarTrackExtraParams& extra_params,
424 const gfx::Rect& rect) const { 420 const gfx::Rect& rect) const {
425 PaintWidget(canvas, rect, GetStyleContextFromCss( 421 PaintWidget(canvas, rect, GetStyleContextFromCss(
426 GtkVersionCheck(3, 20) 422 GtkVersionCheck(3, 20)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 State state, 472 State state,
477 const gfx::Rect& rect, 473 const gfx::Rect& rect,
478 const MenuSeparatorExtraParams& menu_separator) const { 474 const MenuSeparatorExtraParams& menu_separator) const {
479 auto separator_offset = [&](int separator_thickness) { 475 auto separator_offset = [&](int separator_thickness) {
480 switch (menu_separator.type) { 476 switch (menu_separator.type) {
481 case ui::LOWER_SEPARATOR: 477 case ui::LOWER_SEPARATOR:
482 return rect.height() - separator_thickness; 478 return rect.height() - separator_thickness;
483 case ui::UPPER_SEPARATOR: 479 case ui::UPPER_SEPARATOR:
484 return 0; 480 return 0;
485 default: 481 default:
486 return rect.height() / 2; 482 return (rect.height() - separator_thickness) / 2;
487 } 483 }
488 }; 484 };
489 if (GtkVersionCheck(3, 20)) { 485 if (GtkVersionCheck(3, 20)) {
490 auto context = 486 auto context = GetStyleContextFromCss(
491 GetStyleContextFromCss("GtkMenu#menu GtkSeparator#separator"); 487 "GtkMenu#menu GtkSeparator#separator.horizontal");
492 GtkBorder margin, border, padding; 488 GtkBorder margin, border, padding;
493 GtkStateFlags state = gtk_style_context_get_state(context); 489 GtkStateFlags state = gtk_style_context_get_state(context);
494 gtk_style_context_get_margin(context, state, &margin); 490 gtk_style_context_get_margin(context, state, &margin);
495 gtk_style_context_get_border(context, state, &border); 491 gtk_style_context_get_border(context, state, &border);
496 gtk_style_context_get_padding(context, state, &padding); 492 gtk_style_context_get_padding(context, state, &padding);
497 int min_height = 0; 493 int min_height = 1;
498 gtk_style_context_get(context, state, "min-height", &min_height, NULL); 494 gtk_style_context_get(context, state, "min-height", &min_height, NULL);
499 int w = rect.width() - margin.left - margin.right; 495 int w = rect.width() - margin.left - margin.right;
500 int h = 496 int h = std::max(
501 min_height + padding.top + padding.bottom + border.top + border.bottom; 497 min_height + padding.top + padding.bottom + border.top + border.bottom,
498 1);
502 int x = margin.left; 499 int x = margin.left;
503 int y = separator_offset(h); 500 int y = separator_offset(h);
504 PaintWidget(canvas, gfx::Rect(x, y, w, h), context, BG_RENDER_NORMAL, true); 501 PaintWidget(canvas, gfx::Rect(x, y, w, h), context, BG_RENDER_NORMAL, true);
505 } else { 502 } else {
506 auto context = 503 auto context = GetStyleContextFromCss(
507 GetStyleContextFromCss("GtkMenu#menu GtkMenuItem#menuitem.separator"); 504 "GtkMenu#menu GtkMenuItem#menuitem.separator.horizontal");
508 gboolean wide_separators = false; 505 gboolean wide_separators = false;
509 gint separator_height = 0; 506 gint separator_height = 0;
510 gtk_style_context_get_style(context, "wide-separators", &wide_separators, 507 gtk_style_context_get_style(context, "wide-separators", &wide_separators,
511 "separator-height", &separator_height, nullptr); 508 "separator-height", &separator_height, nullptr);
512 // This code was adapted from gtk/gtkmenuitem.c. For some reason, 509 // This code was adapted from gtk/gtkmenuitem.c. For some reason,
513 // padding is used as the margin. 510 // padding is used as the margin.
514 GtkBorder padding; 511 GtkBorder padding;
515 gtk_style_context_get_padding(context, gtk_style_context_get_state(context), 512 gtk_style_context_get_padding(context, gtk_style_context_get_state(context),
516 &padding); 513 &padding);
517 int w = rect.width() - padding.left - padding.right; 514 int w = rect.width() - padding.left - padding.right;
518 int x = rect.x() + padding.left; 515 int x = rect.x() + padding.left;
519 int h = wide_separators ? separator_height : 1; 516 int h = wide_separators ? separator_height : 1;
520 int y = rect.y() + separator_offset(h); 517 int y = rect.y() + separator_offset(h);
521 if (wide_separators) { 518 if (wide_separators) {
522 PaintWidget(canvas, gfx::Rect(x, y, w, h), context, BG_RENDER_NONE, true); 519 PaintWidget(canvas, gfx::Rect(x, y, w, h), context, BG_RENDER_NONE, true);
523 } else { 520 } else {
524 SkPaint paint; 521 SkPaint paint;
525 paint.setColor(SkColorFromStyleContext(context)); 522 paint.setColor(GetFgColorFromStyleContext(context));
526 canvas->drawLine(x, y, x + w, y, paint); 523 canvas->drawLine(x, y, x + w, y, paint);
527 } 524 }
528 } 525 }
529 } 526 }
530 527
531 void NativeThemeGtk3::PaintFrameTopArea( 528 void NativeThemeGtk3::PaintFrameTopArea(
532 cc::PaintCanvas* canvas, 529 cc::PaintCanvas* canvas,
533 State state, 530 State state,
534 const gfx::Rect& rect, 531 const gfx::Rect& rect,
535 const FrameTopAreaExtraParams& frame_top_area) const { 532 const FrameTopAreaExtraParams& frame_top_area) const {
536 auto context = GetStyleContextFromCss(frame_top_area.use_custom_frame 533 auto context = GetStyleContextFromCss(frame_top_area.use_custom_frame
537 ? "#headerbar.header-bar.titlebar" 534 ? "#headerbar.header-bar.titlebar"
538 : "GtkMenuBar#menubar"); 535 : "GtkMenuBar#menubar");
539 RemoveBorders(context); 536 ApplyCssToContext(context, "* { border-radius: 0px; border-style: none; }");
540 gtk_style_context_set_state(context, frame_top_area.is_active 537 gtk_style_context_set_state(context, frame_top_area.is_active
541 ? GTK_STATE_FLAG_NORMAL 538 ? GTK_STATE_FLAG_NORMAL
542 : GTK_STATE_FLAG_BACKDROP); 539 : GTK_STATE_FLAG_BACKDROP);
543 540
544 SkBitmap bitmap = 541 SkBitmap bitmap =
545 GetWidgetBitmap(rect.size(), context, BG_RENDER_RECURSIVE, false); 542 GetWidgetBitmap(rect.size(), context, BG_RENDER_RECURSIVE, false);
546 543
547 if (frame_top_area.incognito) { 544 if (frame_top_area.incognito) {
548 bitmap = SkBitmapOperations::CreateHSLShiftedBitmap( 545 bitmap = SkBitmapOperations::CreateHSLShiftedBitmap(
549 bitmap, kDefaultTintFrameIncognito); 546 bitmap, kDefaultTintFrameIncognito);
550 } 547 }
551 548
552 canvas->drawBitmap(bitmap, rect.x(), rect.y()); 549 canvas->drawBitmap(bitmap, rect.x(), rect.y());
553 } 550 }
554 551
555 } // namespace libgtkui 552 } // namespace libgtkui
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtkui/gtk_util.cc ('k') | docs/linux_gtk_theme_integration.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698