| OLD | NEW |
| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 case ui::NativeTheme::kColorId_LabelTextSelectionColor: | 114 case ui::NativeTheme::kColorId_LabelTextSelectionColor: |
| 115 return GetFgColor("GtkLabel#label #selection:selected"); | 115 return GetFgColor("GtkLabel#label #selection:selected"); |
| 116 case ui::NativeTheme::kColorId_LabelTextSelectionBackgroundFocused: | 116 case ui::NativeTheme::kColorId_LabelTextSelectionBackgroundFocused: |
| 117 return GetBgColor("GtkLabel#label #selection:selected"); | 117 return GetBgColor("GtkLabel#label #selection:selected"); |
| 118 | 118 |
| 119 // Link | 119 // Link |
| 120 case ui::NativeTheme::kColorId_LinkDisabled: | 120 case ui::NativeTheme::kColorId_LinkDisabled: |
| 121 return SkColorSetA( | 121 return SkColorSetA( |
| 122 SkColorFromColorId(ui::NativeTheme::kColorId_LinkEnabled), 0xBB); | 122 SkColorFromColorId(ui::NativeTheme::kColorId_LinkEnabled), 0xBB); |
| 123 case ui::NativeTheme::kColorId_LinkPressed: | 123 case ui::NativeTheme::kColorId_LinkPressed: |
| 124 if (GtkVersionCheck(3, 12)) |
| 125 return GetFgColor("GtkLabel#label.link:link:hover:active"); |
| 126 // fallthrough |
| 124 case ui::NativeTheme::kColorId_LinkEnabled: { | 127 case ui::NativeTheme::kColorId_LinkEnabled: { |
| 125 // TODO(thomasanderson): Gtk changed the way links are colored in 3.12. | 128 if (GtkVersionCheck(3, 12)) { |
| 126 // Add code for later versions. | 129 return GetFgColor("GtkLabel#label.link:link"); |
| 130 } |
| 127 auto link_context = GetStyleContextFromCss("GtkLabel#label.view"); | 131 auto link_context = GetStyleContextFromCss("GtkLabel#label.view"); |
| 128 GdkColor* color; | 132 GdkColor* color; |
| 129 gtk_style_context_get_style(link_context, "link-color", &color, nullptr); | 133 gtk_style_context_get_style(link_context, "link-color", &color, nullptr); |
| 130 if (color) { | 134 if (color) { |
| 131 SkColor ret_color = SkColorSetRGB(color->red / 255, color->green / 255, | 135 SkColor ret_color = SkColorSetRGB(color->red / 255, color->green / 255, |
| 132 color->blue / 255); | 136 color->blue / 255); |
| 137 // gdk_color_free() was deprecated in Gtk3.14. This code path is only |
| 138 // taken on versions earlier than Gtk3.12, but the compiler doesn't know |
| 139 // that, so silence the deprecation warnings. |
| 140 G_GNUC_BEGIN_IGNORE_DEPRECATIONS; |
| 133 gdk_color_free(color); | 141 gdk_color_free(color); |
| 142 G_GNUC_END_IGNORE_DEPRECATIONS; |
| 134 return ret_color; | 143 return ret_color; |
| 135 } else { | |
| 136 // Default color comes from gtklinkbutton.c. | |
| 137 return SkColorSetRGB(0x00, 0x00, 0xEE); | |
| 138 } | 144 } |
| 145 |
| 146 // Default color comes from gtklinkbutton.c. |
| 147 return SkColorSetRGB(0x00, 0x00, 0xEE); |
| 139 } | 148 } |
| 140 | 149 |
| 141 // Separator | 150 // Separator |
| 142 case ui::NativeTheme::kColorId_SeparatorColor: | 151 case ui::NativeTheme::kColorId_SeparatorColor: |
| 143 if (GtkVersionCheck(3, 20)) | 152 if (GtkVersionCheck(3, 20)) |
| 144 return GetBgColor("GtkSeparator#separator.horizontal"); | 153 return GetBgColor("GtkSeparator#separator.horizontal"); |
| 145 else | 154 else |
| 146 return GetFgColor("GtkSeparator#separator.horizontal"); | 155 return GetFgColor("GtkSeparator#separator.horizontal"); |
| 147 | 156 |
| 148 // Button | 157 // Button |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 void NativeThemeGtk3::PaintMenuItemBackground( | 364 void NativeThemeGtk3::PaintMenuItemBackground( |
| 356 SkCanvas* canvas, | 365 SkCanvas* canvas, |
| 357 State state, | 366 State state, |
| 358 const gfx::Rect& rect, | 367 const gfx::Rect& rect, |
| 359 const MenuItemExtraParams& menu_item) const { | 368 const MenuItemExtraParams& menu_item) const { |
| 360 PaintWidget(canvas, rect, "GtkMenu#menu GtkMenuItem#menuitem", | 369 PaintWidget(canvas, rect, "GtkMenu#menu GtkMenuItem#menuitem", |
| 361 StateToStateFlags(state)); | 370 StateToStateFlags(state)); |
| 362 } | 371 } |
| 363 | 372 |
| 364 } // namespace libgtkui | 373 } // namespace libgtkui |
| OLD | NEW |