css: Move "border-style: none" special case to CssValueNumber

This fixes the background being shifted by the border-width even though
the border-style was none.
This commit is contained in:
Sebastian Keller
2015-01-21 15:29:54 +01:00
committed by Benjamin Otte
parent 610f7e8f70
commit 728bce2cf8
2 changed files with 34 additions and 61 deletions

View File

@ -64,6 +64,40 @@ gtk_css_value_number_compute (GtkCssValue *number,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkBorderStyle border_style;
/* special case according to http://dev.w3.org/csswg/css-backgrounds/#the-border-width */
switch (property_id)
{
case GTK_CSS_PROPERTY_BORDER_TOP_WIDTH:
border_style = _gtk_css_border_style_value_get(gtk_css_style_get_value (values, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
return _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
break;
case GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH:
border_style = _gtk_css_border_style_value_get(gtk_css_style_get_value (values, GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE));
if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
return _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH:
border_style = _gtk_css_border_style_value_get(gtk_css_style_get_value (values, GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE));
if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
return _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
break;
case GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH:
border_style = _gtk_css_border_style_value_get(gtk_css_style_get_value (values, GTK_CSS_PROPERTY_BORDER_LEFT_STYLE));
if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
return _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
break;
case GTK_CSS_PROPERTY_OUTLINE_WIDTH:
border_style = _gtk_css_border_style_value_get(gtk_css_style_get_value (values, GTK_CSS_PROPERTY_OUTLINE_STYLE));
if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
return _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
break;
default:
break;
}
switch (number->unit)
{
default: