diff --git a/widget/gtk/gtk3drawing.c b/widget/gtk/gtk3drawing.c index 7ffabf8bd128..b053f5532676 100644 --- a/widget/gtk/gtk3drawing.c +++ b/widget/gtk/gtk3drawing.c @@ -1133,6 +1133,7 @@ static gint moz_gtk_scrollbar_trough_paint(GtkThemeWidgetType widget, cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state, + GtkScrollbarTrackFlags flags, GtkTextDirection direction) { GtkStyleContext* style; @@ -1147,6 +1148,11 @@ moz_gtk_scrollbar_trough_paint(GtkThemeWidgetType widget, gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction); + if (flags & MOZ_GTK_TRACK_OPAQUE) { + style = gtk_widget_get_style_context(GTK_WIDGET(gProtoWindow)); + gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height); + } + style = gtk_widget_get_style_context(GTK_WIDGET(scrollbar)); gtk_style_context_save(style); gtk_style_context_add_class(style, GTK_STYLE_CLASS_TROUGH); @@ -3104,7 +3110,9 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, cairo_t *cr, case MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL: case MOZ_GTK_SCROLLBAR_TRACK_VERTICAL: return moz_gtk_scrollbar_trough_paint(widget, cr, rect, - state, direction); + state, + (GtkScrollbarTrackFlags) flags, + direction); break; case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL: case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL: diff --git a/widget/gtk/gtkdrawing.h b/widget/gtk/gtkdrawing.h index e83bf467f712..da30e1f5eb33 100644 --- a/widget/gtk/gtkdrawing.h +++ b/widget/gtk/gtkdrawing.h @@ -51,6 +51,10 @@ typedef enum { MOZ_GTK_STEPPER_VERTICAL = 1 << 2 } GtkScrollbarButtonFlags; +typedef enum { + MOZ_GTK_TRACK_OPAQUE = 1 << 0 +} GtkScrollbarTrackFlags; + /** flags for tab state **/ typedef enum { /* first eight bits are used to pass a margin */ diff --git a/widget/gtk/nsNativeThemeGTK.cpp b/widget/gtk/nsNativeThemeGTK.cpp index 1b4a50387037..c5d335c169dd 100644 --- a/widget/gtk/nsNativeThemeGTK.cpp +++ b/widget/gtk/nsNativeThemeGTK.cpp @@ -412,9 +412,17 @@ nsNativeThemeGTK::GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame, break; case NS_THEME_SCROLLBAR_TRACK_VERTICAL: aGtkWidgetType = MOZ_GTK_SCROLLBAR_TRACK_VERTICAL; + if (GetWidgetTransparency(aFrame, aWidgetType) == eOpaque) + *aWidgetFlags = MOZ_GTK_TRACK_OPAQUE; + else + *aWidgetFlags = 0; break; case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL: aGtkWidgetType = MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL; + if (GetWidgetTransparency(aFrame, aWidgetType) == eOpaque) + *aWidgetFlags = MOZ_GTK_TRACK_OPAQUE; + else + *aWidgetFlags = 0; break; case NS_THEME_SCROLLBAR_THUMB_VERTICAL: aGtkWidgetType = MOZ_GTK_SCROLLBAR_THUMB_VERTICAL; @@ -1807,8 +1815,6 @@ nsNativeThemeGTK::GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) switch (aWidgetType) { // These widgets always draw a default background. #if (MOZ_WIDGET_GTK == 2) - case NS_THEME_SCROLLBAR_TRACK_VERTICAL: - case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL: case NS_THEME_TOOLBAR: case NS_THEME_MENUBAR: #endif @@ -1816,6 +1822,17 @@ nsNativeThemeGTK::GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) case NS_THEME_WINDOW: case NS_THEME_DIALOG: return eOpaque; + case NS_THEME_SCROLLBAR_TRACK_VERTICAL: + case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL: +#if (MOZ_WIDGET_GTK == 3) + // Make scrollbar tracks opaque on the window's scroll frame to prevent + // leaf layers from overlapping. See bug 1179780. + if (!(CheckBooleanAttr(aFrame, nsGkAtoms::root_) && + aFrame->PresContext()->IsRootContentDocument() && + IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XUL))) + return eTransparent; +#endif + return eOpaque; // Tooltips use gtk_paint_flat_box() on Gtk2 // but are shaped on Gtk3 case NS_THEME_TOOLTIP: