[gtk+/wip/cssdep: 4/21] css: Move special case for 0px borders
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssdep: 4/21] css: Move special case for 0px borders
- Date: Sat, 25 Aug 2012 08:36:16 +0000 (UTC)
commit f5286dfba6e4b9045a08c0e28809b20249ba733f
Author: Benjamin Otte <otte redhat com>
Date: Mon Jul 16 13:42:18 2012 +0200
css: Move special case for 0px borders
This is in preparation for the next commits.
gtk/gtkcssnumbervalue.c | 35 +++++++++++++++++++++++++++++++++++
gtk/gtkcssstylepropertyimpl.c | 17 +++--------------
2 files changed, 38 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkcssnumbervalue.c b/gtk/gtkcssnumbervalue.c
index c929f1d..479662c 100644
--- a/gtk/gtkcssnumbervalue.c
+++ b/gtk/gtkcssnumbervalue.c
@@ -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:
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index bf7fa99..840e3ae 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]