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

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

Issue 2863843002: [Merge to M59] Gtk3: Add background class to tooltips (Closed)
Patch Set: Created 3 years, 7 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.h ('k') | no next file » | 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 19 matching lines...) Expand all
30 const gchar* prop_name) { 30 const gchar* prop_name) {
31 GValue layout = G_VALUE_INIT; 31 GValue layout = G_VALUE_INIT;
32 g_value_init(&layout, G_TYPE_STRING); 32 g_value_init(&layout, G_TYPE_STRING);
33 g_object_get_property(G_OBJECT(settings), prop_name, &layout); 33 g_object_get_property(G_OBJECT(settings), prop_name, &layout);
34 DCHECK(G_VALUE_HOLDS_STRING(&layout)); 34 DCHECK(G_VALUE_HOLDS_STRING(&layout));
35 std::string prop_value(g_value_get_string(&layout)); 35 std::string prop_value(g_value_get_string(&layout));
36 g_value_unset(&layout); 36 g_value_unset(&layout);
37 return prop_value; 37 return prop_value;
38 } 38 }
39 39
40 ScopedStyleContext GetTooltipContext() {
41 return AppendCssNodeToStyleContext(
42 nullptr, GtkVersionCheck(3, 20) ? "#tooltip.background"
43 : "GtkWindow#window.background.tooltip");
44 }
45
40 SkBitmap GetWidgetBitmap(const gfx::Size& size, 46 SkBitmap GetWidgetBitmap(const gfx::Size& size,
41 GtkStyleContext* context, 47 GtkStyleContext* context,
42 BackgroundRenderMode bg_mode, 48 BackgroundRenderMode bg_mode,
43 bool render_frame) { 49 bool render_frame) {
44 DCHECK(bg_mode != BG_RENDER_NONE || render_frame); 50 DCHECK(bg_mode != BG_RENDER_NONE || render_frame);
45 SkBitmap bitmap; 51 SkBitmap bitmap;
46 bitmap.allocN32Pixels(size.width(), size.height()); 52 bitmap.allocN32Pixels(size.width(), size.height());
47 bitmap.eraseColor(0); 53 bitmap.eraseColor(0);
48 54
49 CairoSurface surface(bitmap); 55 CairoSurface surface(bitmap);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 return GetFgColor(GtkVersionCheck(3, 20) 242 return GetFgColor(GtkVersionCheck(3, 20)
237 ? "GtkTextView#textview.view #text #selection" 243 ? "GtkTextView#textview.view #text #selection"
238 : "GtkTextView.view:selected"); 244 : "GtkTextView.view:selected");
239 case ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused: 245 case ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused:
240 return GetSelectionBgColor( 246 return GetSelectionBgColor(
241 GtkVersionCheck(3, 20) ? "GtkTextView#textview.view #text #selection" 247 GtkVersionCheck(3, 20) ? "GtkTextView#textview.view #text #selection"
242 : "GtkTextView.view:selected"); 248 : "GtkTextView.view:selected");
243 249
244 // Tooltips 250 // Tooltips
245 case ui::NativeTheme::kColorId_TooltipBackground: 251 case ui::NativeTheme::kColorId_TooltipBackground:
246 return GetBgColor("GtkTooltip#tooltip"); 252 return GetBgColorFromStyleContext(GetTooltipContext());
247 case ui::NativeTheme::kColorId_TooltipText: 253 case ui::NativeTheme::kColorId_TooltipText: {
248 return GetFgColor("GtkTooltip#tooltip GtkLabel"); 254 auto context = GetTooltipContext();
255 context = AppendCssNodeToStyleContext(context, "GtkLabel");
256 return GetFgColorFromStyleContext(context);
257 }
249 258
250 // Trees and Tables (implemented on GTK using the same class) 259 // Trees and Tables (implemented on GTK using the same class)
251 case ui::NativeTheme::kColorId_TableBackground: 260 case ui::NativeTheme::kColorId_TableBackground:
252 case ui::NativeTheme::kColorId_TreeBackground: 261 case ui::NativeTheme::kColorId_TreeBackground:
253 return GetBgColor( 262 return GetBgColor(
254 "GtkTreeView#treeview.view GtkTreeView#treeview.view.cell"); 263 "GtkTreeView#treeview.view GtkTreeView#treeview.view.cell");
255 case ui::NativeTheme::kColorId_TableText: 264 case ui::NativeTheme::kColorId_TableText:
256 case ui::NativeTheme::kColorId_TreeText: 265 case ui::NativeTheme::kColorId_TreeText:
257 case ui::NativeTheme::kColorId_TableGroupingIndicatorColor: 266 case ui::NativeTheme::kColorId_TableGroupingIndicatorColor:
258 return GetFgColor( 267 return GetFgColor(
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 g_type_class_unref(g_type_class_ref(gtk_label_get_type())); 411 g_type_class_unref(g_type_class_ref(gtk_label_get_type()));
403 g_type_class_unref(g_type_class_ref(gtk_menu_get_type())); 412 g_type_class_unref(g_type_class_ref(gtk_menu_get_type()));
404 g_type_class_unref(g_type_class_ref(gtk_menu_bar_get_type())); 413 g_type_class_unref(g_type_class_ref(gtk_menu_bar_get_type()));
405 g_type_class_unref(g_type_class_ref(gtk_menu_item_get_type())); 414 g_type_class_unref(g_type_class_ref(gtk_menu_item_get_type()));
406 g_type_class_unref(g_type_class_ref(gtk_range_get_type())); 415 g_type_class_unref(g_type_class_ref(gtk_range_get_type()));
407 g_type_class_unref(g_type_class_ref(gtk_scrollbar_get_type())); 416 g_type_class_unref(g_type_class_ref(gtk_scrollbar_get_type()));
408 g_type_class_unref(g_type_class_ref(gtk_scrolled_window_get_type())); 417 g_type_class_unref(g_type_class_ref(gtk_scrolled_window_get_type()));
409 g_type_class_unref(g_type_class_ref(gtk_separator_get_type())); 418 g_type_class_unref(g_type_class_ref(gtk_separator_get_type()));
410 g_type_class_unref(g_type_class_ref(gtk_spinner_get_type())); 419 g_type_class_unref(g_type_class_ref(gtk_spinner_get_type()));
411 g_type_class_unref(g_type_class_ref(gtk_text_view_get_type())); 420 g_type_class_unref(g_type_class_ref(gtk_text_view_get_type()));
412 g_type_class_unref(g_type_class_ref(gtk_tooltip_get_type()));
413 g_type_class_unref(g_type_class_ref(gtk_tree_view_get_type())); 421 g_type_class_unref(g_type_class_ref(gtk_tree_view_get_type()));
414 g_type_class_unref(g_type_class_ref(gtk_window_get_type())); 422 g_type_class_unref(g_type_class_ref(gtk_window_get_type()));
415 423
416 g_signal_connect_after(gtk_settings_get_default(), "notify::gtk-theme-name", 424 g_signal_connect_after(gtk_settings_get_default(), "notify::gtk-theme-name",
417 G_CALLBACK(OnThemeChangedThunk), this); 425 G_CALLBACK(OnThemeChangedThunk), this);
418 OnThemeChanged(gtk_settings_get_default(), nullptr); 426 OnThemeChanged(gtk_settings_get_default(), nullptr);
419 } 427 }
420 428
421 NativeThemeGtk3::~NativeThemeGtk3() { 429 NativeThemeGtk3::~NativeThemeGtk3() {
422 NOTREACHED(); 430 NOTREACHED();
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 638
631 if (frame_top_area.incognito) { 639 if (frame_top_area.incognito) {
632 bitmap = SkBitmapOperations::CreateHSLShiftedBitmap( 640 bitmap = SkBitmapOperations::CreateHSLShiftedBitmap(
633 bitmap, kDefaultTintFrameIncognito); 641 bitmap, kDefaultTintFrameIncognito);
634 } 642 }
635 643
636 canvas->drawBitmap(bitmap, rect.x(), rect.y()); 644 canvas->drawBitmap(bitmap, rect.x(), rect.y());
637 } 645 }
638 646
639 } // namespace libgtkui 647 } // namespace libgtkui
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtkui/gtk_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698