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

Commit 6597eec

Browse files
[GTK] Off-by-one error in getStyleContext()
https://bugs.webkit.org/show_bug.cgi?id=151524 Reviewed by Carlos Garcia Campos. GtkWidgetPath* path = gtk_widget_path_new(); gtk_widget_path_append_type(path, widgetType); // ... gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_BUTTON); gtk_widget_path_iter_add_class(path, 1, "text-button"); Only one widget type was appended to the widget path, so the maximum valid index is 0. This code means to add both style classes to the first widget type in the widget path, so the second call should use index 0 rather than index 1. This caused no bug in practice, because when the index is invalid, gtk_widget_path_iter_add_class() automatically changes the index to the last valid position in the widget path -- in this case, 0. This is routinely done with -1 as a convention for specifying the last position in the widget path. * rendering/RenderThemeGtk.cpp: (WebCore::getStyleContext): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@192724 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 1e03807 commit 6597eec

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Source/WebCore/ChangeLog

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
2015-11-21 Michael Catanzaro <[email protected]>
2+
3+
[GTK] Off-by-one error in getStyleContext()
4+
https://bugs.webkit.org/show_bug.cgi?id=151524
5+
6+
Reviewed by Carlos Garcia Campos.
7+
8+
GtkWidgetPath* path = gtk_widget_path_new();
9+
gtk_widget_path_append_type(path, widgetType);
10+
// ...
11+
gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_BUTTON);
12+
gtk_widget_path_iter_add_class(path, 1, "text-button");
13+
14+
Only one widget type was appended to the widget path, so the maximum valid index is 0. This
15+
code means to add both style classes to the first widget type in the widget path, so the
16+
second call should use index 0 rather than index 1.
17+
18+
This caused no bug in practice, because when the index is invalid,
19+
gtk_widget_path_iter_add_class() automatically changes the index to the last valid position
20+
in the widget path -- in this case, 0. This is routinely done with -1 as a convention for
21+
specifying the last position in the widget path.
22+
23+
* rendering/RenderThemeGtk.cpp:
24+
(WebCore::getStyleContext):
25+
126
2015-11-21 Michael Catanzaro <[email protected]>
227

328
[GTK] Warning spam from GtkStyleContext

Source/WebCore/rendering/RenderThemeGtk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ static GtkStyleContext* getStyleContext(GType widgetType)
175175
gtk_widget_path_iter_add_class(path, 0, "arrow");
176176
else if (widgetType == GTK_TYPE_BUTTON) {
177177
gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_BUTTON);
178-
gtk_widget_path_iter_add_class(path, 1, "text-button");
178+
gtk_widget_path_iter_add_class(path, 0, "text-button");
179179
} else if (widgetType == GTK_TYPE_SCALE)
180180
gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SCALE);
181181
else if (widgetType == GTK_TYPE_SEPARATOR)

0 commit comments

Comments
 (0)