updated patch from mzbz#1160154

This commit is contained in:
Martin Stransky 2015-08-07 13:48:05 +02:00
parent 282611cf0e
commit cac7263b53

View File

@ -1,53 +1,115 @@
# 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 diff --git a/widget/gtk/gtk3drawing.c b/widget/gtk/gtk3drawing.c
--- a/widget/gtk/gtk3drawing.c --- a/widget/gtk/gtk3drawing.c
+++ b/widget/gtk/gtk3drawing.c +++ b/widget/gtk/gtk3drawing.c
@@ -72,16 +72,19 @@ static gboolean is_initialized; @@ -2629,26 +2629,35 @@ moz_gtk_get_widget_border(GtkThemeWidget
#define ARROW_DOWN G_PI
#define ARROW_RIGHT G_PI_2
#define ARROW_LEFT (G_PI+G_PI_2)
#if !GTK_CHECK_VERSION(3,14,0)
#define GTK_STATE_FLAG_CHECKED (1 << 11)
#endif
+// See Bug 1160154 for details
+#define MAX_WIDGET_PADDING 6
+
static GtkStateFlags
GetStateFlagsFromGtkWidgetState(GtkWidgetState* state)
{
GtkStateFlags stateFlags = GTK_STATE_FLAG_NORMAL;
if (state->disabled)
stateFlags = GTK_STATE_FLAG_INSENSITIVE;
else {
@@ -2590,22 +2593,22 @@ moz_gtk_add_style_border(GtkStyleContext
}
static void
moz_gtk_add_style_padding(GtkStyleContext* style,
gint* left, gint* top, gint* right, gint* bottom)
{
GtkBorder padding;
- gtk_style_context_get_padding(style, 0, &padding);
-
- *left += padding.left;
- *right += padding.right;
- *top += padding.top;
- *bottom += padding.bottom;
+ gtk_style_context_get_padding(style, 0, &padding);
+
+ *left += (padding.left > MAX_WIDGET_PADDING) ? MAX_WIDGET_PADDING : padding.left;
+ *right += (padding.right > MAX_WIDGET_PADDING) ? MAX_WIDGET_PADDING : padding.right;
+ *top += (padding.top > MAX_WIDGET_PADDING) ? MAX_WIDGET_PADDING : padding.top;
+ *bottom += (padding.bottom > MAX_WIDGET_PADDING) ? MAX_WIDGET_PADDING : padding.bottom;
}
gint
moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
gint* right, gint* bottom, GtkTextDirection direction,
gboolean inhtml) gboolean inhtml)
{ {
GtkWidget* w; 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;