firefox/mozilla-1160154.patch
2015-08-07 13:48:05 +02:00

116 lines
4.1 KiB
Diff

# HG changeset patch
# Parent 3a4bfa5d2d026f7d3fbfd0f87663b87b5caa9344
# User Petr Jasicek <pjasicek@redhat.com>
Bug 1160154 - Decrease padding between icons in the personal toolbar with Gtk3 by using "image-button" css style class. r=karlt
diff --git a/widget/gtk/gtk3drawing.c b/widget/gtk/gtk3drawing.c
--- a/widget/gtk/gtk3drawing.c
+++ b/widget/gtk/gtk3drawing.c
@@ -2629,26 +2629,35 @@ moz_gtk_get_widget_border(GtkThemeWidget
gboolean inhtml)
{
GtkWidget* w;
GtkStyleContext* style;
*left = *top = *right = *bottom = 0;
switch (widget) {
case MOZ_GTK_BUTTON:
+ case MOZ_GTK_TOOLBAR_BUTTON:
{
ensure_button_widget();
style = gtk_widget_get_style_context(gButtonWidget);
*left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(gButtonWidget));
/* Don't add this padding in HTML, otherwise the buttons will
become too big and stuff the layout. */
if (!inhtml) {
+ if (widget == MOZ_GTK_TOOLBAR_BUTTON) {
+ gtk_style_context_save(style);
+ gtk_style_context_add_class(style, "image-button");
+ }
+
moz_gtk_add_style_padding(style, left, top, right, bottom);
+
+ if (widget == MOZ_GTK_TOOLBAR_BUTTON)
+ gtk_style_context_restore(style);
}
moz_gtk_add_style_border(style, left, top, right, bottom);
return MOZ_GTK_SUCCESS;
}
case MOZ_GTK_ENTRY:
{
ensure_entry_widget();
@@ -3081,16 +3090,17 @@ moz_gtk_widget_paint(GtkThemeWidgetType
GtkTextDirection direction)
{
/* A workaround for https://bugzilla.gnome.org/show_bug.cgi?id=694086
*/
cairo_new_path(cr);
switch (widget) {
case MOZ_GTK_BUTTON:
+ case MOZ_GTK_TOOLBAR_BUTTON:
if (state->depressed) {
ensure_toggle_button_widget();
return moz_gtk_button_paint(cr, rect, state,
(GtkReliefStyle) flags,
gToggleButtonWidget, direction);
}
ensure_button_widget();
return moz_gtk_button_paint(cr, rect, state,
diff --git a/widget/gtk/gtkdrawing.h b/widget/gtk/gtkdrawing.h
--- a/widget/gtk/gtkdrawing.h
+++ b/widget/gtk/gtkdrawing.h
@@ -84,16 +84,18 @@ typedef gint (*style_prop_t)(GtkStyle*,
/*** checkbox/radio flags ***/
#define MOZ_GTK_WIDGET_CHECKED 1
#define MOZ_GTK_WIDGET_INCONSISTENT (1 << 1)
/*** widget type constants ***/
typedef enum {
/* Paints a GtkButton. flags is a GtkReliefStyle. */
MOZ_GTK_BUTTON,
+ /* Paints a button with image and no text */
+ MOZ_GTK_TOOLBAR_BUTTON,
/* Paints a GtkCheckButton. flags is a boolean, 1=checked, 0=not checked. */
MOZ_GTK_CHECKBUTTON,
/* Paints a GtkRadioButton. flags is a boolean, 1=checked, 0=not checked. */
MOZ_GTK_RADIOBUTTON,
/**
* Paints the button of a GtkScrollbar. flags is a GtkArrowType giving
* the arrow direction.
*/
diff --git a/widget/gtk/nsNativeThemeGTK.cpp b/widget/gtk/nsNativeThemeGTK.cpp
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -386,21 +386,25 @@ nsNativeThemeGTK::GetGtkWidgetAndState(u
*aWidgetFlags = CheckBooleanAttr(aFrame, nsGkAtoms::parentfocused);
}
}
}
}
switch (aWidgetType) {
case NS_THEME_BUTTON:
+ if (aWidgetFlags)
+ *aWidgetFlags = GTK_RELIEF_NORMAL;
+ aGtkWidgetType = MOZ_GTK_BUTTON;
+ break;
case NS_THEME_TOOLBAR_BUTTON:
case NS_THEME_TOOLBAR_DUAL_BUTTON:
if (aWidgetFlags)
- *aWidgetFlags = (aWidgetType == NS_THEME_BUTTON) ? GTK_RELIEF_NORMAL : GTK_RELIEF_NONE;
- aGtkWidgetType = MOZ_GTK_BUTTON;
+ *aWidgetFlags = GTK_RELIEF_NONE;
+ aGtkWidgetType = MOZ_GTK_TOOLBAR_BUTTON;
break;
case NS_THEME_FOCUS_OUTLINE:
aGtkWidgetType = MOZ_GTK_ENTRY;
break;
case NS_THEME_CHECKBOX:
case NS_THEME_RADIO:
aGtkWidgetType = (aWidgetType == NS_THEME_RADIO) ? MOZ_GTK_RADIOBUTTON : MOZ_GTK_CHECKBUTTON;
break;