зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1275407 - Adds CSS contents node to have correct scrollbar background on Gtk >= 3.20. r=karlt
Also derive default widget style from widget path. r=?karlt Patch from Bug 1250704 needs to land prior to this one. --HG-- extra : rebase_source : b831bb11a7a0a00c4bf51f93e07a41f432c78ec1
This commit is contained in:
Родитель
1db86caf2d
Коммит
150a870af2
|
@ -224,17 +224,25 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType)
|
|||
return style;
|
||||
|
||||
switch (aNodeType) {
|
||||
case MOZ_GTK_SCROLLBAR_CONTENTS_HORIZONTAL:
|
||||
style = CreateChildCSSNode("contents",
|
||||
MOZ_GTK_SCROLLBAR_HORIZONTAL);
|
||||
break;
|
||||
case MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL:
|
||||
style = CreateChildCSSNode(GTK_STYLE_CLASS_TROUGH,
|
||||
MOZ_GTK_SCROLLBAR_HORIZONTAL);
|
||||
MOZ_GTK_SCROLLBAR_CONTENTS_HORIZONTAL);
|
||||
break;
|
||||
case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
|
||||
style = CreateChildCSSNode(GTK_STYLE_CLASS_SLIDER,
|
||||
MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL);
|
||||
break;
|
||||
case MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL:
|
||||
style = CreateChildCSSNode("contents",
|
||||
MOZ_GTK_SCROLLBAR_VERTICAL);
|
||||
break;
|
||||
case MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL:
|
||||
style = CreateChildCSSNode(GTK_STYLE_CLASS_TROUGH,
|
||||
MOZ_GTK_SCROLLBAR_VERTICAL);
|
||||
MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL);
|
||||
break;
|
||||
case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
|
||||
style = CreateChildCSSNode(GTK_STYLE_CLASS_SLIDER,
|
||||
|
|
|
@ -1014,6 +1014,36 @@ moz_gtk_scrollbar_button_paint(cairo_t *cr, GdkRectangle* rect,
|
|||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
moz_gtk_update_scrollbar_style(GtkStyleContext* style,
|
||||
WidgetNodeType widget,
|
||||
GtkTextDirection direction)
|
||||
{
|
||||
if (widget == MOZ_GTK_SCROLLBAR_HORIZONTAL) {
|
||||
gtk_style_context_add_class(style, GTK_STYLE_CLASS_BOTTOM);
|
||||
} else {
|
||||
if (direction == GTK_TEXT_DIR_LTR) {
|
||||
gtk_style_context_add_class(style, GTK_STYLE_CLASS_RIGHT);
|
||||
gtk_style_context_remove_class(style, GTK_STYLE_CLASS_LEFT);
|
||||
} else {
|
||||
gtk_style_context_add_class(style, GTK_STYLE_CLASS_LEFT);
|
||||
gtk_style_context_remove_class(style, GTK_STYLE_CLASS_RIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
moz_gtk_draw_styled_frame(GtkStyleContext* style, cairo_t *cr,
|
||||
GdkRectangle* rect, bool drawFocus)
|
||||
{
|
||||
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);
|
||||
if (drawFocus) {
|
||||
gtk_render_focus(style, cr,
|
||||
rect->x, rect->y, rect->width, rect->height);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
moz_gtk_scrollbar_trough_paint(WidgetNodeType widget,
|
||||
cairo_t *cr, GdkRectangle* rect,
|
||||
|
@ -1028,19 +1058,28 @@ moz_gtk_scrollbar_trough_paint(WidgetNodeType widget,
|
|||
ReleaseStyleContext(style);
|
||||
}
|
||||
|
||||
GtkStyleContext* style =
|
||||
ClaimStyleContext(widget == MOZ_GTK_SCROLLBAR_HORIZONTAL ?
|
||||
bool isHorizontal = (widget == MOZ_GTK_SCROLLBAR_HORIZONTAL);
|
||||
GtkStyleContext* style;
|
||||
|
||||
// Draw all child CSS Nodes for Gtk >= 3.20
|
||||
if (gtk_check_version(3, 20, 0) == nullptr) {
|
||||
style = ClaimStyleContext(widget, direction);
|
||||
moz_gtk_update_scrollbar_style(style, widget, direction);
|
||||
moz_gtk_draw_styled_frame(style, cr, rect, state->focused);
|
||||
ReleaseStyleContext(style);
|
||||
|
||||
style = ClaimStyleContext(isHorizontal ?
|
||||
MOZ_GTK_SCROLLBAR_CONTENTS_HORIZONTAL :
|
||||
MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL,
|
||||
direction);
|
||||
moz_gtk_draw_styled_frame(style, cr, rect, state->focused);
|
||||
ReleaseStyleContext(style);
|
||||
}
|
||||
style = ClaimStyleContext(isHorizontal ?
|
||||
MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL :
|
||||
MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL,
|
||||
direction);
|
||||
|
||||
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);
|
||||
|
||||
if (state->focused) {
|
||||
gtk_render_focus(style, cr,
|
||||
rect->x, rect->y, rect->width, rect->height);
|
||||
}
|
||||
moz_gtk_draw_styled_frame(style, cr, rect, state->focused);
|
||||
ReleaseStyleContext(style);
|
||||
|
||||
return MOZ_GTK_SUCCESS;
|
||||
|
|
|
@ -109,6 +109,7 @@ typedef enum {
|
|||
|
||||
/* Horizontal GtkScrollbar counterparts */
|
||||
MOZ_GTK_SCROLLBAR_HORIZONTAL,
|
||||
MOZ_GTK_SCROLLBAR_CONTENTS_HORIZONTAL,
|
||||
/* Paints the trough (track) of a GtkScrollbar. */
|
||||
MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL,
|
||||
/* Paints the slider (thumb) of a GtkScrollbar. */
|
||||
|
@ -116,6 +117,7 @@ typedef enum {
|
|||
|
||||
/* Vertical GtkScrollbar counterparts */
|
||||
MOZ_GTK_SCROLLBAR_VERTICAL,
|
||||
MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL,
|
||||
MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL,
|
||||
MOZ_GTK_SCROLLBAR_THUMB_VERTICAL,
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче