[gtk/wip/baedert/css-values: 78/84] Make GtkCssFontSizeValue represent all font sizes



commit 9341104a0f2a2409edda034cb05b89fa8332c932
Author: Timm Bäder <mail baedert org>
Date:   Wed Jan 15 09:58:34 2020 +0100

    Make GtkCssFontSizeValue represent all font sizes
    
    Instead of just using it for the enum types like larger or medium, use
    it for all font sizes, including pixel values and percentages.  This
    makes semantic sense, but is especially interesting because we can mark
    percentage values as is_computed in a later commit.

 gtk/gtkcssdimensionvalue.c        |   2 +-
 gtk/gtkcssenumvalue.c             | 144 -------------------
 gtk/gtkcssenumvalueprivate.h      |   6 -
 gtk/gtkcssfontsizevalue.c         | 285 ++++++++++++++++++++++++++++++++++++++
 gtk/gtkcssfontsizevalueprivate.h  |  36 +++++
 gtk/gtkcssshorthandpropertyimpl.c |   3 +-
 gtk/gtkcssstylepropertyimpl.c     |  18 +--
 gtk/gtkcssstylepropertyprivate.h  |   1 -
 gtk/meson.build                   |   1 +
 9 files changed, 327 insertions(+), 169 deletions(-)
---
diff --git a/gtk/gtkcssdimensionvalue.c b/gtk/gtkcssdimensionvalue.c
index 712742735c..2297473116 100644
--- a/gtk/gtkcssdimensionvalue.c
+++ b/gtk/gtkcssdimensionvalue.c
@@ -19,7 +19,7 @@
 
 #include "gtkcssdimensionvalueprivate.h"
 
-#include "gtkcssenumvalueprivate.h"
+#include "gtkcssfontsizevalueprivate.h"
 #include "gtkstylepropertyprivate.h"
 
 #include "fallback-c89.c"
diff --git a/gtk/gtkcssenumvalue.c b/gtk/gtkcssenumvalue.c
index d558964fc9..93285233eb 100644
--- a/gtk/gtkcssenumvalue.c
+++ b/gtk/gtkcssenumvalue.c
@@ -197,150 +197,6 @@ _gtk_css_blend_mode_value_get (const GtkCssValue *value)
   return value->value;
 }
 
-/* GtkCssFontSize */
-
-static double
-get_dpi (GtkCssStyle *style)
-{
-  return _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_DPI), 96);
-}
-
-/* XXX: Kinda bad to have that machinery here, nobody expects vital font
- * size code to appear in gtkcssvalueenum.c.
- */
-#define DEFAULT_FONT_SIZE_PT 10
-
-double
-gtk_css_font_size_get_default_px (GtkStyleProvider *provider,
-                                  GtkCssStyle      *style)
-{
-  GtkSettings *settings;
-  int font_size;
-
-  settings = gtk_style_provider_get_settings (provider);
-  if (settings == NULL)
-    return DEFAULT_FONT_SIZE_PT * get_dpi (style) / 72.0;
-
-  font_size = gtk_settings_get_font_size (settings);
-  if (font_size == 0)
-    return DEFAULT_FONT_SIZE_PT * get_dpi (style) / 72.0;
-  else if (gtk_settings_get_font_size_is_absolute (settings))
-    return (double) font_size / PANGO_SCALE;
-  else
-    return ((double) font_size / PANGO_SCALE) * get_dpi (style) / 72.0;
-}
-
-static GtkCssValue *
-gtk_css_value_font_size_compute (GtkCssValue      *value,
-                                 guint             property_id,
-                                 GtkStyleProvider *provider,
-                                 GtkCssStyle      *style,
-                                 GtkCssStyle      *parent_style)
-{
-  double font_size;
-
-  switch (value->value)
-    {
-    case GTK_CSS_FONT_SIZE_XX_SMALL:
-      font_size = gtk_css_font_size_get_default_px (provider, style) * 3. / 5;
-      break;
-    case GTK_CSS_FONT_SIZE_X_SMALL:
-      font_size = gtk_css_font_size_get_default_px (provider, style) * 3. / 4;
-      break;
-    case GTK_CSS_FONT_SIZE_SMALL:
-      font_size = gtk_css_font_size_get_default_px (provider, style) * 8. / 9;
-      break;
-    default:
-      g_assert_not_reached ();
-      /* fall thru */
-    case GTK_CSS_FONT_SIZE_MEDIUM:
-      font_size = gtk_css_font_size_get_default_px (provider, style);
-      break;
-    case GTK_CSS_FONT_SIZE_LARGE:
-      font_size = gtk_css_font_size_get_default_px (provider, style) * 6. / 5;
-      break;
-    case GTK_CSS_FONT_SIZE_X_LARGE:
-      font_size = gtk_css_font_size_get_default_px (provider, style) * 3. / 2;
-      break;
-    case GTK_CSS_FONT_SIZE_XX_LARGE:
-      font_size = gtk_css_font_size_get_default_px (provider, style) * 2;
-      break;
-    case GTK_CSS_FONT_SIZE_SMALLER:
-      if (parent_style)
-        font_size = _gtk_css_number_value_get (gtk_css_style_get_value (parent_style, 
GTK_CSS_PROPERTY_FONT_SIZE), 100);
-      else
-        font_size = gtk_css_font_size_get_default_px (provider, style);
-      /* XXX: This is what WebKit does... */
-      font_size /= 1.2;
-      break;
-    case GTK_CSS_FONT_SIZE_LARGER:
-      if (parent_style)
-        font_size = _gtk_css_number_value_get (gtk_css_style_get_value (parent_style, 
GTK_CSS_PROPERTY_FONT_SIZE), 100);
-      else
-        font_size = gtk_css_font_size_get_default_px (provider, style);
-      /* XXX: This is what WebKit does... */
-      font_size *= 1.2;
-      break;
-  }
-
-  return _gtk_css_number_value_new (font_size, GTK_CSS_PX);
-}
-
-static const GtkCssValueClass GTK_CSS_VALUE_FONT_SIZE = {
-  "GtkCssFontSizeValue",
-  gtk_css_value_enum_free,
-  gtk_css_value_font_size_compute,
-  gtk_css_value_enum_equal,
-  gtk_css_value_enum_transition,
-  NULL,
-  NULL,
-  gtk_css_value_enum_print
-};
-
-static GtkCssValue font_size_values[] = {
-  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_SMALLER, "smaller" },
-  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_LARGER, "larger" },
-  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_XX_SMALL, "xx-small" },
-  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_X_SMALL, "x-small" },
-  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_SMALL, "small" },
-  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_MEDIUM, "medium" },
-  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_LARGE, "large" },
-  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_X_LARGE, "x-large" },
-  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_XX_LARGE, "xx-large" }
-};
-
-GtkCssValue *
-_gtk_css_font_size_value_new (GtkCssFontSize font_size)
-{
-  g_return_val_if_fail (font_size < G_N_ELEMENTS (font_size_values), NULL);
-
-  return _gtk_css_value_ref (&font_size_values[font_size]);
-}
-
-GtkCssValue *
-_gtk_css_font_size_value_try_parse (GtkCssParser *parser)
-{
-  guint i;
-
-  g_return_val_if_fail (parser != NULL, NULL);
-
-  for (i = 0; i < G_N_ELEMENTS (font_size_values); i++)
-    {
-      if (gtk_css_parser_try_ident (parser, font_size_values[i].name))
-        return _gtk_css_value_ref (&font_size_values[i]);
-    }
-
-  return NULL;
-}
-
-GtkCssFontSize
-_gtk_css_font_size_value_get (const GtkCssValue *value)
-{
-  g_return_val_if_fail (value->class == &GTK_CSS_VALUE_FONT_SIZE, GTK_CSS_FONT_SIZE_MEDIUM);
-
-  return value->value;
-}
-
 /* PangoStyle */
 
 static const GtkCssValueClass GTK_CSS_VALUE_FONT_STYLE = {
diff --git a/gtk/gtkcssenumvalueprivate.h b/gtk/gtkcssenumvalueprivate.h
index 22bab5f1f4..422b49bc13 100644
--- a/gtk/gtkcssenumvalueprivate.h
+++ b/gtk/gtkcssenumvalueprivate.h
@@ -35,12 +35,6 @@ GtkCssValue *   _gtk_css_border_style_value_new       (GtkBorderStyle     border
 GtkCssValue *   _gtk_css_border_style_value_try_parse (GtkCssParser      *parser);
 GtkBorderStyle  _gtk_css_border_style_value_get       (const GtkCssValue *value);
 
-GtkCssValue *   _gtk_css_font_size_value_new          (GtkCssFontSize     size);
-GtkCssValue *   _gtk_css_font_size_value_try_parse    (GtkCssParser      *parser);
-GtkCssFontSize  _gtk_css_font_size_value_get          (const GtkCssValue *value);
-double          gtk_css_font_size_get_default_px      (GtkStyleProvider  *provider,
-                                                       GtkCssStyle       *style);
-
 GtkCssValue *   _gtk_css_font_style_value_new         (PangoStyle         style);
 GtkCssValue *   _gtk_css_font_style_value_try_parse   (GtkCssParser      *parser);
 PangoStyle      _gtk_css_font_style_value_get         (const GtkCssValue *value);
diff --git a/gtk/gtkcssfontsizevalue.c b/gtk/gtkcssfontsizevalue.c
new file mode 100644
index 0000000000..e7acc6c253
--- /dev/null
+++ b/gtk/gtkcssfontsizevalue.c
@@ -0,0 +1,285 @@
+/* GTK - The GIMP Toolkit
+ * Copyright © 2016 Benjamin Otte <otte gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gtkcssfontsizevalueprivate.h"
+#include "gtkcssdimensionvalueprivate.h"
+#include "gtkcssstyleprivate.h"
+#include "gtkstyleproviderprivate.h"
+#include "gtksettingsprivate.h"
+
+#include <string.h>
+
+#define DEFAULT_FONT_SIZE_PT 10
+
+struct _GtkCssValue {
+  GTK_CSS_VALUE_BASE
+
+  guint is_symbolic: 1;
+  union {
+    struct {
+      GtkCssFontSize value;
+      const char *name;
+    } symbolic;
+    GtkCssValue *number;
+  };
+};
+
+static void
+gtk_css_value_font_size_free (GtkCssValue *value)
+{
+  if (!value->is_symbolic)
+    _gtk_css_value_unref (value->number);
+
+  g_slice_free (GtkCssValue, value);
+}
+
+static double
+get_dpi (GtkCssStyle *style)
+{
+  return _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_DPI), 96);
+}
+
+double
+gtk_css_font_size_get_default_px (GtkStyleProvider *provider,
+                                  GtkCssStyle      *style)
+{
+  GtkSettings *settings;
+  int font_size;
+
+  settings = gtk_style_provider_get_settings (provider);
+  if (settings == NULL)
+    return DEFAULT_FONT_SIZE_PT * get_dpi (style) / 72.0;
+
+  font_size = gtk_settings_get_font_size (settings);
+  if (font_size == 0)
+    return DEFAULT_FONT_SIZE_PT * get_dpi (style) / 72.0;
+  else if (gtk_settings_get_font_size_is_absolute (settings))
+    return (double) font_size / PANGO_SCALE;
+  else
+    return ((double) font_size / PANGO_SCALE) * get_dpi (style) / 72.0;
+}
+
+static double
+get_base_font_size_px (guint             property_id,
+                       GtkStyleProvider *provider,
+                       GtkCssStyle      *style,
+                       GtkCssStyle      *parent_style)
+{
+  if (property_id == GTK_CSS_PROPERTY_FONT_SIZE)
+    {
+      if (parent_style)
+        return _gtk_css_number_value_get (gtk_css_style_get_value (parent_style, 
GTK_CSS_PROPERTY_FONT_SIZE), 100);
+      else
+        return gtk_css_font_size_get_default_px (provider, style);
+    }
+
+  return _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_SIZE), 100);
+}
+
+static GtkCssValue *
+gtk_css_value_font_size_compute (GtkCssValue      *value,
+                                 guint             property_id,
+                                 GtkStyleProvider *provider,
+                                 GtkCssStyle      *style,
+                                 GtkCssStyle      *parent_style)
+{
+
+  if (value->is_symbolic)
+    {
+      double font_size;
+
+      switch (value->symbolic.value)
+        {
+        case GTK_CSS_FONT_SIZE_XX_SMALL:
+          font_size = gtk_css_font_size_get_default_px (provider, style) * 3. / 5;
+          break;
+        case GTK_CSS_FONT_SIZE_X_SMALL:
+          font_size = gtk_css_font_size_get_default_px (provider, style) * 3. / 4;
+          break;
+        case GTK_CSS_FONT_SIZE_SMALL:
+          font_size = gtk_css_font_size_get_default_px (provider, style) * 8. / 9;
+          break;
+        default:
+          g_assert_not_reached ();
+          /* fall thru */
+        case GTK_CSS_FONT_SIZE_MEDIUM:
+          font_size = gtk_css_font_size_get_default_px (provider, style);
+          break;
+        case GTK_CSS_FONT_SIZE_LARGE:
+          font_size = gtk_css_font_size_get_default_px (provider, style) * 6. / 5;
+          break;
+        case GTK_CSS_FONT_SIZE_X_LARGE:
+          font_size = gtk_css_font_size_get_default_px (provider, style) * 3. / 2;
+          break;
+        case GTK_CSS_FONT_SIZE_XX_LARGE:
+          font_size = gtk_css_font_size_get_default_px (provider, style) * 2;
+          break;
+        case GTK_CSS_FONT_SIZE_SMALLER:
+          if (parent_style)
+            font_size = gtk_css_font_size_value_get_value (gtk_css_style_get_value (parent_style, 
GTK_CSS_PROPERTY_FONT_SIZE));
+          else
+            font_size = gtk_css_font_size_get_default_px (provider, style);
+          /* XXX: This is what WebKit does... */
+          font_size /= 1.2;
+          break;
+        case GTK_CSS_FONT_SIZE_LARGER:
+          if (parent_style)
+            font_size = gtk_css_font_size_value_get_value (gtk_css_style_get_value (parent_style, 
GTK_CSS_PROPERTY_FONT_SIZE));
+          else
+            font_size = gtk_css_font_size_get_default_px (provider, style);
+          /* XXX: This is what WebKit does... */
+          font_size *= 1.2;
+          break;
+        }
+      return gtk_css_font_size_value_new (_gtk_css_number_value_new (font_size, GTK_CSS_PX));
+    }
+
+  if (gtk_css_number_value_has_percent (value->number) &&
+      property_id == GTK_CSS_PROPERTY_FONT_SIZE)
+    {
+      GtkCssValue *size_value = gtk_css_dimension_value_new (_gtk_css_number_value_get (value->number, 100) 
/ 100.0 *
+                                          get_base_font_size_px (property_id, provider, style, parent_style),
+                                          GTK_CSS_PX);
+
+      return gtk_css_font_size_value_new (size_value);
+    }
+
+  return gtk_css_font_size_value_new (_gtk_css_value_compute (value->number,
+                                                              property_id,
+                                                              provider,
+                                                              style,
+                                                              parent_style));
+}
+
+static gboolean
+gtk_css_value_font_size_equal (const GtkCssValue *value1,
+                               const GtkCssValue *value2)
+{
+  if (value1->is_symbolic != value2->is_symbolic)
+    return FALSE;
+
+  if (value1->is_symbolic)
+    return value1->symbolic.value == value2->symbolic.value;
+
+  return _gtk_css_value_equal0 (value1->number, value2->number);
+}
+
+static GtkCssValue *
+gtk_css_value_font_size_transition (GtkCssValue *start,
+                                    GtkCssValue *end,
+                                    guint        property_id,
+                                    double       progress)
+{
+  /* Can't transition symbolic values */
+  if (start->is_symbolic || end->is_symbolic)
+    return NULL;
+
+  return gtk_css_font_size_value_new (_gtk_css_value_transition (start->number,
+                                                                 end->number,
+                                                                 property_id,
+                                                                 progress));
+}
+
+static void
+gtk_css_value_font_size_print (const GtkCssValue *value,
+                               GString           *string)
+{
+  if (value->is_symbolic)
+    {
+      g_string_append (string, value->symbolic.name);
+      return;
+    }
+
+  _gtk_css_value_print (value->number, string);
+}
+
+static const GtkCssValueClass GTK_CSS_VALUE_FONT_SIZE = {
+  "GtkCssFontSizeValue",
+  gtk_css_value_font_size_free,
+  gtk_css_value_font_size_compute,
+  gtk_css_value_font_size_equal,
+  gtk_css_value_font_size_transition,
+  NULL,
+  NULL,
+  gtk_css_value_font_size_print
+};
+
+GtkCssValue *
+gtk_css_font_size_value_new (GtkCssValue *number)
+{
+  GtkCssValue *result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_FONT_SIZE);
+
+  result->is_symbolic = FALSE;
+  result->number = number;
+  result->is_computed = gtk_css_value_is_computed (number);
+
+  return result;
+}
+
+static GtkCssValue font_size_values[] = {
+  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, TRUE, .symbolic = { GTK_CSS_FONT_SIZE_SMALLER, "smaller" }},
+  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, TRUE, .symbolic = { GTK_CSS_FONT_SIZE_LARGER, "larger" }},
+  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, TRUE, .symbolic = { GTK_CSS_FONT_SIZE_XX_SMALL, "xx-small" }},
+  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, TRUE, .symbolic = { GTK_CSS_FONT_SIZE_X_SMALL, "x-small" }},
+  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, TRUE, .symbolic = { GTK_CSS_FONT_SIZE_SMALL, "small" }},
+  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, TRUE, .symbolic = { GTK_CSS_FONT_SIZE_MEDIUM, "medium" }},
+  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, TRUE, .symbolic = { GTK_CSS_FONT_SIZE_LARGE, "large" }},
+  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, TRUE, .symbolic = { GTK_CSS_FONT_SIZE_X_LARGE, "x-large" }},
+  { &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, TRUE, .symbolic = { GTK_CSS_FONT_SIZE_XX_LARGE, "xx-large" }}
+};
+
+GtkCssValue *
+gtk_css_font_size_value_new_enum (GtkCssFontSize font_size)
+{
+  return _gtk_css_value_ref (&font_size_values[font_size]);
+}
+
+GtkCssValue *
+gtk_css_font_size_value_parse (GtkCssParser *parser)
+{
+  guint i;
+  GtkCssValue *number;
+
+  /* Try enum values first */
+  for (i = 0; i < G_N_ELEMENTS (font_size_values); i++)
+    {
+      if (gtk_css_parser_try_ident (parser, font_size_values[i].symbolic.name))
+        return _gtk_css_value_ref (&font_size_values[i]);
+    }
+
+  /* Then try numbers */
+  number = _gtk_css_number_value_parse (parser,
+                                        GTK_CSS_PARSE_LENGTH |
+                                        GTK_CSS_PARSE_PERCENT |
+                                        GTK_CSS_POSITIVE_ONLY);
+
+  if (number)
+    return gtk_css_font_size_value_new (number);
+
+  return NULL;
+}
+
+double
+gtk_css_font_size_value_get_value (GtkCssValue *value)
+{
+  if (value->is_symbolic)
+    return 0;
+
+  return _gtk_css_number_value_get (value->number, 100);
+}
diff --git a/gtk/gtkcssfontsizevalueprivate.h b/gtk/gtkcssfontsizevalueprivate.h
new file mode 100644
index 0000000000..7096d7e24f
--- /dev/null
+++ b/gtk/gtkcssfontsizevalueprivate.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2016 Benjamin Otte <otte gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_CSS_FONT_SIZE_VALUE_PRIVATE_H__
+#define __GTK_CSS_FONT_SIZE_VALUE_PRIVATE_H__
+
+#include "gtkcssnumbervalueprivate.h"
+
+G_BEGIN_DECLS
+
+GtkCssValue *   gtk_css_font_size_value_new        (GtkCssValue    *number);
+GtkCssValue *   gtk_css_font_size_value_new_enum   (GtkCssFontSize  font_size);
+
+GtkCssValue *   gtk_css_font_size_value_parse      (GtkCssParser   *parser);
+double          gtk_css_font_size_value_get_value  (GtkCssValue      *value);
+
+double          gtk_css_font_size_get_default_px   (GtkStyleProvider *provider,
+                                                    GtkCssStyle      *style);
+
+G_END_DECLS
+
+#endif /* __GTK_CSS_FONT_SIZE_VALUE_PRIVATE_H__ */
diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c
index 290c6afdd0..528fe5bb15 100644
--- a/gtk/gtkcssshorthandpropertyimpl.c
+++ b/gtk/gtkcssshorthandpropertyimpl.c
@@ -38,6 +38,7 @@
 #include "gtkcssrepeatvalueprivate.h"
 #include "gtkcssstringvalueprivate.h"
 #include "gtkcssvalueprivate.h"
+#include "gtkcssfontsizevalueprivate.h"
 #include "gtktypebuiltins.h"
 
 /* this is in case round() is not provided by the compiler, 
@@ -1159,7 +1160,7 @@ pack_font_description (GtkCssShorthandProperty *shorthand,
 
   v = (* query_func) (GTK_CSS_PROPERTY_FONT_SIZE, query_data);
   if (v)
-    pango_font_description_set_absolute_size (description, round (_gtk_css_number_value_get (v, 100) * 
PANGO_SCALE));
+    pango_font_description_set_absolute_size (description, round (gtk_css_font_size_value_get_value (v) * 
PANGO_SCALE));
 
   v = (* query_func) (GTK_CSS_PROPERTY_FONT_STYLE, query_data);
   if (v)
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 7a5bd8a9ee..f1103a578a 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -57,6 +57,7 @@
 #include "gtkcssstringvalueprivate.h"
 #include "gtkcsstransformvalueprivate.h"
 #include "gtkcssfontvariationsvalueprivate.h"
+#include "gtkcssfontsizevalueprivate.h"
 #include "gtktypebuiltins.h"
 
 /*** REGISTRATION ***/
@@ -695,21 +696,6 @@ dpi_parse (GtkCssStyleProperty *property,
   return _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER);
 }
 
-GtkCssValue *
-gtk_css_font_size_value_parse (GtkCssParser *parser)
-{
-  GtkCssValue *value;
-
-  value = _gtk_css_font_size_value_try_parse (parser);
-  if (value)
-    return value;
-
-  return _gtk_css_number_value_parse (parser,
-                                      GTK_CSS_PARSE_LENGTH
-                                      | GTK_CSS_PARSE_PERCENT
-                                      | GTK_CSS_POSITIVE_ONLY);
-}
-
 static GtkCssValue *
 font_size_parse (GtkCssStyleProperty *property,
                  GtkCssParser        *parser)
@@ -951,7 +937,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_TEXT_SIZE,
                                           font_size_parse,
                                           query_font_size,
-                                          _gtk_css_font_size_value_new (GTK_CSS_FONT_SIZE_MEDIUM));
+                                          gtk_css_font_size_value_new_enum (GTK_CSS_FONT_SIZE_MEDIUM));
   gtk_css_style_property_register        ("-gtk-icon-theme",
                                           GTK_CSS_PROPERTY_ICON_THEME,
                                           G_TYPE_NONE,
diff --git a/gtk/gtkcssstylepropertyprivate.h b/gtk/gtkcssstylepropertyprivate.h
index 005ada4e70..48e2f61bbd 100644
--- a/gtk/gtkcssstylepropertyprivate.h
+++ b/gtk/gtkcssstylepropertyprivate.h
@@ -82,7 +82,6 @@ void                    _gtk_css_style_property_print_value     (GtkCssStyleProp
 
 /* XXX - find a better place for these */
 GtkCssValue * gtk_css_font_family_value_parse (GtkCssParser *parser);
-GtkCssValue * gtk_css_font_size_value_parse   (GtkCssParser *parser);
 
 G_END_DECLS
 
diff --git a/gtk/meson.build b/gtk/meson.build
index 000bbb0dcd..1dc1f6646d 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -54,6 +54,7 @@ gtk_private_sources = files([
   'gtkcssenumvalue.c',
   'gtkcssfiltervalue.c',
   'gtkcssfontfeaturesvalue.c',
+  'gtkcssfontsizevalue.c',
   'gtkcssfontvariationsvalue.c',
   'gtkcssiconthemevalue.c',
   'gtkcssimage.c',


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