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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 return GetFgColor("GtkLabel.link:link:hover:active"); | 141 return GetFgColor("GtkLabel.link:link:hover:active"); |
142 // fallthrough | 142 // fallthrough |
143 case ui::NativeTheme::kColorId_LinkEnabled: { | 143 case ui::NativeTheme::kColorId_LinkEnabled: { |
144 if (GtkVersionCheck(3, 12)) { | 144 if (GtkVersionCheck(3, 12)) { |
145 return GetFgColor("GtkLabel.link:link"); | 145 return GetFgColor("GtkLabel.link:link"); |
146 } | 146 } |
147 auto link_context = GetStyleContextFromCss("GtkLabel.view"); | 147 auto link_context = GetStyleContextFromCss("GtkLabel.view"); |
148 GdkColor* color; | 148 GdkColor* color; |
149 gtk_style_context_get_style(link_context, "link-color", &color, nullptr); | 149 gtk_style_context_get_style(link_context, "link-color", &color, nullptr); |
150 if (color) { | 150 if (color) { |
151 SkColor ret_color = SkColorSetRGB(color->red / 255, color->green / 255, | 151 SkColor ret_color = GdkColorToSkColor(*color); |
152 color->blue / 255); | |
153 // gdk_color_free() was deprecated in Gtk3.14. This code path is only | 152 // gdk_color_free() was deprecated in Gtk3.14. This code path is only |
154 // taken on versions earlier than Gtk3.12, but the compiler doesn't know | 153 // taken on versions earlier than Gtk3.12, but the compiler doesn't know |
155 // that, so silence the deprecation warnings. | 154 // that, so silence the deprecation warnings. |
156 G_GNUC_BEGIN_IGNORE_DEPRECATIONS; | 155 G_GNUC_BEGIN_IGNORE_DEPRECATIONS; |
157 gdk_color_free(color); | 156 gdk_color_free(color); |
158 G_GNUC_END_IGNORE_DEPRECATIONS; | 157 G_GNUC_END_IGNORE_DEPRECATIONS; |
159 return ret_color; | 158 return ret_color; |
160 } | 159 } |
161 | 160 |
162 // Default color comes from gtklinkbutton.c. | 161 // Default color comes from gtklinkbutton.c. |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 canvas->drawLine(x, y, x + w, y, flags); | 566 canvas->drawLine(x, y, x + w, y, flags); |
568 } | 567 } |
569 } | 568 } |
570 } | 569 } |
571 | 570 |
572 void NativeThemeGtk3::PaintFrameTopArea( | 571 void NativeThemeGtk3::PaintFrameTopArea( |
573 cc::PaintCanvas* canvas, | 572 cc::PaintCanvas* canvas, |
574 State state, | 573 State state, |
575 const gfx::Rect& rect, | 574 const gfx::Rect& rect, |
576 const FrameTopAreaExtraParams& frame_top_area) const { | 575 const FrameTopAreaExtraParams& frame_top_area) const { |
577 auto context = GetStyleContextFromCss(frame_top_area.use_custom_frame | 576 auto context = GetStyleContextFromCss(frame_top_area.use_custom_frame && |
| 577 GtkVersionCheck(3, 10) |
578 ? "#headerbar.header-bar.titlebar" | 578 ? "#headerbar.header-bar.titlebar" |
579 : "GtkMenuBar#menubar"); | 579 : "GtkMenuBar#menubar"); |
580 ApplyCssToContext(context, "* { border-radius: 0px; border-style: none; }"); | 580 ApplyCssToContext(context, "* { border-radius: 0px; border-style: none; }"); |
581 gtk_style_context_set_state(context, frame_top_area.is_active | 581 gtk_style_context_set_state(context, frame_top_area.is_active |
582 ? GTK_STATE_FLAG_NORMAL | 582 ? GTK_STATE_FLAG_NORMAL |
583 : GTK_STATE_FLAG_BACKDROP); | 583 : GTK_STATE_FLAG_BACKDROP); |
584 | 584 |
585 SkBitmap bitmap = | 585 SkBitmap bitmap = |
586 GetWidgetBitmap(rect.size(), context, BG_RENDER_RECURSIVE, false); | 586 GetWidgetBitmap(rect.size(), context, BG_RENDER_RECURSIVE, false); |
587 | 587 |
588 if (frame_top_area.incognito) { | 588 if (frame_top_area.incognito) { |
589 bitmap = SkBitmapOperations::CreateHSLShiftedBitmap( | 589 bitmap = SkBitmapOperations::CreateHSLShiftedBitmap( |
590 bitmap, kDefaultTintFrameIncognito); | 590 bitmap, kDefaultTintFrameIncognito); |
591 } | 591 } |
592 | 592 |
593 canvas->drawBitmap(bitmap, rect.x(), rect.y()); | 593 canvas->drawBitmap(bitmap, rect.x(), rect.y()); |
594 } | 594 } |
595 | 595 |
596 } // namespace libgtkui | 596 } // namespace libgtkui |
OLD | NEW |