commit 00beb3311073
Author: Karl Tomlinson <karlt+@karlt.net>
Date: Tue Sep 5 09:16:01 2017 +1200
bug 1396722 remove no-op ReleaseStyleContext() r=stransky+263117
MozReview-Commit-ID: DgKM0wrStrk
--HG--
extra : rebase_source : a26fdc5e5d6c63e21bb98a19ee7bf58042f9b3ba
---
widget/gtk/WidgetStyleCache.cpp | 9 +-
widget/gtk/WidgetStyleCache.h | 15 +-
widget/gtk/gtk3drawing.cpp | 306 +++++++++++++++-------------------------
widget/gtk/nsLookAndFeel.cpp | 63 +++------
4 files changed, 142 insertions(+), 251 deletions(-)
diff --git widget/gtk/WidgetStyleCache.cpp widget/gtk/WidgetStyleCache.cpp
index bf0c2d080c17..39b7893df3bd 100644
--- widget/gtk/WidgetStyleCache.cpp
+++ widget/gtk/WidgetStyleCache.cpp
@@ -1220,8 +1220,8 @@ ResetWidgetCache(void)
}
GtkStyleContext*
-ClaimStyleContext(WidgetNodeType aNodeType, GtkTextDirection aDirection,
- GtkStateFlags aStateFlags, StyleFlags aFlags)
+GetStyleContext(WidgetNodeType aNodeType, GtkTextDirection aDirection,
+ GtkStateFlags aStateFlags, StyleFlags aFlags)
{
GtkStyleContext* style;
if (gtk_check_version(3, 20, 0) != nullptr) {
@@ -1276,8 +1276,3 @@ ClaimStyleContext(WidgetNodeType aNodeType, GtkTextDirection aDirection,
}
return style;
}
-
-void
-ReleaseStyleContext(GtkStyleContext* aStyleContext)
-{
-}
diff --git widget/gtk/WidgetStyleCache.h widget/gtk/WidgetStyleCache.h
index 2cbb5f96076f..6cce492de2b6 100644
--- widget/gtk/WidgetStyleCache.h
+++ widget/gtk/WidgetStyleCache.h
@@ -33,14 +33,15 @@ CreateCSSNode(const char* aName,
GtkStyleContext* aParentStyle,
GType aType = G_TYPE_NONE);
-// Callers must call ReleaseStyleContext() on the returned context.
+/*
+ * Returns a pointer to a style context for the specified node and state.
+ * The context is owned by WidgetStyleCache. Do not unref.
+ */
GtkStyleContext*
-ClaimStyleContext(WidgetNodeType aNodeType,
- GtkTextDirection aDirection = GTK_TEXT_DIR_NONE,
- GtkStateFlags aStateFlags = GTK_STATE_FLAG_NORMAL,
- StyleFlags aFlags = NO_STYLE_FLAGS);
-void
-ReleaseStyleContext(GtkStyleContext* style);
+GetStyleContext(WidgetNodeType aNodeType,
+ GtkTextDirection aDirection = GTK_TEXT_DIR_NONE,
+ GtkStateFlags aStateFlags = GTK_STATE_FLAG_NORMAL,
+ StyleFlags aFlags = NO_STYLE_FLAGS);
void
ResetWidgetCache(void);
diff --git widget/gtk/gtk3drawing.cpp widget/gtk/gtk3drawing.cpp
index 73bd1987fd39..4c562b380095 100644
--- widget/gtk/gtk3drawing.cpp
+++ widget/gtk/gtk3drawing.cpp
@@ -100,10 +100,9 @@ moz_gtk_refresh()
gtk_check_version(3, 20, 0) != nullptr)
{
// Deprecated for Gtk >= 3.20+
- GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_TAB_TOP);
+ GtkStyleContext *style = GetStyleContext(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;
@@ -149,31 +148,28 @@ moz_gtk_get_focus_outline_size(GtkStyleContext* style,
gint
moz_gtk_get_focus_outline_size(gint* focus_h_width, gint* focus_v_width)
{
- GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_ENTRY);
+ GtkStyleContext *style = GetStyleContext(MOZ_GTK_ENTRY);
moz_gtk_get_focus_outline_size(style, focus_h_width, focus_v_width);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
gint
moz_gtk_menuitem_get_horizontal_padding(gint* horizontal_padding)
{
- GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_MENUITEM);
+ GtkStyleContext *style = GetStyleContext(MOZ_GTK_MENUITEM);
gtk_style_context_get_style(style,
"horizontal-padding", horizontal_padding,
nullptr);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
gint
moz_gtk_checkmenuitem_get_horizontal_padding(gint* horizontal_padding)
{
- GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_CHECKMENUITEM);
+ GtkStyleContext *style = GetStyleContext(MOZ_GTK_CHECKMENUITEM);
gtk_style_context_get_style(style,
"horizontal-padding", horizontal_padding,
nullptr);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -183,11 +179,10 @@ moz_gtk_button_get_default_overflow(gint* border_top, gint* border_left,
{
GtkBorder* default_outside_border;
- GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_BUTTON);
+ GtkStyleContext *style = GetStyleContext(MOZ_GTK_BUTTON);
gtk_style_context_get_style(style,
"default-outside-border", &default_outside_border,
NULL);
- ReleaseStyleContext(style);
if (default_outside_border) {
*border_top = default_outside_border->top;
@@ -207,11 +202,10 @@ moz_gtk_button_get_default_border(gint* border_top, gint* border_left,
{
GtkBorder* default_border;
- GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_BUTTON);
+ GtkStyleContext *style = GetStyleContext(MOZ_GTK_BUTTON);
gtk_style_context_get_style(style,
"default-border", &default_border,
NULL);
- ReleaseStyleContext(style);
if (default_border) {
*border_top = default_border->top;
@@ -231,12 +225,11 @@ moz_gtk_splitter_get_metrics(gint orientation, gint* size)
{
GtkStyleContext *style;
if (orientation == GTK_ORIENTATION_HORIZONTAL) {
- style = ClaimStyleContext(MOZ_GTK_SPLITTER_HORIZONTAL);
+ style = GetStyleContext(MOZ_GTK_SPLITTER_HORIZONTAL);
} else {
- style = ClaimStyleContext(MOZ_GTK_SPLITTER_VERTICAL);
+ style = GetStyleContext(MOZ_GTK_SPLITTER_VERTICAL);
}
gtk_style_context_get_style(style, "handle_size", size, NULL);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -244,15 +237,13 @@ static gint
moz_gtk_window_paint(cairo_t *cr, GdkRectangle* rect,
GtkTextDirection direction)
{
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_WINDOW, direction);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_WINDOW, direction);
gtk_style_context_save(style);
gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND);
gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
gtk_style_context_restore(style);
- ReleaseStyleContext(style);
-
return MOZ_GTK_SUCCESS;
}
@@ -351,9 +342,8 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRectangle* rect,
if (inconsistent)
state_flags = static_cast<GtkStateFlags>(state_flags|GTK_STATE_FLAG_INCONSISTENT);
- style = ClaimStyleContext(isradio ? MOZ_GTK_RADIOBUTTON :
- MOZ_GTK_CHECKBUTTON,
- direction, state_flags);
+ style = GetStyleContext(isradio ? MOZ_GTK_RADIOBUTTON : MOZ_GTK_CHECKBUTTON,
+ direction, state_flags);
if (gtk_check_version(3, 20, 0) == nullptr) {
gtk_render_background(style, cr, x, y, width, height);
@@ -375,8 +365,6 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRectangle* rect,
}
}
- ReleaseStyleContext(style);
-
return MOZ_GTK_SUCCESS;
}
@@ -460,7 +448,7 @@ static void
moz_gtk_get_widget_min_size(WidgetNodeType aGtkWidgetType, int* width,
int* height)
{
- GtkStyleContext* style = ClaimStyleContext(aGtkWidgetType);
+ GtkStyleContext* style = GetStyleContext(aGtkWidgetType);
GtkStateFlags state_flags = gtk_style_context_get_state(style);
gtk_style_context_get(style, state_flags,
"min-height", height,
@@ -471,7 +459,6 @@ moz_gtk_get_widget_min_size(WidgetNodeType aGtkWidgetType, int* width,
gtk_style_context_get_border(style, state_flags, &border);
gtk_style_context_get_padding(style, state_flags, &padding);
gtk_style_context_get_margin(style, state_flags, &margin);
- ReleaseStyleContext(style);
*width += border.left + border.right + margin.left + margin.right +
padding.left + padding.right;
@@ -666,7 +653,7 @@ moz_gtk_scrollbar_trough_paint(WidgetNodeType widget,
MOZ_GTK_SCROLLBAR_THUMB_VERTICAL :
MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL;
MozGtkSize thumbSize = GetMinMarginBox(thumb);
- style = ClaimStyleContext(widget, direction);
+ style = GetStyleContext(widget, direction);
MozGtkSize trackSize = GetMinContentBox(style);
trackSize.Include(thumbSize);
trackSize += GetMarginBorderPadding(style);
@@ -681,11 +668,10 @@ moz_gtk_scrollbar_trough_paint(WidgetNodeType widget,
rect.height = trackSize.height;
}
} else {
- style = ClaimStyleContext(widget, direction);
+ style = GetStyleContext(widget, direction);
}
moz_gtk_draw_styled_frame(style, cr, &rect, state->focused);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -696,18 +682,16 @@ moz_gtk_scrollbar_paint(WidgetNodeType widget,
GtkWidgetState* state,
GtkTextDirection direction)
{
- GtkStyleContext* style = ClaimStyleContext(widget, direction);
+ GtkStyleContext* style = GetStyleContext(widget, direction);
moz_gtk_update_scrollbar_style(style, widget, direction);
moz_gtk_draw_styled_frame(style, cr, rect, state->focused);
- ReleaseStyleContext(style);
- style = ClaimStyleContext((widget == MOZ_GTK_SCROLLBAR_HORIZONTAL) ?
- MOZ_GTK_SCROLLBAR_CONTENTS_HORIZONTAL :
- MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL,
- direction);
+ style = GetStyleContext((widget == MOZ_GTK_SCROLLBAR_HORIZONTAL) ?
+ MOZ_GTK_SCROLLBAR_CONTENTS_HORIZONTAL :
+ MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL,
+ direction);
moz_gtk_draw_styled_frame(style, cr, rect, state->focused);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -721,7 +705,7 @@ moz_gtk_scrollbar_thumb_paint(WidgetNodeType widget,
GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
GdkRectangle rect = *aRect;
- GtkStyleContext* style = ClaimStyleContext(widget, direction, state_flags);
+ GtkStyleContext* style = GetStyleContext(widget, direction, state_flags);
InsetByMargin(&rect, style);
gtk_render_slider(style, cr,
@@ -732,7 +716,6 @@ moz_gtk_scrollbar_thumb_paint(WidgetNodeType widget,
(widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) ?
GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -741,10 +724,9 @@ static gint
moz_gtk_spin_paint(cairo_t *cr, GdkRectangle* rect,
GtkTextDirection direction)
{
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_SPINBUTTON, direction);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_SPINBUTTON, 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);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -753,7 +735,7 @@ moz_gtk_spin_updown_paint(cairo_t *cr, GdkRectangle* rect,
gboolean isDown, GtkWidgetState* state,
GtkTextDirection direction)
{
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_SPINBUTTON, direction,
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_SPINBUTTON, direction,
GetStateFlagsFromGtkWidgetState(state));
gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
@@ -772,7 +754,6 @@ moz_gtk_spin_updown_paint(cairo_t *cr, GdkRectangle* rect,
arrow_rect.x, arrow_rect.y,
arrow_rect.width);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -793,7 +774,7 @@ moz_gtk_scale_paint(cairo_t *cr, GdkRectangle* rect,
WidgetNodeType widget = (flags == GTK_ORIENTATION_HORIZONTAL) ?
MOZ_GTK_SCALE_TROUGH_HORIZONTAL :
MOZ_GTK_SCALE_TROUGH_VERTICAL;
- style = ClaimStyleContext(widget, direction, state_flags);
+ style = GetStyleContext(widget, direction, state_flags);
gtk_style_context_get_margin(style, state_flags, &margin);
// Clamp the dimension perpendicular to the direction that the slider crosses
@@ -817,7 +798,6 @@ moz_gtk_scale_paint(cairo_t *cr, GdkRectangle* rect,
gtk_render_focus(style, cr,
rect->x, rect->y, rect->width, rect->height);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -846,9 +826,8 @@ moz_gtk_scale_thumb_paint(cairo_t *cr, GdkRectangle* rect,
WidgetNodeType widget = (flags == GTK_ORIENTATION_HORIZONTAL) ?
MOZ_GTK_SCALE_THUMB_HORIZONTAL :
MOZ_GTK_SCALE_THUMB_VERTICAL;
- style = ClaimStyleContext(widget, direction, state_flags);
+ style = GetStyleContext(widget, direction, state_flags);
gtk_render_slider(style, cr, x, y, thumb_width, thumb_height, flags);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -859,11 +838,10 @@ moz_gtk_gripper_paint(cairo_t *cr, GdkRectangle* rect,
GtkTextDirection direction)
{
GtkStyleContext* style =
- ClaimStyleContext(MOZ_GTK_GRIPPER, direction,
- GetStateFlagsFromGtkWidgetState(state));
+ GetStyleContext(MOZ_GTK_GRIPPER, direction,
+ GetStateFlagsFromGtkWidgetState(state));
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);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -872,12 +850,11 @@ moz_gtk_hpaned_paint(cairo_t *cr, GdkRectangle* rect,
GtkWidgetState* state)
{
GtkStyleContext* style =
- ClaimStyleContext(MOZ_GTK_SPLITTER_SEPARATOR_HORIZONTAL,
- GTK_TEXT_DIR_LTR,
- GetStateFlagsFromGtkWidgetState(state));
+ GetStyleContext(MOZ_GTK_SPLITTER_SEPARATOR_HORIZONTAL,
+ GTK_TEXT_DIR_LTR,
+ GetStateFlagsFromGtkWidgetState(state));
gtk_render_handle(style, cr,
rect->x, rect->y, rect->width, rect->height);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -886,12 +863,11 @@ moz_gtk_vpaned_paint(cairo_t *cr, GdkRectangle* rect,
GtkWidgetState* state)
{
GtkStyleContext* style =
- ClaimStyleContext(MOZ_GTK_SPLITTER_SEPARATOR_VERTICAL,
- GTK_TEXT_DIR_LTR,
- GetStateFlagsFromGtkWidgetState(state));
+ GetStyleContext(MOZ_GTK_SPLITTER_SEPARATOR_VERTICAL,
+ GTK_TEXT_DIR_LTR,
+ GetStateFlagsFromGtkWidgetState(state));
gtk_render_handle(style, cr,
rect->x, rect->y, rect->width, rect->height);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -939,26 +915,22 @@ moz_gtk_text_view_paint(cairo_t *cr, GdkRectangle* aRect,
GTK_STATE_FLAG_NORMAL;
GtkStyleContext* style_frame =
- ClaimStyleContext(MOZ_GTK_SCROLLED_WINDOW, direction, state_flags);
+ GetStyleContext(MOZ_GTK_SCROLLED_WINDOW, direction, state_flags);
gtk_render_frame(style_frame, cr,
aRect->x, aRect->y, aRect->width, aRect->height);
GdkRectangle rect = *aRect;
InsetByBorderPadding(&rect, style_frame);
- ReleaseStyleContext(style_frame);
-
GtkStyleContext* style =
- ClaimStyleContext(MOZ_GTK_TEXT_VIEW, direction, state_flags);
+ GetStyleContext(MOZ_GTK_TEXT_VIEW, direction, state_flags);
gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height);
- ReleaseStyleContext(style);
// There is a separate "text" window, which usually provides the
// background behind the text. However, this is transparent in Ambiance
// for GTK 3.20, in which case the MOZ_GTK_TEXT_VIEW background is
// visible.
- style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW_TEXT, direction, state_flags);
+ style = GetStyleContext(MOZ_GTK_TEXT_VIEW_TEXT, direction, state_flags);
gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -978,23 +950,20 @@ moz_gtk_treeview_paint(cairo_t *cr, GdkRectangle* rect,
* area will be painted differently with other states */
state_flags = state->disabled ? GTK_STATE_FLAG_INSENSITIVE : GTK_STATE_FLAG_NORMAL;
- style = ClaimStyleContext(MOZ_GTK_SCROLLED_WINDOW, direction);
+ style = GetStyleContext(MOZ_GTK_SCROLLED_WINDOW, direction);
gtk_style_context_get_border(style, state_flags, &border);
xthickness = border.left;
ythickness = border.top;
- ReleaseStyleContext(style);
- style_tree = ClaimStyleContext(MOZ_GTK_TREEVIEW_VIEW, direction);
+ style_tree = GetStyleContext(MOZ_GTK_TREEVIEW_VIEW, direction);
gtk_render_background(style_tree, cr,
rect->x + xthickness, rect->y + ythickness,
rect->width - 2 * xthickness,
rect->height - 2 * ythickness);
- ReleaseStyleContext(style_tree);
- style = ClaimStyleContext(MOZ_GTK_SCROLLED_WINDOW, direction);
+ style = GetStyleContext(MOZ_GTK_SCROLLED_WINDOW, direction);
gtk_render_frame(style, cr,
rect->x, rect->y, rect->width, rect->height);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1022,8 +991,8 @@ moz_gtk_tree_header_sort_arrow_paint(cairo_t *cr, GdkRectangle* rect,
arrow_rect.height = 11;
arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2;
arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2;
- style = ClaimStyleContext(MOZ_GTK_TREE_HEADER_SORTARROW, direction,
- GetStateFlagsFromGtkWidgetState(state));
+ style = GetStyleContext(MOZ_GTK_TREE_HEADER_SORTARROW, direction,
+ GetStateFlagsFromGtkWidgetState(state));
switch (arrow_type) {
case GTK_ARROW_LEFT:
arrow_angle = ARROW_LEFT;
@@ -1042,7 +1011,6 @@ moz_gtk_tree_header_sort_arrow_paint(cairo_t *cr, GdkRectangle* rect,
gtk_render_arrow(style, cr, arrow_angle,
arrow_rect.x, arrow_rect.y,
arrow_rect.width);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1067,15 +1035,14 @@ moz_gtk_treeview_expander_paint(cairo_t *cr, GdkRectangle* rect,
else
state_flags = static_cast<GtkStateFlags>(state_flags&~(checkbox_check_state));
- GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_TREEVIEW_EXPANDER,
- direction, state_flags);
+ GtkStyleContext *style = GetStyleContext(MOZ_GTK_TREEVIEW_EXPANDER,
+ direction, state_flags);
gtk_render_expander(style, cr,
rect->x,
rect->y,
rect->width,
rect->height);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1112,11 +1079,10 @@ moz_gtk_combo_box_paint(cairo_t *cr, GdkRectangle* rect,
calculate_arrow_rect(comboBoxArrow,
&arrow_rect, &real_arrow_rect, direction);
- style = ClaimStyleContext(MOZ_GTK_COMBOBOX_ARROW);
+ style = GetStyleContext(MOZ_GTK_COMBOBOX_ARROW);
gtk_render_arrow(style, cr, ARROW_DOWN,
real_arrow_rect.x, real_arrow_rect.y,
real_arrow_rect.width);
- ReleaseStyleContext(style);
/* If there is no separator in the theme, there's nothing left to do. */
GtkWidget* widget = GetWidget(MOZ_GTK_COMBOBOX_SEPARATOR);
@@ -1187,11 +1153,10 @@ moz_gtk_arrow_paint(cairo_t *cr, GdkRectangle* rect,
calculate_arrow_rect(GetWidget(MOZ_GTK_BUTTON_ARROW), rect, &arrow_rect,
direction);
GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_BUTTON_ARROW,
- direction, state_flags);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_BUTTON_ARROW,
+ direction, state_flags);
gtk_render_arrow(style, cr, arrow_angle,
arrow_rect.x, arrow_rect.y, arrow_rect.width);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1224,11 +1189,10 @@ moz_gtk_combo_box_entry_button_paint(cairo_t *cr, GdkRectangle* rect,
calculate_arrow_rect(GetWidget(MOZ_GTK_COMBOBOX_ENTRY_ARROW),
&arrow_rect, &real_arrow_rect, direction);
- style = ClaimStyleContext(MOZ_GTK_COMBOBOX_ENTRY_ARROW);
+ style = GetStyleContext(MOZ_GTK_COMBOBOX_ENTRY_ARROW);
gtk_render_arrow(style, cr, ARROW_DOWN,
real_arrow_rect.x, real_arrow_rect.y,
real_arrow_rect.width);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1239,15 +1203,14 @@ moz_gtk_container_paint(cairo_t *cr, GdkRectangle* rect,
GtkTextDirection direction)
{
GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
- GtkStyleContext* style = ClaimStyleContext(widget_type, direction,
- state_flags);
+ GtkStyleContext* style = GetStyleContext(widget_type, direction,
+ state_flags);
/* this is for drawing a prelight box */
if (state_flags & GTK_STATE_FLAG_PRELIGHT) {
gtk_render_background(style, cr,
rect->x, rect->y, rect->width, rect->height);
}
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1260,15 +1223,13 @@ moz_gtk_toggle_label_paint(cairo_t *cr, GdkRectangle* rect,
return MOZ_GTK_SUCCESS;
GtkStyleContext *style =
- ClaimStyleContext(isradio ? MOZ_GTK_RADIOBUTTON_CONTAINER :
- MOZ_GTK_CHECKBUTTON_CONTAINER,
- direction,
- GetStateFlagsFromGtkWidgetState(state));
+ GetStyleContext(isradio ? MOZ_GTK_RADIOBUTTON_CONTAINER :
+ MOZ_GTK_CHECKBUTTON_CONTAINER,
+ direction,
+ GetStateFlagsFromGtkWidgetState(state));
gtk_render_focus(style, cr,
rect->x, rect->y, rect->width, rect->height);
- ReleaseStyleContext(style);
-
return MOZ_GTK_SUCCESS;
}
@@ -1276,10 +1237,9 @@ static gint
moz_gtk_toolbar_paint(cairo_t *cr, GdkRectangle* rect,
GtkTextDirection direction)
{
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_TOOLBAR, direction);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_TOOLBAR, 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);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1297,14 +1257,13 @@ moz_gtk_toolbar_separator_paint(cairo_t *cr, GdkRectangle* rect,
const double start_fraction = 0.2;
const double end_fraction = 0.8;
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_TOOLBAR);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_TOOLBAR);
gtk_style_context_get_style(style,
"wide-separators", &wide_separators,
"separator-width", &separator_width,
NULL);
- ReleaseStyleContext(style);
- style = ClaimStyleContext(MOZ_GTK_TOOLBAR_SEPARATOR, direction);
+ style = GetStyleContext(MOZ_GTK_TOOLBAR_SEPARATOR, direction);
if (wide_separators) {
if (separator_width > rect->width)
separator_width = rect->width;
@@ -1328,7 +1287,6 @@ moz_gtk_toolbar_separator_paint(cairo_t *cr, GdkRectangle* rect,
rect->x + (rect->width - paint_width) / 2,
rect->y + rect->height * end_fraction);
}
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1345,11 +1303,10 @@ moz_gtk_tooltip_paint(cairo_t *cr, const GdkRectangle* aRect,
// We have to draw all elements with appropriate offset and right dimensions.
// Tooltip drawing
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_TOOLTIP, direction);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_TOOLTIP, direction);
GdkRectangle rect = *aRect;
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);
- ReleaseStyleContext(style);
// Horizontal Box drawing
//
@@ -1359,7 +1316,7 @@ moz_gtk_tooltip_paint(cairo_t *cr, const GdkRectangle* aRect,
// 6px margin.
// For drawing Horizontal Box we have to inset drawing area by that 6px
// plus its CSS margin.
- GtkStyleContext* boxStyle = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX, direction);
+ GtkStyleContext* boxStyle = GetStyleContext(MOZ_GTK_TOOLTIP_BOX, direction);
rect.x += 6;
rect.y += 6;
@@ -1372,12 +1329,10 @@ moz_gtk_tooltip_paint(cairo_t *cr, const GdkRectangle* aRect,
// Label drawing
InsetByBorderPadding(&rect, boxStyle);
- ReleaseStyleContext(boxStyle);
GtkStyleContext* labelStyle =
- ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL, direction);
+ GetStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL, direction);
moz_gtk_draw_styled_frame(labelStyle, cr, &rect, false);
- ReleaseStyleContext(labelStyle);
return MOZ_GTK_SUCCESS;
}
@@ -1388,8 +1343,8 @@ moz_gtk_resizer_paint(cairo_t *cr, GdkRectangle* rect,
GtkTextDirection direction)
{
GtkStyleContext* style =
- ClaimStyleContext(MOZ_GTK_RESIZER, GTK_TEXT_DIR_LTR,
- GetStateFlagsFromGtkWidgetState(state));
+ GetStyleContext(MOZ_GTK_RESIZER, GTK_TEXT_DIR_LTR,
+ GetStateFlagsFromGtkWidgetState(state));
// Workaround unico not respecting the text direction for resizers.
// See bug 1174248.
@@ -1403,7 +1358,6 @@ moz_gtk_resizer_paint(cairo_t *cr, GdkRectangle* rect,
gtk_render_handle(style, cr, rect->x, rect->y, rect->width, rect->height);
cairo_restore(cr);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1412,9 +1366,8 @@ static gint
moz_gtk_frame_paint(cairo_t *cr, GdkRectangle* rect,
GtkTextDirection direction)
{
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_FRAME, direction);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_FRAME, direction);
gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1422,11 +1375,10 @@ static gint
moz_gtk_progressbar_paint(cairo_t *cr, GdkRectangle* rect,
GtkTextDirection direction)
{
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_PROGRESS_TROUGH,
- direction);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_PROGRESS_TROUGH,
+ 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);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1437,7 +1389,7 @@ moz_gtk_progress_chunk_paint(cairo_t *cr, GdkRectangle* rect,
WidgetNodeType widget)
{
GtkStyleContext* style =
- ClaimStyleContext(MOZ_GTK_PROGRESS_CHUNK, direction);
+ GetStyleContext(MOZ_GTK_PROGRESS_CHUNK, direction);
if (widget == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE ||
widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) {
@@ -1481,7 +1433,6 @@ moz_gtk_progress_chunk_paint(cairo_t *cr, GdkRectangle* rect,
} else {
gtk_render_activity(style, cr, rect->x, rect->y, rect->width, rect->height);
}
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1503,9 +1454,8 @@ moz_gtk_get_tab_thickness(GtkStyleContext *style)
gint
moz_gtk_get_tab_thickness(WidgetNodeType aNodeType)
{
- GtkStyleContext *style = ClaimStyleContext(aNodeType);
+ GtkStyleContext *style = GetStyleContext(aNodeType);
int thickness = moz_gtk_get_tab_thickness(style);
- ReleaseStyleContext(style);
return thickness;
}
@@ -1528,8 +1478,8 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectangle* rect,
int initial_gap = 0;
bool isBottomTab = (widget == MOZ_GTK_TAB_BOTTOM);
- style = ClaimStyleContext(widget, direction,
- GetStateFlagsFromGtkTabFlags(flags));
+ style = GetStyleContext(widget, direction,
+ GetStateFlagsFromGtkTabFlags(flags));
tabRect = *rect;
if (flags & MOZ_GTK_TAB_FIRST) {
@@ -1606,7 +1556,7 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectangle* rect,
}
GtkStyleContext* panelStyle =
- ClaimStyleContext(MOZ_GTK_TABPANELS, direction);
+ GetStyleContext(MOZ_GTK_TABPANELS, direction);
if (isBottomTab) {
/* Draw the tab on bottom */
@@ -1681,7 +1631,6 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectangle* rect,
gtk_render_focus(style, cr,
focusRect.x, focusRect.y, focusRect.width, focusRect.height);
}
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1691,7 +1640,7 @@ static gint
moz_gtk_tabpanels_paint(cairo_t *cr, GdkRectangle* rect,
GtkTextDirection direction)
{
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_TABPANELS, direction);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_TABPANELS, direction);
gtk_render_background(style, cr, rect->x, rect->y,
rect->width, rect->height);
/*
@@ -1728,7 +1677,6 @@ moz_gtk_tabpanels_paint(cairo_t *cr, GdkRectangle* rect,
GTK_POS_TOP, 0, 1);
cairo_restore(cr);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1763,11 +1711,10 @@ moz_gtk_tab_scroll_arrow_paint(cairo_t *cr, GdkRectangle* rect,
break;
}
if (arrow_type != GTK_ARROW_NONE) {
- style = ClaimStyleContext(MOZ_GTK_TAB_SCROLLARROW, direction,
- GetStateFlagsFromGtkWidgetState(state));
+ style = GetStyleContext(MOZ_GTK_TAB_SCROLLARROW, direction,
+ GetStateFlagsFromGtkWidgetState(state));
gtk_render_arrow(style, cr, arrow_angle,
x, y, arrow_size);
- ReleaseStyleContext(style);
}
return MOZ_GTK_SUCCESS;
}
@@ -1833,7 +1780,7 @@ moz_gtk_menu_separator_paint(cairo_t *cr, GdkRectangle* rect,
gint x, y, w;
GtkBorder padding;
- style = ClaimStyleContext(MOZ_GTK_MENUSEPARATOR, direction);
+ style = GetStyleContext(MOZ_GTK_MENUSEPARATOR, direction);
gtk_style_context_get_padding(style, GTK_STATE_FLAG_NORMAL, &padding);
x = rect->x;
@@ -1863,7 +1810,6 @@ moz_gtk_menu_separator_paint(cairo_t *cr, GdkRectangle* rect,
}
gtk_style_context_restore(style);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1883,7 +1829,7 @@ moz_gtk_menu_item_paint(WidgetNodeType widget, cairo_t *cr, GdkRectangle* rect,
!(state_flags & GTK_STATE_FLAG_PRELIGHT)))
return MOZ_GTK_SUCCESS;
- GtkStyleContext* style = ClaimStyleContext(widget, direction, state_flags);
+ GtkStyleContext* style = GetStyleContext(widget, direction, state_flags);
if (minorVersion < 6) {
// GTK+ 3.4 saves the style context and adds the menubar class to
@@ -1906,7 +1852,6 @@ moz_gtk_menu_item_paint(WidgetNodeType widget, cairo_t *cr, GdkRectangle* rect,
if (minorVersion < 6) {
gtk_style_context_restore(style);
}
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1917,12 +1862,11 @@ moz_gtk_menu_arrow_paint(cairo_t *cr, GdkRectangle* rect,
GtkTextDirection direction)
{
GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_MENUITEM,
- direction, state_flags);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_MENUITEM,
+ direction, state_flags);
gtk_render_arrow(style, cr,
(direction == GTK_TEXT_DIR_LTR) ? ARROW_RIGHT : ARROW_LEFT,
rect->x, rect->y, rect->width);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1947,7 +1891,7 @@ moz_gtk_check_menu_item_paint(WidgetNodeType widgetType,
bool pre_3_20 = gtk_get_minor_version() < 20;
gint offset;
- style = ClaimStyleContext(widgetType, direction);
+ style = GetStyleContext(widgetType, direction);
gtk_style_context_get_style(style,
"indicator-size", &indicator_size,
"horizontal-padding", &horizontal_padding,
@@ -1962,12 +1906,11 @@ moz_gtk_check_menu_item_paint(WidgetNodeType widgetType,
InsetByBorderPadding(&r, style);
offset = r.x;
}
- ReleaseStyleContext(style);
bool isRadio = (widgetType == MOZ_GTK_RADIOMENUITEM);
WidgetNodeType indicatorType = isRadio ? MOZ_GTK_RADIOMENUITEM_INDICATOR
: MOZ_GTK_CHECKMENUITEM_INDICATOR;
- style = ClaimStyleContext(indicatorType, direction, state_flags);
+ style = GetStyleContext(indicatorType, direction, state_flags);
if (direction == GTK_TEXT_DIR_RTL) {
x = rect->width - indicator_size - offset;
@@ -1987,7 +1930,6 @@ moz_gtk_check_menu_item_paint(WidgetNodeType widgetType,
} else {
gtk_render_check(style, cr, x, y, indicator_size, indicator_size);
}
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -1997,12 +1939,11 @@ moz_gtk_info_bar_paint(cairo_t *cr, GdkRectangle* rect,
GtkWidgetState* state)
{
GtkStyleContext *style =
- ClaimStyleContext(MOZ_GTK_INFO_BAR, GTK_TEXT_DIR_LTR,
- GetStateFlagsFromGtkWidgetState(state));
+ GetStyleContext(MOZ_GTK_INFO_BAR, GTK_TEXT_DIR_LTR,
+ GetStateFlagsFromGtkWidgetState(state));
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);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -2087,7 +2028,7 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
case MOZ_GTK_BUTTON:
case MOZ_GTK_TOOLBAR_BUTTON:
{
- style = ClaimStyleContext(MOZ_GTK_BUTTON);
+ style = GetStyleContext(MOZ_GTK_BUTTON);
*left = *top = *right = *bottom =
gtk_container_get_border_width(GTK_CONTAINER(GetWidget(MOZ_GTK_BUTTON)));
@@ -2104,12 +2045,11 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
moz_gtk_add_style_border(style, left, top, right, bottom);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
case MOZ_GTK_ENTRY:
{
- style = ClaimStyleContext(MOZ_GTK_ENTRY);
+ style = GetStyleContext(MOZ_GTK_ENTRY);
// XXX: Subtract 1 pixel from the padding to account for the default
// padding in forms.css. See bug 1187385.
@@ -2117,15 +2057,13 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
moz_gtk_add_style_padding(style, left, top, right, bottom);
moz_gtk_add_style_border(style, left, top, right, bottom);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
case MOZ_GTK_TEXT_VIEW:
case MOZ_GTK_TREEVIEW:
{
- style = ClaimStyleContext(MOZ_GTK_SCROLLED_WINDOW);
+ style = GetStyleContext(MOZ_GTK_SCROLLED_WINDOW);
moz_gtk_add_style_border(style, left, top, right, bottom);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
case MOZ_GTK_TREE_HEADER_CELL:
@@ -2139,10 +2077,9 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
gtk_container_get_border_width(GTK_CONTAINER(
GetWidget(MOZ_GTK_TREE_HEADER_CELL)));
- style = ClaimStyleContext(MOZ_GTK_TREE_HEADER_CELL);
+ style = GetStyleContext(MOZ_GTK_TREE_HEADER_CELL);
moz_gtk_add_style_border(style, left, top, right, bottom);
moz_gtk_add_style_padding(style, left, top, right, bottom);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
case MOZ_GTK_TREE_HEADER_SORTARROW:
@@ -2167,10 +2104,9 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
*left = *top = *right = *bottom =
gtk_container_get_border_width(GTK_CONTAINER(
GetWidget(MOZ_GTK_COMBOBOX_BUTTON)));
- style = ClaimStyleContext(MOZ_GTK_COMBOBOX_BUTTON);
+ style = GetStyleContext(MOZ_GTK_COMBOBOX_BUTTON);
moz_gtk_add_style_padding(style, left, top, right, bottom);
moz_gtk_add_style_border(style, left, top, right, bottom);
- ReleaseStyleContext(style);
/* If there is no separator, don't try to count its width. */
separator_width = 0;
@@ -2241,7 +2177,7 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
// Bug 1274143 for MOZ_GTK_MENUBARITEM
WidgetNodeType type =
widget == MOZ_GTK_MENUBARITEM ? MOZ_GTK_MENUITEM : widget;
- style = ClaimStyleContext(type);
+ style = GetStyleContext(type);
if (gtk_get_minor_version() < 20) {
moz_gtk_add_style_padding(style, left, top, right, bottom);
@@ -2249,7 +2185,6 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
moz_gtk_add_margin_border_padding(style,
left, top, right, bottom);
}
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
case MOZ_GTK_INFO_BAR:
@@ -2265,15 +2200,13 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
// We also need to add margin/padding/borders from Tooltip content.
// Tooltip contains horizontal box, where icon and label is put.
// We ignore icon as long as we don't have support for it.
- GtkStyleContext* boxStyle = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX);
+ GtkStyleContext* boxStyle = GetStyleContext(MOZ_GTK_TOOLTIP_BOX);
moz_gtk_add_margin_border_padding(boxStyle,
left, top, right, bottom);
- ReleaseStyleContext(boxStyle);
- GtkStyleContext* labelStyle = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL);
+ GtkStyleContext* labelStyle = GetStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL);
moz_gtk_add_margin_border_padding(labelStyle,
left, top, right, bottom);
- ReleaseStyleContext(labelStyle);
return MOZ_GTK_SUCCESS;
}
@@ -2324,7 +2257,7 @@ moz_gtk_get_tab_border(gint* left, gint* top, gint* right, gint* bottom,
GtkTextDirection direction, GtkTabFlags flags,
WidgetNodeType widget)
{
- GtkStyleContext* style = ClaimStyleContext(widget, direction,
+ GtkStyleContext* style = GetStyleContext(widget, direction,
GetStateFlagsFromGtkTabFlags(flags));
*left = *top = *right = *bottom = 0;
@@ -2354,15 +2287,13 @@ moz_gtk_get_tab_border(gint* left, gint* top, gint* right, gint* bottom,
*right += margin.right;
if (flags & MOZ_GTK_TAB_FIRST) {
- ReleaseStyleContext(style);
- style = ClaimStyleContext(MOZ_GTK_NOTEBOOK_HEADER, direction);
+ style = GetStyleContext(MOZ_GTK_NOTEBOOK_HEADER, direction);
gtk_style_context_get_margin(style, GTK_STATE_FLAG_NORMAL, &margin);
*left += margin.left;
*right += margin.right;
}
}
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -2389,11 +2320,10 @@ moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height)
{
gint arrow_size;
- GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_TABPANELS);
+ GtkStyleContext *style = GetStyleContext(MOZ_GTK_TABPANELS);
gtk_style_context_get_style(style,
"scroll-arrow-hlength", &arrow_size,
NULL);
- ReleaseStyleContext(style);
*height = *width = arrow_size;
@@ -2426,7 +2356,7 @@ moz_gtk_get_toolbar_separator_width(gint* size)
gint separator_width;
GtkBorder border;
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_TOOLBAR);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_TOOLBAR);
gtk_style_context_get_style(style,
"space-size", size,
"wide-separators", &wide_separators,
@@ -2435,27 +2365,24 @@ moz_gtk_get_toolbar_separator_width(gint* size)
/* Just in case... */
gtk_style_context_get_border(style, GTK_STATE_FLAG_NORMAL, &border);
*size = MAX(*size, (wide_separators ? separator_width : border.left));
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
gint
moz_gtk_get_expander_size(gint* size)
{
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_EXPANDER);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_EXPANDER);
gtk_style_context_get_style(style,
"expander-size", size,
NULL);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
gint
moz_gtk_get_treeview_expander_size(gint* size)
{
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_TREEVIEW);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_TREEVIEW);
gtk_style_context_get_style(style, "expander-size", size, NULL);
- ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@@ -2466,7 +2393,7 @@ moz_gtk_get_menu_separator_height(gint *size)
gboolean wide_separators;
gint separator_height;
GtkBorder padding;
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_MENUSEPARATOR);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_MENUSEPARATOR);
gtk_style_context_get_padding(style, GTK_STATE_FLAG_NORMAL, &padding);
gtk_style_context_save(style);
@@ -2478,7 +2405,6 @@ moz_gtk_get_menu_separator_height(gint *size)
NULL);
gtk_style_context_restore(style);
- ReleaseStyleContext(style);
*size = padding.top + padding.bottom;
*size += (wide_separators) ? separator_height : 1;
@@ -2489,7 +2415,7 @@ moz_gtk_get_menu_separator_height(gint *size)
void
moz_gtk_get_entry_min_height(gint* height)
{
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_ENTRY);
+ GtkStyleContext* style = GetStyleContext(MOZ_GTK_ENTRY);
if (!gtk_check_version(3, 20, 0)) {
gtk_style_context_get(style, gtk_style_context_get_state(style),
"min-height", height,
@@ -2504,7 +2430,6 @@ moz_gtk_get_entry_min_height(gint* height)
gtk_style_context_get_padding(style, GTK_STATE_FLAG_NORMAL, &padding);
*height += (border.top + border.bottom + padding.top + padding.bottom);
- ReleaseStyleContext(style);
}
void
@@ -2519,7 +2444,7 @@ moz_gtk_get_scale_metrics(GtkOrientation orient, gint* scale_width,
gint thumb_length, thumb_height, trough_border;
moz_gtk_get_scalethumb_metrics(orient, &thumb_length, &thumb_height);
- GtkStyleContext* style = ClaimStyleContext(widget);
+ GtkStyleContext* style = GetStyleContext(widget);
gtk_style_context_get_style(style, "trough-border", &trough_border, NULL);
if (orient == GTK_ORIENTATION_HORIZONTAL) {
@@ -2529,7 +2454,6 @@ moz_gtk_get_scale_metrics(GtkOrientation orient, gint* scale_width,
*scale_width = thumb_height + trough_border * 2;
*scale_height = thumb_length + trough_border * 2;
}
- ReleaseStyleContext(style);
} else {
WidgetNodeType widget = (orient == GTK_ORIENTATION_HORIZONTAL) ?
MOZ_GTK_SCALE_TROUGH_HORIZONTAL :
@@ -2546,17 +2470,16 @@ moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint*
WidgetNodeType widget = (orient == GTK_ORIENTATION_HORIZONTAL) ?
MOZ_GTK_SCALE_HORIZONTAL:
MOZ_GTK_SCALE_VERTICAL;
- GtkStyleContext* style = ClaimStyleContext(widget);
+ GtkStyleContext* style = GetStyleContext(widget);
gtk_style_context_get_style(style,
"slider_length", thumb_length,
"slider_width", thumb_height,
NULL);
- ReleaseStyleContext(style);
} else {
WidgetNodeType widget = (orient == GTK_ORIENTATION_HORIZONTAL) ?
MOZ_GTK_SCALE_THUMB_HORIZONTAL:
MOZ_GTK_SCALE_THUMB_VERTICAL;
- GtkStyleContext* style = ClaimStyleContext(widget);
+ GtkStyleContext* style = GetStyleContext(widget);
gint min_width, min_height;
GtkStateFlags state = gtk_style_context_get_state(style);
@@ -2578,8 +2501,6 @@ moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint*
*thumb_length = min_width;
*thumb_height = min_height;
-
- ReleaseStyleContext(style);
}
return MOZ_GTK_SUCCESS;
@@ -2606,7 +2527,7 @@ GetScrollbarMetrics(GtkOrientation aOrientation)
MOZ_GTK_SCROLLBAR_HORIZONTAL : MOZ_GTK_SCROLLBAR_VERTICAL;
gboolean backward, forward, secondary_backward, secondary_forward;
- GtkStyleContext* style = ClaimStyleContext(scrollbar);
+ GtkStyleContext* style = GetStyleContext(scrollbar);
gtk_style_context_get_style(style,
"has-backward-stepper", &backward,
"has-forward-stepper", &forward,
@@ -2626,7 +2547,6 @@ GetScrollbarMetrics(GtkOrientation aOrientation)
"stepper-size", &stepper_size,
"min-slider-length", &min_slider_size,
nullptr);
- ReleaseStyleContext(style);
metrics->size.thumb =
SizeFromLengthAndBreadth(aOrientation, min_slider_size, slider_width);
@@ -2663,7 +2583,6 @@ GetScrollbarMetrics(GtkOrientation aOrientation)
// GTK version > 3.20
// scrollbar
metrics->border.scrollbar = GetMarginBorderPadding(style);
- ReleaseStyleContext(style);
WidgetNodeType contents, track, thumb;
if (aOrientation == GTK_ORIENTATION_HORIZONTAL) {
@@ -2678,10 +2597,9 @@ GetScrollbarMetrics(GtkOrientation aOrientation)
// thumb
metrics->size.thumb = GetMinMarginBox(thumb);
// track
- style = ClaimStyleContext(track);
+ style = GetStyleContext(track);
metrics->border.track = GetMarginBorderPadding(style);
MozGtkSize trackMinSize = GetMinContentBox(style) + metrics->border.track;
- ReleaseStyleContext(style);
MozGtkSize trackSizeForThumb = metrics->size.thumb + metrics->border.track;
// button
if (hasButtons) {
@@ -2719,9 +2637,8 @@ GetScrollbarMetrics(GtkOrientation aOrientation)
}
}
- style = ClaimStyleContext(contents);
+ style = GetStyleContext(contents);
GtkBorder contentsBorder = GetMarginBorderPadding(style);
- ReleaseStyleContext(style);
metrics->size.scrollbar =
trackSizeForThumb + contentsBorder + metrics->border.scrollbar;
@@ -2771,10 +2688,9 @@ moz_gtk_widget_paint(WidgetNodeType widget, cairo_t *cr,
case MOZ_GTK_SCROLLBAR_VERTICAL:
if (flags & MOZ_GTK_TRACK_OPAQUE) {
GtkStyleContext* style =
- ClaimStyleContext(MOZ_GTK_WINDOW, direction);
+ GetStyleContext(MOZ_GTK_WINDOW, direction);
gtk_render_background(style, cr,
rect->x, rect->y, rect->width, rect->height);
- ReleaseStyleContext(style);
}
if (gtk_check_version(3,20,0) == nullptr) {
return moz_gtk_scrollbar_paint(widget, cr, rect, state, direction);
@@ -2818,10 +2734,10 @@ moz_gtk_widget_paint(WidgetNodeType widget, cairo_t *cr,
break;
case MOZ_GTK_SPINBUTTON_ENTRY:
{
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_SPINBUTTON_ENTRY,
- direction, GetStateFlagsFromGtkWidgetState(state));
+ GtkStyleContext* style =
+ GetStyleContext(MOZ_GTK_SPINBUTTON_ENTRY, direction,
+ GetStateFlagsFromGtkWidgetState(state));
gint ret = moz_gtk_entry_paint(cr, rect, state, style);
- ReleaseStyleContext(style);
return ret;
}
break;
@@ -2849,10 +2765,10 @@ moz_gtk_widget_paint(WidgetNodeType widget, cairo_t *cr,
break;
case MOZ_GTK_ENTRY:
{
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_ENTRY,
- direction, GetStateFlagsFromGtkWidgetState(state));
+ GtkStyleContext* style =
+ GetStyleContext(MOZ_GTK_ENTRY, direction,
+ GetStateFlagsFromGtkWidgetState(state));
gint ret = moz_gtk_entry_paint(cr, rect, state, style);
- ReleaseStyleContext(style);
return ret;
}
case MOZ_GTK_TEXT_VIEW:
@@ -2867,10 +2783,10 @@ moz_gtk_widget_paint(WidgetNodeType widget, cairo_t *cr,
break;
case MOZ_GTK_DROPDOWN_ENTRY:
{
- GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA,
- direction, GetStateFlagsFromGtkWidgetState(state));
+ GtkStyleContext* style =
+ GetStyleContext(MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA, direction,
+ GetStateFlagsFromGtkWidgetState(state));
gint ret = moz_gtk_entry_paint(cr, rect, state, style);
- ReleaseStyleContext(style);
return ret;
}
break;
diff --git widget/gtk/nsLookAndFeel.cpp widget/gtk/nsLookAndFeel.cpp
index f4c35d82200a..9a2684412ee8 100644
--- widget/gtk/nsLookAndFeel.cpp
+++ widget/gtk/nsLookAndFeel.cpp
@@ -300,21 +300,19 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor)
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
case eColorID_activeborder: {
// active window border
- GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_WINDOW);
+ GtkStyleContext *style = GetStyleContext(MOZ_GTK_WINDOW);
gtk_style_context_get_border_color(style,
GTK_STATE_FLAG_NORMAL, &gdk_color);
aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
- ReleaseStyleContext(style);
break;
}
case eColorID_inactiveborder: {
// inactive window border
- GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_WINDOW);
+ GtkStyleContext *style = GetStyleContext(MOZ_GTK_WINDOW);
gtk_style_context_get_border_color(style,
GTK_STATE_FLAG_INSENSITIVE,
&gdk_color);
aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
- ReleaseStyleContext(style);
break;
}
case eColorID_graytext: // disabled text in windows, menus, etc.
@@ -323,12 +321,11 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor)
break;
case eColorID_inactivecaption: {
// inactive window caption
- GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_WINDOW);
+ GtkStyleContext *style = GetStyleContext(MOZ_GTK_WINDOW);
gtk_style_context_get_background_color(style,
GTK_STATE_FLAG_INSENSITIVE,
&gdk_color);
aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
- ReleaseStyleContext(style);
break;
}
case eColorID_infobackground:
@@ -394,20 +391,18 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor)
break;
case eColorID__moz_buttondefault: {
// default button border color
- GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_BUTTON);
+ GtkStyleContext *style = GetStyleContext(MOZ_GTK_BUTTON);
gtk_style_context_get_border_color(style,
GTK_STATE_FLAG_NORMAL, &gdk_color);
aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
- ReleaseStyleContext(style);
break;
}
case eColorID__moz_buttonhoverface: {
- GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_BUTTON);
+ GtkStyleContext *style = GetStyleContext(MOZ_GTK_BUTTON);
gtk_style_context_get_background_color(style,
GTK_STATE_FLAG_PRELIGHT,
&gdk_color);
aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
- ReleaseStyleContext(style);
break;
}
case eColorID__moz_buttonhovertext:
@@ -858,38 +853,33 @@ nsLookAndFeel::EnsureInit()
g_object_ref_sink(labelWidget);
// Scrollbar colors
- style = ClaimStyleContext(MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL);
+ style = GetStyleContext(MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL);
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
sMozScrollbar = GDK_RGBA_TO_NS_RGBA(color);
- ReleaseStyleContext(style);
// Window colors
- style = ClaimStyleContext(MOZ_GTK_WINDOW);
+ style = GetStyleContext(MOZ_GTK_WINDOW);
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
sMozWindowBackground = GDK_RGBA_TO_NS_RGBA(color);
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
sMozWindowText = GDK_RGBA_TO_NS_RGBA(color);
- ReleaseStyleContext(style);
- style = ClaimStyleContext(MOZ_GTK_WINDOW_CONTAINER);
+ style = GetStyleContext(MOZ_GTK_WINDOW_CONTAINER);
{
GtkStyleContext* labelStyle = CreateStyleForWidget(labelWidget, style);
GetSystemFontInfo(labelStyle, &mDefaultFontName, &mDefaultFontStyle);
g_object_unref(labelStyle);
}
- ReleaseStyleContext(style);
// tooltip foreground and background
- style = ClaimStyleContext(MOZ_GTK_TOOLTIP);
+ style = GetStyleContext(MOZ_GTK_TOOLTIP);
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
sInfoBackground = GDK_RGBA_TO_NS_RGBA(color);
- ReleaseStyleContext(style);
- style = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL);
+ style = GetStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL);
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
sInfoText = GDK_RGBA_TO_NS_RGBA(color);
- ReleaseStyleContext(style);
- style = ClaimStyleContext(MOZ_GTK_MENUITEM);
+ style = GetStyleContext(MOZ_GTK_MENUITEM);
{
GtkStyleContext* accelStyle =
CreateStyleForWidget(gtk_accel_label_new("M"), style);
@@ -902,19 +892,16 @@ nsLookAndFeel::EnsureInit()
sMenuTextInactive = GDK_RGBA_TO_NS_RGBA(color);
g_object_unref(accelStyle);
}
- ReleaseStyleContext(style);
- style = ClaimStyleContext(MOZ_GTK_MENUPOPUP);
+ style = GetStyleContext(MOZ_GTK_MENUPOPUP);
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
sMenuBackground = GDK_RGBA_TO_NS_RGBA(color);
- ReleaseStyleContext(style);
- style = ClaimStyleContext(MOZ_GTK_MENUITEM);
+ style = GetStyleContext(MOZ_GTK_MENUITEM);
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
sMenuHover = GDK_RGBA_TO_NS_RGBA(color);
gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
sMenuHoverText = GDK_RGBA_TO_NS_RGBA(color);
- ReleaseStyleContext(style);
GtkWidget *parent = gtk_fixed_new();
GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);
@@ -937,12 +924,11 @@ nsLookAndFeel::EnsureInit()
GdkRGBA bgColor;
// If the text window background is translucent, then the background of
// the textview root node is visible.
- style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW);
+ style = GetStyleContext(MOZ_GTK_TEXT_VIEW);
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL,
&bgColor);
- ReleaseStyleContext(style);
- style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW_TEXT);
+ style = GetStyleContext(MOZ_GTK_TEXT_VIEW_TEXT);
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL,
&color);
ApplyColorOver(color, &bgColor);
@@ -959,10 +945,9 @@ nsLookAndFeel::EnsureInit()
static_cast<GtkStateFlags>(GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_SELECTED),
&color);
sTextSelectedText = GDK_RGBA_TO_NS_RGBA(color);
- ReleaseStyleContext(style);
// Button text color
- style = ClaimStyleContext(MOZ_GTK_BUTTON);
+ style = GetStyleContext(MOZ_GTK_BUTTON);
{
GtkStyleContext* labelStyle = CreateStyleForWidget(labelWidget, style);
@@ -974,21 +959,18 @@ nsLookAndFeel::EnsureInit()
sButtonHoverText = GDK_RGBA_TO_NS_RGBA(color);
g_object_unref(labelStyle);
}
- ReleaseStyleContext(style);
// Combobox text color
- style = ClaimStyleContext(MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA);
+ style = GetStyleContext(MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA);
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
sComboBoxText = GDK_RGBA_TO_NS_RGBA(color);
- ReleaseStyleContext(style);
// Menubar text and hover text colors
- style = ClaimStyleContext(MOZ_GTK_MENUBARITEM);
+ style = GetStyleContext(MOZ_GTK_MENUBARITEM);
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
sMenuBarText = GDK_RGBA_TO_NS_RGBA(color);
gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
sMenuBarHoverText = GDK_RGBA_TO_NS_RGBA(color);
- ReleaseStyleContext(style);
// GTK's guide to fancy odd row background colors:
// 1) Check if a theme explicitly defines an odd row color
@@ -996,7 +978,7 @@ nsLookAndFeel::EnsureInit()
// slightly by a hardcoded value (gtkstyle.c)
// 3) If neither are defined, take the base background color and
// darken that by a hardcoded value
- style = ClaimStyleContext(MOZ_GTK_TREEVIEW);
+ style = GetStyleContext(MOZ_GTK_TREEVIEW);
// Get odd row background color
gtk_style_context_save(style);
@@ -1004,20 +986,17 @@ nsLookAndFeel::EnsureInit()
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
sOddCellBackground = GDK_RGBA_TO_NS_RGBA(color);
gtk_style_context_restore(style);
- ReleaseStyleContext(style);
// GtkFrame has a "border" subnode on which Adwaita draws the border.
// Some themes do not draw on this node but draw a border on the widget
// root node, so check the root node if no border is found on the border
// node.
- style = ClaimStyleContext(MOZ_GTK_FRAME_BORDER);
+ style = GetStyleContext(MOZ_GTK_FRAME_BORDER);
bool themeUsesColors =
GetBorderColors(style, &sFrameOuterLightBorder, &sFrameInnerDarkBorder);
- ReleaseStyleContext(style);
if (!themeUsesColors) {
- style = ClaimStyleContext(MOZ_GTK_FRAME);
+ style = GetStyleContext(MOZ_GTK_FRAME);
GetBorderColors(style, &sFrameOuterLightBorder, &sFrameInnerDarkBorder);
- ReleaseStyleContext(style);
}
// GtkInfoBar