css: Redo the pseudo class deprecation warnings

Putting the deprecated class behind the official variant does
not work for the case of :focus and :focused - we were matching
:focus and leave a dangling 'ed'. So, put the deprecated classes
before the official variant, and explicitly mark them as deprecated.
This commit is contained in:
Matthias Clasen 2015-12-27 17:24:25 -05:00
parent c4ca671a9e
commit f3069d7e94

View File

@ -1167,32 +1167,33 @@ parse_selector_pseudo_class (GtkCssParser *parser,
{
static const struct {
const char *name;
gboolean deprecated;
GtkStateFlags state_flag;
PositionType position_type;
int position_a;
int position_b;
} pseudo_classes[] = {
{ "first-child", 0, POSITION_FORWARD, 0, 1 },
{ "last-child", 0, POSITION_BACKWARD, 0, 1 },
{ "only-child", 0, POSITION_ONLY, 0, 0 },
{ "sorted", 0, POSITION_SORTED, 0, 0 },
{ "active", GTK_STATE_FLAG_ACTIVE, },
{ "hover", GTK_STATE_FLAG_PRELIGHT, },
{ "prelight", GTK_STATE_FLAG_PRELIGHT, },
{ "selected", GTK_STATE_FLAG_SELECTED, },
{ "disabled", GTK_STATE_FLAG_INSENSITIVE, },
{ "insensitive", GTK_STATE_FLAG_INSENSITIVE, },
{ "indeterminate",GTK_STATE_FLAG_INCONSISTENT, },
{ "inconsistent", GTK_STATE_FLAG_INCONSISTENT, },
{ "focus", GTK_STATE_FLAG_FOCUSED, },
{ "focused", GTK_STATE_FLAG_FOCUSED, },
{ "backdrop", GTK_STATE_FLAG_BACKDROP, },
{ "dir(ltr)", GTK_STATE_FLAG_DIR_LTR, },
{ "dir(rtl)", GTK_STATE_FLAG_DIR_RTL, },
{ "link", GTK_STATE_FLAG_LINK, },
{ "visited", GTK_STATE_FLAG_VISITED, },
{ "checked", GTK_STATE_FLAG_CHECKED, },
{ "drop(active)", GTK_STATE_FLAG_DROP_ACTIVE, }
{ "first-child", 0, 0, POSITION_FORWARD, 0, 1 },
{ "last-child", 0, 0, POSITION_BACKWARD, 0, 1 },
{ "only-child", 0, 0, POSITION_ONLY, 0, 0 },
{ "sorted", 0, 0, POSITION_SORTED, 0, 0 },
{ "active", 0, GTK_STATE_FLAG_ACTIVE, },
{ "prelight", 1, GTK_STATE_FLAG_PRELIGHT, },
{ "hover", 0, GTK_STATE_FLAG_PRELIGHT, },
{ "selected", 0, GTK_STATE_FLAG_SELECTED, },
{ "insensitive", 1, GTK_STATE_FLAG_INSENSITIVE, },
{ "disabled", 0, GTK_STATE_FLAG_INSENSITIVE, },
{ "inconsistent", 1, GTK_STATE_FLAG_INCONSISTENT, },
{ "indeterminate", 0, GTK_STATE_FLAG_INCONSISTENT, },
{ "focused", 1, GTK_STATE_FLAG_FOCUSED, },
{ "focus", 0, GTK_STATE_FLAG_FOCUSED, },
{ "backdrop", 0, GTK_STATE_FLAG_BACKDROP, },
{ "dir(ltr)", 0, GTK_STATE_FLAG_DIR_LTR, },
{ "dir(rtl)", 0, GTK_STATE_FLAG_DIR_RTL, },
{ "link", 0, GTK_STATE_FLAG_LINK, },
{ "visited", 0, GTK_STATE_FLAG_VISITED, },
{ "checked", 0, GTK_STATE_FLAG_CHECKED, },
{ "drop(active)", 0, GTK_STATE_FLAG_DROP_ACTIVE, }
};
guint i;
@ -1212,13 +1213,13 @@ parse_selector_pseudo_class (GtkCssParser *parser,
: &GTK_CSS_SELECTOR_PSEUDOCLASS_STATE,
selector);
selector->state.state = pseudo_classes[i].state_flag;
if (pseudo_classes[i].state_flag == pseudo_classes[i - 1].state_flag)
if (pseudo_classes[i].deprecated)
{
_gtk_css_parser_error_full (parser,
GTK_CSS_PROVIDER_ERROR_DEPRECATED,
"The :%s pseudo-class is deprecated. Use :%s instead.",
pseudo_classes[i].name,
pseudo_classes[i - 1].name);
pseudo_classes[i + 1].name);
}
}
else