diff --git a/gtk/gtkcsstypes.c b/gtk/gtkcsstypes.c index 3553683229..3a848704b2 100644 --- a/gtk/gtkcsstypes.c +++ b/gtk/gtkcsstypes.c @@ -70,28 +70,26 @@ _gtk_css_change_for_sibling (GtkCssChange match) GtkCssChange _gtk_css_change_for_child (GtkCssChange match) { - static const GtkCssChangeTranslation table[] = { - { GTK_CSS_CHANGE_CLASS, GTK_CSS_CHANGE_PARENT_CLASS }, - { GTK_CSS_CHANGE_NAME, GTK_CSS_CHANGE_PARENT_NAME }, - { GTK_CSS_CHANGE_ID, GTK_CSS_CHANGE_PARENT_ID }, - { GTK_CSS_CHANGE_FIRST_CHILD, GTK_CSS_CHANGE_PARENT_FIRST_CHILD }, - { GTK_CSS_CHANGE_LAST_CHILD, GTK_CSS_CHANGE_PARENT_LAST_CHILD }, - { GTK_CSS_CHANGE_NTH_CHILD, GTK_CSS_CHANGE_PARENT_NTH_CHILD }, - { GTK_CSS_CHANGE_NTH_LAST_CHILD, GTK_CSS_CHANGE_PARENT_NTH_LAST_CHILD }, - { GTK_CSS_CHANGE_STATE, GTK_CSS_CHANGE_PARENT_STATE }, - { GTK_CSS_CHANGE_SIBLING_CLASS, GTK_CSS_CHANGE_PARENT_SIBLING_CLASS }, - { GTK_CSS_CHANGE_SIBLING_NAME, GTK_CSS_CHANGE_PARENT_SIBLING_NAME }, - { GTK_CSS_CHANGE_SIBLING_ID, GTK_CSS_CHANGE_PARENT_SIBLING_ID }, - { GTK_CSS_CHANGE_SIBLING_FIRST_CHILD, GTK_CSS_CHANGE_PARENT_SIBLING_FIRST_CHILD }, - { GTK_CSS_CHANGE_SIBLING_LAST_CHILD, GTK_CSS_CHANGE_PARENT_SIBLING_LAST_CHILD }, - { GTK_CSS_CHANGE_SIBLING_NTH_CHILD, GTK_CSS_CHANGE_PARENT_SIBLING_NTH_CHILD }, - { GTK_CSS_CHANGE_SIBLING_NTH_LAST_CHILD, GTK_CSS_CHANGE_PARENT_SIBLING_NTH_LAST_CHILD }, - { GTK_CSS_CHANGE_SIBLING_STATE, GTK_CSS_CHANGE_PARENT_SIBLING_STATE }, - { GTK_CSS_CHANGE_SOURCE, 0 }, - { GTK_CSS_CHANGE_PARENT_STYLE, 0 } - }; +#define BASE_STATES ( GTK_CSS_CHANGE_CLASS \ + | GTK_CSS_CHANGE_NAME \ + | GTK_CSS_CHANGE_ID \ + | GTK_CSS_CHANGE_FIRST_CHILD \ + | GTK_CSS_CHANGE_LAST_CHILD \ + | GTK_CSS_CHANGE_NTH_CHILD \ + | GTK_CSS_CHANGE_NTH_LAST_CHILD \ + | GTK_CSS_CHANGE_STATE \ + | GTK_CSS_CHANGE_SIBLING_CLASS \ + | GTK_CSS_CHANGE_SIBLING_NAME \ + | GTK_CSS_CHANGE_SIBLING_ID \ + | GTK_CSS_CHANGE_SIBLING_FIRST_CHILD \ + | GTK_CSS_CHANGE_SIBLING_LAST_CHILD \ + | GTK_CSS_CHANGE_SIBLING_NTH_CHILD \ + | GTK_CSS_CHANGE_SIBLING_NTH_LAST_CHILD \ + | GTK_CSS_CHANGE_SIBLING_STATE ) - return gtk_css_change_translate (match, table, G_N_ELEMENTS (table)); +#define PARENT_SHIFT 16 + + return (match & ~(BASE_STATES|GTK_CSS_CHANGE_SOURCE|GTK_CSS_CHANGE_PARENT_STYLE)) | ((match & BASE_STATES) << PARENT_SHIFT); } void