RESOLVED FIXED Bug 151524
[GTK] Off-by-one error in getStyleContext()
https://bugs.webkit.org/show_bug.cgi?id=151524
Summary [GTK] Off-by-one error in getStyleContext()
Michael Catanzaro
Reported 2015-11-20 15:56:52 PST
In getStyleContext() in RenderThemeGtk.cpp: 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. 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.
Attachments
Patch (2.34 KB, patch)
2015-11-20 15:59 PST, Michael Catanzaro
no flags
Michael Catanzaro
Comment 1 2015-11-20 15:59:51 PST
Carlos Garcia Campos
Comment 2 2015-11-21 01:44:21 PST
Comment on attachment 266010 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=266010&action=review Good catch, thanks! > Source/WebCore/rendering/RenderThemeGtk.cpp:178 > - gtk_widget_path_iter_add_class(path, 1, "text-button"); > + gtk_widget_path_iter_add_class(path, 0, "text-button"); I guess I understood this as the position of the class, rather than the widget at the given position. Since we always add one widget only, maybe it would be less confusing to use -1 in all cases.
Michael Catanzaro
Comment 3 2015-11-21 08:14:38 PST
Now that I understand how the API works, using 0 seems better to me; I would use -1 when I don't know how long the widget path is.
WebKit Commit Bot
Comment 4 2015-11-21 09:00:06 PST
Comment on attachment 266010 [details] Patch Clearing flags on attachment: 266010 Committed r192724: <http://trac.webkit.org/changeset/192724>
WebKit Commit Bot
Comment 5 2015-11-21 09:00:10 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.