Bug 1287085 - Move GtkInfoBar from gtk3drawing to WidgetCache. r=acomminos

This commit is contained in:
Martin Stransky 2016-07-19 00:03:00 -04:00
parent 1677159f2c
commit a344deacb1
3 changed files with 23 additions and 24 deletions

View File

@ -157,6 +157,14 @@ CreateToolbarSeparatorWidget()
return widget;
}
static GtkWidget*
CreateInfoBarWidget()
{
GtkWidget* widget = gtk_info_bar_new();
AddToWindowContainer(widget);
return widget;
}
static GtkWidget*
CreateWidget(WidgetNodeType aWidgetType)
{
@ -195,6 +203,8 @@ CreateWidget(WidgetNodeType aWidgetType)
return CreateToolbarWidget();
case MOZ_GTK_TOOLBAR_SEPARATOR:
return CreateToolbarSeparatorWidget();
case MOZ_GTK_INFO_BAR:
return CreateInfoBarWidget();
default:
/* Not implemented */
return nullptr;
@ -335,6 +345,10 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType)
// TODO - create from CSS node
return GetWidgetStyleWithClass(MOZ_GTK_GRIPPER,
GTK_STYLE_CLASS_GRIP);
case MOZ_GTK_INFO_BAR:
// TODO - create from CSS node
return GetWidgetStyleWithClass(MOZ_GTK_INFO_BAR,
GTK_STYLE_CLASS_INFO);
default:
// TODO - create style from style path
GtkWidget* widget = GetWidget(aNodeType);
@ -389,6 +403,9 @@ GetWidgetStyleInternal(WidgetNodeType aNodeType)
case MOZ_GTK_GRIPPER:
return GetWidgetStyleWithClass(MOZ_GTK_GRIPPER,
GTK_STYLE_CLASS_GRIP);
case MOZ_GTK_INFO_BAR:
return GetWidgetStyleWithClass(MOZ_GTK_INFO_BAR,
GTK_STYLE_CLASS_INFO);
default:
GtkWidget* widget = GetWidget(aNodeType);
MOZ_ASSERT(widget);

View File

@ -46,7 +46,6 @@ static GtkWidget* gMenuSeparatorWidget;
static GtkWidget* gHPanedWidget;
static GtkWidget* gVPanedWidget;
static GtkWidget* gScrolledWindowWidget;
static GtkWidget* gInfoBar;
static style_prop_t style_prop_func;
static gboolean have_arrow_scaling;
@ -286,15 +285,6 @@ ensure_combo_box_widgets()
return MOZ_GTK_SUCCESS;
}
static void
ensure_info_bar()
{
if (!gInfoBar) {
gInfoBar = gtk_info_bar_new();
setup_widget_prototype(gInfoBar);
}
}
/* We need to have pointers to the inner widgets (entry, button, arrow) of
* the ComboBoxEntry to get the correct rendering from theme engines which
* special cases their look. Since the inner layout can change, we ask GTK
@ -2416,21 +2406,13 @@ static gint
moz_gtk_info_bar_paint(cairo_t *cr, GdkRectangle* rect,
GtkWidgetState* state)
{
GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
GtkStyleContext *style;
ensure_info_bar();
style = gtk_widget_get_style_context(gInfoBar);
gtk_style_context_save(style);
gtk_style_context_set_state(style, state_flags);
gtk_style_context_add_class(style, GTK_STYLE_CLASS_INFO);
GtkStyleContext *style =
ClaimStyleContext(MOZ_GTK_INFO_BAR, GTK_TEXT_DIR_LTR,
GetStateFlagsFromGtkWidgetState(state));
gtk_render_background(style, cr, rect->x, rect->y, rect->width,
rect->height);
gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
gtk_style_context_restore(style);
ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@ -2652,8 +2634,7 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
return MOZ_GTK_SUCCESS;
}
case MOZ_GTK_INFO_BAR:
ensure_info_bar();
w = gInfoBar;
w = GetWidget(MOZ_GTK_INFO_BAR);
break;
case MOZ_GTK_TOOLTIP:
{

View File

@ -1357,6 +1357,7 @@ nsLookAndFeel::Init()
gtk_widget_path_free(path);
// GtkInfoBar
// TODO - Use WidgetCache for it?
GtkWidget* infoBar = gtk_info_bar_new();
GtkWidget* infoBarContent = gtk_info_bar_get_content_area(GTK_INFO_BAR(infoBar));
GtkWidget* infoBarLabel = gtk_label_new(nullptr);