[gtk/wip/matthiasc/css-values: 1/2] css: Simplify default values



commit 03943bc6ab5c318a7f32e955a022f2264dc889a3
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jan 11 19:05:39 2020 -0500

    css: Simplify default values
    
    We no longer need to create one-element arrays or
    corners with two identical values.

 gtk/gtkcssinitialvalue.c      |  2 +-
 gtk/gtkcssstylepropertyimpl.c | 70 +++++++++++++++++++------------------------
 2 files changed, 31 insertions(+), 41 deletions(-)
---
diff --git a/gtk/gtkcssinitialvalue.c b/gtk/gtkcssinitialvalue.c
index ad3c2e352e..f01b49c612 100644
--- a/gtk/gtkcssinitialvalue.c
+++ b/gtk/gtkcssinitialvalue.c
@@ -64,7 +64,7 @@ gtk_css_value_initial_compute (GtkCssValue      *value,
     case GTK_CSS_PROPERTY_FONT_FAMILY:
       settings = gtk_style_provider_get_settings (provider);
       if (settings && gtk_settings_get_font_family (settings) != NULL)
-        return _gtk_css_array_value_new (_gtk_css_string_value_new (gtk_settings_get_font_family 
(settings)));
+        return _gtk_css_string_value_new (gtk_settings_get_font_family (settings));
       break;
 
     default:
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index eee5bfbde3..0e37bf0ff4 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -988,7 +988,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_TEXT_SIZE,
                                           font_family_parse,
                                           font_family_query,
-                                          _gtk_css_array_value_new (_gtk_css_string_value_new ("Sans")));
+                                          _gtk_css_string_value_new ("Sans"));
   gtk_css_style_property_register        ("font-style",
                                           GTK_CSS_PROPERTY_FONT_STYLE,
                                           PANGO_TYPE_STYLE,
@@ -1260,8 +1260,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_BACKGROUND | GTK_CSS_AFFECTS_BORDER,
                                           border_corner_radius_value_parse,
                                           NULL,
-                                          _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
-                                                                     _gtk_css_number_value_new (0, 
GTK_CSS_PX)));
+                                          _gtk_css_number_value_new (0, GTK_CSS_PX));
   gtk_css_style_property_register        ("border-top-right-radius",
                                           GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS,
                                           G_TYPE_NONE,
@@ -1269,8 +1268,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_BACKGROUND | GTK_CSS_AFFECTS_BORDER,
                                           border_corner_radius_value_parse,
                                           NULL,
-                                          _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
-                                                                     _gtk_css_number_value_new (0, 
GTK_CSS_PX)));
+                                          _gtk_css_number_value_new (0, GTK_CSS_PX));
   gtk_css_style_property_register        ("border-bottom-right-radius",
                                           GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS,
                                           G_TYPE_NONE,
@@ -1278,8 +1276,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_BACKGROUND | GTK_CSS_AFFECTS_BORDER,
                                           border_corner_radius_value_parse,
                                           NULL,
-                                          _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
-                                                                     _gtk_css_number_value_new (0, 
GTK_CSS_PX)));
+                                          _gtk_css_number_value_new (0, GTK_CSS_PX));
   gtk_css_style_property_register        ("border-bottom-left-radius",
                                           GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS,
                                           G_TYPE_NONE,
@@ -1287,8 +1284,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_BACKGROUND | GTK_CSS_AFFECTS_BORDER,
                                           border_corner_radius_value_parse,
                                           NULL,
-                                          _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
-                                                                     _gtk_css_number_value_new (0, 
GTK_CSS_PX)));
+                                          _gtk_css_number_value_new (0, GTK_CSS_PX));
 
   gtk_css_style_property_register        ("outline-style",
                                           GTK_CSS_PROPERTY_OUTLINE_STYLE,
@@ -1322,8 +1318,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_OUTLINE,
                                           border_corner_radius_value_parse,
                                           NULL,
-                                          _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
-                                                                     _gtk_css_number_value_new (0, 
GTK_CSS_PX)));
+                                          _gtk_css_number_value_new (0, GTK_CSS_PX));
   gtk_css_style_property_register        ("-gtk-outline-top-right-radius",
                                           GTK_CSS_PROPERTY_OUTLINE_TOP_RIGHT_RADIUS,
                                           G_TYPE_NONE,
@@ -1331,8 +1326,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_OUTLINE,
                                           border_corner_radius_value_parse,
                                           NULL,
-                                          _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
-                                                                     _gtk_css_number_value_new (0, 
GTK_CSS_PX)));
+                                          _gtk_css_number_value_new (0, GTK_CSS_PX));
   gtk_css_style_property_register        ("-gtk-outline-bottom-right-radius",
                                           GTK_CSS_PROPERTY_OUTLINE_BOTTOM_RIGHT_RADIUS,
                                           G_TYPE_NONE,
@@ -1340,8 +1334,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_OUTLINE,
                                           border_corner_radius_value_parse,
                                           NULL,
-                                          _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
-                                                                     _gtk_css_number_value_new (0, 
GTK_CSS_PX)));
+                                          _gtk_css_number_value_new (0, GTK_CSS_PX));
   gtk_css_style_property_register        ("-gtk-outline-bottom-left-radius",
                                           GTK_CSS_PROPERTY_OUTLINE_BOTTOM_LEFT_RADIUS,
                                           G_TYPE_NONE,
@@ -1349,8 +1342,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_OUTLINE,
                                           border_corner_radius_value_parse,
                                           NULL,
-                                          _gtk_css_corner_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PX),
-                                                                     _gtk_css_number_value_new (0, 
GTK_CSS_PX)));
+                                          _gtk_css_number_value_new (0, GTK_CSS_PX));
 
   gtk_css_style_property_register        ("background-clip",
                                           GTK_CSS_PROPERTY_BACKGROUND_CLIP,
@@ -1359,7 +1351,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_BACKGROUND,
                                           parse_css_area,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_area_value_new 
(GTK_CSS_AREA_BORDER_BOX)));
+                                          _gtk_css_area_value_new (GTK_CSS_AREA_BORDER_BOX));
   gtk_css_style_property_register        ("background-origin",
                                           GTK_CSS_PROPERTY_BACKGROUND_ORIGIN,
                                           G_TYPE_NONE,
@@ -1367,7 +1359,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_BACKGROUND,
                                           parse_css_area,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_area_value_new 
(GTK_CSS_AREA_PADDING_BOX)));
+                                          _gtk_css_area_value_new (GTK_CSS_AREA_PADDING_BOX));
   gtk_css_style_property_register        ("background-size",
                                           GTK_CSS_PROPERTY_BACKGROUND_SIZE,
                                           G_TYPE_NONE,
@@ -1375,7 +1367,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_BACKGROUND,
                                           background_size_parse,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_bg_size_value_new (NULL, 
NULL)));
+                                          _gtk_css_bg_size_value_new (NULL, NULL));
   gtk_css_style_property_register        ("background-position",
                                           GTK_CSS_PROPERTY_BACKGROUND_POSITION,
                                           G_TYPE_NONE,
@@ -1383,8 +1375,8 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_BACKGROUND,
                                           background_position_parse,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_position_value_new 
(_gtk_css_number_value_new (0, GTK_CSS_PERCENT),
-                                                                                                 
_gtk_css_number_value_new (0, GTK_CSS_PERCENT))));
+                                          _gtk_css_position_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_PERCENT),
+                                                                       _gtk_css_number_value_new (0, 
GTK_CSS_PERCENT)));
 
   gtk_css_style_property_register        ("border-top-color",
                                           GTK_CSS_PROPERTY_BORDER_TOP_COLOR,
@@ -1434,8 +1426,8 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_BACKGROUND,
                                           background_repeat_value_parse,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_background_repeat_value_new 
(GTK_CSS_REPEAT_STYLE_REPEAT,
-                                                                                                          
GTK_CSS_REPEAT_STYLE_REPEAT)));
+                                          _gtk_css_background_repeat_value_new (GTK_CSS_REPEAT_STYLE_REPEAT,
+                                                                                
GTK_CSS_REPEAT_STYLE_REPEAT));
   gtk_css_style_property_register        ("background-image",
                                           GTK_CSS_PROPERTY_BACKGROUND_IMAGE,
                                           G_TYPE_NONE,
@@ -1443,7 +1435,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_BACKGROUND,
                                           background_image_value_parse,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_image_value_new (NULL)));
+                                          _gtk_css_image_value_new (NULL));
 
   gtk_css_style_property_register        ("background-blend-mode",
                                           GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE,
@@ -1452,7 +1444,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_BACKGROUND,
                                           blend_mode_value_parse,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_blend_mode_value_new 
(GSK_BLEND_MODE_DEFAULT)));
+                                          _gtk_css_blend_mode_value_new (GSK_BLEND_MODE_DEFAULT));
 
   gtk_css_style_property_register        ("border-image-source",
                                           GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE,
@@ -1585,7 +1577,7 @@ _gtk_css_style_property_init_properties (void)
                                           0,
                                           transition_property_parse,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_ident_value_new ("all")));
+                                          _gtk_css_ident_value_new ("all"));
   gtk_css_style_property_register        ("transition-duration",
                                           GTK_CSS_PROPERTY_TRANSITION_DURATION,
                                           G_TYPE_NONE,
@@ -1593,7 +1585,7 @@ _gtk_css_style_property_init_properties (void)
                                           0,
                                           transition_time_parse,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_S)));
+                                          _gtk_css_number_value_new (0, GTK_CSS_S));
   gtk_css_style_property_register        ("transition-timing-function",
                                           GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION,
                                           G_TYPE_NONE,
@@ -1601,8 +1593,7 @@ _gtk_css_style_property_init_properties (void)
                                           0,
                                           transition_timing_function_parse,
                                           NULL,
-                                          _gtk_css_array_value_new (
-                                            _gtk_css_ease_value_new_cubic_bezier (0.25, 0.1, 0.25, 1.0)));
+                                          _gtk_css_ease_value_new_cubic_bezier (0.25, 0.1, 0.25, 1.0));
   gtk_css_style_property_register        ("transition-delay",
                                           GTK_CSS_PROPERTY_TRANSITION_DELAY,
                                           G_TYPE_NONE,
@@ -1610,7 +1601,7 @@ _gtk_css_style_property_init_properties (void)
                                           0,
                                           transition_time_parse,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_S)));
+                                          _gtk_css_number_value_new (0, GTK_CSS_S));
 
   gtk_css_style_property_register        ("animation-name",
                                           GTK_CSS_PROPERTY_ANIMATION_NAME,
@@ -1619,7 +1610,7 @@ _gtk_css_style_property_init_properties (void)
                                           0,
                                           transition_property_parse,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_ident_value_new ("none")));
+                                          _gtk_css_ident_value_new ("none"));
   gtk_css_style_property_register        ("animation-duration",
                                           GTK_CSS_PROPERTY_ANIMATION_DURATION,
                                           G_TYPE_NONE,
@@ -1627,7 +1618,7 @@ _gtk_css_style_property_init_properties (void)
                                           0,
                                           transition_time_parse,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_S)));
+                                          _gtk_css_number_value_new (0, GTK_CSS_S));
   gtk_css_style_property_register        ("animation-timing-function",
                                           GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION,
                                           G_TYPE_NONE,
@@ -1635,8 +1626,7 @@ _gtk_css_style_property_init_properties (void)
                                           0,
                                           transition_timing_function_parse,
                                           NULL,
-                                          _gtk_css_array_value_new (
-                                            _gtk_css_ease_value_new_cubic_bezier (0.25, 0.1, 0.25, 1.0)));
+                                          _gtk_css_ease_value_new_cubic_bezier (0.25, 0.1, 0.25, 1.0));
   gtk_css_style_property_register        ("animation-iteration-count",
                                           GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT,
                                           G_TYPE_NONE,
@@ -1644,7 +1634,7 @@ _gtk_css_style_property_init_properties (void)
                                           0,
                                           iteration_count_parse,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_number_value_new (1, 
GTK_CSS_NUMBER)));
+                                          _gtk_css_number_value_new (1, GTK_CSS_NUMBER));
   gtk_css_style_property_register        ("animation-direction",
                                           GTK_CSS_PROPERTY_ANIMATION_DIRECTION,
                                           G_TYPE_NONE,
@@ -1652,7 +1642,7 @@ _gtk_css_style_property_init_properties (void)
                                           0,
                                           parse_css_direction,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_direction_value_new 
(GTK_CSS_DIRECTION_NORMAL)));
+                                          _gtk_css_direction_value_new (GTK_CSS_DIRECTION_NORMAL));
   gtk_css_style_property_register        ("animation-play-state",
                                           GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE,
                                           G_TYPE_NONE,
@@ -1660,7 +1650,7 @@ _gtk_css_style_property_init_properties (void)
                                           0,
                                           parse_css_play_state,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_play_state_value_new 
(GTK_CSS_PLAY_STATE_RUNNING)));
+                                          _gtk_css_play_state_value_new (GTK_CSS_PLAY_STATE_RUNNING));
   gtk_css_style_property_register        ("animation-delay",
                                           GTK_CSS_PROPERTY_ANIMATION_DELAY,
                                           G_TYPE_NONE,
@@ -1668,7 +1658,7 @@ _gtk_css_style_property_init_properties (void)
                                           0,
                                           transition_time_parse,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_number_value_new (0, 
GTK_CSS_S)));
+                                          _gtk_css_number_value_new (0, GTK_CSS_S));
   gtk_css_style_property_register        ("animation-fill-mode",
                                           GTK_CSS_PROPERTY_ANIMATION_FILL_MODE,
                                           G_TYPE_NONE,
@@ -1676,7 +1666,7 @@ _gtk_css_style_property_init_properties (void)
                                           0,
                                           parse_css_fill_mode,
                                           NULL,
-                                          _gtk_css_array_value_new (_gtk_css_fill_mode_value_new 
(GTK_CSS_FILL_NONE)));
+                                          _gtk_css_fill_mode_value_new (GTK_CSS_FILL_NONE));
 
   gtk_css_style_property_register        ("opacity",
                                           GTK_CSS_PROPERTY_OPACITY,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]