diff --git a/widget/gtk/WidgetStyleCache.cpp b/widget/gtk/WidgetStyleCache.cpp index 6dbc2d113900..92b4178bdd8b 100644 --- a/widget/gtk/WidgetStyleCache.cpp +++ b/widget/gtk/WidgetStyleCache.cpp @@ -338,6 +338,14 @@ CreateScaleWidget(GtkOrientation aOrientation) return widget; } +static GtkWidget* +CreateNotebookWidget() +{ + GtkWidget* widget = gtk_notebook_new(); + AddToWindowContainer(widget); + return widget; +} + static GtkWidget* CreateWidget(WidgetNodeType aWidgetType) { @@ -414,6 +422,8 @@ CreateWidget(WidgetNodeType aWidgetType) return CreateScaleWidget(GTK_ORIENTATION_HORIZONTAL); case MOZ_GTK_SCALE_VERTICAL: return CreateScaleWidget(GTK_ORIENTATION_VERTICAL); + case MOZ_GTK_NOTEBOOK: + return CreateNotebookWidget(); default: /* Not implemented */ return nullptr; @@ -621,6 +631,33 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType) style = CreateChildCSSNode(GTK_STYLE_CLASS_SLIDER, MOZ_GTK_SCALE_TROUGH_VERTICAL); break; + case MOZ_GTK_TAB_TOP: + { + // TODO - create from CSS node + style = GetWidgetStyleWithClass(MOZ_GTK_NOTEBOOK, + GTK_STYLE_CLASS_TOP); + gtk_style_context_add_region(style, GTK_STYLE_REGION_TAB, + static_cast(0)); + return style; + } + case MOZ_GTK_TAB_BOTTOM: + { + // TODO - create from CSS node + style = GetWidgetStyleWithClass(MOZ_GTK_NOTEBOOK, + GTK_STYLE_CLASS_BOTTOM); + gtk_style_context_add_region(style, GTK_STYLE_REGION_TAB, + static_cast(0)); + return style; + } + case MOZ_GTK_NOTEBOOK: + case MOZ_GTK_NOTEBOOK_HEADER: + case MOZ_GTK_TABPANELS: + case MOZ_GTK_TAB_SCROLLARROW: + { + // TODO - create from CSS node + GtkWidget* widget = GetWidget(MOZ_GTK_NOTEBOOK); + return gtk_widget_get_style_context(widget); + } default: // TODO - create style from style path GtkWidget* widget = GetWidget(aNodeType); @@ -719,6 +756,30 @@ GetWidgetStyleInternal(WidgetNodeType aNodeType) case MOZ_GTK_SCALE_THUMB_VERTICAL: return GetWidgetStyleWithClass(MOZ_GTK_SCALE_VERTICAL, GTK_STYLE_CLASS_SLIDER); + case MOZ_GTK_TAB_TOP: + { + GtkStyleContext* style = GetWidgetStyleWithClass(MOZ_GTK_NOTEBOOK, + GTK_STYLE_CLASS_TOP); + gtk_style_context_add_region(style, GTK_STYLE_REGION_TAB, + static_cast(0)); + return style; + } + case MOZ_GTK_TAB_BOTTOM: + { + GtkStyleContext* style = GetWidgetStyleWithClass(MOZ_GTK_NOTEBOOK, + GTK_STYLE_CLASS_BOTTOM); + gtk_style_context_add_region(style, GTK_STYLE_REGION_TAB, + static_cast(0)); + return style; + } + case MOZ_GTK_NOTEBOOK: + case MOZ_GTK_NOTEBOOK_HEADER: + case MOZ_GTK_TABPANELS: + case MOZ_GTK_TAB_SCROLLARROW: + { + GtkWidget* widget = GetWidget(MOZ_GTK_NOTEBOOK); + return gtk_widget_get_style_context(widget); + } default: GtkWidget* widget = GetWidget(aNodeType); MOZ_ASSERT(widget); diff --git a/widget/gtk/gtk2drawing.c b/widget/gtk/gtk2drawing.c index 2a8cc778fc82..b261a3113cbd 100644 --- a/widget/gtk/gtk2drawing.c +++ b/widget/gtk/gtk2drawing.c @@ -2281,7 +2281,7 @@ moz_gtk_progress_chunk_paint(GdkDrawable* drawable, GdkRectangle* rect, } gint -moz_gtk_get_tab_thickness(void) +moz_gtk_get_tab_thickness(WidgetNodeType aNodeType) { ensure_tab_widget(); if (YTHICKNESS(gTabWidget->style) < 2) @@ -2293,7 +2293,8 @@ moz_gtk_get_tab_thickness(void) static gint moz_gtk_tab_paint(GdkDrawable* drawable, GdkRectangle* rect, GdkRectangle* cliprect, GtkWidgetState* state, - GtkTabFlags flags, GtkTextDirection direction) + GtkTabFlags flags, GtkTextDirection direction, + WidgetNodeType widget) { /* When the tab isn't selected, we just draw a notebook extension. * When it is selected, we overwrite the adjacent border of the tabpanel @@ -2302,6 +2303,7 @@ moz_gtk_tab_paint(GdkDrawable* drawable, GdkRectangle* rect, GtkStyle* style; GdkRectangle focusRect; + gboolean isBottomTab = (widget == MOZ_GTK_TAB_BOTTOM); ensure_tab_widget(); gtk_widget_set_direction(gTabWidget, direction); @@ -2315,8 +2317,7 @@ moz_gtk_tab_paint(GdkDrawable* drawable, GdkRectangle* rect, gtk_paint_extension(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_OUT, cliprect, gTabWidget, "tab", rect->x, rect->y, rect->width, rect->height, - (flags & MOZ_GTK_TAB_BOTTOM) ? - GTK_POS_TOP : GTK_POS_BOTTOM ); + isBottomTab ? GTK_POS_TOP : GTK_POS_BOTTOM ); } else { /* Draw the tab and the gap * We want the gap to be positioned exactly on the tabpanel top @@ -2357,7 +2358,7 @@ moz_gtk_tab_paint(GdkDrawable* drawable, GdkRectangle* rect, gint gap_loffset, gap_roffset, gap_voffset, gap_height; /* Get height needed by the gap */ - gap_height = moz_gtk_get_tab_thickness(); + gap_height = moz_gtk_get_tab_thickness(widget); /* Extract gap_voffset from the first bits of flags */ gap_voffset = flags & MOZ_GTK_TAB_MARGIN_MASK; @@ -2373,7 +2374,7 @@ moz_gtk_tab_paint(GdkDrawable* drawable, GdkRectangle* rect, gap_loffset = 0; } - if (flags & MOZ_GTK_TAB_BOTTOM) { + if (isBottomTab) { /* Draw the tab */ focusRect.y += gap_voffset; focusRect.height -= gap_voffset; @@ -2971,7 +2972,8 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top, ensure_check_menu_item_widget(); w = gCheckMenuItemWidget; break; - case MOZ_GTK_TAB: + case MOZ_GTK_TAB_TOP: + case MOZ_GTK_TAB_BOTTOM: ensure_tab_widget(); w = gTabWidget; break; @@ -3019,14 +3021,15 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top, gint moz_gtk_get_tab_border(gint* left, gint* top, gint* right, gint* bottom, - GtkTextDirection direction, GtkTabFlags flags) + GtkTextDirection direction, GtkTabFlags flags, + WidgetNodeType widget) { - moz_gtk_get_widget_border(MOZ_GTK_TAB, left, top, + moz_gtk_get_widget_border(widget, left, top, right, bottom, direction, FALSE); // Top tabs have no bottom border, bottom tabs have no top border - if (flags & MOZ_GTK_TAB_BOTTOM) { + if (widget == MOZ_GTK_TAB_BOTTOM) { *top = 0; } else { *bottom = 0; @@ -3368,9 +3371,10 @@ moz_gtk_widget_paint(WidgetNodeType widget, GdkDrawable* drawable, return moz_gtk_progress_chunk_paint(drawable, rect, cliprect, direction, widget); break; - case MOZ_GTK_TAB: + case MOZ_GTK_TAB_TOP: + case MOZ_GTK_TAB_BOTTOM: return moz_gtk_tab_paint(drawable, rect, cliprect, state, - (GtkTabFlags) flags, direction); + (GtkTabFlags) flags, direction, widget); break; case MOZ_GTK_TABPANELS: return moz_gtk_tabpanels_paint(drawable, rect, cliprect, direction); diff --git a/widget/gtk/gtk3drawing.cpp b/widget/gtk/gtk3drawing.cpp index d5d622dd02e6..070347472cbe 100644 --- a/widget/gtk/gtk3drawing.cpp +++ b/widget/gtk/gtk3drawing.cpp @@ -27,7 +27,6 @@ static GtkWidget* gComboBoxEntryWidget; static GtkWidget* gComboBoxEntryTextareaWidget; static GtkWidget* gComboBoxEntryButtonWidget; static GtkWidget* gComboBoxEntryArrowWidget; -static GtkWidget* gTabWidget; static style_prop_t style_prop_func; static gboolean have_arrow_scaling; @@ -44,6 +43,9 @@ static gboolean is_initialized; #define GTK_STATE_FLAG_CHECKED (1 << 11) #endif +static gint +moz_gtk_get_tab_thickness(GtkStyleContext *style); + static GtkStateFlags GetStateFlagsFromGtkWidgetState(GtkWidgetState* state) { @@ -63,6 +65,13 @@ GetStateFlagsFromGtkWidgetState(GtkWidgetState* state) return stateFlags; } +static GtkStateFlags +GetStateFlagsFromGtkTabFlags(GtkTabFlags flags) +{ + return ((flags & MOZ_GTK_TAB_SELECTED) == 0) ? + GTK_STATE_FLAG_NORMAL : GTK_STATE_FLAG_ACTIVE; +} + gint moz_gtk_enable_style_props(style_prop_t styleGetProp) { @@ -276,16 +285,6 @@ ensure_combo_box_entry_widgets() return MOZ_GTK_SUCCESS; } -static gint -ensure_tab_widget() -{ - if (!gTabWidget) { - gTabWidget = gtk_notebook_new(); - setup_widget_prototype(gTabWidget); - } - return MOZ_GTK_SUCCESS; -} - gint moz_gtk_init() { @@ -301,13 +300,17 @@ moz_gtk_init() else checkbox_check_state = GTK_STATE_FLAG_ACTIVE; - if(!gtk_check_version(3, 12, 0)) { - ensure_tab_widget(); - gtk_style_context_get_style(gtk_widget_get_style_context(gTabWidget), + if (gtk_check_version(3, 12, 0) == nullptr && + gtk_check_version(3, 20, 0) != nullptr) + { + // Deprecated for Gtk >= 3.20+ + GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_TAB_TOP); + gtk_style_context_get_style(style, "has-tab-gap", ¬ebook_has_tab_gap, NULL); + ReleaseStyleContext(style); } else { - notebook_has_tab_gap = TRUE; + notebook_has_tab_gap = true; } return MOZ_GTK_SUCCESS; @@ -1563,46 +1566,35 @@ moz_gtk_progress_chunk_paint(cairo_t *cr, GdkRectangle* rect, return MOZ_GTK_SUCCESS; } -gint -moz_gtk_get_tab_thickness(void) +static gint +moz_gtk_get_tab_thickness(GtkStyleContext *style) { - GtkBorder border; - GtkStyleContext * style; - - ensure_tab_widget(); if (!notebook_has_tab_gap) return 0; /* tabs do not overdraw the tabpanel border with "no gap" style */ - style = gtk_widget_get_style_context(gTabWidget); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_NOTEBOOK); + GtkBorder border; gtk_style_context_get_border(style, GTK_STATE_FLAG_NORMAL, &border); - if (border.top < 2) return 2; /* some themes don't set ythickness correctly */ return border.top; } -static void -moz_gtk_tab_prepare_style_context(GtkStyleContext *style, - GtkTabFlags flags) -{ - gtk_style_context_set_state(style, ((flags & MOZ_GTK_TAB_SELECTED) == 0) ? - GTK_STATE_FLAG_NORMAL : - GTK_STATE_FLAG_ACTIVE); - gtk_style_context_add_region(style, GTK_STYLE_REGION_TAB, - (flags & MOZ_GTK_TAB_FIRST) ? - GTK_REGION_FIRST : static_cast(0)); - gtk_style_context_add_class(style, (flags & MOZ_GTK_TAB_BOTTOM) ? - GTK_STYLE_CLASS_BOTTOM : - GTK_STYLE_CLASS_TOP); +gint +moz_gtk_get_tab_thickness(WidgetNodeType aNodeType) +{ + GtkStyleContext *style = ClaimStyleContext(aNodeType); + int thickness = moz_gtk_get_tab_thickness(style); + ReleaseStyleContext(style); + return thickness; } /* actual small tabs */ static gint moz_gtk_tab_paint(cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state, - GtkTabFlags flags, GtkTextDirection direction) + GtkTabFlags flags, GtkTextDirection direction, + WidgetNodeType widget) { /* When the tab isn't selected, we just draw a notebook extension. * When it is selected, we overwrite the adjacent border of the tabpanel @@ -1614,14 +1606,10 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectangle* rect, GdkRectangle focusRect; GdkRectangle backRect; int initial_gap = 0; + bool isBottomTab = (widget == MOZ_GTK_TAB_BOTTOM); - ensure_tab_widget(); - gtk_widget_set_direction(gTabWidget, direction); - - style = gtk_widget_get_style_context(gTabWidget); - gtk_style_context_save(style); - moz_gtk_tab_prepare_style_context(style, flags); - + style = ClaimStyleContext(widget, direction, + GetStateFlagsFromGtkTabFlags(flags)); tabRect = *rect; if (flags & MOZ_GTK_TAB_FIRST) { @@ -1640,8 +1628,7 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectangle* rect, /* Only draw the tab */ gtk_render_extension(style, cr, tabRect.x, tabRect.y, tabRect.width, tabRect.height, - (flags & MOZ_GTK_TAB_BOTTOM) ? - GTK_POS_TOP : GTK_POS_BOTTOM ); + isBottomTab ? GTK_POS_TOP : GTK_POS_BOTTOM ); } else { /* Draw the tab and the gap * We want the gap to be positioned exactly on the tabpanel top @@ -1682,7 +1669,7 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectangle* rect, gint gap_loffset, gap_roffset, gap_voffset, gap_height; /* Get height needed by the gap */ - gap_height = moz_gtk_get_tab_thickness(); + gap_height = moz_gtk_get_tab_thickness(style); /* Extract gap_voffset from the first bits of flags */ gap_voffset = flags & MOZ_GTK_TAB_MARGIN_MASK; @@ -1698,7 +1685,7 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectangle* rect, gap_loffset = initial_gap; } - if (flags & MOZ_GTK_TAB_BOTTOM) { + if (isBottomTab) { /* Draw the tab on bottom */ focusRect.y += gap_voffset; focusRect.height -= gap_voffset; @@ -1762,15 +1749,9 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectangle* rect, gtk_render_frame(style, cr, tabRect.x, tabRect.y, tabRect.width, tabRect.height); } - gtk_style_context_restore(style); - if (state->focused) { /* Paint the focus ring */ GtkBorder padding; - - gtk_style_context_save(style); - moz_gtk_tab_prepare_style_context(style, flags); - gtk_style_context_get_padding(style, GetStateFlagsFromGtkWidgetState(state), &padding); focusRect.x += padding.left; @@ -1780,10 +1761,8 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectangle* rect, gtk_render_focus(style, cr, focusRect.x, focusRect.y, focusRect.width, focusRect.height); - - gtk_style_context_restore(style); } - + ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; } @@ -1793,14 +1772,7 @@ static gint moz_gtk_tabpanels_paint(cairo_t *cr, GdkRectangle* rect, GtkTextDirection direction) { - GtkStyleContext* style; - - ensure_tab_widget(); - gtk_widget_set_direction(gTabWidget, direction); - - style = gtk_widget_get_style_context(gTabWidget); - gtk_style_context_save(style); - + GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_TABPANELS, direction); gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height); /* @@ -1824,7 +1796,7 @@ moz_gtk_tabpanels_paint(cairo_t *cr, GdkRectangle* rect, rect->width, rect->height, GTK_POS_TOP, rect->width - 1, rect->width); cairo_restore(cr); - + /* right side */ cairo_save(cr); cairo_rectangle(cr, rect->x + rect->width / 2, rect->y, @@ -1837,7 +1809,7 @@ moz_gtk_tabpanels_paint(cairo_t *cr, GdkRectangle* rect, GTK_POS_TOP, 0, 1); cairo_restore(cr); - gtk_style_context_restore(style); + ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; } @@ -1847,17 +1819,12 @@ moz_gtk_tab_scroll_arrow_paint(cairo_t *cr, GdkRectangle* rect, GtkArrowType arrow_type, GtkTextDirection direction) { - GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state); GtkStyleContext* style; gdouble arrow_angle; gint arrow_size = MIN(rect->width, rect->height); gint x = rect->x + (rect->width - arrow_size) / 2; gint y = rect->y + (rect->height - arrow_size) / 2; - ensure_tab_widget(); - - style = gtk_widget_get_style_context(gTabWidget); - gtk_style_context_save(style); if (direction == GTK_TEXT_DIR_RTL) { arrow_type = (arrow_type == GTK_ARROW_LEFT) ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT; @@ -1877,12 +1844,12 @@ moz_gtk_tab_scroll_arrow_paint(cairo_t *cr, GdkRectangle* rect, break; } if (arrow_type != GTK_ARROW_NONE) { - gtk_style_context_add_class(style, GTK_STYLE_CLASS_NOTEBOOK); /* TODO TEST */ - gtk_style_context_set_state(style, state_flags); + style = ClaimStyleContext(MOZ_GTK_TAB_SCROLLARROW, direction, + GetStateFlagsFromGtkWidgetState(state)); gtk_render_arrow(style, cr, arrow_angle, x, y, arrow_size); + ReleaseStyleContext(style); } - gtk_style_context_restore(style); return MOZ_GTK_SUCCESS; } @@ -2269,8 +2236,7 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top, return MOZ_GTK_SUCCESS; } case MOZ_GTK_TABPANELS: - ensure_tab_widget(); - w = gTabWidget; + w = GetWidget(MOZ_GTK_TABPANELS); break; case MOZ_GTK_PROGRESSBAR: w = GetWidget(MOZ_GTK_PROGRESSBAR); @@ -2376,35 +2342,48 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top, gint moz_gtk_get_tab_border(gint* left, gint* top, gint* right, gint* bottom, - GtkTextDirection direction, GtkTabFlags flags) + GtkTextDirection direction, GtkTabFlags flags, + WidgetNodeType widget) { - GtkStyleContext* style; - int tab_curvature; - - ensure_tab_widget(); - - style = gtk_widget_get_style_context(gTabWidget); - gtk_style_context_save(style); - moz_gtk_tab_prepare_style_context(style, flags); + GtkStyleContext* style = ClaimStyleContext(widget, direction, + GetStateFlagsFromGtkTabFlags(flags)); *left = *top = *right = *bottom = 0; moz_gtk_add_style_padding(style, left, top, right, bottom); - gtk_style_context_get_style(style, "tab-curvature", &tab_curvature, NULL); - *left += tab_curvature; - *right += tab_curvature; + // Gtk >= 3.20 does not use those styles + if (gtk_check_version(3, 20, 0) != nullptr) { + int tab_curvature; - if (flags & MOZ_GTK_TAB_FIRST) { - int initial_gap; - gtk_style_context_get_style(style, "initial-gap", &initial_gap, NULL); - if (direction == GTK_TEXT_DIR_RTL) - *right += initial_gap; - else - *left += initial_gap; + gtk_style_context_get_style(style, "tab-curvature", &tab_curvature, NULL); + *left += tab_curvature; + *right += tab_curvature; + + if (flags & MOZ_GTK_TAB_FIRST) { + int initial_gap = 0; + gtk_style_context_get_style(style, "initial-gap", &initial_gap, NULL); + if (direction == GTK_TEXT_DIR_RTL) + *right += initial_gap; + else + *left += initial_gap; + } + } else { + GtkBorder margin; + + gtk_style_context_get_margin(style, GTK_STATE_FLAG_NORMAL, &margin); + *left += margin.left; + *right += margin.right; + + if (flags & MOZ_GTK_TAB_FIRST) { + ReleaseStyleContext(style); + style = ClaimStyleContext(MOZ_GTK_NOTEBOOK_HEADER, direction); + gtk_style_context_get_margin(style, GTK_STATE_FLAG_NORMAL, &margin); + *left += margin.left; + *right += margin.right; + } } - gtk_style_context_restore(style); - + ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; } @@ -2431,10 +2410,11 @@ moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height) { gint arrow_size; - ensure_tab_widget(); - gtk_style_context_get_style(gtk_widget_get_style_context(gTabWidget), + GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_TABPANELS); + gtk_style_context_get_style(style, "scroll-arrow-hlength", &arrow_size, NULL); + ReleaseStyleContext(style); *height = *width = arrow_size; @@ -2816,9 +2796,10 @@ moz_gtk_widget_paint(WidgetNodeType widget, cairo_t *cr, return moz_gtk_progress_chunk_paint(cr, rect, direction, widget); break; - case MOZ_GTK_TAB: + case MOZ_GTK_TAB_TOP: + case MOZ_GTK_TAB_BOTTOM: return moz_gtk_tab_paint(cr, rect, state, - (GtkTabFlags) flags, direction); + (GtkTabFlags) flags, direction, widget); break; case MOZ_GTK_TABPANELS: return moz_gtk_tabpanels_paint(cr, rect, direction); @@ -2911,7 +2892,6 @@ moz_gtk_shutdown() gComboBoxEntryButtonWidget = NULL; gComboBoxEntryArrowWidget = NULL; gComboBoxEntryTextareaWidget = NULL; - gTabWidget = NULL; is_initialized = FALSE; diff --git a/widget/gtk/gtkdrawing.h b/widget/gtk/gtkdrawing.h index 5bee35382d96..3e1f4f95099b 100644 --- a/widget/gtk/gtkdrawing.h +++ b/widget/gtk/gtkdrawing.h @@ -61,8 +61,6 @@ typedef enum { typedef enum { /* first eight bits are used to pass a margin */ MOZ_GTK_TAB_MARGIN_MASK = 0xFF, - /* bottom tabs */ - MOZ_GTK_TAB_BOTTOM = 1 << 8, /* the first tab in the group */ MOZ_GTK_TAB_FIRST = 1 << 9, /* the selected tab */ @@ -178,8 +176,14 @@ typedef enum { MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE, /* Paints a progress chunk of a vertical indeterminated GtkProgressBar. */ MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE, + /* Used as root style of whole GtkNotebook widget */ + MOZ_GTK_NOTEBOOK, + /* Used as root style of active GtkNotebook area which contains tabs and arrows. */ + MOZ_GTK_NOTEBOOK_HEADER, /* Paints a tab of a GtkNotebook. flags is a GtkTabFlags, defined above. */ - MOZ_GTK_TAB, + MOZ_GTK_TAB_TOP, + /* Paints a tab of a GtkNotebook. flags is a GtkTabFlags, defined above. */ + MOZ_GTK_TAB_BOTTOM, /* Paints the background and border of a GtkNotebook. */ MOZ_GTK_TABPANELS, /* Paints a GtkArrow for a GtkNotebook. flags is a GtkArrowType. */ @@ -314,12 +318,14 @@ gint moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top, * top/bottom: [OUT] the tab's top/bottom border * direction: the text direction for the widget * flags: tab-dependant flags; see the GtkTabFlags definition. + * widget: tab widget * * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise */ gint moz_gtk_get_tab_border(gint* left, gint* top, gint* right, gint* bottom, - GtkTextDirection direction, GtkTabFlags flags); + GtkTextDirection direction, GtkTabFlags flags, + WidgetNodeType widget); /** * Get the desired size of a GtkCheckButton @@ -495,7 +501,8 @@ GtkWidget* moz_gtk_get_scrollbar_widget(void); /** * Get the YTHICKNESS of a tab (notebook extension). */ -gint moz_gtk_get_tab_thickness(void); +gint +moz_gtk_get_tab_thickness(WidgetNodeType aNodeType); /** * Get a boolean which indicates whether or not to use images in menus. diff --git a/widget/gtk/nsNativeThemeGTK.cpp b/widget/gtk/nsNativeThemeGTK.cpp index 9ae159222c23..54cf8ec12e46 100644 --- a/widget/gtk/nsNativeThemeGTK.cpp +++ b/widget/gtk/nsNativeThemeGTK.cpp @@ -638,17 +638,17 @@ nsNativeThemeGTK::GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame, break; case NS_THEME_TAB: { + if (IsBottomTab(aFrame)) { + aGtkWidgetType = MOZ_GTK_TAB_BOTTOM; + } else { + aGtkWidgetType = MOZ_GTK_TAB_TOP; + } + if (aWidgetFlags) { /* First bits will be used to store max(0,-bmargin) where bmargin * is the bottom margin of the tab in pixels (resp. top margin, * for bottom tabs). */ - if (IsBottomTab(aFrame)) { - *aWidgetFlags = MOZ_GTK_TAB_BOTTOM; - } else { - *aWidgetFlags = 0; - } - - *aWidgetFlags |= GetTabMarginPixels(aFrame); + *aWidgetFlags = GetTabMarginPixels(aFrame); if (IsSelectedTab(aFrame)) *aWidgetFlags |= MOZ_GTK_TAB_SELECTED; @@ -656,8 +656,6 @@ nsNativeThemeGTK::GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame, if (IsFirstTab(aFrame)) *aWidgetFlags |= MOZ_GTK_TAB_FIRST; } - - aGtkWidgetType = MOZ_GTK_TAB; } break; case NS_THEME_SPLITTER: @@ -1071,7 +1069,8 @@ nsNativeThemeGTK::GetExtraSizeForWidget(nsIFrame* aFrame, uint8_t aWidgetType, if (!IsSelectedTab(aFrame)) return false; - gint gap_height = moz_gtk_get_tab_thickness(); + gint gap_height = moz_gtk_get_tab_thickness(IsBottomTab(aFrame) ? + MOZ_GTK_TAB_BOTTOM : MOZ_GTK_TAB_TOP); if (!gap_height) return false; @@ -1298,7 +1297,7 @@ nsNativeThemeGTK::GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame, moz_gtk_get_tab_border(&aResult->left, &aResult->top, &aResult->right, &aResult->bottom, direction, - (GtkTabFlags)flags); + (GtkTabFlags)flags, gtkWidgetType); } break; case NS_THEME_MENUITEM: