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

Unified Diff: chrome/browser/ui/libgtkui/gtk_ui.cc

Issue 2765883003: Gtk3: Fix button outline sizing on different GTK minor versions (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/libgtkui/gtk_ui.cc
diff --git a/chrome/browser/ui/libgtkui/gtk_ui.cc b/chrome/browser/ui/libgtkui/gtk_ui.cc
index dd59476a70333754846827023d83ff534227c372..e17e70c07bf1e0970464edb8d4429d0db9d5105d 100644
--- a/chrome/browser/ui/libgtkui/gtk_ui.cc
+++ b/chrome/browser/ui/libgtkui/gtk_ui.cc
@@ -177,8 +177,36 @@ class GtkButtonImageSource : public gfx::ImageSkiaSource {
gtk_style_context_set_state(context, state_flags);
gtk_render_background(context, cr, 0, 0, width, height);
gtk_render_frame(context, cr, 0, 0, width, height);
- if (focus_)
- gtk_render_focus(context, cr, 0, 0, width, height);
+ if (focus_) {
+ gfx::Rect focus_rect(width, height);
+
+ if (!GtkVersionCheck(3, 14)) {
+ gint focus_pad;
+ gtk_style_context_get_style(context, "focus-padding", &focus_pad,
+ nullptr);
+ focus_rect.Inset(focus_pad, focus_pad);
+
+ if (state_ == ui::NativeTheme::kPressed) {
+ gint child_displacement_x, child_displacement_y;
+ gboolean displace_focus;
+ gtk_style_context_get_style(
+ context, "child-displacement-x", &child_displacement_x,
+ "child-displacement-y", &child_displacement_y, "displace-focus",
+ &displace_focus, nullptr);
+ if (displace_focus)
+ focus_rect.Offset(child_displacement_x, child_displacement_y);
+ }
+ }
+
+ if (!GtkVersionCheck(3, 20)) {
+ GtkBorder border;
+ gtk_style_context_get_border(context, state_flags, &border);
+ focus_rect.Inset(border.left, border.top, border.right, border.bottom);
+ }
+
+ gtk_render_focus(context, cr, focus_rect.x(), focus_rect.y(),
+ focus_rect.width(), focus_rect.height());
+ }
#endif
cairo_destroy(cr);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698