Skip to content

Commit

Permalink
Merge r192723 - [GTK] Warning spam from GtkStyleContext
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=151520

Reviewed by Carlos Garcia Campos.

Audit every use of gtk_style_context_get_* to fix compatibility with GTK+ 3.19. Some of
these were already fine and are only changed for clarity.

Company:  gtk_style_context_get() (and _get_padding/border/color()) should only ever be
          called with the same state as gtk_style_context_get_state()
Company:  usually that's a simple replacing of the old state (like in the trace you posted)
Company:  sometimes it requires calling gtk_style_context_set_sate() with the right state
          first
Company:  and in very rare cases it needs a gtk_style_context_save() before the set_state(),
          too

* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::adjustRectAccordingToMargin):
* rendering/RenderThemeGtk.cpp:
(gtk_css_section_print):
(WebCore::getStyleContext):
(WebCore::RenderThemeGtk::initMediaColors):
(WebCore::renderButton):
(WebCore::getComboBoxMetrics):
(WebCore::RenderThemeGtk::paintMenuList):
(WebCore::RenderThemeGtk::paintTextField):
(WebCore::RenderThemeGtk::paintProgressBar):
(WebCore::spinButtonArrowSize):
(WebCore::RenderThemeGtk::adjustInnerSpinButtonStyle):
(WebCore::styleColor):
  • Loading branch information
mcatanzaro authored and carlosgcampos committed Feb 27, 2016
1 parent c75b11c commit 5cddb13
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 13 deletions.
33 changes: 33 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,36 @@
2015-11-21 Michael Catanzaro <mcatanzaro@igalia.com>

[GTK] Warning spam from GtkStyleContext
https://bugs.webkit.org/show_bug.cgi?id=151520

Reviewed by Carlos Garcia Campos.

Audit every use of gtk_style_context_get_* to fix compatibility with GTK+ 3.19. Some of
these were already fine and are only changed for clarity.

Company: gtk_style_context_get() (and _get_padding/border/color()) should only ever be
called with the same state as gtk_style_context_get_state()
Company: usually that's a simple replacing of the old state (like in the trace you posted)
Company: sometimes it requires calling gtk_style_context_set_sate() with the right state
first
Company: and in very rare cases it needs a gtk_style_context_save() before the set_state(),
too

* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::adjustRectAccordingToMargin):
* rendering/RenderThemeGtk.cpp:
(gtk_css_section_print):
(WebCore::getStyleContext):
(WebCore::RenderThemeGtk::initMediaColors):
(WebCore::renderButton):
(WebCore::getComboBoxMetrics):
(WebCore::RenderThemeGtk::paintMenuList):
(WebCore::RenderThemeGtk::paintTextField):
(WebCore::RenderThemeGtk::paintProgressBar):
(WebCore::spinButtonArrowSize):
(WebCore::RenderThemeGtk::adjustInnerSpinButtonStyle):
(WebCore::styleColor):

2015-10-07 ChangSeok Oh <changseok.oh@collabora.com>

[GTK] Progress bar is broken on recent GTK+
Expand Down
33 changes: 21 additions & 12 deletions Source/WebCore/platform/gtk/RenderThemeGtk3.cpp
Expand Up @@ -139,12 +139,19 @@ void RenderThemeGtk::initMediaColors()
GdkRGBA color;
GtkStyleContext* containerContext = getStyleContext(GTK_TYPE_CONTAINER);

gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_NORMAL, &color);
gtk_style_context_save(containerContext);

gtk_style_context_set_state(containerContext, GTK_STATE_FLAG_NORMAL);
gtk_style_context_get_background_color(containerContext, gtk_style_context_get_state(containerContext), &color);
m_panelColor = color;
gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_ACTIVE, &color);
gtk_style_context_set_state(containerContext, GTK_STATE_FLAG_ACTIVE);
gtk_style_context_get_background_color(containerContext, gtk_style_context_get_state(containerContext), &color);
m_sliderColor = color;
gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_SELECTED, &color);
gtk_style_context_set_state(containerContext, GTK_STATE_FLAG_SELECTED);
gtk_style_context_get_background_color(containerContext, gtk_style_context_get_state(containerContext), &color);
m_sliderThumbColor = color;

gtk_style_context_restore(containerContext);
}
#endif

Expand Down Expand Up @@ -346,7 +353,7 @@ static void renderButton(RenderTheme* theme, GtkStyleContext* context, RenderObj

if (interiorFocus) {
GtkBorder borderWidth;
gtk_style_context_get_border(context, static_cast<GtkStateFlags>(flags), &borderWidth);
gtk_style_context_get_border(context, gtk_style_context_get_state(context), &borderWidth);

buttonRect = IntRect(buttonRect.x() + borderWidth.left + focusPad, buttonRect.y() + borderWidth.top + focusPad,
buttonRect.width() - (2 * focusPad + borderWidth.left + borderWidth.right),
Expand Down Expand Up @@ -395,7 +402,8 @@ static void getComboBoxMetrics(RenderStyle* style, GtkBorder& border, int& focus
gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(gtkTextDirection(style->direction())));

gtk_style_context_get_border(context, static_cast<GtkStateFlags>(0), &border);
gtk_style_context_set_state(context, static_cast<GtkStateFlags>(0));
gtk_style_context_get_border(context, gtk_style_context_get_state(context), &border);

gboolean interiorFocus;
gint focusWidth, focusPad;
Expand Down Expand Up @@ -575,9 +583,9 @@ bool RenderThemeGtk::paintMenuList(RenderObject* renderObject, const PaintInfo&
separatorWidth, innerRect.height());
} else {
GtkBorder padding;
gtk_style_context_get_padding(separatorStyleContext, state, &padding);
gtk_style_context_get_padding(separatorStyleContext, gtk_style_context_get_state(separatorStyleContext), &padding);
GtkBorder border;
gtk_style_context_get_border(separatorStyleContext, state, &border);
gtk_style_context_get_border(separatorStyleContext, gtk_style_context_get_state(separatorStyleContext), &border);

if (direction == GTK_TEXT_DIR_LTR)
separatorPosition.move(-(padding.left + border.left), 0);
Expand Down Expand Up @@ -751,9 +759,10 @@ bool RenderThemeGtk::paintProgressBar(RenderObject* renderObject, const PaintInf
gtk_style_context_save(context);
gtk_style_context_add_class(context, GTK_STYLE_CLASS_PROGRESSBAR);

gtk_style_context_set_state(context, static_cast<GtkStateFlags>(0));

GtkBorder padding;
gtk_style_context_get_padding(context, static_cast<GtkStateFlags>(0), &padding);
gtk_style_context_get_padding(context, gtk_style_context_get_state(context), &padding);
IntRect progressRect(rect.x() + padding.left, rect.y() + padding.top,
rect.width() - (padding.left + padding.right),
rect.height() - (padding.top + padding.bottom));
Expand All @@ -775,7 +784,7 @@ bool RenderThemeGtk::paintProgressBar(RenderObject* renderObject, const PaintInf
static gint spinButtonArrowSize(GtkStyleContext* context)
{
PangoFontDescription* fontDescription;
gtk_style_context_get(context, static_cast<GtkStateFlags>(0), "font", &fontDescription, NULL);
gtk_style_context_get(context, gtk_style_context_get_state(context), "font", &fontDescription, nullptr);
gint fontSize = pango_font_description_get_size(fontDescription);
gint arrowSize = std::max(PANGO_PIXELS(fontSize), minSpinButtonArrowSize);
pango_font_description_free(fontDescription);
Expand All @@ -788,7 +797,7 @@ void RenderThemeGtk::adjustInnerSpinButtonStyle(StyleResolver*, RenderStyle* sty
GtkStyleContext* context = getStyleContext(GTK_TYPE_SPIN_BUTTON);

GtkBorder padding;
gtk_style_context_get_padding(context, static_cast<GtkStateFlags>(0), &padding);
gtk_style_context_get_padding(context, gtk_style_context_get_state(context), &padding);

int width = spinButtonArrowSize(context) + padding.left + padding.right;
style->setWidth(Length(width, Fixed));
Expand Down Expand Up @@ -947,9 +956,9 @@ static Color styleColor(GType widgetType, GtkStateFlags state, StyleColorType co

GdkRGBA gdkRGBAColor;
if (colorType == StyleColorBackground)
gtk_style_context_get_background_color(context, state, &gdkRGBAColor);
gtk_style_context_get_background_color(context, gtk_style_context_get_state(context), &gdkRGBAColor);
else
gtk_style_context_get_color(context, state, &gdkRGBAColor);
gtk_style_context_get_color(context, gtk_style_context_get_state(context), &gdkRGBAColor);
return gdkRGBAColor;
}

Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/platform/gtk/ScrollbarThemeGtk3.cpp
Expand Up @@ -75,7 +75,8 @@ static void applyScrollbarStyleContextClasses(GtkStyleContext* context, Scrollba
static void adjustRectAccordingToMargin(GtkStyleContext* context, GtkStateFlags state, IntRect& rect)
{
GtkBorder margin;
gtk_style_context_get_margin(context, state, &margin);
gtk_style_context_set_state(context, state);
gtk_style_context_get_margin(context, gtk_style_context_get_state(context), &margin);
rect.move(margin.left, margin.right);
rect.contract(margin.left + margin.right, margin.top + margin.bottom);
}
Expand Down

0 comments on commit 5cddb13

Please sign in to comment.