Bug 1749645 - Remove unused native scrollbar drawing on gtk. r=stransky

We decided to keep it when initially making scrollbars non-native, but I think
it's time for it to go, since it's pretty much untested.

Nobody has complained about the non-native scrollbars in chrome documents, and
the GTK scrollbar implementation is not suitable for content because it doesn't
support scrollbar-width among other things.

Differential Revision: https://phabricator.services.mozilla.com/D135670
This commit is contained in:
Emilio Cobos Álvarez 2022-01-12 17:06:12 +00:00
parent 98c3acf4c2
commit 288890e8bb
8 changed files with 2 additions and 860 deletions

View file

@ -725,8 +725,6 @@ static GtkWidget* CreateWidget(WidgetNodeType aAppearance) {
return CreateProgressWidget();
case MOZ_GTK_RADIOBUTTON_CONTAINER:
return CreateRadiobuttonWidget();
case MOZ_GTK_SCROLLBAR_HORIZONTAL:
return CreateScrollbarWidget(aAppearance, GTK_ORIENTATION_HORIZONTAL);
case MOZ_GTK_SCROLLBAR_VERTICAL:
return CreateScrollbarWidget(aAppearance, GTK_ORIENTATION_VERTICAL);
case MOZ_GTK_MENUBAR:
@ -1065,17 +1063,6 @@ static GtkStyleContext* GetCssNodeStyleInternal(WidgetNodeType aNodeType) {
if (style) 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_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;
@ -1087,10 +1074,6 @@ static GtkStyleContext* GetCssNodeStyleInternal(WidgetNodeType aNodeType) {
style = CreateChildCSSNode(GTK_STYLE_CLASS_SLIDER,
MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL);
break;
case MOZ_GTK_SCROLLBAR_BUTTON:
style = CreateChildCSSNode(GTK_STYLE_CLASS_BUTTON,
MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL);
break;
case MOZ_GTK_RADIOBUTTON:
style = CreateChildCSSNode(GTK_STYLE_CLASS_RADIO,
MOZ_GTK_RADIOBUTTON_CONTAINER);
@ -1254,14 +1237,6 @@ static GtkStyleContext* GetWidgetStyleInternal(WidgetNodeType aNodeType) {
if (style) return style;
switch (aNodeType) {
case MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL:
style = CreateSubStyleWithClass(MOZ_GTK_SCROLLBAR_HORIZONTAL,
GTK_STYLE_CLASS_TROUGH);
break;
case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
style = CreateSubStyleWithClass(MOZ_GTK_SCROLLBAR_HORIZONTAL,
GTK_STYLE_CLASS_SLIDER);
break;
case MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL:
style = CreateSubStyleWithClass(MOZ_GTK_SCROLLBAR_VERTICAL,
GTK_STYLE_CLASS_TROUGH);

View file

@ -26,8 +26,6 @@
static gboolean checkbox_check_state;
static gboolean notebook_has_tab_gap;
static ScrollbarGTKMetrics sScrollbarMetrics[2];
static ScrollbarGTKMetrics sActiveScrollbarMetrics[2];
static ToggleGTKMetrics sCheckboxMetrics;
static ToggleGTKMetrics sRadioMetrics;
static ToggleGTKMetrics sMenuRadioMetrics;
@ -59,24 +57,6 @@ style_path_print(GtkStyleContext *context)
}
#endif
static GtkBorder operator-(const GtkBorder& first, const GtkBorder& second) {
GtkBorder result;
result.left = first.left - second.left;
result.right = first.right - second.right;
result.top = first.top - second.top;
result.bottom = first.bottom - second.bottom;
return result;
}
static GtkBorder operator+(const GtkBorder& first, const GtkBorder& second) {
GtkBorder result;
result.left = first.left + second.left;
result.right = first.right + second.right;
result.top = first.top + second.top;
result.bottom = first.bottom + second.bottom;
return result;
}
static GtkBorder operator+=(GtkBorder& first, const GtkBorder& second) {
first.left += second.left;
first.right += second.right;
@ -91,8 +71,6 @@ static gint moz_gtk_menu_item_paint(WidgetNodeType widget, cairo_t* cr,
GdkRectangle* rect, GtkWidgetState* state,
GtkTextDirection direction);
static GtkBorder GetMarginBorderPadding(GtkStyleContext* aStyle);
static void Inset(GdkRectangle*, const GtkBorder&);
static void InsetByMargin(GdkRectangle*, GtkStyleContext* style);
@ -223,10 +201,6 @@ void moz_gtk_refresh() {
notebook_has_tab_gap = true;
}
sScrollbarMetrics[GTK_ORIENTATION_HORIZONTAL].initialized = false;
sScrollbarMetrics[GTK_ORIENTATION_VERTICAL].initialized = false;
sActiveScrollbarMetrics[GTK_ORIENTATION_HORIZONTAL].initialized = false;
sActiveScrollbarMetrics[GTK_ORIENTATION_VERTICAL].initialized = false;
sCheckboxMetrics.initialized = false;
sRadioMetrics.initialized = false;
sMenuCheckboxMetrics.initialized = false;
@ -725,14 +699,6 @@ static gint calculate_arrow_rect(GtkWidget* arrow, GdkRectangle* rect,
return MOZ_GTK_SUCCESS;
}
static MozGtkSize GetMinContentBox(GtkStyleContext* style) {
GtkStateFlags state_flags = gtk_style_context_get_state(style);
gint width, height;
gtk_style_context_get(style, state_flags, "min-width", &width, "min-height",
&height, nullptr);
return {width, height};
}
/**
* Get minimum widget size as sum of margin, padding, border and
* min-width/min-height.
@ -754,12 +720,6 @@ static void moz_gtk_get_widget_min_size(GtkStyleContext* style, int* width,
padding.top + padding.bottom;
}
static MozGtkSize GetMinMarginBox(GtkStyleContext* style) {
gint width, height;
moz_gtk_get_widget_min_size(style, &width, &height);
return {width, height};
}
static void Inset(GdkRectangle* rect, const GtkBorder& aBorder) {
rect->x += aBorder.left;
rect->y += aBorder.top;
@ -786,114 +746,6 @@ static void InsetByBorderPadding(GdkRectangle* rect, GtkStyleContext* style) {
Inset(rect, border);
}
static gint moz_gtk_scrollbar_button_paint(cairo_t* cr,
const GdkRectangle* aRect,
GtkWidgetState* state,
GtkScrollbarButtonFlags flags,
GtkTextDirection direction) {
GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
GdkRectangle arrow_rect;
gdouble arrow_angle;
GtkStyleContext* style;
gint arrow_displacement_x, arrow_displacement_y;
GtkWidget* scrollbar = GetWidget(flags & MOZ_GTK_STEPPER_VERTICAL
? MOZ_GTK_SCROLLBAR_VERTICAL
: MOZ_GTK_SCROLLBAR_HORIZONTAL);
gtk_widget_set_direction(scrollbar, direction);
if (flags & MOZ_GTK_STEPPER_VERTICAL) {
arrow_angle = (flags & MOZ_GTK_STEPPER_DOWN) ? ARROW_DOWN : ARROW_UP;
} else {
arrow_angle = (flags & MOZ_GTK_STEPPER_DOWN) ? ARROW_RIGHT : ARROW_LEFT;
}
style = gtk_widget_get_style_context(scrollbar);
gtk_style_context_save(style);
gtk_style_context_add_class(style, GTK_STYLE_CLASS_BUTTON);
StyleContextSetScale(style, state->scale);
gtk_style_context_set_state(style, state_flags);
if (arrow_angle == ARROW_RIGHT) {
gtk_style_context_add_class(style, GTK_STYLE_CLASS_RIGHT);
} else if (arrow_angle == ARROW_DOWN) {
gtk_style_context_add_class(style, GTK_STYLE_CLASS_BOTTOM);
} else if (arrow_angle == ARROW_LEFT) {
gtk_style_context_add_class(style, GTK_STYLE_CLASS_LEFT);
} else {
gtk_style_context_add_class(style, GTK_STYLE_CLASS_TOP);
}
GdkRectangle rect = *aRect;
if (gtk_check_version(3, 20, 0) == nullptr) {
// The "trough-border" is not used since GTK 3.20. The stepper margin
// box occupies the full width of the "contents" gadget content box.
InsetByMargin(&rect, style);
} else {
// Scrollbar button has to be inset by trough_border because its DOM
// element is filling width of vertical scrollbar's track (or height
// in case of horizontal scrollbars).
GtkOrientation orientation = flags & MOZ_GTK_STEPPER_VERTICAL
? GTK_ORIENTATION_VERTICAL
: GTK_ORIENTATION_HORIZONTAL;
const ScrollbarGTKMetrics* metrics = GetScrollbarMetrics(orientation);
if (flags & MOZ_GTK_STEPPER_VERTICAL) {
rect.x += metrics->border.track.left;
rect.width = metrics->size.thumb.width;
} else {
rect.y += metrics->border.track.top;
rect.height = metrics->size.thumb.height;
}
}
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);
arrow_rect.width = rect.width / 2;
arrow_rect.height = rect.height / 2;
gfloat arrow_scaling;
gtk_style_context_get_style(style, "arrow-scaling", &arrow_scaling, NULL);
gdouble arrow_size = MIN(rect.width, rect.height) * arrow_scaling;
arrow_rect.x = rect.x + (rect.width - arrow_size) / 2;
arrow_rect.y = rect.y + (rect.height - arrow_size) / 2;
if (state_flags & GTK_STATE_FLAG_ACTIVE) {
gtk_style_context_get_style(style, "arrow-displacement-x",
&arrow_displacement_x, "arrow-displacement-y",
&arrow_displacement_y, NULL);
arrow_rect.x += arrow_displacement_x;
arrow_rect.y += arrow_displacement_y;
}
gtk_render_arrow(style, cr, arrow_angle, arrow_rect.x, arrow_rect.y,
arrow_size);
gtk_style_context_restore(style);
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,
const GdkRectangle* aRect,
bool drawFocus) {
@ -908,89 +760,6 @@ static void moz_gtk_draw_styled_frame(GtkStyleContext* style, cairo_t* cr,
}
}
static gint moz_gtk_scrollbar_trough_paint(WidgetNodeType widget, cairo_t* cr,
const GdkRectangle* aRect,
GtkWidgetState* state,
GtkTextDirection direction) {
GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
GdkRectangle rect = *aRect;
GtkStyleContext* style;
if (gtk_get_minor_version() >= 20) {
WidgetNodeType thumb = widget == MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL
? MOZ_GTK_SCROLLBAR_THUMB_VERTICAL
: MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL;
MozGtkSize thumbSize = GetMinMarginBox(GetStyleContext(thumb));
style = GetStyleContext(widget, state->scale, direction, state_flags);
MozGtkSize trackSize = GetMinContentBox(style);
trackSize.Include(thumbSize);
trackSize += GetMarginBorderPadding(style);
// Gecko's trough |aRect| fills available breadth, but GTK's trough is
// centered in the contents_gadget. The centering here round left
// and up, like gtk_box_gadget_allocate_child().
if (widget == MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL) {
rect.x += (rect.width - trackSize.width) / 2;
rect.width = trackSize.width;
} else {
rect.y += (rect.height - trackSize.height) / 2;
rect.height = trackSize.height;
}
} else {
style = GetStyleContext(widget, state->scale, direction, state_flags);
}
moz_gtk_draw_styled_frame(style, cr, &rect, state->focused);
return MOZ_GTK_SUCCESS;
}
static gint moz_gtk_scrollbar_paint(WidgetNodeType widget, cairo_t* cr,
const GdkRectangle* rect,
GtkWidgetState* state,
GtkTextDirection direction) {
GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
GtkStyleContext* style =
GetStyleContext(widget, state->scale, direction, state_flags);
moz_gtk_update_scrollbar_style(style, widget, direction);
moz_gtk_draw_styled_frame(style, cr, rect, state->focused);
style = GetStyleContext((widget == MOZ_GTK_SCROLLBAR_HORIZONTAL)
? MOZ_GTK_SCROLLBAR_CONTENTS_HORIZONTAL
: MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL,
state->scale, direction, state_flags);
moz_gtk_draw_styled_frame(style, cr, rect, state->focused);
return MOZ_GTK_SUCCESS;
}
static gint moz_gtk_scrollbar_thumb_paint(WidgetNodeType widget, cairo_t* cr,
const GdkRectangle* aRect,
GtkWidgetState* state,
GtkTextDirection direction) {
GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
GtkStyleContext* style =
GetStyleContext(widget, state->scale, direction, state_flags);
GtkOrientation orientation = (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL)
? GTK_ORIENTATION_HORIZONTAL
: GTK_ORIENTATION_VERTICAL;
GdkRectangle rect = *aRect;
const ScrollbarGTKMetrics* metrics =
(state->depressed || state->active || state->inHover)
? GetActiveScrollbarMetrics(orientation)
: GetScrollbarMetrics(orientation);
Inset(&rect, metrics->margin.thumb);
gtk_render_slider(style, cr, rect.x, rect.y, rect.width, rect.height,
orientation);
return MOZ_GTK_SUCCESS;
}
static gint moz_gtk_inner_spin_paint(cairo_t* cr, GdkRectangle* rect,
GtkWidgetState* state,
GtkTextDirection direction) {
@ -2221,18 +1990,6 @@ static gint moz_gtk_header_bar_paint(WidgetNodeType widgetType, cairo_t* cr,
return MOZ_GTK_SUCCESS;
}
static GtkBorder GetMarginBorderPadding(GtkStyleContext* aStyle) {
gint left = 0, top = 0, right = 0, bottom = 0;
moz_gtk_add_margin_border_padding(aStyle, &left, &top, &right, &bottom);
// narrowing conversions to gint16:
GtkBorder result;
result.left = left;
result.right = right;
result.top = top;
result.bottom = bottom;
return result;
}
gint moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
gint* right, gint* bottom,
// NOTE: callers depend on direction being used
@ -2425,9 +2182,6 @@ gint moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
case MOZ_GTK_SPLITTER_VERTICAL:
case MOZ_GTK_CHECKBUTTON:
case MOZ_GTK_RADIOBUTTON:
case MOZ_GTK_SCROLLBAR_BUTTON:
case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
case MOZ_GTK_SCALE_THUMB_VERTICAL:
case MOZ_GTK_GRIPPER:
@ -2697,13 +2451,6 @@ gint moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length,
return MOZ_GTK_SUCCESS;
}
static MozGtkSize SizeFromLengthAndBreadth(GtkOrientation aOrientation,
gint aLength, gint aBreadth) {
return aOrientation == GTK_ORIENTATION_HORIZONTAL
? MozGtkSize({aLength, aBreadth})
: MozGtkSize({aBreadth, aLength});
}
const ToggleGTKMetrics* GetToggleMetrics(WidgetNodeType aWidgetType) {
ToggleGTKMetrics* metrics;
@ -2768,190 +2515,6 @@ const ToggleGTKMetrics* GetToggleMetrics(WidgetNodeType aWidgetType) {
return metrics;
}
static void InitScrollbarMetrics(ScrollbarGTKMetrics* aMetrics,
GtkOrientation aOrientation,
GtkStateFlags aStateFlags) {
WidgetNodeType scrollbar = aOrientation == GTK_ORIENTATION_HORIZONTAL
? MOZ_GTK_SCROLLBAR_HORIZONTAL
: MOZ_GTK_SCROLLBAR_VERTICAL;
gboolean backward, forward, secondary_backward, secondary_forward;
GtkStyleContext* style =
GetStyleContext(scrollbar, 1, GTK_TEXT_DIR_NONE, aStateFlags);
gtk_style_context_get_style(
style, "has-backward-stepper", &backward, "has-forward-stepper", &forward,
"has-secondary-backward-stepper", &secondary_backward,
"has-secondary-forward-stepper", &secondary_forward, nullptr);
bool hasButtons =
backward || forward || secondary_backward || secondary_forward;
if (gtk_get_minor_version() < 20) {
gint slider_width, trough_border, stepper_size, min_slider_size;
gtk_style_context_get_style(style, "slider-width", &slider_width,
"trough-border", &trough_border, "stepper-size",
&stepper_size, "min-slider-length",
&min_slider_size, nullptr);
aMetrics->size.thumb =
SizeFromLengthAndBreadth(aOrientation, min_slider_size, slider_width);
aMetrics->size.button =
SizeFromLengthAndBreadth(aOrientation, stepper_size, slider_width);
// overall scrollbar
gint breadth = slider_width + 2 * trough_border;
// Require room for the slider in the track if we don't have buttons.
gint length = hasButtons ? 0 : min_slider_size + 2 * trough_border;
aMetrics->size.scrollbar =
SizeFromLengthAndBreadth(aOrientation, length, breadth);
// Borders on the major axis are set on the outermost scrollbar
// element to correctly position the buttons when
// trough-under-steppers is true.
// Borders on the minor axis are set on the track element so that it
// receives mouse events, as in GTK.
// Other borders have been zero-initialized.
if (aOrientation == GTK_ORIENTATION_HORIZONTAL) {
aMetrics->border.scrollbar.left = aMetrics->border.scrollbar.right =
aMetrics->border.track.top = aMetrics->border.track.bottom =
trough_border;
} else {
aMetrics->border.scrollbar.top = aMetrics->border.scrollbar.bottom =
aMetrics->border.track.left = aMetrics->border.track.right =
trough_border;
}
// We're done here for Gtk+ < 3.20...
return;
}
// GTK version > 3.20
// scrollbar
aMetrics->border.scrollbar = GetMarginBorderPadding(style);
WidgetNodeType contents, track, thumb;
if (aOrientation == GTK_ORIENTATION_HORIZONTAL) {
contents = MOZ_GTK_SCROLLBAR_CONTENTS_HORIZONTAL;
track = MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL;
thumb = MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL;
} else {
contents = MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL;
track = MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL;
thumb = MOZ_GTK_SCROLLBAR_THUMB_VERTICAL;
}
/* GetStyleContext() sets GtkStateFlags to the latest widget name
* in css selector string. When we call:
*
* GetStyleContext(thumb, GTK_STATE_FLAG_PRELIGHT)
*
* we get:
*
* "scrollbar contents trough slider:hover"
*
* Some themes (Ubuntu Ambiance) styles trough/thumb by scrollbar,
* the Gtk+ css rule looks like:
*
* "scrollbar:hover contents trough slider"
*
* So we need to apply GtkStateFlags to each widgets in style path.
*/
// thumb
style =
CreateStyleContextWithStates(thumb, 1, GTK_TEXT_DIR_NONE, aStateFlags);
aMetrics->size.thumb = GetMinMarginBox(style);
gtk_style_context_get_margin(style, gtk_style_context_get_state(style),
&aMetrics->margin.thumb);
g_object_unref(style);
// track
style =
CreateStyleContextWithStates(track, 1, GTK_TEXT_DIR_NONE, aStateFlags);
aMetrics->border.track = GetMarginBorderPadding(style);
MozGtkSize trackMinSize = GetMinContentBox(style) + aMetrics->border.track;
MozGtkSize trackSizeForThumb = aMetrics->size.thumb + aMetrics->border.track;
g_object_unref(style);
// button
if (hasButtons) {
style = CreateStyleContextWithStates(MOZ_GTK_SCROLLBAR_BUTTON, 1,
GTK_TEXT_DIR_NONE, aStateFlags);
aMetrics->size.button = GetMinMarginBox(style);
g_object_unref(style);
} else {
aMetrics->size.button = {0, 0};
}
if (aOrientation == GTK_ORIENTATION_HORIZONTAL) {
aMetrics->size.button.Rotate();
// If the track is wider than necessary for the thumb, including when
// the buttons will cause Gecko to expand the track to fill
// available breadth, then add to the track border to prevent Gecko
// from expanding the thumb to fill available breadth.
gint extra = std::max(trackMinSize.height, aMetrics->size.button.height) -
trackSizeForThumb.height;
if (extra > 0) {
// If extra is odd, then the thumb is 0.5 pixels above
// center as in gtk_range_compute_slider_position().
aMetrics->border.track.top += extra / 2;
aMetrics->border.track.bottom += extra - extra / 2;
// Update size for change in border.
trackSizeForThumb.height += extra;
}
} else {
gint extra = std::max(trackMinSize.width, aMetrics->size.button.width) -
trackSizeForThumb.width;
if (extra > 0) {
// If extra is odd, then the thumb is 0.5 pixels to the left
// of center as in gtk_range_compute_slider_position().
aMetrics->border.track.left += extra / 2;
aMetrics->border.track.right += extra - extra / 2;
trackSizeForThumb.width += extra;
}
}
style =
CreateStyleContextWithStates(contents, 1, GTK_TEXT_DIR_NONE, aStateFlags);
GtkBorder contentsBorder = GetMarginBorderPadding(style);
g_object_unref(style);
aMetrics->size.scrollbar =
trackSizeForThumb + contentsBorder + aMetrics->border.scrollbar;
}
const ScrollbarGTKMetrics* GetScrollbarMetrics(GtkOrientation aOrientation) {
auto metrics = &sScrollbarMetrics[aOrientation];
if (!metrics->initialized) {
InitScrollbarMetrics(metrics, aOrientation, GTK_STATE_FLAG_NORMAL);
// We calculate thumb margin here because it's composited from
// thumb class margin + difference margin between active and inactive
// scrollbars. It's a workaround which alows us to emulate
// overlay scrollbars for some Gtk+ themes (Ubuntu/Ambiance),
// when an inactive scrollbar thumb is smaller than the active one.
const ScrollbarGTKMetrics* metricsActive =
GetActiveScrollbarMetrics(aOrientation);
if (metrics->size.thumb < metricsActive->size.thumb) {
metrics->margin.thumb +=
(metrics->border.scrollbar + metrics->border.track) -
(metricsActive->border.scrollbar + metricsActive->border.track);
}
metrics->initialized = true;
}
return metrics;
}
const ScrollbarGTKMetrics* GetActiveScrollbarMetrics(
GtkOrientation aOrientation) {
auto metrics = &sActiveScrollbarMetrics[aOrientation];
if (!metrics->initialized) {
InitScrollbarMetrics(metrics, aOrientation, GTK_STATE_FLAG_PRELIGHT);
metrics->initialized = true;
}
return metrics;
}
/*
* get_shadow_width() from gtkwindow.c is not public so we need
* to implement it.
@ -3052,35 +2615,6 @@ gint moz_gtk_widget_paint(WidgetNodeType widget, cairo_t* cr,
!!(flags & MOZ_GTK_WIDGET_CHECKED),
!!(flags & MOZ_GTK_WIDGET_INCONSISTENT),
(widget == MOZ_GTK_RADIOBUTTON), direction);
case MOZ_GTK_SCROLLBAR_BUTTON:
return moz_gtk_scrollbar_button_paint(
cr, rect, state, (GtkScrollbarButtonFlags)flags, direction);
case MOZ_GTK_SCROLLBAR_HORIZONTAL:
case MOZ_GTK_SCROLLBAR_VERTICAL: {
if (flags & MOZ_GTK_TRACK_OPAQUE) {
GtkStyleContext* style = GetStyleContext(MOZ_GTK_WINDOW, direction);
gtk_render_background(style, cr, rect->x, rect->y, rect->width,
rect->height);
}
if (gtk_check_version(3, 20, 0) == nullptr) {
return moz_gtk_scrollbar_paint(widget, cr, rect, state, direction);
}
WidgetNodeType trough_widget = (widget == MOZ_GTK_SCROLLBAR_HORIZONTAL)
? MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL
: MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL;
return moz_gtk_scrollbar_trough_paint(trough_widget, cr, rect, state,
direction);
}
case MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL:
case MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL:
if (gtk_check_version(3, 20, 0) == nullptr) {
return moz_gtk_scrollbar_trough_paint(widget, cr, rect, state,
direction);
}
break;
case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
return moz_gtk_scrollbar_thumb_paint(widget, cr, rect, state, direction);
case MOZ_GTK_SCALE_HORIZONTAL:
case MOZ_GTK_SCALE_VERTICAL:
return moz_gtk_scale_paint(cr, rect, state, (GtkOrientation)flags,

View file

@ -69,22 +69,6 @@ struct MozGtkSize {
}
};
typedef struct {
bool initialized;
struct {
MozGtkSize scrollbar;
MozGtkSize thumb;
MozGtkSize button;
} size;
struct {
GtkBorder scrollbar;
GtkBorder track;
} border;
struct {
GtkBorder thumb;
} margin;
} ScrollbarGTKMetrics;
typedef struct {
bool initialized;
MozGtkSize minSizeWithBorder;
@ -112,14 +96,6 @@ typedef struct {
GtkBorder decorationSize;
} CSDWindowDecorationSize;
typedef enum {
MOZ_GTK_STEPPER_DOWN = 1 << 0,
MOZ_GTK_STEPPER_BOTTOM = 1 << 1,
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 */
@ -163,20 +139,6 @@ enum WidgetNodeType : int {
MOZ_GTK_RADIOBUTTON,
/* Paints the label of a GtkRadioButton (focus outline) */
MOZ_GTK_RADIOBUTTON_LABEL,
/**
* Paints the button of a GtkScrollbar. flags is a GtkArrowType giving
* the arrow direction.
*/
MOZ_GTK_SCROLLBAR_BUTTON,
/* 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. */
MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL,
/* Vertical GtkScrollbar counterparts */
MOZ_GTK_SCROLLBAR_VERTICAL,
MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL,
@ -510,20 +472,6 @@ void moz_gtk_get_scale_metrics(GtkOrientation orient, gint* scale_width,
gint moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length,
gint* thumb_height);
/**
* Get the metrics in GTK pixels for a scrollbar.
* aOrientation: [IN] the scrollbar orientation
*/
const ScrollbarGTKMetrics* GetScrollbarMetrics(GtkOrientation aOrientation);
/**
* Get the metrics in GTK pixels for a scrollbar which is active
* (selected by mouse pointer).
* aOrientation: [IN] the scrollbar orientation
*/
const ScrollbarGTKMetrics* GetActiveScrollbarMetrics(
GtkOrientation aOrientation);
/**
* Get the desired size of a dropdown arrow button
* width: [OUT] the desired width

View file

@ -737,7 +737,7 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
aResult = threshold;
} break;
case IntID::ScrollArrowStyle: {
GtkWidget* scrollbar = GetWidget(MOZ_GTK_SCROLLBAR_HORIZONTAL);
GtkWidget* scrollbar = GetWidget(MOZ_GTK_SCROLLBAR_VERTICAL);
aResult = ConvertGTKStepperStyleToMozillaScrollArrowStyle(scrollbar);
break;
}

View file

@ -126,7 +126,7 @@ static bool IsFrameContentNodeInNamespace(nsIFrame* aFrame,
static bool IsWidgetTypeDisabled(const uint8_t* aDisabledVector,
StyleAppearance aAppearance) {
auto type = static_cast<size_t>(aAppearance);
MOZ_ASSERT(type < static_cast<size_t>(mozilla::StyleAppearance::Count));
MOZ_ASSERT(type < static_cast<size_t>(StyleAppearance::Count));
return (aDisabledVector[type >> 3] & (1 << (type & 7))) != 0;
}
@ -182,16 +182,6 @@ gint nsNativeThemeGTK::GetTabMarginPixels(nsIFrame* aFrame) {
std::max(0, aFrame->PresContext()->AppUnitsToDevPixels(-margin)));
}
static bool ShouldScrollbarButtonBeDisabled(int32_t aCurpos, int32_t aMaxpos,
StyleAppearance aAppearance) {
return (aCurpos == 0 &&
(aAppearance == StyleAppearance::ScrollbarbuttonUp ||
aAppearance == StyleAppearance::ScrollbarbuttonLeft)) ||
(aCurpos == aMaxpos &&
(aAppearance == StyleAppearance::ScrollbarbuttonDown ||
aAppearance == StyleAppearance::ScrollbarbuttonRight));
}
bool nsNativeThemeGTK::GetGtkWidgetAndState(StyleAppearance aAppearance,
nsIFrame* aFrame,
WidgetNodeType& aGtkWidgetType,
@ -264,50 +254,6 @@ bool nsNativeThemeGTK::GetGtkWidgetAndState(StyleAppearance aAppearance,
aState->focused = FALSE;
}
if (aAppearance == StyleAppearance::ScrollbarthumbVertical ||
aAppearance == StyleAppearance::ScrollbarthumbHorizontal) {
// for scrollbars we need to go up two to go from the thumb to
// the slider to the actual scrollbar object
nsIFrame* tmpFrame = aFrame->GetParent()->GetParent();
aState->curpos = CheckIntAttr(tmpFrame, nsGkAtoms::curpos, 0);
aState->maxpos = CheckIntAttr(tmpFrame, nsGkAtoms::maxpos, 100);
if (CheckBooleanAttr(aFrame, nsGkAtoms::active)) {
aState->active = TRUE;
// Set hover state to emulate Gtk style of active scrollbar thumb
aState->inHover = TRUE;
}
}
if (aAppearance == StyleAppearance::ScrollbarbuttonUp ||
aAppearance == StyleAppearance::ScrollbarbuttonDown ||
aAppearance == StyleAppearance::ScrollbarbuttonLeft ||
aAppearance == StyleAppearance::ScrollbarbuttonRight) {
// set the state to disabled when the scrollbar is scrolled to
// the beginning or the end, depending on the button type.
int32_t curpos = CheckIntAttr(aFrame, nsGkAtoms::curpos, 0);
int32_t maxpos = CheckIntAttr(aFrame, nsGkAtoms::maxpos, 100);
if (ShouldScrollbarButtonBeDisabled(curpos, maxpos, aAppearance)) {
aState->disabled = true;
}
// In order to simulate native GTK scrollbar click behavior,
// we set the active attribute on the element to true if it's
// pressed with any mouse button.
// This allows us to show that it's active without setting :active
else if (CheckBooleanAttr(aFrame, nsGkAtoms::active))
aState->active = true;
if (aWidgetFlags) {
*aWidgetFlags = GetScrollbarButtonType(aFrame);
if (static_cast<uint8_t>(aAppearance) -
static_cast<uint8_t>(StyleAppearance::ScrollbarbuttonUp) <
2)
*aWidgetFlags |= MOZ_GTK_STEPPER_VERTICAL;
}
}
// menu item state is determined by the attribute "_moz-menuactive",
// and not by the mouse hovering (accessibility). as a special case,
// menus which are children of a menu bar are only marked as prelight
@ -376,21 +322,6 @@ bool nsNativeThemeGTK::GetGtkWidgetAndState(StyleAppearance aAppearance,
aAppearance == StyleAppearance::MozWindowButtonRestore) {
aState->backdrop = !nsWindow::GetTopLevelWindowActiveState(aFrame);
}
if (aAppearance == StyleAppearance::ScrollbarbuttonUp ||
aAppearance == StyleAppearance::ScrollbarbuttonDown ||
aAppearance == StyleAppearance::ScrollbarbuttonLeft ||
aAppearance == StyleAppearance::ScrollbarbuttonRight ||
aAppearance == StyleAppearance::ScrollbarVertical ||
aAppearance == StyleAppearance::ScrollbarHorizontal ||
aAppearance == StyleAppearance::ScrollbartrackHorizontal ||
aAppearance == StyleAppearance::ScrollbartrackVertical ||
aAppearance == StyleAppearance::ScrollbarthumbVertical ||
aAppearance == StyleAppearance::ScrollbarthumbHorizontal) {
EventStates docState =
aFrame->GetContent()->OwnerDoc()->GetDocumentState();
aState->backdrop = docState.HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE);
}
}
switch (aAppearance) {
@ -412,38 +343,6 @@ bool nsNativeThemeGTK::GetGtkWidgetAndState(StyleAppearance aAppearance,
? MOZ_GTK_RADIOBUTTON
: MOZ_GTK_CHECKBUTTON;
break;
case StyleAppearance::ScrollbarbuttonUp:
case StyleAppearance::ScrollbarbuttonDown:
case StyleAppearance::ScrollbarbuttonLeft:
case StyleAppearance::ScrollbarbuttonRight:
aGtkWidgetType = MOZ_GTK_SCROLLBAR_BUTTON;
break;
case StyleAppearance::ScrollbarVertical:
aGtkWidgetType = MOZ_GTK_SCROLLBAR_VERTICAL;
if (GetWidgetTransparency(aFrame, aAppearance) == eOpaque)
*aWidgetFlags = MOZ_GTK_TRACK_OPAQUE;
else
*aWidgetFlags = 0;
break;
case StyleAppearance::ScrollbarHorizontal:
aGtkWidgetType = MOZ_GTK_SCROLLBAR_HORIZONTAL;
if (GetWidgetTransparency(aFrame, aAppearance) == eOpaque)
*aWidgetFlags = MOZ_GTK_TRACK_OPAQUE;
else
*aWidgetFlags = 0;
break;
case StyleAppearance::ScrollbartrackHorizontal:
aGtkWidgetType = MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL;
break;
case StyleAppearance::ScrollbartrackVertical:
aGtkWidgetType = MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL;
break;
case StyleAppearance::ScrollbarthumbVertical:
aGtkWidgetType = MOZ_GTK_SCROLLBAR_THUMB_VERTICAL;
break;
case StyleAppearance::ScrollbarthumbHorizontal:
aGtkWidgetType = MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL;
break;
case StyleAppearance::Spinner:
aGtkWidgetType = MOZ_GTK_SPINBUTTON;
break;
@ -932,13 +831,6 @@ bool nsNativeThemeGTK::GetExtraSizeForWidget(nsIFrame* aFrame,
// GTK2 themes (Ximian Industrial, Bluecurve, Misty, at least);
// We modify the frame's overflow area. See bug 297508.
switch (aAppearance) {
case StyleAppearance::ScrollbarthumbVertical:
aExtra->top = aExtra->bottom = 1;
break;
case StyleAppearance::ScrollbarthumbHorizontal:
aExtra->left = aExtra->right = 1;
break;
case StyleAppearance::Button: {
if (IsDefaultButton(aFrame)) {
// Some themes draw a default indicator outside the widget,
@ -1201,36 +1093,6 @@ LayoutDeviceIntMargin nsNativeThemeGTK::GetWidgetBorder(
LayoutDeviceIntMargin result;
GtkTextDirection direction = GetTextDirection(aFrame);
switch (aAppearance) {
case StyleAppearance::ScrollbarHorizontal:
case StyleAppearance::ScrollbarVertical: {
GtkOrientation orientation =
aAppearance == StyleAppearance::ScrollbarHorizontal
? GTK_ORIENTATION_HORIZONTAL
: GTK_ORIENTATION_VERTICAL;
const ScrollbarGTKMetrics* metrics =
GetActiveScrollbarMetrics(orientation);
const GtkBorder& border = metrics->border.scrollbar;
result.top = border.top;
result.right = border.right;
result.bottom = border.bottom;
result.left = border.left;
} break;
case StyleAppearance::ScrollbartrackHorizontal:
case StyleAppearance::ScrollbartrackVertical: {
GtkOrientation orientation =
aAppearance == StyleAppearance::ScrollbartrackHorizontal
? GTK_ORIENTATION_HORIZONTAL
: GTK_ORIENTATION_VERTICAL;
const ScrollbarGTKMetrics* metrics =
GetActiveScrollbarMetrics(orientation);
const GtkBorder& border = metrics->border.track;
result.top = border.top;
result.right = border.right;
result.bottom = border.bottom;
result.left = border.left;
} break;
case StyleAppearance::Toolbox:
// gtk has no toolbox equivalent. So, although we map toolbox to
// gtk's 'toolbar' for purposes of painting the widget background,
@ -1366,9 +1228,6 @@ bool nsNativeThemeGTK::GetWidgetOverflow(nsDeviceContext* aContext,
auto nsNativeThemeGTK::IsWidgetNonNative(nsIFrame* aFrame,
StyleAppearance aAppearance)
-> NonNative {
if (!StaticPrefs::widget_non_native_theme_enabled()) {
return NonNative::No;
}
if (IsWidgetScrollbarPart(aAppearance)) {
return NonNative::Always;
}
@ -1397,24 +1256,6 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext,
*aIsOverridable = true;
switch (aAppearance) {
case StyleAppearance::ScrollbarbuttonUp:
case StyleAppearance::ScrollbarbuttonDown: {
const ScrollbarGTKMetrics* metrics =
GetActiveScrollbarMetrics(GTK_ORIENTATION_VERTICAL);
aResult->width = metrics->size.button.width;
aResult->height = metrics->size.button.height;
*aIsOverridable = false;
} break;
case StyleAppearance::ScrollbarbuttonLeft:
case StyleAppearance::ScrollbarbuttonRight: {
const ScrollbarGTKMetrics* metrics =
GetActiveScrollbarMetrics(GTK_ORIENTATION_HORIZONTAL);
aResult->width = metrics->size.button.width;
aResult->height = metrics->size.button.height;
*aIsOverridable = false;
} break;
case StyleAppearance::Splitter: {
gint metrics;
if (IsHorizontal(aFrame)) {
@ -1428,36 +1269,6 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext,
}
*aIsOverridable = false;
} break;
case StyleAppearance::ScrollbarHorizontal:
case StyleAppearance::ScrollbarVertical: {
/* While we enforce a minimum size for the thumb, this is ignored
* for the some scrollbars if buttons are hidden (bug 513006) because
* the thumb isn't a direct child of the scrollbar, unlike the buttons
* or track. So add a minimum size to the track as well to prevent a
* 0-width scrollbar. */
GtkOrientation orientation =
aAppearance == StyleAppearance::ScrollbarHorizontal
? GTK_ORIENTATION_HORIZONTAL
: GTK_ORIENTATION_VERTICAL;
const ScrollbarGTKMetrics* metrics =
GetActiveScrollbarMetrics(orientation);
aResult->width = metrics->size.scrollbar.width;
aResult->height = metrics->size.scrollbar.height;
} break;
case StyleAppearance::ScrollbarthumbVertical:
case StyleAppearance::ScrollbarthumbHorizontal: {
GtkOrientation orientation =
aAppearance == StyleAppearance::ScrollbarthumbHorizontal
? GTK_ORIENTATION_HORIZONTAL
: GTK_ORIENTATION_VERTICAL;
const ScrollbarGTKMetrics* metrics =
GetActiveScrollbarMetrics(orientation);
aResult->width = metrics->size.thumb.width;
aResult->height = metrics->size.thumb.height;
*aIsOverridable = false;
} break;
case StyleAppearance::RangeThumb: {
gint thumb_length, thumb_height;
@ -1666,42 +1477,6 @@ nsNativeThemeGTK::WidgetStateChanged(nsIFrame* aFrame,
return NS_OK;
}
if ((aAppearance == StyleAppearance::ScrollbarthumbVertical ||
aAppearance == StyleAppearance::ScrollbarthumbHorizontal) &&
aAttribute == nsGkAtoms::active) {
*aShouldRepaint = true;
return NS_OK;
}
if ((aAppearance == StyleAppearance::ScrollbarbuttonUp ||
aAppearance == StyleAppearance::ScrollbarbuttonDown ||
aAppearance == StyleAppearance::ScrollbarbuttonLeft ||
aAppearance == StyleAppearance::ScrollbarbuttonRight) &&
(aAttribute == nsGkAtoms::curpos || aAttribute == nsGkAtoms::maxpos)) {
// If 'curpos' has changed and we are passed its old value, we can
// determine whether the button's enablement actually needs to change.
if (aAttribute == nsGkAtoms::curpos && aOldValue) {
int32_t curpos = CheckIntAttr(aFrame, nsGkAtoms::curpos, 0);
int32_t maxpos = CheckIntAttr(aFrame, nsGkAtoms::maxpos, 0);
nsAutoString str;
aOldValue->ToString(str);
nsresult err;
int32_t oldCurpos = str.ToInteger(&err);
if (str.IsEmpty() || NS_FAILED(err)) {
*aShouldRepaint = true;
} else {
bool disabledBefore =
ShouldScrollbarButtonBeDisabled(oldCurpos, maxpos, aAppearance);
bool disabledNow =
ShouldScrollbarButtonBeDisabled(curpos, maxpos, aAppearance);
*aShouldRepaint = (disabledBefore != disabledNow);
}
} else {
*aShouldRepaint = true;
}
return NS_OK;
}
// XXXdwh Not sure what can really be done here. Can at least guess for
// specific widgets that they're highly unlikely to have certain states.
// For example, a toolbar doesn't care about any states.
@ -1735,11 +1510,6 @@ nsNativeThemeGTK::ThemeChanged() {
return NS_OK;
}
static bool CanHandleScrollbar(const ComputedStyle& aStyle) {
return !aStyle.StyleUI()->HasCustomScrollbars() &&
aStyle.StyleUIReset()->mScrollbarWidth != StyleScrollbarWidth::Thin;
}
NS_IMETHODIMP_(bool)
nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
nsIFrame* aFrame,
@ -1753,13 +1523,6 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
aAppearance);
}
if (IsWidgetScrollbarPart(aAppearance)) {
ComputedStyle* cs = nsLayoutUtils::StyleForScrollbar(aFrame);
if (!CanHandleScrollbar(*cs)) {
return false;
}
}
switch (aAppearance) {
// Combobox dropdowns don't support native theming in vertical mode.
case StyleAppearance::Menulist:
@ -1809,16 +1572,6 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
case StyleAppearance::SpinnerUpbutton:
case StyleAppearance::SpinnerDownbutton:
case StyleAppearance::SpinnerTextfield:
case StyleAppearance::ScrollbarbuttonUp:
case StyleAppearance::ScrollbarbuttonDown:
case StyleAppearance::ScrollbarbuttonLeft:
case StyleAppearance::ScrollbarbuttonRight:
case StyleAppearance::ScrollbarHorizontal:
case StyleAppearance::ScrollbarVertical:
case StyleAppearance::ScrollbartrackHorizontal:
case StyleAppearance::ScrollbartrackVertical:
case StyleAppearance::ScrollbarthumbHorizontal:
case StyleAppearance::ScrollbarthumbVertical:
case StyleAppearance::NumberInput:
case StyleAppearance::Textfield:
case StyleAppearance::Textarea:
@ -1908,16 +1661,6 @@ nsITheme::Transparency nsNativeThemeGTK::GetWidgetTransparency(
}
switch (aAppearance) {
case StyleAppearance::ScrollbarVertical:
case StyleAppearance::ScrollbarHorizontal:
// 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()->IsRootContentDocumentCrossProcess() &&
IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XUL))) {
return eTransparent;
}
return eOpaque;
// Tooltips use gtk_paint_flat_box() on Gtk2
// but are shaped on Gtk3
case StyleAppearance::Tooltip:
@ -1927,31 +1670,6 @@ nsITheme::Transparency nsNativeThemeGTK::GetWidgetTransparency(
}
}
auto nsNativeThemeGTK::GetScrollbarSizes(nsPresContext* aPresContext,
StyleScrollbarWidth aWidth,
Overlay aOverlay) -> ScrollbarSizes {
if (StaticPrefs::widget_non_native_theme_enabled()) {
return Theme::GetScrollbarSizes(aPresContext, aWidth,
aOverlay);
}
CSSIntCoord vertical;
CSSIntCoord horizontal;
if (aWidth != StyleScrollbarWidth::Thin) {
const ScrollbarGTKMetrics* verticalMetrics =
GetActiveScrollbarMetrics(GTK_ORIENTATION_VERTICAL);
const ScrollbarGTKMetrics* horizontalMetrics =
GetActiveScrollbarMetrics(GTK_ORIENTATION_HORIZONTAL);
vertical = verticalMetrics->size.scrollbar.width;
horizontal = horizontalMetrics->size.scrollbar.height;
} else {
auto unthemed = nsLayoutUtils::UnthemedScrollbarSize(aWidth);
vertical = horizontal = unthemed;
}
auto scale = GetMonitorScaleFactor(aPresContext);
return {int32_t(vertical) * scale, int32_t(horizontal) * scale};
}
already_AddRefed<nsITheme> do_GetNativeThemeDoNotUseDirectly() {
static nsCOMPtr<nsITheme> inst;

View file

@ -80,8 +80,6 @@ class nsNativeThemeGTK final : public mozilla::widget::Theme {
bool ThemeNeedsComboboxDropmarker() override;
Transparency GetWidgetTransparency(nsIFrame*, StyleAppearance) override;
ScrollbarSizes GetScrollbarSizes(nsPresContext*, StyleScrollbarWidth,
Overlay) override;
nsNativeThemeGTK();

View file

@ -301,34 +301,6 @@ bool nsNativeTheme::IsHTMLContent(nsIFrame* aFrame) {
return content && content->IsHTMLElement();
}
// scrollbar button:
int32_t nsNativeTheme::GetScrollbarButtonType(nsIFrame* aFrame) {
if (!aFrame) return 0;
static Element::AttrValuesArray strings[] = {
nsGkAtoms::scrollbarDownBottom, nsGkAtoms::scrollbarDownTop,
nsGkAtoms::scrollbarUpBottom, nsGkAtoms::scrollbarUpTop, nullptr};
nsIContent* content = aFrame->GetContent();
if (!content || !content->IsElement()) {
return 0;
}
switch (content->AsElement()->FindAttrValueIn(
kNameSpaceID_None, nsGkAtoms::sbattr, strings, eCaseMatters)) {
case 0:
return eScrollbarButton_Down | eScrollbarButton_Bottom;
case 1:
return eScrollbarButton_Down;
case 2:
return eScrollbarButton_Bottom;
case 3:
return eScrollbarButton_UpTop;
}
return 0;
}
// treeheadercell:
nsNativeTheme::TreeSortDirection nsNativeTheme::GetTreeSortDirection(
nsIFrame* aFrame) {

View file

@ -74,9 +74,6 @@ class nsNativeTheme : public nsITimerCallback, public nsINamed {
bool IsButtonTypeMenu(nsIFrame* aFrame);
// scrollbar button:
int32_t GetScrollbarButtonType(nsIFrame* aFrame);
// tab:
bool IsSelectedTab(nsIFrame* aFrame) {
return CheckBooleanAttr(aFrame, nsGkAtoms::visuallyselected);