Commit c0df9067 authored by Benjamin Otte's avatar Benjamin Otte

css: Move special case for 0px borders

This is in preparation for the next commits.
parent 09f9fd42
......@@ -19,6 +19,7 @@
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "gtkstylepropertyprivate.h"
struct _GtkCssValue {
......@@ -38,6 +39,40 @@ gtk_css_value_number_compute (GtkCssValue *number,
guint property_id,
GtkStyleContext *context)
{
GtkBorderStyle border_style;
/* I don't like this special case being here in this generic code path, but no idea where else to put it. */
switch (property_id)
{
case GTK_CSS_PROPERTY_BORDER_TOP_WIDTH:
border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, 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_PX);
break;
case GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH:
border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, 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_PX);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH:
border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, 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_PX);
break;
case GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH:
border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, 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_PX);
break;
case GTK_CSS_PROPERTY_OUTLINE_WIDTH:
border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, 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_PX);
break;
default:
break;
}
switch (number->unit)
{
default:
......
......@@ -831,18 +831,7 @@ compute_border_width (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *specified)
{
GtkBorderStyle border_style;
/* The -1 is magic that is only true because we register the style
* properties directly after the width properties.
*/
border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, _gtk_css_style_property_get_id (property) - 1));
if (border_style == GTK_BORDER_STYLE_NONE ||
border_style == GTK_BORDER_STYLE_HIDDEN)
return _gtk_css_number_value_new (0, GTK_CSS_PX);
else
return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
}
static GtkCssValue *
......@@ -1107,8 +1096,8 @@ _gtk_css_style_property_init_properties (void)
query_length_as_int,
assign_length_from_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
/* IMPORTANT: compute_border_width() requires that the border-width
* properties be immeditaly followed by the border-style properties
/* IMPORTANT: the border-width properties must come after border-style properties,
* they depend on them for their value computation.
*/
gtk_css_style_property_register ("border-top-style",
GTK_CSS_PROPERTY_BORDER_TOP_STYLE,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment