[gtk+] css: Move "border-style: none" special case to CssValueNumber
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] css: Move "border-style: none" special case to CssValueNumber
- Date: Wed, 21 Jan 2015 15:25:26 +0000 (UTC)
commit 728bce2cf8258e46f11c3452539b3bf064f60f5c
Author: Sebastian Keller <sebastian-keller gmx de>
Date: Wed Jan 21 15:29:54 2015 +0100
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.
gtk/gtkcssnumbervalue.c | 34 +++++++++++++++++++++++++
gtk/gtkcssstyleproperty.c | 61 ---------------------------------------------
2 files changed, 34 insertions(+), 61 deletions(-)
---
diff --git a/gtk/gtkcssnumbervalue.c b/gtk/gtkcssnumbervalue.c
index e827819..1c95317 100644
--- a/gtk/gtkcssnumbervalue.c
+++ b/gtk/gtkcssnumbervalue.c
@@ -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:
diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c
index 0ba6567..1590ed2 100644
--- a/gtk/gtkcssstyleproperty.c
+++ b/gtk/gtkcssstyleproperty.c
@@ -156,63 +156,6 @@ _gtk_css_style_property_assign (GtkStyleProperty *property,
_gtk_css_value_unref (css_value);
}
-static gboolean
-_gtk_css_style_property_query_special_case (GtkCssStyleProperty *property,
- GValue *value,
- GtkStyleQueryFunc query_func,
- gpointer query_data)
-{
- GtkBorderStyle border_style;
-
- switch (property->id)
- {
- case GTK_CSS_PROPERTY_BORDER_TOP_WIDTH:
- border_style = _gtk_css_border_style_value_get (query_func (GTK_CSS_PROPERTY_BORDER_TOP_STYLE,
query_data));
- if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
- {
- g_value_init (value, G_TYPE_INT);
- return TRUE;
- }
- break;
- case GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH:
- border_style = _gtk_css_border_style_value_get (query_func (GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE,
query_data));
- if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
- {
- g_value_init (value, G_TYPE_INT);
- return TRUE;
- }
- break;
- case GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH:
- border_style = _gtk_css_border_style_value_get (query_func (GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE,
query_data));
- if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
- {
- g_value_init (value, G_TYPE_INT);
- return TRUE;
- }
- break;
- case GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH:
- border_style = _gtk_css_border_style_value_get (query_func (GTK_CSS_PROPERTY_BORDER_LEFT_STYLE,
query_data));
- if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
- {
- g_value_init (value, G_TYPE_INT);
- return TRUE;
- }
- break;
- case GTK_CSS_PROPERTY_OUTLINE_WIDTH:
- border_style = _gtk_css_border_style_value_get (query_func (GTK_CSS_PROPERTY_OUTLINE_STYLE,
query_data));
- if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
- {
- g_value_init (value, G_TYPE_INT);
- return TRUE;
- }
- break;
- default:
- break;
- }
-
- return FALSE;
-}
-
static void
_gtk_css_style_property_query (GtkStyleProperty *property,
GValue *value,
@@ -221,10 +164,6 @@ _gtk_css_style_property_query (GtkStyleProperty *property,
{
GtkCssStyleProperty *style_property = GTK_CSS_STYLE_PROPERTY (property);
GtkCssValue *css_value;
-
- /* I don't like this special case being here in this generic code path, but no idea where else to put it.
*/
- if (_gtk_css_style_property_query_special_case (style_property, value, query_func, query_data))
- return;
css_value = (* query_func) (GTK_CSS_STYLE_PROPERTY (property)->id, query_data);
if (css_value == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]