mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
bug 1272194 replace MOZ_TOPLEVEL_MENU_ITEM flag with MOZ_GTK_MENUBARITEM node r=stransky+263117
This provides a better mapping between WidgetNodeType and GtkWidgets. MozReview-Commit-ID: 3YYzK4aZCbP --HG-- extra : rebase_source : b2a2dc92b77a265fc73077345c1b6a18d9a4abc5
This commit is contained in:
parent
e97acb68fb
commit
50d0eedfba
@ -2614,16 +2614,16 @@ moz_gtk_menu_separator_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
moz_gtk_menu_item_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
moz_gtk_menu_item_paint(WidgetNodeType widget, GdkDrawable* drawable,
|
||||||
GdkRectangle* cliprect, GtkWidgetState* state,
|
GdkRectangle* rect, GdkRectangle* cliprect,
|
||||||
gint flags, GtkTextDirection direction)
|
GtkWidgetState* state, GtkTextDirection direction)
|
||||||
{
|
{
|
||||||
GtkStyle* style;
|
GtkStyle* style;
|
||||||
GtkShadowType shadow_type;
|
GtkShadowType shadow_type;
|
||||||
GtkWidget* item_widget;
|
GtkWidget* item_widget;
|
||||||
|
|
||||||
if (state->inHover && !state->disabled) {
|
if (state->inHover && !state->disabled) {
|
||||||
if (flags & MOZ_TOPLEVEL_MENU_ITEM) {
|
if (widget == MOZ_GTK_MENUBARITEM) {
|
||||||
ensure_menu_bar_item_widget();
|
ensure_menu_bar_item_widget();
|
||||||
item_widget = gMenuBarItemWidget;
|
item_widget = gMenuBarItemWidget;
|
||||||
} else {
|
} else {
|
||||||
@ -2682,7 +2682,8 @@ moz_gtk_check_menu_item_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|||||||
gint indicator_size, horizontal_padding;
|
gint indicator_size, horizontal_padding;
|
||||||
gint x, y;
|
gint x, y;
|
||||||
|
|
||||||
moz_gtk_menu_item_paint(drawable, rect, cliprect, state, FALSE, direction);
|
moz_gtk_menu_item_paint(MOZ_GTK_MENUITEM, drawable, rect, cliprect, state,
|
||||||
|
direction);
|
||||||
|
|
||||||
ensure_check_menu_item_widget();
|
ensure_check_menu_item_widget();
|
||||||
gtk_widget_set_direction(gCheckMenuItemWidget, direction);
|
gtk_widget_set_direction(gCheckMenuItemWidget, direction);
|
||||||
@ -2957,6 +2958,9 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
|
|||||||
ensure_menu_popup_widget();
|
ensure_menu_popup_widget();
|
||||||
w = gMenuPopupWidget;
|
w = gMenuPopupWidget;
|
||||||
break;
|
break;
|
||||||
|
case MOZ_GTK_MENUBARITEM:
|
||||||
|
// Bug 1274143 for MOZ_GTK_MENUBARITEM.
|
||||||
|
// Fall through to MOZ_GTK_MENUITEM for now.
|
||||||
case MOZ_GTK_MENUITEM:
|
case MOZ_GTK_MENUITEM:
|
||||||
ensure_menu_item_widget();
|
ensure_menu_item_widget();
|
||||||
ensure_menu_bar_item_widget();
|
ensure_menu_bar_item_widget();
|
||||||
@ -3385,8 +3389,9 @@ moz_gtk_widget_paint(WidgetNodeType widget, GdkDrawable* drawable,
|
|||||||
return moz_gtk_menu_separator_paint(drawable, rect, cliprect,
|
return moz_gtk_menu_separator_paint(drawable, rect, cliprect,
|
||||||
direction);
|
direction);
|
||||||
break;
|
break;
|
||||||
|
case MOZ_GTK_MENUBARITEM:
|
||||||
case MOZ_GTK_MENUITEM:
|
case MOZ_GTK_MENUITEM:
|
||||||
return moz_gtk_menu_item_paint(drawable, rect, cliprect, state, flags,
|
return moz_gtk_menu_item_paint(widget, drawable, rect, cliprect, state,
|
||||||
direction);
|
direction);
|
||||||
break;
|
break;
|
||||||
case MOZ_GTK_MENUARROW:
|
case MOZ_GTK_MENUARROW:
|
||||||
|
@ -2455,9 +2455,8 @@ moz_gtk_menu_separator_paint(cairo_t *cr, GdkRectangle* rect,
|
|||||||
|
|
||||||
// See gtk_menu_item_draw() for reference.
|
// See gtk_menu_item_draw() for reference.
|
||||||
static gint
|
static gint
|
||||||
moz_gtk_menu_item_paint(cairo_t *cr, GdkRectangle* rect,
|
moz_gtk_menu_item_paint(WidgetNodeType widget, cairo_t *cr, GdkRectangle* rect,
|
||||||
GtkWidgetState* state,
|
GtkWidgetState* state, GtkTextDirection direction)
|
||||||
gint flags, GtkTextDirection direction)
|
|
||||||
{
|
{
|
||||||
GtkStyleContext* style;
|
GtkStyleContext* style;
|
||||||
GtkWidget* item_widget;
|
GtkWidget* item_widget;
|
||||||
@ -2465,7 +2464,7 @@ moz_gtk_menu_item_paint(cairo_t *cr, GdkRectangle* rect,
|
|||||||
gint x, y, w, h;
|
gint x, y, w, h;
|
||||||
|
|
||||||
if (state->inHover && !state->disabled) {
|
if (state->inHover && !state->disabled) {
|
||||||
if (flags & MOZ_TOPLEVEL_MENU_ITEM) {
|
if (widget == MOZ_GTK_MENUBARITEM) {
|
||||||
ensure_menu_bar_item_widget();
|
ensure_menu_bar_item_widget();
|
||||||
item_widget = gMenuBarItemWidget;
|
item_widget = gMenuBarItemWidget;
|
||||||
} else {
|
} else {
|
||||||
@ -2474,7 +2473,7 @@ moz_gtk_menu_item_paint(cairo_t *cr, GdkRectangle* rect,
|
|||||||
}
|
}
|
||||||
style = gtk_widget_get_style_context(item_widget);
|
style = gtk_widget_get_style_context(item_widget);
|
||||||
|
|
||||||
if (flags & MOZ_TOPLEVEL_MENU_ITEM) {
|
if (widget == MOZ_GTK_MENUBARITEM) {
|
||||||
gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUBAR);
|
gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUBAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2491,7 +2490,7 @@ moz_gtk_menu_item_paint(cairo_t *cr, GdkRectangle* rect,
|
|||||||
gtk_render_background(style, cr, x, y, w, h);
|
gtk_render_background(style, cr, x, y, w, h);
|
||||||
gtk_render_frame(style, cr, x, y, w, h);
|
gtk_render_frame(style, cr, x, y, w, h);
|
||||||
|
|
||||||
if (flags & MOZ_TOPLEVEL_MENU_ITEM) {
|
if (widget == MOZ_GTK_MENUBARITEM) {
|
||||||
gtk_style_context_remove_class(style, GTK_STYLE_CLASS_MENUBAR);
|
gtk_style_context_remove_class(style, GTK_STYLE_CLASS_MENUBAR);
|
||||||
}
|
}
|
||||||
gtk_style_context_set_state(style, GTK_STATE_FLAG_NORMAL);
|
gtk_style_context_set_state(style, GTK_STATE_FLAG_NORMAL);
|
||||||
@ -2537,7 +2536,7 @@ moz_gtk_check_menu_item_paint(cairo_t *cr, GdkRectangle* rect,
|
|||||||
gint indicator_size, horizontal_padding;
|
gint indicator_size, horizontal_padding;
|
||||||
gint x, y;
|
gint x, y;
|
||||||
|
|
||||||
moz_gtk_menu_item_paint(cr, rect, state, FALSE, direction);
|
moz_gtk_menu_item_paint(MOZ_GTK_MENUITEM, cr, rect, state, direction);
|
||||||
|
|
||||||
ensure_check_menu_item_widget();
|
ensure_check_menu_item_widget();
|
||||||
gtk_widget_set_direction(gCheckMenuItemWidget, direction);
|
gtk_widget_set_direction(gCheckMenuItemWidget, direction);
|
||||||
@ -2808,16 +2807,15 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
|
|||||||
ensure_menu_popup_widget();
|
ensure_menu_popup_widget();
|
||||||
w = gMenuPopupWidget;
|
w = gMenuPopupWidget;
|
||||||
break;
|
break;
|
||||||
|
case MOZ_GTK_MENUBARITEM:
|
||||||
case MOZ_GTK_MENUITEM:
|
case MOZ_GTK_MENUITEM:
|
||||||
case MOZ_GTK_CHECKMENUITEM:
|
case MOZ_GTK_CHECKMENUITEM:
|
||||||
case MOZ_GTK_RADIOMENUITEM:
|
case MOZ_GTK_RADIOMENUITEM:
|
||||||
{
|
{
|
||||||
if (widget == MOZ_GTK_MENUITEM) {
|
if (widget == MOZ_GTK_MENUBARITEM || widget == MOZ_GTK_MENUITEM) {
|
||||||
ensure_menu_item_widget();
|
ensure_menu_item_widget();
|
||||||
ensure_menu_bar_item_widget();
|
w = gMenuItemWidget; // Bug 1274143 for MOZ_GTK_MENUBARITEM
|
||||||
w = gMenuItemWidget;
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
ensure_check_menu_item_widget();
|
ensure_check_menu_item_widget();
|
||||||
w = gCheckMenuItemWidget;
|
w = gCheckMenuItemWidget;
|
||||||
}
|
}
|
||||||
@ -3318,9 +3316,9 @@ moz_gtk_widget_paint(WidgetNodeType widget, cairo_t *cr,
|
|||||||
return moz_gtk_menu_separator_paint(cr, rect,
|
return moz_gtk_menu_separator_paint(cr, rect,
|
||||||
direction);
|
direction);
|
||||||
break;
|
break;
|
||||||
|
case MOZ_GTK_MENUBARITEM:
|
||||||
case MOZ_GTK_MENUITEM:
|
case MOZ_GTK_MENUITEM:
|
||||||
return moz_gtk_menu_item_paint(cr, rect, state, flags,
|
return moz_gtk_menu_item_paint(widget, cr, rect, state, direction);
|
||||||
direction);
|
|
||||||
break;
|
break;
|
||||||
case MOZ_GTK_MENUARROW:
|
case MOZ_GTK_MENUARROW:
|
||||||
return moz_gtk_menu_arrow_paint(cr, rect, state,
|
return moz_gtk_menu_arrow_paint(cr, rect, state,
|
||||||
|
@ -69,12 +69,6 @@ typedef enum {
|
|||||||
MOZ_GTK_TAB_SELECTED = 1 << 10
|
MOZ_GTK_TAB_SELECTED = 1 << 10
|
||||||
} GtkTabFlags;
|
} GtkTabFlags;
|
||||||
|
|
||||||
/** flags for menuitems **/
|
|
||||||
typedef enum {
|
|
||||||
/* menuitem is part of the menubar */
|
|
||||||
MOZ_TOPLEVEL_MENU_ITEM = 1 << 0
|
|
||||||
} GtkMenuItemFlags;
|
|
||||||
|
|
||||||
/* function type for moz_gtk_enable_style_props */
|
/* function type for moz_gtk_enable_style_props */
|
||||||
typedef gint (*style_prop_t)(GtkStyle*, const gchar*, gint);
|
typedef gint (*style_prop_t)(GtkStyle*, const gchar*, gint);
|
||||||
|
|
||||||
@ -189,7 +183,9 @@ typedef enum {
|
|||||||
MOZ_GTK_MENUARROW,
|
MOZ_GTK_MENUARROW,
|
||||||
/* Paints an arrow in a toolbar button. flags is a GtkArrowType. */
|
/* Paints an arrow in a toolbar button. flags is a GtkArrowType. */
|
||||||
MOZ_GTK_TOOLBARBUTTON_ARROW,
|
MOZ_GTK_TOOLBARBUTTON_ARROW,
|
||||||
/* Paints items of menubar and popups. */
|
/* Paints items of menubar. */
|
||||||
|
MOZ_GTK_MENUBARITEM,
|
||||||
|
/* Paints items of popup menus. */
|
||||||
MOZ_GTK_MENUITEM,
|
MOZ_GTK_MENUITEM,
|
||||||
MOZ_GTK_CHECKMENUITEM,
|
MOZ_GTK_CHECKMENUITEM,
|
||||||
MOZ_GTK_RADIOMENUITEM,
|
MOZ_GTK_RADIOMENUITEM,
|
||||||
|
@ -354,10 +354,8 @@ nsNativeThemeGTK::GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame,
|
|||||||
|
|
||||||
if (isTopLevel) {
|
if (isTopLevel) {
|
||||||
aState->inHover = menuFrame->IsOpen();
|
aState->inHover = menuFrame->IsOpen();
|
||||||
*aWidgetFlags |= MOZ_TOPLEVEL_MENU_ITEM;
|
|
||||||
} else {
|
} else {
|
||||||
aState->inHover = CheckBooleanAttr(aFrame, nsGkAtoms::menuactive);
|
aState->inHover = CheckBooleanAttr(aFrame, nsGkAtoms::menuactive);
|
||||||
*aWidgetFlags &= ~MOZ_TOPLEVEL_MENU_ITEM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aState->active = FALSE;
|
aState->active = FALSE;
|
||||||
@ -679,6 +677,13 @@ nsNativeThemeGTK::GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame,
|
|||||||
aGtkWidgetType = MOZ_GTK_MENUPOPUP;
|
aGtkWidgetType = MOZ_GTK_MENUPOPUP;
|
||||||
break;
|
break;
|
||||||
case NS_THEME_MENUITEM:
|
case NS_THEME_MENUITEM:
|
||||||
|
{
|
||||||
|
nsMenuFrame *menuFrame = do_QueryFrame(aFrame);
|
||||||
|
if (menuFrame && menuFrame->IsOnMenuBar()) {
|
||||||
|
aGtkWidgetType = MOZ_GTK_MENUBARITEM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
aGtkWidgetType = MOZ_GTK_MENUITEM;
|
aGtkWidgetType = MOZ_GTK_MENUITEM;
|
||||||
break;
|
break;
|
||||||
case NS_THEME_MENUSEPARATOR:
|
case NS_THEME_MENUSEPARATOR:
|
||||||
|
Loading…
Reference in New Issue
Block a user