Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 1e03807

Browse files
[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): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@192723 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 0fbe2ac commit 1e03807

File tree

3 files changed

+56
-14
lines changed

3 files changed

+56
-14
lines changed

Source/WebCore/ChangeLog

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
2015-11-21 Michael Catanzaro <[email protected]>
2+
3+
[GTK] Warning spam from GtkStyleContext
4+
https://bugs.webkit.org/show_bug.cgi?id=151520
5+
6+
Reviewed by Carlos Garcia Campos.
7+
8+
Audit every use of gtk_style_context_get_* to fix compatibility with GTK+ 3.19. Some of
9+
these were already fine and are only changed for clarity.
10+
11+
Company: gtk_style_context_get() (and _get_padding/border/color()) should only ever be
12+
called with the same state as gtk_style_context_get_state()
13+
Company: usually that's a simple replacing of the old state (like in the trace you posted)
14+
Company: sometimes it requires calling gtk_style_context_set_sate() with the right state
15+
first
16+
Company: and in very rare cases it needs a gtk_style_context_save() before the set_state(),
17+
too
18+
19+
* platform/gtk/ScrollbarThemeGtk.cpp:
20+
(WebCore::adjustRectAccordingToMargin):
21+
* rendering/RenderThemeGtk.cpp:
22+
(gtk_css_section_print):
23+
(WebCore::getStyleContext):
24+
(WebCore::RenderThemeGtk::initMediaColors):
25+
(WebCore::renderButton):
26+
(WebCore::getComboBoxMetrics):
27+
(WebCore::RenderThemeGtk::paintMenuList):
28+
(WebCore::RenderThemeGtk::paintTextField):
29+
(WebCore::RenderThemeGtk::paintProgressBar):
30+
(WebCore::spinButtonArrowSize):
31+
(WebCore::RenderThemeGtk::adjustInnerSpinButtonStyle):
32+
(WebCore::styleColor):
33+
134
2015-11-20 Brady Eidson <[email protected]>
235

336
Modern IDB: After versionchange transactions complete, fire onsuccess on the original IDBOpenDBRequest

Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ static void applyScrollbarStyleContextClasses(GtkStyleContext* context, Scrollba
281281
static void adjustRectAccordingToMargin(GtkStyleContext* context, GtkStateFlags state, IntRect& rect)
282282
{
283283
GtkBorder margin;
284-
gtk_style_context_get_margin(context, state, &margin);
284+
gtk_style_context_set_state(context, state);
285+
gtk_style_context_get_margin(context, gtk_style_context_get_state(context), &margin);
285286
rect.move(margin.left, margin.right);
286287
rect.contract(margin.left + margin.right, margin.top + margin.bottom);
287288
}

Source/WebCore/rendering/RenderThemeGtk.cpp

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,19 @@ void RenderThemeGtk::initMediaColors()
273273
GdkRGBA color;
274274
GtkStyleContext* containerContext = getStyleContext(GTK_TYPE_CONTAINER);
275275

276-
gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_NORMAL, &color);
276+
gtk_style_context_save(containerContext);
277+
278+
gtk_style_context_set_state(containerContext, GTK_STATE_FLAG_NORMAL);
279+
gtk_style_context_get_background_color(containerContext, gtk_style_context_get_state(containerContext), &color);
277280
m_panelColor = color;
278-
gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_ACTIVE, &color);
281+
gtk_style_context_set_state(containerContext, GTK_STATE_FLAG_ACTIVE);
282+
gtk_style_context_get_background_color(containerContext, gtk_style_context_get_state(containerContext), &color);
279283
m_sliderColor = color;
280-
gtk_style_context_get_background_color(containerContext, GTK_STATE_FLAG_SELECTED, &color);
284+
gtk_style_context_set_state(containerContext, GTK_STATE_FLAG_SELECTED);
285+
gtk_style_context_get_background_color(containerContext, gtk_style_context_get_state(containerContext), &color);
281286
m_sliderThumbColor = color;
287+
288+
gtk_style_context_restore(containerContext);
282289
}
283290

284291
void RenderThemeGtk::initMediaButtons()
@@ -610,7 +617,7 @@ static void renderButton(RenderTheme* theme, GtkStyleContext* context, const Ren
610617

611618
if (interiorFocus) {
612619
GtkBorder borderWidth;
613-
gtk_style_context_get_border(context, static_cast<GtkStateFlags>(flags), &borderWidth);
620+
gtk_style_context_get_border(context, gtk_style_context_get_state(context), &borderWidth);
614621

615622
buttonRect = IntRect(
616623
buttonRect.x() + borderWidth.left + focusPad,
@@ -672,7 +679,8 @@ static void getComboBoxMetrics(RenderStyle& style, GtkBorder& border, int& focus
672679
gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
673680
gtk_style_context_set_direction(context, static_cast<GtkTextDirection>(gtkTextDirection(style.direction())));
674681

675-
gtk_style_context_get_border(context, static_cast<GtkStateFlags>(0), &border);
682+
gtk_style_context_set_state(context, static_cast<GtkStateFlags>(0));
683+
gtk_style_context_get_border(context, gtk_style_context_get_state(context), &border);
676684

677685
gboolean interiorFocus;
678686
gint focusWidth, focusPad;
@@ -838,9 +846,9 @@ bool RenderThemeGtk::paintMenuList(const RenderObject& renderObject, const Paint
838846
gtk_render_frame(separatorStyleContext, cairoContext, separatorPosition.x(), separatorPosition.y(), separatorWidth, innerRect.height());
839847
} else {
840848
GtkBorder padding;
841-
gtk_style_context_get_padding(separatorStyleContext, state, &padding);
849+
gtk_style_context_get_padding(separatorStyleContext, gtk_style_context_get_state(separatorStyleContext), &padding);
842850
GtkBorder border;
843-
gtk_style_context_get_border(separatorStyleContext, state, &border);
851+
gtk_style_context_get_border(separatorStyleContext, gtk_style_context_get_state(separatorStyleContext), &border);
844852

845853
if (direction == GTK_TEXT_DIR_LTR)
846854
separatorPosition.move(-(padding.left + border.left), 0);
@@ -1184,10 +1192,10 @@ bool RenderThemeGtk::paintProgressBar(const RenderObject& renderObject, const Pa
11841192

11851193
gtk_style_context_save(context);
11861194
gtk_style_context_add_class(context, GTK_STYLE_CLASS_PROGRESSBAR);
1187-
1195+
gtk_style_context_set_state(context, static_cast<GtkStateFlags>(0));
11881196

11891197
GtkBorder padding;
1190-
gtk_style_context_get_padding(context, static_cast<GtkStateFlags>(0), &padding);
1198+
gtk_style_context_get_padding(context, gtk_style_context_get_state(context), &padding);
11911199
IntRect progressRect(
11921200
rect.x() + padding.left,
11931201
rect.y() + padding.top,
@@ -1211,7 +1219,7 @@ bool RenderThemeGtk::paintProgressBar(const RenderObject& renderObject, const Pa
12111219
static gint spinButtonArrowSize(GtkStyleContext* context)
12121220
{
12131221
PangoFontDescription* fontDescription;
1214-
gtk_style_context_get(context, static_cast<GtkStateFlags>(0), "font", &fontDescription, nullptr);
1222+
gtk_style_context_get(context, gtk_style_context_get_state(context), "font", &fontDescription, nullptr);
12151223
gint fontSize = pango_font_description_get_size(fontDescription);
12161224
gint arrowSize = std::max(PANGO_PIXELS(fontSize), minSpinButtonArrowSize);
12171225
pango_font_description_free(fontDescription);
@@ -1224,7 +1232,7 @@ void RenderThemeGtk::adjustInnerSpinButtonStyle(StyleResolver&, RenderStyle& sty
12241232
GtkStyleContext* context = getStyleContext(GTK_TYPE_SPIN_BUTTON);
12251233

12261234
GtkBorder padding;
1227-
gtk_style_context_get_padding(context, static_cast<GtkStateFlags>(0), &padding);
1235+
gtk_style_context_get_padding(context, gtk_style_context_get_state(context), &padding);
12281236

12291237
int width = spinButtonArrowSize(context) + padding.left + padding.right;
12301238
style.setWidth(Length(width, Fixed));
@@ -1347,9 +1355,9 @@ static Color styleColor(GType widgetType, GtkStateFlags state, StyleColorType co
13471355

13481356
GdkRGBA gdkRGBAColor;
13491357
if (colorType == StyleColorBackground)
1350-
gtk_style_context_get_background_color(context, state, &gdkRGBAColor);
1358+
gtk_style_context_get_background_color(context, gtk_style_context_get_state(context), &gdkRGBAColor);
13511359
else
1352-
gtk_style_context_get_color(context, state, &gdkRGBAColor);
1360+
gtk_style_context_get_color(context, gtk_style_context_get_state(context), &gdkRGBAColor);
13531361
return gdkRGBAColor;
13541362
}
13551363

0 commit comments

Comments
 (0)