Changeset 192724 in webkit


Ignore:
Timestamp:
Nov 21, 2015 9:00:00 AM (8 years ago)
Author:
Michael Catanzaro
Message:

[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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r192723 r192724  
     12015-11-21  Michael Catanzaro  <mcatanzaro@igalia.com>
     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
    1262015-11-21  Michael Catanzaro  <mcatanzaro@igalia.com>
    227
  • trunk/Source/WebCore/rendering/RenderThemeGtk.cpp

    r192723 r192724  
    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);
Note: See TracChangeset for help on using the changeset viewer.