From 0e7691c12ec2249b80e6f7d46f5e8f2aeecf345a Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 4 Feb 2016 19:37:44 +0100 Subject: [PATCH] css: Add rem unit Good luck, Lapo. --- gtk/gtkcssnumbervalue.c | 9 ++++----- gtk/gtkcssparser.c | 1 + gtk/gtkcsstypesprivate.h | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gtk/gtkcssnumbervalue.c b/gtk/gtkcssnumbervalue.c index 49bd67cd7e..2524d46524 100644 --- a/gtk/gtkcssnumbervalue.c +++ b/gtk/gtkcssnumbervalue.c @@ -117,29 +117,27 @@ gtk_css_value_number_compute (GtkCssValue *number, case GTK_CSS_PC: return _gtk_css_number_value_new (number->value * 96.0 / 72.0 * 12.0, GTK_CSS_PX); - break; case GTK_CSS_IN: return _gtk_css_number_value_new (number->value * 96.0, GTK_CSS_PX); - break; case GTK_CSS_CM: return _gtk_css_number_value_new (number->value * 96.0 * 0.39370078740157477, GTK_CSS_PX); - break; case GTK_CSS_MM: return _gtk_css_number_value_new (number->value * 96.0 * 0.039370078740157477, GTK_CSS_PX); - break; case GTK_CSS_EM: return _gtk_css_number_value_new (number->value * get_base_font_size (property_id, provider, style, parent_style), GTK_CSS_PX); - break; case GTK_CSS_EX: /* for now we pretend ex is half of em */ return _gtk_css_number_value_new (number->value * 0.5 * get_base_font_size (property_id, provider, style, parent_style), GTK_CSS_PX); + case GTK_CSS_REM: + return _gtk_css_number_value_new (number->value * _gtk_css_font_size_get_default (provider), + GTK_CSS_PX); case GTK_CSS_RAD: return _gtk_css_number_value_new (number->value * 360.0 / (2 * G_PI), GTK_CSS_DEG); @@ -191,6 +189,7 @@ gtk_css_value_number_print (const GtkCssValue *number, /* [GTK_CSS_PT] = */ "pt", /* [GTK_CSS_EM] = */ "em", /* [GTK_CSS_EX] = */ "ex", + /* [GTK_CSS_REM] = */ "rem", /* [GTK_CSS_PC] = */ "pc", /* [GTK_CSS_IN] = */ "in", /* [GTK_CSS_CM] = */ "cm", diff --git a/gtk/gtkcssparser.c b/gtk/gtkcssparser.c index 13d81e1792..2c52fb2144 100644 --- a/gtk/gtkcssparser.c +++ b/gtk/gtkcssparser.c @@ -617,6 +617,7 @@ _gtk_css_number_value_parse (GtkCssParser *parser, { "pt", GTK_CSS_PT, GTK_CSS_PARSE_LENGTH }, { "em", GTK_CSS_EM, GTK_CSS_PARSE_LENGTH }, { "ex", GTK_CSS_EX, GTK_CSS_PARSE_LENGTH }, + { "rem", GTK_CSS_REM, GTK_CSS_PARSE_LENGTH }, { "pc", GTK_CSS_PC, GTK_CSS_PARSE_LENGTH }, { "in", GTK_CSS_IN, GTK_CSS_PARSE_LENGTH }, { "cm", GTK_CSS_CM, GTK_CSS_PARSE_LENGTH }, diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h index b32c05af4b..dacba6633e 100644 --- a/gtk/gtkcsstypesprivate.h +++ b/gtk/gtkcsstypesprivate.h @@ -348,6 +348,7 @@ typedef enum /*< skip >*/ { GTK_CSS_PT, GTK_CSS_EM, GTK_CSS_EX, + GTK_CSS_REM, GTK_CSS_PC, GTK_CSS_IN, GTK_CSS_CM,