--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -447,36 +447,35 @@ moz_gtk_get_widget_min_size(WidgetNodeTy
*width += border.left + border.right + margin.left + margin.right +
padding.left + padding.right;
*height += border.top + border.bottom + margin.top + margin.bottom +
padding.top + padding.bottom;
}
static void
-moz_gtk_rectangle_inset(GdkRectangle* rect, GtkBorder& aBorder)
+Inset(GdkRectangle* rect, GtkBorder& aBorder)
{
MOZ_ASSERT(rect);
rect->x += aBorder.left;
rect->y += aBorder.top;
rect->width -= aBorder.left + aBorder.right;
rect->height -= aBorder.top + aBorder.bottom;
}
-/* Subtracting margin is used to inset drawing of element which can have margins,
- * like scrollbar, scrollbar's trough, thumb and scrollbar's button */
+// Inset a rectangle by the margins specified in a style context.
static void
-moz_gtk_subtract_margin(GtkStyleContext* style, GdkRectangle* rect)
+InsetByMargin(GdkRectangle* rect, GtkStyleContext* style)
{
MOZ_ASSERT(rect);
GtkBorder margin;
gtk_style_context_get_margin(style, gtk_style_context_get_state(style),
&margin);
- moz_gtk_rectangle_inset(rect, margin);
+ Inset(rect, margin);
}
static gint
moz_gtk_scrollbar_button_paint(cairo_t *cr, const GdkRectangle* aRect,
GtkWidgetState* state,
GtkScrollbarButtonFlags flags,
GtkTextDirection direction)
{
@@ -512,17 +511,17 @@ moz_gtk_scrollbar_button_paint(cairo_t *
} 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.
- moz_gtk_subtract_margin(style, &rect);
+ 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).
MozGtkScrollbarMetrics metrics;
moz_gtk_get_scrollbar_metrics(&metrics);
if (flags & MOZ_GTK_STEPPER_VERTICAL) {
rect.x += metrics.trough_border;
@@ -585,17 +584,17 @@ moz_gtk_update_scrollbar_style(GtkStyleC
}
static void
moz_gtk_draw_styled_frame(GtkStyleContext* style, cairo_t *cr,
const GdkRectangle* aRect, bool drawFocus)
{
GdkRectangle rect = *aRect;
if (gtk_check_version(3, 6, 0) == nullptr) {
- moz_gtk_subtract_margin(style, &rect);
+ InsetByMargin(&rect, style);
}
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);
}
}
@@ -648,17 +647,17 @@ moz_gtk_scrollbar_thumb_paint(WidgetNode
cairo_t *cr, const GdkRectangle* aRect,
GtkWidgetState* state,
GtkTextDirection direction)
{
GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
GdkRectangle rect = *aRect;
GtkStyleContext* style = ClaimStyleContext(widget, direction, state_flags);
- moz_gtk_subtract_margin(style, &rect);
+ InsetByMargin(&rect, style);
gtk_render_slider(style, cr,
rect.x,
rect.y,
rect.width,
rect.height,
(widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) ?
GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
@@ -1283,26 +1282,26 @@ moz_gtk_tooltip_paint(cairo_t *cr, const
GtkStyleContext* boxStyle =
CreateStyleForWidget(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0), style);
rect.x += 6;
rect.y += 6;
rect.width -= 12;
rect.height -= 12;
- moz_gtk_subtract_margin(boxStyle, &rect);
+ InsetByMargin(&rect, boxStyle);
gtk_render_background(boxStyle, cr, rect.x, rect.y, rect.width, rect.height);
gtk_render_frame(boxStyle, cr, rect.x, rect.y, rect.width, rect.height);
// Label drawing
GtkBorder padding, border;
gtk_style_context_get_padding(boxStyle, GTK_STATE_FLAG_NORMAL, &padding);
- moz_gtk_rectangle_inset(&rect, padding);
+ Inset(&rect, padding);
gtk_style_context_get_border(boxStyle, GTK_STATE_FLAG_NORMAL, &border);
- moz_gtk_rectangle_inset(&rect, border);
+ Inset(&rect, border);
GtkStyleContext* labelStyle =
CreateStyleForWidget(gtk_label_new(nullptr), boxStyle);
moz_gtk_draw_styled_frame(labelStyle, cr, &rect, false);
g_object_unref(labelStyle);
g_object_unref(boxStyle);