[gtk/wip/css-value-unboxing: 12783/12783] wip: Unbox css values
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/css-value-unboxing: 12783/12783] wip: Unbox css values
- Date: Wed, 14 Sep 2022 04:11:59 +0000 (UTC)
commit 5bbe811090d11840bbd65f46b6f5100b3079ac97
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Sep 13 17:04:19 2022 -0400
wip: Unbox css values
Keep css values unboxed in the values structs, for faster access
to these values, where it makes sense.
gtk/gskpango.c | 8 +-
gtk/gtkboxlayout.c | 10 +-
gtk/gtkbuiltinicon.c | 2 +-
gtk/gtkcellrendererspinner.c | 2 +-
gtk/gtkcellrenderertoggle.c | 2 +-
gtk/gtkcolumnviewcell.c | 22 ++--
gtk/gtkcolumnviewtitle.c | 18 ++-
gtk/gtkcssanimatedstyle.c | 76 ++++++++++++
gtk/gtkcssboxesimplprivate.h | 184 ++++++++---------------------
gtk/gtkcssboxesprivate.h | 16 +--
gtk/gtkcssenumvalue.c | 12 +-
gtk/gtkcssimagerecolor.c | 2 +-
gtk/gtkcssnumbervalue.c | 20 ++--
gtk/gtkcssstaticstyle.c | 269 ++++++++++++++++++++++++++++++++++++++----
gtk/gtkcssstyle.c | 53 +++++----
gtk/gtkcssstyleprivate.h | 44 +++++++
gtk/gtkcsstypesprivate.h | 7 ++
gtk/gtkflowbox.c | 4 +-
gtk/gtkgridlayout.c | 11 +-
gtk/gtkiconhelper.c | 7 +-
gtk/gtkicontheme.c | 5 +-
gtk/gtklabel.c | 2 +-
gtk/gtknative.c | 44 +++----
gtk/gtkpicture.c | 2 +-
gtk/gtkpopover.c | 20 ++--
gtk/gtkrender.c | 6 +-
gtk/gtkrenderbackground.c | 2 +-
gtk/gtkrenderborder.c | 58 ++++-----
gtk/gtksizerequest.c | 56 ++++-----
gtk/gtksnapshot.c | 6 +-
gtk/gtkspinner.c | 2 +-
gtk/gtkstylecontext.c | 31 ++---
gtk/gtktexthandle.c | 8 +-
gtk/gtktextlayout.c | 7 +-
gtk/gtktextutil.c | 6 +-
gtk/gtktextview.c | 10 +-
gtk/gtktreeview.c | 16 +--
gtk/gtkwidget.c | 44 ++++---
gtk/gtkwindow.c | 20 ++--
gtk/inspector/layoutoverlay.c | 42 ++++---
40 files changed, 674 insertions(+), 482 deletions(-)
---
diff --git a/gtk/gskpango.c b/gtk/gskpango.c
index e96c84a2fc..737ef21be5 100644
--- a/gtk/gskpango.c
+++ b/gtk/gskpango.c
@@ -342,20 +342,16 @@ gsk_pango_renderer_prepare_run (PangoRenderer *renderer,
GTK_IS_TEXT_VIEW (crenderer->widget))
{
GtkCssNode *node;
- GtkCssValue *value;
node = gtk_text_view_get_selection_node ((GtkTextView *)crenderer->widget);
- value = gtk_css_node_get_style (node)->core->color;
- fg_rgba = gtk_css_color_value_get_rgba (value);
+ fg_rgba = >k_css_node_get_style (node)->core->_color;
}
else if (crenderer->state == GSK_PANGO_RENDERER_CURSOR && gtk_widget_has_focus (crenderer->widget))
{
GtkCssNode *node;
- GtkCssValue *value;
node = gtk_widget_get_css_node (crenderer->widget);
- value = gtk_css_node_get_style (node)->background->background_color;
- fg_rgba = gtk_css_color_value_get_rgba (value);
+ fg_rgba = >k_css_node_get_style (node)->background->_background_color;
}
else
fg_rgba = appearance->fg_rgba;
diff --git a/gtk/gtkboxlayout.c b/gtk/gtkboxlayout.c
index 275e0371c9..2fbaa973aa 100644
--- a/gtk/gtkboxlayout.c
+++ b/gtk/gtkboxlayout.c
@@ -188,16 +188,8 @@ get_spacing (GtkBoxLayout *self,
GtkCssNode *node)
{
GtkCssStyle *style = gtk_css_node_get_style (node);
- GtkCssValue *border_spacing;
- int css_spacing;
- border_spacing = style->size->border_spacing;
- if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
- css_spacing = _gtk_css_position_value_get_x (border_spacing, 100);
- else
- css_spacing = _gtk_css_position_value_get_y (border_spacing, 100);
-
- return css_spacing + self->spacing;
+ return style->size->_border_spacing[self->orientation] + self->spacing;
}
static void
diff --git a/gtk/gtkbuiltinicon.c b/gtk/gtkbuiltinicon.c
index 642b77bd18..cdb5ed4e21 100644
--- a/gtk/gtkbuiltinicon.c
+++ b/gtk/gtkbuiltinicon.c
@@ -84,7 +84,7 @@ gtk_builtin_icon_measure (GtkWidget *widget,
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
- *minimum = *natural = _gtk_css_number_value_get (style->icon->icon_size, 100);
+ *minimum = *natural = style->icon->_icon_size;
}
static void
diff --git a/gtk/gtkcellrendererspinner.c b/gtk/gtkcellrendererspinner.c
index 52559f83a0..48cb22b378 100644
--- a/gtk/gtkcellrendererspinner.c
+++ b/gtk/gtkcellrendererspinner.c
@@ -247,7 +247,7 @@ gtk_cell_renderer_spinner_update_size (GtkCellRendererSpinner *cell,
node = gtk_style_context_get_node (context);
gtk_icon_size_set_style_classes (node, priv->icon_size);
style = gtk_css_node_get_style (node);
- priv->size = _gtk_css_number_value_get (style->icon->icon_size, 100);
+ priv->size = style->icon->_icon_size;
gtk_style_context_restore (context);
}
diff --git a/gtk/gtkcellrenderertoggle.c b/gtk/gtkcellrenderertoggle.c
index 2a4c9669a9..1404e5b02a 100644
--- a/gtk/gtkcellrenderertoggle.c
+++ b/gtk/gtkcellrenderertoggle.c
@@ -364,7 +364,7 @@ static int
calc_indicator_size (GtkStyleContext *context)
{
GtkCssStyle *style = gtk_style_context_lookup_style (context);
- return _gtk_css_number_value_get (style->icon->icon_size, 100);
+ return style->icon->_icon_size;
}
static void
diff --git a/gtk/gtkcolumnviewcell.c b/gtk/gtkcolumnviewcell.c
index 1ada1b4292..eff3a1f976 100644
--- a/gtk/gtkcolumnviewcell.c
+++ b/gtk/gtkcolumnviewcell.c
@@ -47,15 +47,13 @@ struct _GtkColumnViewCellClass
G_DEFINE_TYPE (GtkColumnViewCell, gtk_column_view_cell, GTK_TYPE_LIST_ITEM_WIDGET)
-static int
-get_number (GtkCssValue *value)
+static inline int
+ceil_or_floor (float d)
{
- double d = _gtk_css_number_value_get (value, 100);
-
if (d < 1)
- return ceil (d);
+ return ceilf (d);
else
- return floor (d);
+ return floorf (d);
}
static int
@@ -67,12 +65,12 @@ unadjust_width (GtkWidget *widget,
int css_extra;
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
- css_extra = get_number (style->size->margin_left) +
- get_number (style->size->margin_right) +
- get_number (style->border->border_left_width) +
- get_number (style->border->border_right_width) +
- get_number (style->size->padding_left) +
- get_number (style->size->padding_right);
+ css_extra = ceil_or_floor (style->size->_margin[GTK_CSS_LEFT]) +
+ ceil_or_floor (style->size->_margin[GTK_CSS_RIGHT]) +
+ ceil_or_floor (style->border->_border_width[GTK_CSS_LEFT]) +
+ ceil_or_floor (style->border->_border_width[GTK_CSS_RIGHT]) +
+ ceil_or_floor (style->size->_padding[GTK_CSS_LEFT]) +
+ ceil_or_floor (style->size->_padding[GTK_CSS_RIGHT]);
widget_margins = widget->priv->margin.left + widget->priv->margin.right;
return MAX (0, width - widget_margins - css_extra);
diff --git a/gtk/gtkcolumnviewtitle.c b/gtk/gtkcolumnviewtitle.c
index e2e57b29fa..192c74ea59 100644
--- a/gtk/gtkcolumnviewtitle.c
+++ b/gtk/gtkcolumnviewtitle.c
@@ -54,11 +54,9 @@ struct _GtkColumnViewTitleClass
G_DEFINE_TYPE (GtkColumnViewTitle, gtk_column_view_title, GTK_TYPE_WIDGET)
-static int
-get_number (GtkCssValue *value)
+static inline int
+ceil_or_floor (float d)
{
- double d = _gtk_css_number_value_get (value, 100);
-
if (d < 1)
return ceil (d);
else
@@ -74,12 +72,12 @@ unadjust_width (GtkWidget *widget,
int css_extra;
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
- css_extra = get_number (style->size->margin_left) +
- get_number (style->size->margin_right) +
- get_number (style->border->border_left_width) +
- get_number (style->border->border_right_width) +
- get_number (style->size->padding_left) +
- get_number (style->size->padding_right);
+ css_extra = ceil_or_floor (style->size->_margin[GTK_CSS_LEFT]) +
+ ceil_or_floor (style->size->_margin[GTK_CSS_RIGHT]) +
+ ceil_or_floor (style->border->_border_width[GTK_CSS_LEFT]) +
+ ceil_or_floor (style->border->_border_width[GTK_CSS_RIGHT]) +
+ ceil_or_floor (style->size->_padding[GTK_CSS_LEFT]) +
+ ceil_or_floor (style->size->_padding[GTK_CSS_RIGHT]);
widget_margins = widget->priv->margin.left + widget->priv->margin.right;
return MAX (0, width - widget_margins - css_extra);
diff --git a/gtk/gtkcssanimatedstyle.c b/gtk/gtkcssanimatedstyle.c
index fdfcf17f1f..c8ce30a412 100644
--- a/gtk/gtkcssanimatedstyle.c
+++ b/gtk/gtkcssanimatedstyle.c
@@ -23,6 +23,9 @@
#include "gtkcssanimationprivate.h"
#include "gtkcssarrayvalueprivate.h"
+#include "gtkcsscolorvalueprivate.h"
+#include "gtkcsscornervalueprivate.h"
+#include "gtkcsspositionvalueprivate.h"
#include "gtkcssdynamicprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "gtkcssinheritvalueprivate.h"
@@ -37,6 +40,7 @@
#include "gtkstyleanimationprivate.h"
#include "gtkstylepropertyprivate.h"
#include "gtkstyleproviderprivate.h"
+#include "gtkcsslineheightvalueprivate.h"
G_DEFINE_TYPE (GtkCssAnimatedStyle, gtk_css_animated_style, GTK_TYPE_CSS_STYLE)
@@ -120,6 +124,9 @@ gtk_css_animated_style_init (GtkCssAnimatedStyle *style)
}
#define DEFINE_UNSHARE(TYPE, NAME) \
+\
+extern void gtk_css_ ## NAME ## _values_unbox (TYPE *values); \
+\
static inline void \
unshare_ ## NAME (GtkCssAnimatedStyle *animated) \
{ \
@@ -128,6 +135,7 @@ unshare_ ## NAME (GtkCssAnimatedStyle *animated) \
{ \
gtk_css_values_unref ((GtkCssValues *)style->NAME); \
style->NAME = (TYPE *)gtk_css_values_copy ((GtkCssValues *)animated->style->NAME); \
+ gtk_css_ ## NAME ## _values_unbox (style->NAME); \
} \
}
@@ -167,14 +175,17 @@ gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *animated,
case GTK_CSS_PROPERTY_COLOR:
unshare_core (animated);
gtk_css_take_value (&style->core->color, value);
+ style->core->_color = *gtk_css_color_value_get_rgba (style->core->color);
break;
case GTK_CSS_PROPERTY_DPI:
unshare_core (animated);
gtk_css_take_value (&style->core->dpi, value);
+ style->core->_dpi = _gtk_css_number_value_get (style->core->dpi, 96);
break;
case GTK_CSS_PROPERTY_FONT_SIZE:
unshare_core (animated);
gtk_css_take_value (&style->core->font_size, value);
+ style->core->_font_size = _gtk_css_number_value_get (style->core->font_size, 100);
break;
case GTK_CSS_PROPERTY_ICON_PALETTE:
unshare_core (animated);
@@ -183,6 +194,7 @@ gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *animated,
case GTK_CSS_PROPERTY_BACKGROUND_COLOR:
unshare_background (animated);
gtk_css_take_value (&style->background->background_color, value);
+ style->background->_background_color = *gtk_css_color_value_get_rgba
(style->background->background_color);
break;
case GTK_CSS_PROPERTY_FONT_FAMILY:
unshare_font (animated);
@@ -191,66 +203,83 @@ gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *animated,
case GTK_CSS_PROPERTY_FONT_STYLE:
unshare_font (animated);
gtk_css_take_value (&style->font->font_style, value);
+ style->font->_font_style = _gtk_css_font_style_value_get (style->font->font_style);
break;
case GTK_CSS_PROPERTY_FONT_WEIGHT:
unshare_font (animated);
gtk_css_take_value (&style->font->font_weight, value);
+ style->font->_font_weight = _gtk_css_number_value_get (style->font->font_weight, 100);
break;
case GTK_CSS_PROPERTY_FONT_STRETCH:
unshare_font (animated);
gtk_css_take_value (&style->font->font_stretch, value);
+ style->font->_font_stretch = _gtk_css_font_stretch_value_get (style->font->font_stretch);
break;
case GTK_CSS_PROPERTY_LETTER_SPACING:
unshare_font (animated);
gtk_css_take_value (&style->font->letter_spacing, value);
+ style->font->_letter_spacing = _gtk_css_number_value_get (style->font->letter_spacing, 100);
break;
case GTK_CSS_PROPERTY_LINE_HEIGHT:
unshare_font (animated);
gtk_css_take_value (&style->font->line_height, value);
+ style->font->_line_height = gtk_css_line_height_value_get (style->font->line_height);
break;
case GTK_CSS_PROPERTY_TEXT_DECORATION_LINE:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->text_decoration_line, value);
+ style->font_variant->_text_decoration_line = _gtk_css_text_decoration_line_value_get
(style->font_variant->text_decoration_line);
break;
case GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->text_decoration_color, value);
+ if (style->font_variant->text_decoration_color)
+ style->font_variant->_text_decoration_color = *gtk_css_color_value_get_rgba
(style->font_variant->text_decoration_color);
break;
case GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->text_decoration_style, value);
+ style->font_variant->_text_decoration_style = _gtk_css_text_decoration_style_value_get
(style->font_variant->text_decoration_style);
break;
case GTK_CSS_PROPERTY_TEXT_TRANSFORM:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->text_transform, value);
+ style->font_variant->_text_transform = _gtk_css_text_transform_value_get
(style->font_variant->text_transform);
break;
case GTK_CSS_PROPERTY_FONT_KERNING:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->font_kerning, value);
+ style->font_variant->_font_kerning = _gtk_css_font_kerning_value_get
(style->font_variant->font_kerning);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->font_variant_ligatures, value);
+ style->font_variant->_font_variant_ligatures = _gtk_css_font_variant_ligature_value_get
(style->font_variant->font_variant_ligatures);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_POSITION:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->font_variant_position, value);
+ style->font_variant->_font_variant_position = _gtk_css_font_variant_position_value_get
(style->font_variant->font_variant_position);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_CAPS:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->font_variant_caps, value);
+ style->font_variant->_font_variant_caps = _gtk_css_font_variant_caps_value_get
(style->font_variant->font_variant_caps);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->font_variant_numeric, value);
+ style->font_variant->_font_variant_numeric = _gtk_css_font_variant_numeric_value_get
(style->font_variant->font_variant_numeric);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->font_variant_alternates, value);
+ style->font_variant->_font_variant_alternates = _gtk_css_font_variant_alternate_value_get
(style->font_variant->font_variant_alternates);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->font_variant_east_asian, value);
+ style->font_variant->_font_variant_east_asian = _gtk_css_font_variant_east_asian_value_get
(style->font_variant->font_variant_east_asian);
break;
case GTK_CSS_PROPERTY_TEXT_SHADOW:
unshare_font (animated);
@@ -263,94 +292,121 @@ gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *animated,
case GTK_CSS_PROPERTY_MARGIN_TOP:
unshare_size (animated);
gtk_css_take_value (&style->size->margin_top, value);
+ style->size->_margin[GTK_CSS_TOP] = _gtk_css_number_value_get (style->size->margin_top, 100);
break;
case GTK_CSS_PROPERTY_MARGIN_LEFT:
unshare_size (animated);
gtk_css_take_value (&style->size->margin_left, value);
+ style->size->_margin[GTK_CSS_LEFT] = _gtk_css_number_value_get (style->size->margin_left, 100);
break;
case GTK_CSS_PROPERTY_MARGIN_BOTTOM:
unshare_size (animated);
gtk_css_take_value (&style->size->margin_bottom, value);
+ style->size->_margin[GTK_CSS_BOTTOM] = _gtk_css_number_value_get (style->size->margin_bottom, 100);
break;
case GTK_CSS_PROPERTY_MARGIN_RIGHT:
unshare_size (animated);
gtk_css_take_value (&style->size->margin_right, value);
+ style->size->_margin[GTK_CSS_RIGHT] = _gtk_css_number_value_get (style->size->margin_right, 100);
break;
case GTK_CSS_PROPERTY_PADDING_TOP:
unshare_size (animated);
gtk_css_take_value (&style->size->padding_top, value);
+ style->size->_padding[GTK_CSS_TOP] = _gtk_css_number_value_get (style->size->padding_top, 100);
break;
case GTK_CSS_PROPERTY_PADDING_LEFT:
unshare_size (animated);
gtk_css_take_value (&style->size->padding_left, value);
+ style->size->_padding[GTK_CSS_LEFT] = _gtk_css_number_value_get (style->size->padding_left, 100);
break;
case GTK_CSS_PROPERTY_PADDING_BOTTOM:
unshare_size (animated);
gtk_css_take_value (&style->size->padding_bottom, value);
+ style->size->_padding[GTK_CSS_BOTTOM] = _gtk_css_number_value_get (style->size->padding_bottom, 100);
break;
case GTK_CSS_PROPERTY_PADDING_RIGHT:
unshare_size (animated);
gtk_css_take_value (&style->size->padding_right, value);
+ style->size->_padding[GTK_CSS_RIGHT] = _gtk_css_number_value_get (style->size->padding_right, 100);
break;
case GTK_CSS_PROPERTY_BORDER_TOP_STYLE:
unshare_border (animated);
gtk_css_take_value (&style->border->border_top_style, value);
+ style->border->_border_style[GTK_CSS_TOP] = _gtk_css_border_style_value_get
(style->border->border_top_style);
break;
case GTK_CSS_PROPERTY_BORDER_TOP_WIDTH:
unshare_border (animated);
gtk_css_take_value (&style->border->border_top_width, value);
+ style->border->_border_width[GTK_CSS_TOP] = _gtk_css_number_value_get
(style->border->border_top_width, 100);
break;
case GTK_CSS_PROPERTY_BORDER_LEFT_STYLE:
unshare_border (animated);
gtk_css_take_value (&style->border->border_left_style, value);
+ style->border->_border_style[GTK_CSS_LEFT] = _gtk_css_border_style_value_get
(style->border->border_left_style);
break;
case GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH:
unshare_border (animated);
gtk_css_take_value (&style->border->border_left_width, value);
+ style->border->_border_width[GTK_CSS_LEFT] = _gtk_css_number_value_get
(style->border->border_left_width, 100);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE:
unshare_border (animated);
gtk_css_take_value (&style->border->border_bottom_style, value);
+ style->border->_border_style[GTK_CSS_BOTTOM] = _gtk_css_border_style_value_get
(style->border->border_bottom_style);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH:
unshare_border (animated);
gtk_css_take_value (&style->border->border_bottom_width, value);
+ style->border->_border_width[GTK_CSS_BOTTOM] = _gtk_css_number_value_get
(style->border->border_bottom_width, 100);
break;
case GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE:
unshare_border (animated);
gtk_css_take_value (&style->border->border_right_style, value);
+ style->border->_border_style[GTK_CSS_RIGHT] = _gtk_css_border_style_value_get
(style->border->border_right_style);
break;
case GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH:
unshare_border (animated);
gtk_css_take_value (&style->border->border_right_width, value);
+ style->border->_border_width[GTK_CSS_RIGHT] = _gtk_css_number_value_get
(style->border->border_right_width, 100);
break;
case GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS:
unshare_border (animated);
gtk_css_take_value (&style->border->border_top_left_radius, value);
+ style->border->_border_radius[GTK_CSS_TOP_LEFT].width = _gtk_css_corner_value_get_x
(style->border->border_top_left_radius, 100);
+ style->border->_border_radius[GTK_CSS_TOP_LEFT].height = _gtk_css_corner_value_get_y
(style->border->border_top_left_radius, 100);
break;
case GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS:
unshare_border (animated);
gtk_css_take_value (&style->border->border_top_right_radius, value);
+ style->border->_border_radius[GTK_CSS_TOP_RIGHT].width = _gtk_css_corner_value_get_x
(style->border->border_top_right_radius, 100);
+ style->border->_border_radius[GTK_CSS_TOP_RIGHT].height = _gtk_css_corner_value_get_y
(style->border->border_top_right_radius, 100);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS:
unshare_border (animated);
gtk_css_take_value (&style->border->border_bottom_right_radius, value);
+ style->border->_border_radius[GTK_CSS_BOTTOM_RIGHT].width = _gtk_css_corner_value_get_x
(style->border->border_bottom_right_radius, 100);
+ style->border->_border_radius[GTK_CSS_BOTTOM_RIGHT].height = _gtk_css_corner_value_get_y
(style->border->border_bottom_right_radius, 100);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS:
unshare_border (animated);
gtk_css_take_value (&style->border->border_bottom_left_radius, value);
+ style->border->_border_radius[GTK_CSS_BOTTOM_LEFT].width = _gtk_css_corner_value_get_x
(style->border->border_bottom_left_radius, 100);
+ style->border->_border_radius[GTK_CSS_BOTTOM_LEFT].height = _gtk_css_corner_value_get_y
(style->border->border_bottom_left_radius, 100);
break;
case GTK_CSS_PROPERTY_OUTLINE_STYLE:
unshare_outline (animated);
gtk_css_take_value (&style->outline->outline_style, value);
+ style->outline->_outline_style = _gtk_css_border_style_value_get (style->outline->outline_style);
break;
case GTK_CSS_PROPERTY_OUTLINE_WIDTH:
unshare_outline (animated);
gtk_css_take_value (&style->outline->outline_width, value);
+ style->outline->_outline_width = _gtk_css_number_value_get (style->outline->outline_width, 100);
break;
case GTK_CSS_PROPERTY_OUTLINE_OFFSET:
unshare_outline (animated);
gtk_css_take_value (&style->outline->outline_offset, value);
+ style->outline->_outline_offset = _gtk_css_number_value_get (style->outline->outline_offset, 100);
break;
case GTK_CSS_PROPERTY_BACKGROUND_CLIP:
unshare_background (animated);
@@ -371,22 +427,32 @@ gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *animated,
case GTK_CSS_PROPERTY_BORDER_TOP_COLOR:
unshare_border (animated);
gtk_css_take_value (&style->border->border_top_color, value);
+ if (style->border->border_top_color)
+ style->border->_border_color[GTK_CSS_TOP] = *gtk_css_color_value_get_rgba
(style->border->border_top_color);
break;
case GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR:
unshare_border (animated);
gtk_css_take_value (&style->border->border_right_color, value);
+ if (style->border->border_right_color)
+ style->border->_border_color[GTK_CSS_RIGHT] = *gtk_css_color_value_get_rgba
(style->border->border_right_color);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR:
unshare_border (animated);
gtk_css_take_value (&style->border->border_bottom_color, value);
+ if (style->border->border_bottom_color)
+ style->border->_border_color[GTK_CSS_BOTTOM] = *gtk_css_color_value_get_rgba
(style->border->border_bottom_color);
break;
case GTK_CSS_PROPERTY_BORDER_LEFT_COLOR:
unshare_border (animated);
gtk_css_take_value (&style->border->border_left_color, value);
+ if (style->border->border_left_color)
+ style->border->_border_color[GTK_CSS_LEFT] = *gtk_css_color_value_get_rgba
(style->border->border_left_color);
break;
case GTK_CSS_PROPERTY_OUTLINE_COLOR:
unshare_outline (animated);
gtk_css_take_value (&style->outline->outline_color, value);
+ if (style->outline->outline_color)
+ style->outline->_outline_color = *gtk_css_color_value_get_rgba (style->outline->outline_color);
break;
case GTK_CSS_PROPERTY_BACKGROUND_REPEAT:
unshare_background (animated);
@@ -423,6 +489,7 @@ gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *animated,
case GTK_CSS_PROPERTY_ICON_SIZE:
unshare_icon (animated);
gtk_css_take_value (&style->icon->icon_size, value);
+ style->icon->_icon_size = _gtk_css_number_value_get (style->icon->icon_size, 100);
break;
case GTK_CSS_PROPERTY_ICON_SHADOW:
unshare_icon (animated);
@@ -431,6 +498,7 @@ gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *animated,
case GTK_CSS_PROPERTY_ICON_STYLE:
unshare_icon (animated);
gtk_css_take_value (&style->icon->icon_style, value);
+ style->icon->_icon_style = _gtk_css_icon_style_value_get (style->icon->icon_style);
break;
case GTK_CSS_PROPERTY_ICON_TRANSFORM:
unshare_other (animated);
@@ -443,6 +511,8 @@ gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *animated,
case GTK_CSS_PROPERTY_BORDER_SPACING:
unshare_size (animated);
gtk_css_take_value (&style->size->border_spacing, value);
+ style->size->_border_spacing[GTK_ORIENTATION_HORIZONTAL] = _gtk_css_position_value_get_x
(style->size->border_spacing, 100);
+ style->size->_border_spacing[GTK_ORIENTATION_VERTICAL] = _gtk_css_position_value_get_y
(style->size->border_spacing, 100);
break;
case GTK_CSS_PROPERTY_TRANSFORM:
unshare_other (animated);
@@ -455,10 +525,12 @@ gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *animated,
case GTK_CSS_PROPERTY_MIN_WIDTH:
unshare_size (animated);
gtk_css_take_value (&style->size->min_width, value);
+ style->size->_min_size[GTK_ORIENTATION_HORIZONTAL] = _gtk_css_number_value_get
(style->size->min_width, 100);
break;
case GTK_CSS_PROPERTY_MIN_HEIGHT:
unshare_size (animated);
gtk_css_take_value (&style->size->min_height, value);
+ style->size->_min_size[GTK_ORIENTATION_VERTICAL] = _gtk_css_number_value_get (style->size->min_height,
100);
break;
case GTK_CSS_PROPERTY_TRANSITION_PROPERTY:
unshare_transition (animated);
@@ -519,10 +591,14 @@ gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *animated,
case GTK_CSS_PROPERTY_CARET_COLOR:
unshare_font (animated);
gtk_css_take_value (&style->font->caret_color, value);
+ if (style->font->caret_color)
+ style->font->_caret_color = *gtk_css_color_value_get_rgba (style->font->caret_color);
break;
case GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR:
unshare_font (animated);
gtk_css_take_value (&style->font->secondary_caret_color, value);
+ if (style->font->secondary_caret_color)
+ style->font->_secondary_caret_color = *gtk_css_color_value_get_rgba
(style->font->secondary_caret_color);
break;
case GTK_CSS_PROPERTY_FONT_FEATURE_SETTINGS:
unshare_font (animated);
diff --git a/gtk/gtkcssboxesimplprivate.h b/gtk/gtkcssboxesimplprivate.h
index 01b046ee4e..d5c8361602 100644
--- a/gtk/gtkcssboxesimplprivate.h
+++ b/gtk/gtkcssboxesimplprivate.h
@@ -44,10 +44,10 @@ gtk_css_boxes_init (GtkCssBoxes *boxes,
static inline void
gtk_css_boxes_init_content_box (GtkCssBoxes *boxes,
GtkCssStyle *style,
- double x,
- double y,
- double width,
- double height)
+ float x,
+ float y,
+ float width,
+ float height)
{
memset (boxes, 0, sizeof (GtkCssBoxes));
@@ -59,10 +59,10 @@ gtk_css_boxes_init_content_box (GtkCssBoxes *boxes,
static inline void
gtk_css_boxes_init_border_box (GtkCssBoxes *boxes,
GtkCssStyle *style,
- double x,
- double y,
- double width,
- double height)
+ float x,
+ float y,
+ float width,
+ float height)
{
memset (boxes, 0, sizeof (GtkCssBoxes));
@@ -74,70 +74,24 @@ gtk_css_boxes_init_border_box (GtkCssBoxes *boxes,
static inline void
gtk_css_boxes_rect_grow (GskRoundedRect *dest,
GskRoundedRect *src,
- GtkCssValue *top,
- GtkCssValue *right,
- GtkCssValue *bottom,
- GtkCssValue *left)
+ const float width[4])
{
- if (gtk_css_dimension_value_is_zero (left))
- {
- dest->bounds.origin.x = src->bounds.origin.x;
- if (gtk_css_dimension_value_is_zero (right))
- dest->bounds.size.width = src->bounds.size.width;
- else
- dest->bounds.size.width = src->bounds.size.width + _gtk_css_number_value_get (right, 100);
- }
- else
- {
- const double left_value = _gtk_css_number_value_get (left, 100);
-
- dest->bounds.origin.x = src->bounds.origin.x - left_value;
- if (gtk_css_dimension_value_is_zero (right))
- dest->bounds.size.width = src->bounds.size.width + left_value;
- else
- dest->bounds.size.width = src->bounds.size.width + left_value + _gtk_css_number_value_get (right,
100);
-
- }
-
-
- if (gtk_css_dimension_value_is_zero (top))
- {
- dest->bounds.origin.y = src->bounds.origin.y;
- if (gtk_css_dimension_value_is_zero (bottom))
- dest->bounds.size.height = src->bounds.size.height;
- else
- dest->bounds.size.height = src->bounds.size.height + _gtk_css_number_value_get (bottom, 100);
- }
- else
- {
- const double top_value = _gtk_css_number_value_get (top, 100);
-
- dest->bounds.origin.y = src->bounds.origin.y - top_value;
- if (gtk_css_dimension_value_is_zero (bottom))
- dest->bounds.size.height = src->bounds.size.height + top_value;
- else
- dest->bounds.size.height = src->bounds.size.height + top_value + _gtk_css_number_value_get (bottom,
100);
- }
+ dest->bounds.origin.x = src->bounds.origin.x - width[GTK_CSS_LEFT];
+ dest->bounds.origin.y = src->bounds.origin.y - width[GTK_CSS_TOP];
+ dest->bounds.size.width = src->bounds.size.width + width[GTK_CSS_LEFT] + width[GTK_CSS_RIGHT];
+ dest->bounds.size.height = src->bounds.size.height + width[GTK_CSS_TOP] + width[GTK_CSS_BOTTOM];
}
static inline void
gtk_css_boxes_rect_shrink (GskRoundedRect *dest,
GskRoundedRect *src,
- GtkCssValue *top_value,
- GtkCssValue *right_value,
- GtkCssValue *bottom_value,
- GtkCssValue *left_value)
+ const float width[4])
{
- double top = _gtk_css_number_value_get (top_value, 100);
- double right = _gtk_css_number_value_get (right_value, 100);
- double bottom = _gtk_css_number_value_get (bottom_value, 100);
- double left = _gtk_css_number_value_get (left_value, 100);
-
/* FIXME: Do we need underflow checks here? */
- dest->bounds.origin.x = src->bounds.origin.x + left;
- dest->bounds.origin.y = src->bounds.origin.y + top;
- dest->bounds.size.width = src->bounds.size.width - left - right;
- dest->bounds.size.height = src->bounds.size.height - top - bottom;
+ dest->bounds.origin.x = src->bounds.origin.x + width[GTK_CSS_LEFT];
+ dest->bounds.origin.y = src->bounds.origin.y + width[GTK_CSS_TOP];
+ dest->bounds.size.width = src->bounds.size.width - width[GTK_CSS_LEFT] - width[GTK_CSS_RIGHT];
+ dest->bounds.size.height = src->bounds.size.height - width[GTK_CSS_TOP] - width[GTK_CSS_BOTTOM];
}
static inline void gtk_css_boxes_compute_padding_rect (GtkCssBoxes *boxes);
@@ -170,10 +124,7 @@ gtk_css_boxes_compute_border_rect (GtkCssBoxes *boxes)
gtk_css_boxes_rect_grow (&boxes->box[GTK_CSS_AREA_BORDER_BOX],
&boxes->box[GTK_CSS_AREA_PADDING_BOX],
- boxes->style->border->border_top_width,
- boxes->style->border->border_right_width,
- boxes->style->border->border_bottom_width,
- boxes->style->border->border_left_width);
+ boxes->style->border->_border_width);
boxes->has_rect[GTK_CSS_AREA_BORDER_BOX] = TRUE;
}
@@ -188,19 +139,13 @@ gtk_css_boxes_compute_padding_rect (GtkCssBoxes *boxes)
{
gtk_css_boxes_rect_shrink (&boxes->box[GTK_CSS_AREA_PADDING_BOX],
&boxes->box[GTK_CSS_AREA_BORDER_BOX],
- boxes->style->border->border_top_width,
- boxes->style->border->border_right_width,
- boxes->style->border->border_bottom_width,
- boxes->style->border->border_left_width);
+ boxes->style->border->_border_width);
}
else
{
gtk_css_boxes_rect_grow (&boxes->box[GTK_CSS_AREA_PADDING_BOX],
&boxes->box[GTK_CSS_AREA_CONTENT_BOX],
- boxes->style->size->padding_top,
- boxes->style->size->padding_right,
- boxes->style->size->padding_bottom,
- boxes->style->size->padding_left);
+ boxes->style->size->_padding);
}
boxes->has_rect[GTK_CSS_AREA_PADDING_BOX] = TRUE;
@@ -216,10 +161,7 @@ gtk_css_boxes_compute_content_rect (GtkCssBoxes *boxes)
gtk_css_boxes_rect_shrink (&boxes->box[GTK_CSS_AREA_CONTENT_BOX],
&boxes->box[GTK_CSS_AREA_PADDING_BOX],
- boxes->style->size->padding_top,
- boxes->style->size->padding_right,
- boxes->style->size->padding_bottom,
- boxes->style->size->padding_left);
+ boxes->style->size->_padding);
boxes->has_rect[GTK_CSS_AREA_CONTENT_BOX] = TRUE;
}
@@ -234,10 +176,7 @@ gtk_css_boxes_compute_margin_rect (GtkCssBoxes *boxes)
gtk_css_boxes_rect_grow (&boxes->box[GTK_CSS_AREA_MARGIN_BOX],
&boxes->box[GTK_CSS_AREA_BORDER_BOX],
- boxes->style->size->margin_top,
- boxes->style->size->margin_right,
- boxes->style->size->margin_bottom,
- boxes->style->size->margin_left);
+ boxes->style->size->_margin);
boxes->has_rect[GTK_CSS_AREA_MARGIN_BOX] = TRUE;
}
@@ -246,7 +185,7 @@ static inline void
gtk_css_boxes_compute_outline_rect (GtkCssBoxes *boxes)
{
graphene_rect_t *dest, *src;
- double d;
+ float d;
if (boxes->has_rect[GTK_CSS_AREA_OUTLINE_BOX])
return;
@@ -256,8 +195,8 @@ gtk_css_boxes_compute_outline_rect (GtkCssBoxes *boxes)
dest = &boxes->box[GTK_CSS_AREA_OUTLINE_BOX].bounds;
src = &boxes->box[GTK_CSS_AREA_BORDER_BOX].bounds;
- d = _gtk_css_number_value_get (boxes->style->outline->outline_offset, 100) +
- _gtk_css_number_value_get (boxes->style->outline->outline_width, 100);
+ d = boxes->style->outline->_outline_offset +
+ boxes->style->outline->_outline_width;
dest->origin.x = src->origin.x - d;
dest->origin.y = src->origin.y - d;
@@ -311,8 +250,8 @@ gtk_css_boxes_get_outline_rect (GtkCssBoxes *boxes)
static inline void
gtk_css_boxes_clamp_border_radius (GskRoundedRect *box)
{
- double factor = 1.0;
- double corners;
+ float factor = 1.0;
+ float corners;
corners = box->corner[GSK_CORNER_TOP_LEFT].width + box->corner[GSK_CORNER_TOP_RIGHT].width;
if (corners != 0)
@@ -341,52 +280,26 @@ gtk_css_boxes_clamp_border_radius (GskRoundedRect *box)
}
static inline void
-gtk_css_boxes_apply_border_radius (GskRoundedRect *box,
- const GtkCssValue *top_left,
- const GtkCssValue *top_right,
- const GtkCssValue *bottom_right,
- const GtkCssValue *bottom_left)
+gtk_css_boxes_apply_border_radius (GskRoundedRect *box,
+ const graphene_size_t corner[4])
{
- gboolean has_border_radius = FALSE;
-
- if (!gtk_css_corner_value_is_zero (top_left))
- {
- box->corner[GSK_CORNER_TOP_LEFT].width = _gtk_css_corner_value_get_x (top_left,
box->bounds.size.width);
- box->corner[GSK_CORNER_TOP_LEFT].height = _gtk_css_corner_value_get_y (top_left,
box->bounds.size.height);
- has_border_radius = TRUE;
- }
-
- if (!gtk_css_corner_value_is_zero (top_right))
- {
- box->corner[GSK_CORNER_TOP_RIGHT].width = _gtk_css_corner_value_get_x (top_right,
box->bounds.size.width);
- box->corner[GSK_CORNER_TOP_RIGHT].height = _gtk_css_corner_value_get_y (top_right,
box->bounds.size.height);
- has_border_radius = TRUE;
- }
-
- if (!gtk_css_corner_value_is_zero (bottom_right))
- {
- box->corner[GSK_CORNER_BOTTOM_RIGHT].width = _gtk_css_corner_value_get_x (bottom_right,
box->bounds.size.width);
- box->corner[GSK_CORNER_BOTTOM_RIGHT].height = _gtk_css_corner_value_get_y (bottom_right,
box->bounds.size.height);
- has_border_radius = TRUE;
- }
-
- if (!gtk_css_corner_value_is_zero (bottom_left))
+ memcpy (box->corner, corner, sizeof (graphene_size_t) * 4);
+ for (int i = 0; i < 4; i++)
{
- box->corner[GSK_CORNER_BOTTOM_LEFT].width = _gtk_css_corner_value_get_x (bottom_left,
box->bounds.size.width);
- box->corner[GSK_CORNER_BOTTOM_LEFT].height = _gtk_css_corner_value_get_y (bottom_left,
box->bounds.size.height);
- has_border_radius = TRUE;
+ if (corner[i].width != 0 || corner[i].height != 0)
+ {
+ gtk_css_boxes_clamp_border_radius (box);
+ break;
+ }
}
-
- if (has_border_radius)
- gtk_css_boxes_clamp_border_radius (box);
}
/* NB: width and height must be >= 0 */
static inline void
gtk_css_boxes_shrink_border_radius (graphene_size_t *dest,
const graphene_size_t *src,
- double width,
- double height)
+ float width,
+ float height)
{
dest->width = src->width - width;
dest->height = src->height - height;
@@ -402,10 +315,10 @@ static inline void
gtk_css_boxes_shrink_corners (GskRoundedRect *dest,
const GskRoundedRect *src)
{
- double top = dest->bounds.origin.y - src->bounds.origin.y;
- double right = src->bounds.origin.x + src->bounds.size.width - dest->bounds.origin.x -
dest->bounds.size.width;
- double bottom = src->bounds.origin.y + src->bounds.size.height - dest->bounds.origin.y -
dest->bounds.size.height;
- double left = dest->bounds.origin.x - src->bounds.origin.x;
+ float top = dest->bounds.origin.y - src->bounds.origin.y;
+ float right = src->bounds.origin.x + src->bounds.size.width - dest->bounds.origin.x -
dest->bounds.size.width;
+ float bottom = src->bounds.origin.y + src->bounds.size.height - dest->bounds.origin.y -
dest->bounds.size.height;
+ float left = dest->bounds.origin.x - src->bounds.origin.x;
gtk_css_boxes_shrink_border_radius (&dest->corner[GSK_CORNER_TOP_LEFT],
&src->corner[GSK_CORNER_TOP_LEFT],
@@ -430,10 +343,7 @@ gtk_css_boxes_compute_border_box (GtkCssBoxes *boxes)
gtk_css_boxes_compute_border_rect (boxes);
gtk_css_boxes_apply_border_radius (&boxes->box[GTK_CSS_AREA_BORDER_BOX],
- boxes->style->border->border_top_left_radius,
- boxes->style->border->border_top_right_radius,
- boxes->style->border->border_bottom_right_radius,
- boxes->style->border->border_bottom_left_radius);
+ boxes->style->border->_border_radius);
boxes->has_box[GTK_CSS_AREA_BORDER_BOX] = TRUE;
}
@@ -473,7 +383,7 @@ gtk_css_boxes_compute_outline_box (GtkCssBoxes *boxes)
{
const GskRoundedRect *src;
GskRoundedRect *dest;
- double d;
+ float d;
int i;
if (boxes->has_box[GTK_CSS_AREA_OUTLINE_BOX])
@@ -484,8 +394,8 @@ gtk_css_boxes_compute_outline_box (GtkCssBoxes *boxes)
src = &boxes->box[GTK_CSS_AREA_BORDER_BOX];
dest = &boxes->box[GTK_CSS_AREA_OUTLINE_BOX];
- d = _gtk_css_number_value_get (boxes->style->outline->outline_offset, 100) +
- _gtk_css_number_value_get (boxes->style->outline->outline_width, 100);
+ d = boxes->style->outline->_outline_offset +
+ boxes->style->outline->_outline_width;
/* Grow border rect into outline rect */
dest->bounds.origin.x = src->bounds.origin.x - d;
diff --git a/gtk/gtkcssboxesprivate.h b/gtk/gtkcssboxesprivate.h
index 24a38ff0de..eae9f323c9 100644
--- a/gtk/gtkcssboxesprivate.h
+++ b/gtk/gtkcssboxesprivate.h
@@ -57,16 +57,16 @@ static inline void gtk_css_boxes_init
GtkWidget *widget);
static inline void gtk_css_boxes_init_content_box (GtkCssBoxes *boxes,
GtkCssStyle *style,
- double x,
- double y,
- double width,
- double height);
+ float x,
+ float y,
+ float width,
+ float height);
static inline void gtk_css_boxes_init_border_box (GtkCssBoxes *boxes,
GtkCssStyle *style,
- double x,
- double y,
- double width,
- double height);
+ float x,
+ float y,
+ float width,
+ float height);
static inline const graphene_rect_t * gtk_css_boxes_get_rect (GtkCssBoxes *boxes,
GtkCssArea area);
diff --git a/gtk/gtkcssenumvalue.c b/gtk/gtkcssenumvalue.c
index dfb7a0d394..32d93ada21 100644
--- a/gtk/gtkcssenumvalue.c
+++ b/gtk/gtkcssenumvalue.c
@@ -197,12 +197,6 @@ _gtk_css_blend_mode_value_get (const GtkCssValue *value)
/* GtkCssFontSize */
-static double
-get_dpi (GtkCssStyle *style)
-{
- return _gtk_css_number_value_get (style->core->dpi, 96);
-}
-
/* XXX: Kinda bad to have that machinery here, nobody expects vital font
* size code to appear in gtkcssvalueenum.c.
*/
@@ -217,15 +211,15 @@ gtk_css_font_size_get_default_px (GtkStyleProvider *provider,
settings = gtk_style_provider_get_settings (provider);
if (settings == NULL)
- return DEFAULT_FONT_SIZE_PT * get_dpi (style) / 72.0;
+ return DEFAULT_FONT_SIZE_PT * style->core->_dpi / 72.0;
font_size = gtk_settings_get_font_size (settings);
if (font_size == 0)
- return DEFAULT_FONT_SIZE_PT * get_dpi (style) / 72.0;
+ return DEFAULT_FONT_SIZE_PT * style->core->_dpi / 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;
+ return ((double) font_size / PANGO_SCALE) * style->core->_dpi / 72.0;
}
static GtkCssValue *
diff --git a/gtk/gtkcssimagerecolor.c b/gtk/gtkcssimagerecolor.c
index d640f8aaa9..4f635b4ec4 100644
--- a/gtk/gtkcssimagerecolor.c
+++ b/gtk/gtkcssimagerecolor.c
@@ -72,7 +72,7 @@ lookup_symbolic_colors (GtkCssStyle *style,
{
const GdkRGBA *lookup;
- *color_out = *gtk_css_color_value_get_rgba (style->core->color);
+ *color_out = style->core->_color;
lookup = gtk_css_palette_value_get_color (palette, "success");
if (lookup)
diff --git a/gtk/gtkcssnumbervalue.c b/gtk/gtkcssnumbervalue.c
index cd8c942c01..e6644c2ff6 100644
--- a/gtk/gtkcssnumbervalue.c
+++ b/gtk/gtkcssnumbervalue.c
@@ -88,12 +88,6 @@ gtk_css_value_number_free (GtkCssValue *number)
}
}
-static double
-get_dpi (GtkCssStyle *style)
-{
- return _gtk_css_number_value_get (style->core->dpi, 96);
-}
-
static double
get_base_font_size_px (guint property_id,
GtkStyleProvider *provider,
@@ -103,12 +97,12 @@ get_base_font_size_px (guint property_id,
if (property_id == GTK_CSS_PROPERTY_FONT_SIZE)
{
if (parent_style)
- return _gtk_css_number_value_get (parent_style->core->font_size, 100);
+ return parent_style->core->_font_size;
else
return gtk_css_font_size_get_default_px (provider, style);
}
- return _gtk_css_number_value_get (style->core->font_size, 100);
+ return style->core->_font_size;
}
static GtkCssValue *
@@ -172,19 +166,19 @@ gtk_css_value_number_compute (GtkCssValue *number,
case GTK_CSS_S:
return _gtk_css_value_ref (number);
case GTK_CSS_PT:
- return gtk_css_dimension_value_new (value * get_dpi (style) / 72.0,
+ return gtk_css_dimension_value_new (value * style->core->_dpi / 72.0,
GTK_CSS_PX);
case GTK_CSS_PC:
- return gtk_css_dimension_value_new (value * get_dpi (style) / 72.0 * 12.0,
+ return gtk_css_dimension_value_new (value * style->core->_dpi / 72.0 * 12.0,
GTK_CSS_PX);
case GTK_CSS_IN:
- return gtk_css_dimension_value_new (value * get_dpi (style),
+ return gtk_css_dimension_value_new (value * style->core->_dpi,
GTK_CSS_PX);
case GTK_CSS_CM:
- return gtk_css_dimension_value_new (value * get_dpi (style) * 0.39370078740157477,
+ return gtk_css_dimension_value_new (value * style->core->_dpi * 0.39370078740157477,
GTK_CSS_PX);
case GTK_CSS_MM:
- return gtk_css_dimension_value_new (value * get_dpi (style) * 0.039370078740157477,
+ return gtk_css_dimension_value_new (value * style->core->_dpi * 0.039370078740157477,
GTK_CSS_PX);
case GTK_CSS_EM:
return gtk_css_dimension_value_new (value *
diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c
index ba7d2ff958..4509c773b7 100644
--- a/gtk/gtkcssstaticstyle.c
+++ b/gtk/gtkcssstaticstyle.c
@@ -23,6 +23,10 @@
#include "gtkcssanimationprivate.h"
#include "gtkcssarrayvalueprivate.h"
+#include "gtkcsscolorvalueprivate.h"
+#include "gtkcsscornervalueprivate.h"
+#include "gtkcssenumvalueprivate.h"
+#include "gtkcsspositionvalueprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "gtkcssinheritvalueprivate.h"
#include "gtkcssinitialvalueprivate.h"
@@ -38,6 +42,7 @@
#include "gtkstylepropertyprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtkcssdimensionvalueprivate.h"
+#include "gtkcsslineheightvalueprivate.h"
static void gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
GtkStyleProvider *provider,
@@ -221,6 +226,7 @@ static GtkBitmask * gtk_css_ ## NAME ## _values_mask; \
static GtkCssValues * gtk_css_ ## NAME ## _initial_values; \
\
static GtkCssValues * gtk_css_ ## NAME ## _create_initial_values (void); \
+void gtk_css_ ## NAME ## _values_unbox (GtkCss ## TYPE ## Values *values); \
\
static void \
gtk_css_ ## NAME ## _values_init (void) \
@@ -234,6 +240,8 @@ gtk_css_ ## NAME ## _values_init (void) \
} \
\
gtk_css_ ## NAME ## _initial_values = gtk_css_ ## NAME ## _create_initial_values (); \
+ if (gtk_css_ ## NAME ## _initial_values) \
+ gtk_css_ ## NAME ## _values_unbox ((GtkCss ## TYPE ## Values *) gtk_css_ ## NAME ## _initial_values); \
} \
\
static inline gboolean \
@@ -391,69 +399,90 @@ gtk_css_static_style_set_value (GtkCssStaticStyle *sstyle,
{
case GTK_CSS_PROPERTY_COLOR:
gtk_css_take_value (&style->core->color, value);
+ style->core->_color = *gtk_css_color_value_get_rgba (style->core->color);
break;
case GTK_CSS_PROPERTY_DPI:
gtk_css_take_value (&style->core->dpi, value);
+ style->core->_dpi = _gtk_css_number_value_get (style->core->dpi, 96);
break;
case GTK_CSS_PROPERTY_FONT_SIZE:
gtk_css_take_value (&style->core->font_size, value);
+ style->core->_font_size = _gtk_css_number_value_get (style->core->font_size, 100);
break;
case GTK_CSS_PROPERTY_ICON_PALETTE:
gtk_css_take_value (&style->core->icon_palette, value);
break;
case GTK_CSS_PROPERTY_BACKGROUND_COLOR:
gtk_css_take_value (&style->background->background_color, value);
+ style->background->_background_color = *gtk_css_color_value_get_rgba
(style->background->background_color);
break;
case GTK_CSS_PROPERTY_FONT_FAMILY:
gtk_css_take_value (&style->font->font_family, value);
break;
case GTK_CSS_PROPERTY_FONT_STYLE:
gtk_css_take_value (&style->font->font_style, value);
+ style->font->_font_style = _gtk_css_font_style_value_get (style->font->font_style);
break;
case GTK_CSS_PROPERTY_FONT_WEIGHT:
gtk_css_take_value (&style->font->font_weight, value);
+ style->font->_font_weight = _gtk_css_number_value_get (style->font->font_weight, 100);
break;
case GTK_CSS_PROPERTY_FONT_STRETCH:
gtk_css_take_value (&style->font->font_stretch, value);
+ style->font->_font_stretch = _gtk_css_font_stretch_value_get (style->font->font_stretch);
break;
case GTK_CSS_PROPERTY_LETTER_SPACING:
gtk_css_take_value (&style->font->letter_spacing, value);
+ style->font->_letter_spacing = _gtk_css_number_value_get (style->font->letter_spacing, 100);
break;
case GTK_CSS_PROPERTY_LINE_HEIGHT:
gtk_css_take_value (&style->font->line_height, value);
+ style->font->_line_height = gtk_css_line_height_value_get (style->font->line_height);
break;
case GTK_CSS_PROPERTY_TEXT_DECORATION_LINE:
gtk_css_take_value (&style->font_variant->text_decoration_line, value);
+ style->font_variant->_text_decoration_line = _gtk_css_text_decoration_line_value_get
(style->font_variant->text_decoration_line);
break;
case GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR:
gtk_css_take_value (&style->font_variant->text_decoration_color, value);
+ if (style->font_variant->text_decoration_color)
+ style->font_variant->_text_decoration_color = *gtk_css_color_value_get_rgba
(style->font_variant->text_decoration_color);
break;
case GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE:
gtk_css_take_value (&style->font_variant->text_decoration_style, value);
+ style->font_variant->_text_decoration_style = _gtk_css_text_decoration_style_value_get
(style->font_variant->text_decoration_style);
break;
case GTK_CSS_PROPERTY_TEXT_TRANSFORM:
gtk_css_take_value (&style->font_variant->text_transform, value);
+ style->font_variant->_text_transform = _gtk_css_text_transform_value_get
(style->font_variant->text_transform);
break;
case GTK_CSS_PROPERTY_FONT_KERNING:
gtk_css_take_value (&style->font_variant->font_kerning, value);
+ style->font_variant->_font_kerning = _gtk_css_font_kerning_value_get
(style->font_variant->font_kerning);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES:
gtk_css_take_value (&style->font_variant->font_variant_ligatures, value);
+ style->font_variant->_font_variant_ligatures = _gtk_css_font_variant_ligature_value_get
(style->font_variant->font_variant_ligatures);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_POSITION:
gtk_css_take_value (&style->font_variant->font_variant_position, value);
+ style->font_variant->_font_variant_position = _gtk_css_font_variant_position_value_get
(style->font_variant->font_variant_position);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_CAPS:
gtk_css_take_value (&style->font_variant->font_variant_caps, value);
+ style->font_variant->_font_variant_caps = _gtk_css_font_variant_caps_value_get
(style->font_variant->font_variant_caps);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC:
gtk_css_take_value (&style->font_variant->font_variant_numeric, value);
+ style->font_variant->_font_variant_numeric = _gtk_css_font_variant_numeric_value_get
(style->font_variant->font_variant_numeric);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES:
gtk_css_take_value (&style->font_variant->font_variant_alternates, value);
+ style->font_variant->_font_variant_alternates = _gtk_css_font_variant_alternate_value_get
(style->font_variant->font_variant_alternates);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN:
gtk_css_take_value (&style->font_variant->font_variant_east_asian, value);
+ style->font_variant->_font_variant_east_asian = _gtk_css_font_variant_east_asian_value_get
(style->font_variant->font_variant_east_asian);
break;
case GTK_CSS_PROPERTY_TEXT_SHADOW:
gtk_css_take_value (&style->font->text_shadow, value);
@@ -463,72 +492,99 @@ gtk_css_static_style_set_value (GtkCssStaticStyle *sstyle,
break;
case GTK_CSS_PROPERTY_MARGIN_TOP:
gtk_css_take_value (&style->size->margin_top, value);
+ style->size->_margin[GTK_CSS_TOP] = _gtk_css_number_value_get (style->size->margin_top, 100);
break;
- case GTK_CSS_PROPERTY_MARGIN_LEFT:
- gtk_css_take_value (&style->size->margin_left, value);
+ case GTK_CSS_PROPERTY_MARGIN_RIGHT:
+ gtk_css_take_value (&style->size->margin_right, value);
+ style->size->_margin[GTK_CSS_RIGHT] = _gtk_css_number_value_get (style->size->margin_right, 100);
break;
case GTK_CSS_PROPERTY_MARGIN_BOTTOM:
gtk_css_take_value (&style->size->margin_bottom, value);
+ style->size->_margin[GTK_CSS_BOTTOM] = _gtk_css_number_value_get (style->size->margin_bottom, 100);
break;
- case GTK_CSS_PROPERTY_MARGIN_RIGHT:
- gtk_css_take_value (&style->size->margin_right, value);
+ case GTK_CSS_PROPERTY_MARGIN_LEFT:
+ gtk_css_take_value (&style->size->margin_left, value);
+ style->size->_margin[GTK_CSS_LEFT] = _gtk_css_number_value_get (style->size->margin_left, 100);
break;
case GTK_CSS_PROPERTY_PADDING_TOP:
gtk_css_take_value (&style->size->padding_top, value);
+ style->size->_padding[GTK_CSS_TOP] = _gtk_css_number_value_get (style->size->padding_top, 100);
break;
- case GTK_CSS_PROPERTY_PADDING_LEFT:
- gtk_css_take_value (&style->size->padding_left, value);
+ case GTK_CSS_PROPERTY_PADDING_RIGHT:
+ gtk_css_take_value (&style->size->padding_right, value);
+ style->size->_padding[GTK_CSS_RIGHT] = _gtk_css_number_value_get (style->size->padding_right, 100);
break;
case GTK_CSS_PROPERTY_PADDING_BOTTOM:
gtk_css_take_value (&style->size->padding_bottom, value);
+ style->size->_padding[GTK_CSS_BOTTOM] = _gtk_css_number_value_get (style->size->padding_bottom, 100);
break;
- case GTK_CSS_PROPERTY_PADDING_RIGHT:
- gtk_css_take_value (&style->size->padding_right, value);
+ case GTK_CSS_PROPERTY_PADDING_LEFT:
+ gtk_css_take_value (&style->size->padding_left, value);
+ style->size->_padding[GTK_CSS_LEFT] = _gtk_css_number_value_get (style->size->padding_left, 100);
break;
case GTK_CSS_PROPERTY_BORDER_TOP_STYLE:
gtk_css_take_value (&style->border->border_top_style, value);
+ style->border->_border_style[GTK_CSS_TOP] = _gtk_css_border_style_value_get
(style->border->border_top_style);
break;
case GTK_CSS_PROPERTY_BORDER_TOP_WIDTH:
gtk_css_take_value (&style->border->border_top_width, value);
+ style->border->_border_width[GTK_CSS_TOP] = _gtk_css_number_value_get
(style->border->border_top_width, 100);
break;
case GTK_CSS_PROPERTY_BORDER_LEFT_STYLE:
gtk_css_take_value (&style->border->border_left_style, value);
+ style->border->_border_style[GTK_CSS_LEFT] = _gtk_css_border_style_value_get
(style->border->border_left_style);
break;
case GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH:
gtk_css_take_value (&style->border->border_left_width, value);
+ style->border->_border_width[GTK_CSS_LEFT] = _gtk_css_number_value_get
(style->border->border_left_width, 100);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE:
gtk_css_take_value (&style->border->border_bottom_style, value);
+ style->border->_border_style[GTK_CSS_BOTTOM] = _gtk_css_border_style_value_get
(style->border->border_bottom_style);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH:
gtk_css_take_value (&style->border->border_bottom_width, value);
+ style->border->_border_width[GTK_CSS_BOTTOM] = _gtk_css_number_value_get
(style->border->border_bottom_width, 100);
break;
case GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE:
gtk_css_take_value (&style->border->border_right_style, value);
+ style->border->_border_style[GTK_CSS_RIGHT] = _gtk_css_border_style_value_get
(style->border->border_right_style);
break;
case GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH:
gtk_css_take_value (&style->border->border_right_width, value);
+ style->border->_border_width[GTK_CSS_RIGHT] = _gtk_css_number_value_get
(style->border->border_right_width, 100);
break;
case GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS:
gtk_css_take_value (&style->border->border_top_left_radius, value);
+ style->border->_border_radius[GTK_CSS_TOP_LEFT].width = _gtk_css_corner_value_get_x
(style->border->border_top_left_radius, 100);
+ style->border->_border_radius[GTK_CSS_TOP_LEFT].height = _gtk_css_corner_value_get_y
(style->border->border_top_left_radius, 100);
break;
case GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS:
gtk_css_take_value (&style->border->border_top_right_radius, value);
+ style->border->_border_radius[GTK_CSS_TOP_RIGHT].width = _gtk_css_corner_value_get_x
(style->border->border_top_right_radius, 100);
+ style->border->_border_radius[GTK_CSS_TOP_RIGHT].height = _gtk_css_corner_value_get_y
(style->border->border_top_right_radius, 100);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS:
gtk_css_take_value (&style->border->border_bottom_right_radius, value);
+ style->border->_border_radius[GTK_CSS_BOTTOM_RIGHT].width = _gtk_css_corner_value_get_x
(style->border->border_bottom_right_radius, 100);
+ style->border->_border_radius[GTK_CSS_BOTTOM_RIGHT].height = _gtk_css_corner_value_get_y
(style->border->border_bottom_right_radius, 100);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS:
gtk_css_take_value (&style->border->border_bottom_left_radius, value);
+ style->border->_border_radius[GTK_CSS_BOTTOM_LEFT].width = _gtk_css_corner_value_get_x
(style->border->border_bottom_left_radius, 100);
+ style->border->_border_radius[GTK_CSS_BOTTOM_LEFT].height = _gtk_css_corner_value_get_y
(style->border->border_bottom_left_radius, 100);
break;
case GTK_CSS_PROPERTY_OUTLINE_STYLE:
gtk_css_take_value (&style->outline->outline_style, value);
+ style->outline->_outline_style = _gtk_css_border_style_value_get (style->outline->outline_style);
break;
case GTK_CSS_PROPERTY_OUTLINE_WIDTH:
gtk_css_take_value (&style->outline->outline_width, value);
+ style->outline->_outline_width = _gtk_css_number_value_get (style->outline->outline_width, 100);
break;
case GTK_CSS_PROPERTY_OUTLINE_OFFSET:
gtk_css_take_value (&style->outline->outline_offset, value);
+ style->outline->_outline_offset = _gtk_css_number_value_get (style->outline->outline_offset, 100);
break;
case GTK_CSS_PROPERTY_BACKGROUND_CLIP:
gtk_css_take_value (&style->background->background_clip, value);
@@ -544,18 +600,28 @@ gtk_css_static_style_set_value (GtkCssStaticStyle *sstyle,
break;
case GTK_CSS_PROPERTY_BORDER_TOP_COLOR:
gtk_css_take_value (&style->border->border_top_color, value);
+ if (style->border->border_top_color)
+ style->border->_border_color[GTK_CSS_TOP] = *gtk_css_color_value_get_rgba
(style->border->border_top_color);
break;
case GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR:
gtk_css_take_value (&style->border->border_right_color, value);
+ if (style->border->border_right_color)
+ style->border->_border_color[GTK_CSS_RIGHT] = *gtk_css_color_value_get_rgba
(style->border->border_right_color);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR:
gtk_css_take_value (&style->border->border_bottom_color, value);
+ if (style->border->border_bottom_color)
+ style->border->_border_color[GTK_CSS_BOTTOM] = *gtk_css_color_value_get_rgba
(style->border->border_bottom_color);
break;
case GTK_CSS_PROPERTY_BORDER_LEFT_COLOR:
gtk_css_take_value (&style->border->border_left_color, value);
+ if (style->border->border_left_color)
+ style->border->_border_color[GTK_CSS_LEFT] = *gtk_css_color_value_get_rgba
(style->border->border_left_color);
break;
case GTK_CSS_PROPERTY_OUTLINE_COLOR:
gtk_css_take_value (&style->outline->outline_color, value);
+ if (style->outline->outline_color)
+ style->outline->_outline_color = *gtk_css_color_value_get_rgba (style->outline->outline_color);
break;
case GTK_CSS_PROPERTY_BACKGROUND_REPEAT:
gtk_css_take_value (&style->background->background_repeat, value);
@@ -583,12 +649,14 @@ gtk_css_static_style_set_value (GtkCssStaticStyle *sstyle,
break;
case GTK_CSS_PROPERTY_ICON_SIZE:
gtk_css_take_value (&style->icon->icon_size, value);
+ style->icon->_icon_size = _gtk_css_number_value_get (style->icon->icon_size, 100);
break;
case GTK_CSS_PROPERTY_ICON_SHADOW:
gtk_css_take_value (&style->icon->icon_shadow, value);
break;
case GTK_CSS_PROPERTY_ICON_STYLE:
gtk_css_take_value (&style->icon->icon_style, value);
+ style->icon->_icon_style = _gtk_css_icon_style_value_get (style->icon->icon_style);
break;
case GTK_CSS_PROPERTY_ICON_TRANSFORM:
gtk_css_take_value (&style->other->icon_transform, value);
@@ -598,6 +666,8 @@ gtk_css_static_style_set_value (GtkCssStaticStyle *sstyle,
break;
case GTK_CSS_PROPERTY_BORDER_SPACING:
gtk_css_take_value (&style->size->border_spacing, value);
+ style->size->_border_spacing[GTK_ORIENTATION_HORIZONTAL] = _gtk_css_position_value_get_x
(style->size->border_spacing, 100);
+ style->size->_border_spacing[GTK_ORIENTATION_VERTICAL] = _gtk_css_position_value_get_y
(style->size->border_spacing, 100);
break;
case GTK_CSS_PROPERTY_TRANSFORM:
gtk_css_take_value (&style->other->transform, value);
@@ -607,9 +677,11 @@ gtk_css_static_style_set_value (GtkCssStaticStyle *sstyle,
break;
case GTK_CSS_PROPERTY_MIN_WIDTH:
gtk_css_take_value (&style->size->min_width, value);
+ style->size->_min_size[GTK_ORIENTATION_HORIZONTAL] = _gtk_css_number_value_get
(style->size->min_width, 100);
break;
case GTK_CSS_PROPERTY_MIN_HEIGHT:
gtk_css_take_value (&style->size->min_height, value);
+ style->size->_min_size[GTK_ORIENTATION_VERTICAL] = _gtk_css_number_value_get (style->size->min_height,
100);
break;
case GTK_CSS_PROPERTY_TRANSITION_PROPERTY:
gtk_css_take_value (&style->transition->transition_property, value);
@@ -655,9 +727,13 @@ gtk_css_static_style_set_value (GtkCssStaticStyle *sstyle,
break;
case GTK_CSS_PROPERTY_CARET_COLOR:
gtk_css_take_value (&style->font->caret_color, value);
+ if (style->font->caret_color)
+ style->font->_caret_color = *gtk_css_color_value_get_rgba (style->font->caret_color);
break;
case GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR:
gtk_css_take_value (&style->font->secondary_caret_color, value);
+ if (style->font->secondary_caret_color)
+ style->font->_secondary_caret_color = *gtk_css_color_value_get_rgba
(style->font->secondary_caret_color);
break;
case GTK_CSS_PROPERTY_FONT_FEATURE_SETTINGS:
gtk_css_take_value (&style->font->font_feature_settings, value);
@@ -726,6 +802,15 @@ gtk_css_core_create_initial_values (void)
return NULL;
}
+
+void
+gtk_css_core_values_unbox (GtkCssCoreValues *values)
+{
+ values->_color = *gtk_css_color_value_get_rgba (values->color);
+ values->_dpi = _gtk_css_number_value_get (values->dpi, 96);
+ values->_font_size = _gtk_css_number_value_get (values->font_size, 100);
+}
+
static GtkCssValues *
gtk_css_background_create_initial_values (void)
{
@@ -746,6 +831,12 @@ gtk_css_background_create_initial_values (void)
return (GtkCssValues *)values;
}
+void
+gtk_css_background_values_unbox (GtkCssBackgroundValues *values)
+{
+ values->_background_color = *gtk_css_color_value_get_rgba (values->background_color);
+}
+
static GtkCssValues *
gtk_css_border_create_initial_values (void)
{
@@ -777,6 +868,35 @@ gtk_css_border_create_initial_values (void)
return (GtkCssValues *)values;
}
+void
+gtk_css_border_values_unbox (GtkCssBorderValues *values)
+{
+ values->_border_style[GTK_CSS_TOP] = _gtk_css_border_style_value_get (values->border_top_style);
+ values->_border_style[GTK_CSS_RIGHT] = _gtk_css_border_style_value_get (values->border_right_style);
+ values->_border_style[GTK_CSS_BOTTOM] = _gtk_css_border_style_value_get (values->border_bottom_style);
+ values->_border_style[GTK_CSS_LEFT] = _gtk_css_border_style_value_get (values->border_left_style);
+ values->_border_width[GTK_CSS_TOP] = _gtk_css_number_value_get (values->border_top_width, 100);
+ values->_border_width[GTK_CSS_RIGHT] = _gtk_css_number_value_get (values->border_right_width, 100);
+ values->_border_width[GTK_CSS_BOTTOM] = _gtk_css_number_value_get (values->border_bottom_width, 100);
+ values->_border_width[GTK_CSS_LEFT] = _gtk_css_number_value_get (values->border_left_width, 100);
+ values->_border_radius[GTK_CSS_TOP_LEFT].width = _gtk_css_corner_value_get_x
(values->border_top_left_radius, 100);
+ values->_border_radius[GTK_CSS_TOP_LEFT].height = _gtk_css_corner_value_get_y
(values->border_top_left_radius, 100);
+ values->_border_radius[GTK_CSS_TOP_RIGHT].width = _gtk_css_corner_value_get_x
(values->border_top_right_radius, 100);
+ values->_border_radius[GTK_CSS_TOP_RIGHT].height = _gtk_css_corner_value_get_y
(values->border_top_right_radius, 100);
+ values->_border_radius[GTK_CSS_BOTTOM_RIGHT].width = _gtk_css_corner_value_get_x
(values->border_bottom_right_radius, 100);
+ values->_border_radius[GTK_CSS_BOTTOM_RIGHT].height = _gtk_css_corner_value_get_y
(values->border_bottom_right_radius, 100);
+ values->_border_radius[GTK_CSS_BOTTOM_LEFT].width = _gtk_css_corner_value_get_x
(values->border_bottom_left_radius, 100);
+ values->_border_radius[GTK_CSS_BOTTOM_LEFT].height = _gtk_css_corner_value_get_y
(values->border_bottom_left_radius, 100);
+ if (values->border_top_color)
+ values->_border_color[GTK_CSS_TOP] = *gtk_css_color_value_get_rgba (values->border_top_color);
+ if (values->border_right_color)
+ values->_border_color[GTK_CSS_RIGHT] = *gtk_css_color_value_get_rgba (values->border_right_color);
+ if (values->border_bottom_color)
+ values->_border_color[GTK_CSS_BOTTOM] = *gtk_css_color_value_get_rgba (values->border_bottom_color);
+ if (values->border_left_color)
+ values->_border_color[GTK_CSS_LEFT] = *gtk_css_color_value_get_rgba (values->border_left_color);
+}
+
static GtkCssValues *
gtk_css_outline_create_initial_values (void)
{
@@ -792,18 +912,49 @@ gtk_css_outline_create_initial_values (void)
return (GtkCssValues *)values;
}
+void
+gtk_css_outline_values_unbox (GtkCssOutlineValues *values)
+{
+ values->_outline_style = _gtk_css_border_style_value_get (values->outline_style);
+ values->_outline_width = _gtk_css_number_value_get (values->outline_width, 100);
+ values->_outline_offset = _gtk_css_number_value_get (values->outline_offset, 100);
+ if (values->outline_color)
+ values->_outline_color = *gtk_css_color_value_get_rgba (values->outline_color);
+}
+
static GtkCssValues *
gtk_css_icon_create_initial_values (void)
{
return NULL;
}
+void
+gtk_css_icon_values_unbox (GtkCssIconValues *values)
+{
+ values->_icon_size = _gtk_css_number_value_get (values->icon_size, 100);
+ values->_icon_style = _gtk_css_icon_style_value_get (values->icon_style);
+}
+
static GtkCssValues *
gtk_css_font_create_initial_values (void)
{
return NULL;
}
+void
+gtk_css_font_values_unbox (GtkCssFontValues *values)
+{
+ values->_font_style = _gtk_css_font_style_value_get (values->font_style);
+ values->_font_weight = _gtk_css_number_value_get (values->font_weight, 100);
+ values->_font_stretch = _gtk_css_font_stretch_value_get (values->font_stretch);
+ values->_letter_spacing = _gtk_css_number_value_get (values->letter_spacing, 100);
+ values->_line_height = gtk_css_line_height_value_get (values->line_height);
+ if (values->caret_color)
+ values->_caret_color = *gtk_css_color_value_get_rgba (values->caret_color);
+ if (values->secondary_caret_color)
+ values->_secondary_caret_color = *gtk_css_color_value_get_rgba (values->secondary_caret_color);
+}
+
static GtkCssValues *
gtk_css_font_variant_create_initial_values (void)
{
@@ -826,6 +977,23 @@ gtk_css_font_variant_create_initial_values (void)
return (GtkCssValues *)values;
}
+void
+gtk_css_font_variant_values_unbox (GtkCssFontVariantValues *values)
+{
+ values->_text_decoration_line = _gtk_css_text_decoration_line_value_get (values->text_decoration_line);
+ if (values->text_decoration_color)
+ values->_text_decoration_color = *gtk_css_color_value_get_rgba (values->text_decoration_color);
+ values->_text_decoration_style = _gtk_css_text_decoration_style_value_get (values->text_decoration_style);
+ values->_text_transform = _gtk_css_text_transform_value_get (values->text_transform);
+ values->_font_kerning = _gtk_css_font_kerning_value_get (values->font_kerning);
+ values->_font_variant_ligatures = _gtk_css_font_variant_ligature_value_get
(values->font_variant_ligatures);
+ values->_font_variant_position = _gtk_css_font_variant_position_value_get (values->font_variant_position);
+ values->_font_variant_caps = _gtk_css_font_variant_caps_value_get (values->font_variant_caps);
+ values->_font_variant_numeric = _gtk_css_font_variant_numeric_value_get (values->font_variant_numeric);
+ values->_font_variant_alternates = _gtk_css_font_variant_alternate_value_get
(values->font_variant_alternates);
+ values->_font_variant_east_asian = _gtk_css_font_variant_east_asian_value_get
(values->font_variant_east_asian);
+}
+
static GtkCssValues *
gtk_css_animation_create_initial_values (void)
{
@@ -845,6 +1013,11 @@ gtk_css_animation_create_initial_values (void)
return (GtkCssValues *)values;
}
+void
+gtk_css_animation_values_unbox (GtkCssAnimationValues *values)
+{
+}
+
static GtkCssValues *
gtk_css_transition_create_initial_values (void)
{
@@ -860,6 +1033,11 @@ gtk_css_transition_create_initial_values (void)
return (GtkCssValues *)values;
}
+void
+gtk_css_transition_values_unbox (GtkCssTransitionValues *values)
+{
+}
+
static GtkCssValues *
gtk_css_size_create_initial_values (void)
{
@@ -868,13 +1046,13 @@ gtk_css_size_create_initial_values (void)
values = (GtkCssSizeValues *)gtk_css_values_new (GTK_CSS_SIZE_INITIAL_VALUES);
values->margin_top = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_TOP, NULL, NULL, NULL);
- values->margin_left = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_LEFT, NULL, NULL, NULL);
- values->margin_bottom = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_BOTTOM, NULL, NULL,
NULL);
values->margin_right = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_RIGHT, NULL, NULL,
NULL);
+ values->margin_bottom = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_BOTTOM, NULL, NULL,
NULL);
+ values->margin_left = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_LEFT, NULL, NULL, NULL);
values->padding_top = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_TOP, NULL, NULL, NULL);
- values->padding_left = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_LEFT, NULL, NULL,
NULL);
- values->padding_bottom = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_BOTTOM, NULL, NULL,
NULL);
values->padding_right = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_RIGHT, NULL, NULL,
NULL);
+ values->padding_bottom = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_BOTTOM, NULL, NULL,
NULL);
+ values->padding_left = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_LEFT, NULL, NULL,
NULL);
values->border_spacing = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_SPACING, NULL, NULL,
NULL);
values->min_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MIN_WIDTH, NULL, NULL, NULL);
values->min_height = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MIN_HEIGHT, NULL, NULL, NULL);
@@ -882,6 +1060,23 @@ gtk_css_size_create_initial_values (void)
return (GtkCssValues *)values;
}
+void
+gtk_css_size_values_unbox (GtkCssSizeValues *values)
+{
+ values->_margin[GTK_CSS_TOP] = _gtk_css_number_value_get (values->margin_top, 100);
+ values->_margin[GTK_CSS_RIGHT] = _gtk_css_number_value_get (values->margin_right, 100);
+ values->_margin[GTK_CSS_BOTTOM] = _gtk_css_number_value_get (values->margin_bottom, 100);
+ values->_margin[GTK_CSS_LEFT] = _gtk_css_number_value_get (values->margin_left, 100);
+ values->_padding[GTK_CSS_TOP] = _gtk_css_number_value_get (values->padding_top, 100);
+ values->_padding[GTK_CSS_RIGHT] = _gtk_css_number_value_get (values->padding_right, 100);
+ values->_padding[GTK_CSS_BOTTOM] = _gtk_css_number_value_get (values->padding_bottom, 100);
+ values->_padding[GTK_CSS_LEFT] = _gtk_css_number_value_get (values->padding_left, 100);
+ values->_border_spacing[GTK_ORIENTATION_HORIZONTAL] = _gtk_css_position_value_get_x
(values->border_spacing, 100);
+ values->_border_spacing[GTK_ORIENTATION_VERTICAL] = _gtk_css_position_value_get_y
(values->border_spacing, 100);
+ values->_min_size[GTK_ORIENTATION_HORIZONTAL] = _gtk_css_number_value_get (values->min_width, 100);
+ values->_min_size[GTK_ORIENTATION_VERTICAL] = _gtk_css_number_value_get (values->min_height, 100);
+}
+
static GtkCssValues *
gtk_css_other_create_initial_values (void)
{
@@ -900,6 +1095,11 @@ gtk_css_other_create_initial_values (void)
return (GtkCssValues *)values;
}
+void
+gtk_css_other_values_unbox (GtkCssOtherValues *values)
+{
+}
+
static void
gtk_css_lookup_resolve (GtkCssLookup *lookup,
GtkStyleProvider *provider,
@@ -1034,12 +1234,6 @@ gtk_css_static_style_new_compute (GtkStyleProvider *provider,
return GTK_CSS_STYLE (result);
}
-G_STATIC_ASSERT (GTK_CSS_PROPERTY_BORDER_TOP_STYLE == GTK_CSS_PROPERTY_BORDER_TOP_WIDTH - 1);
-G_STATIC_ASSERT (GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE == GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH - 1);
-G_STATIC_ASSERT (GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE == GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH - 1);
-G_STATIC_ASSERT (GTK_CSS_PROPERTY_BORDER_LEFT_STYLE == GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH - 1);
-G_STATIC_ASSERT (GTK_CSS_PROPERTY_OUTLINE_STYLE == GTK_CSS_PROPERTY_OUTLINE_WIDTH - 1);
-
static void
gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
GtkStyleProvider *provider,
@@ -1049,7 +1243,7 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
GtkCssSection *section)
{
GtkCssValue *value;
- GtkBorderStyle border_style;
+ GtkCssStyle *_style = GTK_CSS_STYLE (style);
gtk_internal_return_if_fail (id < GTK_CSS_PROPERTY_N_PROPERTIES);
@@ -1058,16 +1252,41 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
{
/* We have them ordered in gtkcssstylepropertyimpl.c accordingly, so the
* border styles are already computed when we compute the border widths.
- *
- * Note that we rely on ..._STYLE == ..._WIDTH - 1 here.
*/
case GTK_CSS_PROPERTY_BORDER_TOP_WIDTH:
+ if (_style->border->_border_style[GTK_CSS_TOP] == GTK_BORDER_STYLE_NONE ||
_style->border->_border_style[GTK_CSS_TOP] == GTK_BORDER_STYLE_HIDDEN)
+ {
+ gtk_css_static_style_set_value (style, id, gtk_css_dimension_value_new (0, GTK_CSS_NUMBER),
section);
+ return;
+ }
+ break;
+
case GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH:
+ if (_style->border->_border_style[GTK_CSS_RIGHT] == GTK_BORDER_STYLE_NONE ||
_style->border->_border_style[GTK_CSS_RIGHT] == GTK_BORDER_STYLE_HIDDEN)
+ {
+ gtk_css_static_style_set_value (style, id, gtk_css_dimension_value_new (0, GTK_CSS_NUMBER),
section);
+ return;
+ }
+ break;
+
case GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH:
+ if (_style->border->_border_style[GTK_CSS_BOTTOM] == GTK_BORDER_STYLE_NONE ||
_style->border->_border_style[GTK_CSS_BOTTOM] == GTK_BORDER_STYLE_HIDDEN)
+ {
+ gtk_css_static_style_set_value (style, id, gtk_css_dimension_value_new (0, GTK_CSS_NUMBER),
section);
+ return;
+ }
+ break;
+
case GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH:
+ if (_style->border->_border_style[GTK_CSS_LEFT] == GTK_BORDER_STYLE_NONE ||
_style->border->_border_style[GTK_CSS_LEFT] == GTK_BORDER_STYLE_HIDDEN)
+ {
+ gtk_css_static_style_set_value (style, id, gtk_css_dimension_value_new (0, GTK_CSS_NUMBER),
section);
+ return;
+ }
+ break;
+
case GTK_CSS_PROPERTY_OUTLINE_WIDTH:
- border_style = _gtk_css_border_style_value_get (gtk_css_style_get_value ((GtkCssStyle *)style, id -
1));
- if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
+ if (_style->outline->_outline_style == GTK_BORDER_STYLE_NONE || _style->outline->_outline_style ==
GTK_BORDER_STYLE_HIDDEN)
{
gtk_css_static_style_set_value (style, id, gtk_css_dimension_value_new (0, GTK_CSS_NUMBER),
section);
return;
@@ -1086,7 +1305,7 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
*/
if (specified)
{
- value = _gtk_css_value_compute (specified, id, provider, (GtkCssStyle *)style, parent_style);
+ value = _gtk_css_value_compute (specified, id, provider, _style, parent_style);
}
else if (parent_style && _gtk_css_style_property_is_inherit (_gtk_css_style_property_lookup_by_id (id)))
{
@@ -1095,7 +1314,7 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
}
else
{
- value = _gtk_css_initial_value_new_compute (id, provider, (GtkCssStyle *)style, parent_style);
+ value = _gtk_css_initial_value_new_compute (id, provider, _style, parent_style);
}
gtk_css_static_style_set_value (style, id, value, section);
diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c
index 0822e80a46..1e6659e572 100644
--- a/gtk/gtkcssstyle.c
+++ b/gtk/gtkcssstyle.c
@@ -405,7 +405,7 @@ get_pango_underline_from_style (GtkTextDecorationStyle style)
PangoTextTransform
gtk_css_style_get_pango_text_transform (GtkCssStyle *style)
{
- switch (_gtk_css_text_transform_value_get (style->font_variant->text_transform))
+ switch (style->font_variant->_text_transform)
{
case GTK_CSS_TEXT_TRANSFORM_NONE:
return PANGO_TEXT_TRANSFORM_NONE;
@@ -460,7 +460,7 @@ gtk_css_style_compute_font_features (GtkCssStyle *style)
char *settings;
GString *s = NULL;
- switch (_gtk_css_font_kerning_value_get (style->font_variant->font_kerning))
+ switch (style->font_variant->_font_kerning)
{
case GTK_CSS_FONT_KERNING_NORMAL:
append_separated (&s, "kern 1");
@@ -473,7 +473,7 @@ gtk_css_style_compute_font_features (GtkCssStyle *style)
break;
}
- ligatures = _gtk_css_font_variant_ligature_value_get (style->font_variant->font_variant_ligatures);
+ ligatures = style->font_variant->_font_variant_ligatures;
if (ligatures == GTK_CSS_FONT_VARIANT_LIGATURE_NORMAL)
{
/* all defaults */
@@ -500,7 +500,7 @@ gtk_css_style_compute_font_features (GtkCssStyle *style)
append_separated (&s, "calt 0");
}
- switch (_gtk_css_font_variant_position_value_get (style->font_variant->font_variant_position))
+ switch (style->font_variant->_font_variant_position)
{
case GTK_CSS_FONT_VARIANT_POSITION_SUB:
append_separated (&s, "subs 1");
@@ -513,7 +513,7 @@ gtk_css_style_compute_font_features (GtkCssStyle *style)
break;
}
- numeric = _gtk_css_font_variant_numeric_value_get (style->font_variant->font_variant_numeric);
+ numeric = style->font_variant->_font_variant_numeric;
if (numeric == GTK_CSS_FONT_VARIANT_NUMERIC_NORMAL)
{
/* all defaults */
@@ -538,7 +538,7 @@ gtk_css_style_compute_font_features (GtkCssStyle *style)
append_separated (&s, "zero 1");
}
- switch (_gtk_css_font_variant_alternate_value_get (style->font_variant->font_variant_alternates))
+ switch (style->font_variant->_font_variant_alternates)
{
case GTK_CSS_FONT_VARIANT_ALTERNATE_HISTORICAL_FORMS:
append_separated (&s, "hist 1");
@@ -548,7 +548,7 @@ gtk_css_style_compute_font_features (GtkCssStyle *style)
break;
}
- east_asian = _gtk_css_font_variant_east_asian_value_get (style->font_variant->font_variant_east_asian);
+ east_asian = style->font_variant->_font_variant_east_asian;
if (east_asian == GTK_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL)
{
/* all defaults */
@@ -599,12 +599,13 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
double letter_spacing;
/* text-decoration */
- decoration_line = _gtk_css_text_decoration_line_value_get (style->font_variant->text_decoration_line);
- decoration_style = _gtk_css_text_decoration_style_value_get (style->font_variant->text_decoration_style);
- color = gtk_css_color_value_get_rgba (style->core->color);
- decoration_color = gtk_css_color_value_get_rgba (style->font_variant->text_decoration_color
- ? style->font_variant->text_decoration_color
- : style->core->color);
+ decoration_line = style->font_variant->_text_decoration_line;
+ decoration_style = style->font_variant->_text_decoration_style;
+ color = &style->core->_color;
+ if (style->font_variant->text_decoration_color)
+ decoration_color = &style->font_variant->_text_decoration_color;
+ else
+ decoration_color = &style->core->_color;
if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE)
{
@@ -632,7 +633,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
}
/* letter-spacing */
- letter_spacing = _gtk_css_number_value_get (style->font->letter_spacing, 100);
+ letter_spacing = style->font->_letter_spacing;
if (letter_spacing != 0)
{
attrs = add_pango_attr (attrs, pango_attr_letter_spacing_new (letter_spacing * PANGO_SCALE));
@@ -640,7 +641,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
/* line-height */
{
- double height = gtk_css_line_height_value_get (style->font->line_height);
+ float height = style->font->_line_height;
if (height != 0.0)
{
if (gtk_css_number_value_get_dimension (style->font->line_height) == GTK_CSS_DIMENSION_LENGTH)
@@ -651,7 +652,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
}
/* casing variants */
- switch (_gtk_css_font_variant_caps_value_get (style->font_variant->font_variant_caps))
+ switch (style->font_variant->_font_variant_caps)
{
case GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS:
attrs = add_pango_attr (attrs, pango_attr_variant_new (PANGO_VARIANT_SMALL_CAPS));
@@ -729,17 +730,13 @@ gtk_css_style_get_pango_font (GtkCssStyle *style)
_gtk_css_string_value_get (_gtk_css_array_value_get_nth (v, 0)));
}
- v = style->core->font_size;
- 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 (style->core->_font_size * PANGO_SCALE));
- v = style->font->font_style;
- pango_font_description_set_style (description, _gtk_css_font_style_value_get (v));
+ pango_font_description_set_style (description, style->font->_font_style);
- v = style->font->font_weight;
- pango_font_description_set_weight (description, _gtk_css_number_value_get (v, 100));
+ pango_font_description_set_weight (description, style->font->_font_weight);
- v = style->font->font_stretch;
- pango_font_description_set_stretch (description, _gtk_css_font_stretch_value_get (v));
+ pango_font_description_set_stretch (description, style->font->_font_stretch);
v = style->font->font_variation_settings;
str = gtk_css_font_variations_value_get_variations (v);
@@ -766,9 +763,13 @@ static const int values_size[] = {
sizeof (GtkCssOtherValues)
};
+static int n_values[] = {
+ 4, 9, 20, 3, 4, 11, 11, 8, 4, 11, 7
+};
+
#define TYPE_INDEX(type) ((type) - ((type) % 2))
#define VALUES_SIZE(type) (values_size[(type) / 2])
-#define N_VALUES(type) ((VALUES_SIZE(type) - sizeof (GtkCssValues)) / sizeof (GtkCssValue *))
+#define N_VALUES(type) (n_values[(type) / 2])
#define GET_VALUES(v) (GtkCssValue **)((guint8 *)(v) + sizeof (GtkCssValues))
@@ -812,7 +813,7 @@ gtk_css_values_copy (GtkCssValues *values)
GtkCssValue **v, **v2;
int i;
- copy = gtk_css_values_new (TYPE_INDEX(values->type));
+ copy = gtk_css_values_new (TYPE_INDEX (values->type));
v = GET_VALUES (values);
v2 = GET_VALUES (copy);
diff --git a/gtk/gtkcssstyleprivate.h b/gtk/gtkcssstyleprivate.h
index d618b7d741..f9d91129d1 100644
--- a/gtk/gtkcssstyleprivate.h
+++ b/gtk/gtkcssstyleprivate.h
@@ -84,6 +84,10 @@ struct _GtkCssCoreValues {
GtkCssValue *dpi;
GtkCssValue *font_size;
GtkCssValue *icon_palette;
+
+ GdkRGBA _color;
+ float _dpi;
+ float _font_size;
};
struct _GtkCssBackgroundValues {
@@ -97,6 +101,8 @@ struct _GtkCssBackgroundValues {
GtkCssValue *background_repeat;
GtkCssValue *background_image;
GtkCssValue *background_blend_mode;
+
+ GdkRGBA _background_color;
};
struct _GtkCssBorderValues {
@@ -121,6 +127,11 @@ struct _GtkCssBorderValues {
GtkCssValue *border_image_repeat;
GtkCssValue *border_image_slice;
GtkCssValue *border_image_width;
+
+ GtkBorderStyle _border_style[4];
+ float _border_width[4];
+ graphene_size_t _border_radius[4];
+ GdkRGBA _border_color[4];
};
struct _GtkCssIconValues {
@@ -128,6 +139,9 @@ struct _GtkCssIconValues {
GtkCssValue *icon_size;
GtkCssValue *icon_shadow;
GtkCssValue *icon_style;
+
+ int _icon_size;
+ GtkCssIconStyle _icon_style;
};
@@ -137,6 +151,11 @@ struct _GtkCssOutlineValues {
GtkCssValue *outline_width;
GtkCssValue *outline_offset;
GtkCssValue *outline_color; // NULL if currentColor
+
+ GtkBorderStyle _outline_style;
+ float _outline_width;
+ float _outline_offset;
+ GdkRGBA _outline_color;
};
struct _GtkCssFontValues {
@@ -152,6 +171,14 @@ struct _GtkCssFontValues {
GtkCssValue *font_feature_settings;
GtkCssValue *font_variation_settings;
GtkCssValue *line_height;
+
+ PangoStyle _font_style;
+ PangoStretch _font_stretch;
+ float _font_weight;
+ float _letter_spacing;
+ float _line_height;
+ GdkRGBA _caret_color;
+ GdkRGBA _secondary_caret_color;
};
struct _GtkCssFontVariantValues {
@@ -167,6 +194,18 @@ struct _GtkCssFontVariantValues {
GtkCssValue *font_variant_numeric;
GtkCssValue *font_variant_alternates;
GtkCssValue *font_variant_east_asian;
+
+ GtkTextDecorationLine _text_decoration_line;
+ GtkTextDecorationStyle _text_decoration_style;
+ GtkTextTransform _text_transform;
+ GtkCssFontKerning _font_kerning;
+ GtkCssFontVariantLigature _font_variant_ligatures;
+ GtkCssFontVariantPosition _font_variant_position;
+ GtkCssFontVariantCaps _font_variant_caps;
+ GtkCssFontVariantNumeric _font_variant_numeric;
+ GtkCssFontVariantAlternate _font_variant_alternates;
+ GtkCssFontVariantEastAsian _font_variant_east_asian;
+ GdkRGBA _text_decoration_color;
};
struct _GtkCssAnimationValues {
@@ -202,6 +241,11 @@ struct _GtkCssSizeValues {
GtkCssValue *border_spacing;
GtkCssValue *min_width;
GtkCssValue *min_height;
+
+ float _margin[4];
+ float _padding[4];
+ float _border_spacing[2];
+ float _min_size[2];
};
struct _GtkCssOtherValues {
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index 3846b1d581..41a5ae1a05 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -354,6 +354,13 @@ typedef enum /*< skip >*/ {
GTK_CSS_LEFT
} GtkCssSide;
+typedef enum /*< skip >*/ {
+ GTK_CSS_TOP_LEFT,
+ GTK_CSS_TOP_RIGHT,
+ GTK_CSS_BOTTOM_RIGHT,
+ GTK_CSS_BOTTOM_LEFT
+} GtkCssCorner;
+
typedef enum /*< skip >*/ {
GTK_CSS_DIMENSION_PERCENTAGE,
GTK_CSS_DIMENSION_NUMBER,
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index 2d9e9d9e70..5cdd7b8d55 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -2571,6 +2571,7 @@ gtk_flow_box_snapshot (GtkWidget *widget,
cairo_path_t *path;
GtkBorder border;
const GdkRGBA *border_color;
+ GtkCssStyle *style;
if (vertical)
path_from_vertical_line_rects (cr, (GdkRectangle *)lines->data, lines->len);
@@ -2590,7 +2591,8 @@ gtk_flow_box_snapshot (GtkWidget *widget,
cairo_append_path (cr, path);
cairo_path_destroy (path);
- border_color = gtk_css_color_value_get_rgba (_gtk_style_context_peek_property (context,
GTK_CSS_PROPERTY_BORDER_TOP_COLOR));
+ style = gtk_style_context_lookup_style (context);
+ border_color = style->border->border_top_color ? &style->border->_border_color[GTK_CSS_TOP] :
&style->core->_color;
gtk_style_context_get_border (context, &border);
cairo_set_line_width (cr, border.left);
diff --git a/gtk/gtkgridlayout.c b/gtk/gtkgridlayout.c
index d449f43da1..4da0a47787 100644
--- a/gtk/gtkgridlayout.c
+++ b/gtk/gtkgridlayout.c
@@ -464,17 +464,8 @@ get_spacing (GtkGridLayout *self,
{
GtkCssNode *node = gtk_widget_get_css_node (widget);
GtkCssStyle *style = gtk_css_node_get_style (node);
- GtkCssValue *border_spacing;
- int css_spacing;
- border_spacing = style->size->border_spacing;
-
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- css_spacing = _gtk_css_position_value_get_x (border_spacing, 100);
- else
- css_spacing = _gtk_css_position_value_get_y (border_spacing, 100);
-
- return css_spacing + self->linedata[orientation].spacing;
+ return style->size->_border_spacing[orientation] + self->linedata[orientation].spacing;
}
/* Calculates the min and max numbers for both orientations. */
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index 80cbca7474..ef5473f24f 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -55,13 +55,10 @@ get_icon_lookup_flags (GtkIconHelper *self,
GtkCssStyle *style)
{
GtkIconLookupFlags flags;
- GtkCssIconStyle icon_style;
flags = 0;
- icon_style = _gtk_css_icon_style_value_get (style->icon->icon_style);
-
- switch (icon_style)
+ switch (style->icon->_icon_style)
{
case GTK_CSS_ICON_STYLE_REGULAR:
flags |= GTK_ICON_LOOKUP_FORCE_REGULAR;
@@ -455,7 +452,7 @@ gtk_icon_helper_get_size (GtkIconHelper *self)
return self->pixel_size;
style = gtk_css_node_get_style (self->node);
- return _gtk_css_number_value_get (style->icon->icon_size, 100);
+ return style->icon->_icon_size;
}
void
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 4c39604132..9f0ce0cab1 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -2546,7 +2546,7 @@ void
gtk_icon_theme_lookup_symbolic_colors (GtkCssStyle *style,
GdkRGBA color_out[4])
{
- GtkCssValue *palette, *color;
+ GtkCssValue *palette;
const char *names[4] = {
[GTK_SYMBOLIC_COLOR_ERROR] = "error",
[GTK_SYMBOLIC_COLOR_WARNING] = "warning",
@@ -2555,9 +2555,8 @@ gtk_icon_theme_lookup_symbolic_colors (GtkCssStyle *style,
const GdkRGBA *lookup;
gsize i;
- color = style->core->color;
palette = style->core->icon_palette;
- color_out[GTK_SYMBOLIC_COLOR_FOREGROUND] = *gtk_css_color_value_get_rgba (color);
+ color_out[GTK_SYMBOLIC_COLOR_FOREGROUND] = style->core->_color;
for (i = 1; i < 4; i++)
{
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 3a9828e9f0..990243b3da 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -828,7 +828,7 @@ gtk_label_update_layout_attributes (GtkLabel *self,
g_slist_free (attributes);
}
- link_color = gtk_css_color_value_get_rgba (style->core->color);
+ link_color = &style->core->_color;
attr = pango_attr_foreground_new (link_color->red * 65535,
link_color->green * 65535,
link_color->blue * 65535);
diff --git a/gtk/gtknative.c b/gtk/gtknative.c
index aafdbb163e..8fcf5ea43f 100644
--- a/gtk/gtknative.c
+++ b/gtk/gtknative.c
@@ -341,16 +341,12 @@ subtract_decoration_corners_from_region (cairo_region_t *region,
cairo_region_subtract_rectangle (region, &rect);
}
-static int
-get_translucent_border_edge (const GtkCssValue *color,
- const GtkCssValue *border_color,
- const GtkCssValue *border_width)
+static inline int
+get_translucent_border_edge (const GdkRGBA *border_color,
+ float border_width)
{
- if (border_color == NULL)
- border_color = color;
-
- if (!gdk_rgba_is_opaque (gtk_css_color_value_get_rgba (border_color)))
- return round (_gtk_css_number_value_get (border_width, 100));
+ if (!gdk_rgba_is_opaque (border_color))
+ return round (border_width);
return 0;
}
@@ -362,18 +358,22 @@ get_translucent_border_width (GtkWidget *widget,
GtkCssNode *css_node = gtk_widget_get_css_node (widget);
GtkCssStyle *style = gtk_css_node_get_style (css_node);
- border->top = get_translucent_border_edge (style->core->color,
- style->border->border_top_color,
- style->border->border_top_width);
- border->bottom = get_translucent_border_edge (style->core->color,
- style->border->border_bottom_color,
- style->border->border_bottom_width);
- border->left = get_translucent_border_edge (style->core->color,
- style->border->border_left_color,
- style->border->border_left_width);
- border->right = get_translucent_border_edge (style->core->color,
- style->border->border_right_color,
- style->border->border_right_width);
+ border->top = get_translucent_border_edge (style->border->border_top_color
+ ? &style->border->_border_color[GTK_CSS_TOP]
+ : &style->core->_color,
+ style->border->_border_width[GTK_CSS_TOP]);
+ border->right = get_translucent_border_edge (style->border->border_right_color
+ ? &style->border->_border_color[GTK_CSS_RIGHT]
+ : &style->core->_color,
+ style->border->_border_width[GTK_CSS_RIGHT]);
+ border->bottom = get_translucent_border_edge (style->border->border_bottom_color
+ ? &style->border->_border_color[GTK_CSS_BOTTOM]
+ : &style->core->_color,
+ style->border->_border_width[GTK_CSS_BOTTOM]);
+ border->left = get_translucent_border_edge (style->border->border_left_color
+ ? &style->border->_border_color[GTK_CSS_LEFT]
+ : &style->core->_color,
+ style->border->_border_width[GTK_CSS_LEFT]);
}
static gboolean
@@ -381,7 +381,7 @@ get_opaque_rect (GtkWidget *widget,
const GtkCssStyle *style,
cairo_rectangle_int_t *rect)
{
- gboolean is_opaque = gdk_rgba_is_opaque (gtk_css_color_value_get_rgba
(style->background->background_color));
+ gboolean is_opaque = gdk_rgba_is_opaque (&style->background->_background_color);
if (is_opaque && gtk_widget_get_opacity (widget) < 1.0)
is_opaque = FALSE;
diff --git a/gtk/gtkpicture.c b/gtk/gtkpicture.c
index aa8599ebd9..5a4b46a273 100644
--- a/gtk/gtkpicture.c
+++ b/gtk/gtkpicture.c
@@ -213,7 +213,7 @@ gtk_picture_measure (GtkWidget *widget,
}
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
- default_size = _gtk_css_number_value_get (style->icon->icon_size, 100);
+ default_size = style->icon->_icon_size;
if (self->can_shrink)
{
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 8ac30372b7..ad18e56d9a 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -1203,10 +1203,10 @@ gtk_popover_get_gap_coords (GtkPopover *popover,
pos = priv->final_position;
style = gtk_css_node_get_style (gtk_widget_get_css_node (priv->contents_widget));
- border_radius = _gtk_css_number_value_get (style->border->border_top_left_radius, 100);
- border_top = _gtk_css_number_value_get (style->border->border_top_width, 100);
- border_right = _gtk_css_number_value_get (style->border->border_right_width, 100);
- border_bottom = _gtk_css_number_value_get (style->border->border_bottom_width, 100);
+ border_radius = style->border->_border_radius[GTK_CSS_TOP_LEFT].width;
+ border_top = style->border->_border_width[GTK_CSS_TOP];
+ border_right = style->border->_border_width[GTK_CSS_RIGHT];
+ border_bottom = style->border->_border_width[GTK_CSS_BOTTOM];
gtk_css_shadow_value_get_extents (style->background->box_shadow, &shadow_width);
@@ -1285,10 +1285,10 @@ get_border (GtkCssNode *node,
style = gtk_css_node_get_style (node);
- border->top = _gtk_css_number_value_get (style->border->border_top_width, 100);
- border->right = _gtk_css_number_value_get (style->border->border_right_width, 100);
- border->bottom = _gtk_css_number_value_get (style->border->border_bottom_width, 100);
- border->left = _gtk_css_number_value_get (style->border->border_left_width, 100);
+ border->top = style->border->_border_width[GTK_CSS_TOP];
+ border->right = style->border->_border_width[GTK_CSS_RIGHT];
+ border->bottom = style->border->_border_width[GTK_CSS_BOTTOM];
+ border->left = style->border->_border_width[GTK_CSS_LEFT];
}
static void
@@ -1405,7 +1405,7 @@ get_border_radius (GtkWidget *widget)
GtkCssStyle *style;
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
- return round (_gtk_css_number_value_get (style->border->border_top_left_radius, 100));
+ return round (style->border->_border_radius[GTK_CSS_TOP_LEFT].width);
}
static int
@@ -1583,7 +1583,7 @@ create_arrow_render_node (GtkPopover *popover)
const GdkRGBA *border_color;
style = gtk_css_node_get_style (priv->arrow_node);
- border_color = gtk_css_color_value_get_rgba (style->border->border_left_color ?
style->border->border_left_color : style->core->color);
+ border_color = style->border->border_left_color ? &style->border->_border_color[GTK_CSS_LEFT] :
&style->core->_color;
gtk_popover_apply_tail_path (popover, cr);
gdk_cairo_set_source_rgba (cr, border_color);
diff --git a/gtk/gtkrender.c b/gtk/gtkrender.c
index 414b940517..4b7592b528 100644
--- a/gtk/gtkrender.c
+++ b/gtk/gtkrender.c
@@ -387,14 +387,14 @@ gtk_render_line (GtkStyleContext *context,
double x1,
double y1)
{
- const GdkRGBA *color;
+ GtkCssStyle *style;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (cr != NULL);
cairo_save (cr);
- color = gtk_css_color_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
+ style = gtk_style_context_lookup_style (context);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
cairo_set_line_width (cr, 1);
@@ -402,7 +402,7 @@ gtk_render_line (GtkStyleContext *context,
cairo_move_to (cr, x0 + 0.5, y0 + 0.5);
cairo_line_to (cr, x1 + 0.5, y1 + 0.5);
- gdk_cairo_set_source_rgba (cr, color);
+ gdk_cairo_set_source_rgba (cr, &style->core->_color);
cairo_stroke (cr);
cairo_restore (cr);
diff --git a/gtk/gtkrenderbackground.c b/gtk/gtkrenderbackground.c
index 92a29ca9fb..d19a79edc8 100644
--- a/gtk/gtkrenderbackground.c
+++ b/gtk/gtkrenderbackground.c
@@ -259,7 +259,7 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
return;
background_image = background->background_image;
- bg_color = gtk_css_color_value_get_rgba (background->background_color);
+ bg_color = &background->_background_color;
box_shadow = background->box_shadow;
has_bg_color = !gdk_rgba_is_clear (bg_color);
diff --git a/gtk/gtkrenderborder.c b/gtk/gtkrenderborder.c
index c9415c4ebf..7377dd0fb9 100644
--- a/gtk/gtkrenderborder.c
+++ b/gtk/gtkrenderborder.c
@@ -525,7 +525,7 @@ snapshot_border (GtkSnapshot *snapshot,
const GskRoundedRect *border_box,
const float border_width[4],
GdkRGBA colors[4],
- GtkBorderStyle border_style[4])
+ const GtkBorderStyle border_style[4])
{
guint hidden_side = 0;
guint i, j;
@@ -648,7 +648,6 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
{
const GtkCssBorderValues *border = boxes->style->border;
GtkBorderImage border_image;
- float border_width[4];
if (border->base.type == GTK_CSS_BORDER_INITIAL_VALUES)
return;
@@ -658,22 +657,16 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
cairo_t *cr;
const graphene_rect_t *bounds;
- border_width[0] = _gtk_css_number_value_get (border->border_top_width, 100);
- border_width[1] = _gtk_css_number_value_get (border->border_right_width, 100);
- border_width[2] = _gtk_css_number_value_get (border->border_bottom_width, 100);
- border_width[3] = _gtk_css_number_value_get (border->border_left_width, 100);
-
bounds = gtk_css_boxes_get_border_rect (boxes);
gtk_snapshot_push_debug (snapshot, "CSS border image");
cr = gtk_snapshot_append_cairo (snapshot, bounds);
- gtk_border_image_render (&border_image, border_width, cr, bounds);
+ gtk_border_image_render (&border_image, border->_border_width, cr, bounds);
cairo_destroy (cr);
gtk_snapshot_pop (snapshot);
}
else
{
- GtkBorderStyle border_style[4];
GdkRGBA colors[4];
graphene_simd4f_t alpha_test_vector;
@@ -682,44 +675,37 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
gtk_css_boxes_get_padding_rect (boxes)))
return;
- colors[0] = *gtk_css_color_value_get_rgba (border->border_top_color ? border->border_top_color :
boxes->style->core->color);
- colors[1] = *gtk_css_color_value_get_rgba (border->border_right_color ? border->border_right_color :
boxes->style->core->color);
- colors[2] = *gtk_css_color_value_get_rgba (border->border_bottom_color ? border->border_bottom_color :
boxes->style->core->color);
- colors[3] = *gtk_css_color_value_get_rgba (border->border_left_color ? border->border_left_color :
boxes->style->core->color);
+ colors[GTK_CSS_TOP] = border->border_top_color ? border->_border_color[GTK_CSS_TOP] :
boxes->style->core->_color;
+ colors[GTK_CSS_RIGHT] = border->border_right_color ? border->_border_color[GTK_CSS_RIGHT] :
boxes->style->core->_color;
+ colors[GTK_CSS_BOTTOM] = border->border_bottom_color ? border->_border_color[GTK_CSS_BOTTOM] :
boxes->style->core->_color;
+ colors[GTK_CSS_LEFT] = border->border_left_color ? border->_border_color[GTK_CSS_LEFT] :
boxes->style->core->_color;
- alpha_test_vector = graphene_simd4f_init (colors[0].alpha, colors[1].alpha, colors[2].alpha,
colors[3].alpha);
+ alpha_test_vector = graphene_simd4f_init (colors[GTK_CSS_TOP].alpha,
+ colors[GTK_CSS_RIGHT].alpha,
+ colors[GTK_CSS_BOTTOM].alpha,
+ colors[GTK_CSS_LEFT].alpha);
if (graphene_simd4f_is_zero4 (alpha_test_vector))
return;
- border_style[0] = _gtk_css_border_style_value_get (border->border_top_style);
- border_style[1] = _gtk_css_border_style_value_get (border->border_right_style);
- border_style[2] = _gtk_css_border_style_value_get (border->border_bottom_style);
- border_style[3] = _gtk_css_border_style_value_get (border->border_left_style);
-
- border_width[0] = _gtk_css_number_value_get (border->border_top_width, 100);
- border_width[1] = _gtk_css_number_value_get (border->border_right_width, 100);
- border_width[2] = _gtk_css_number_value_get (border->border_bottom_width, 100);
- border_width[3] = _gtk_css_number_value_get (border->border_left_width, 100);
-
gtk_snapshot_push_debug (snapshot, "CSS border");
- if (border_style[0] <= GTK_BORDER_STYLE_SOLID &&
- border_style[1] <= GTK_BORDER_STYLE_SOLID &&
- border_style[2] <= GTK_BORDER_STYLE_SOLID &&
- border_style[3] <= GTK_BORDER_STYLE_SOLID)
+ if (border->_border_style[GTK_CSS_TOP] <= GTK_BORDER_STYLE_SOLID &&
+ border->_border_style[GTK_CSS_RIGHT] <= GTK_BORDER_STYLE_SOLID &&
+ border->_border_style[GTK_CSS_BOTTOM] <= GTK_BORDER_STYLE_SOLID &&
+ border->_border_style[GTK_CSS_LEFT] <= GTK_BORDER_STYLE_SOLID)
{
/* The most common case of a solid border */
gtk_snapshot_append_border (snapshot,
gtk_css_boxes_get_border_box (boxes),
- border_width,
+ border->_border_width,
colors);
}
else
{
snapshot_border (snapshot,
gtk_css_boxes_get_border_box (boxes),
- border_width,
+ border->_border_width,
colors,
- border_style);
+ border->_border_style);
}
gtk_snapshot_pop (snapshot);
}
@@ -734,16 +720,16 @@ gtk_css_style_snapshot_outline (GtkCssBoxes *boxes,
float border_width[4];
GdkRGBA colors[4];
- border_style[0] = _gtk_css_border_style_value_get (outline->outline_style);
+ border_style[0] = outline->_outline_style;
if (border_style[0] != GTK_BORDER_STYLE_NONE)
{
- const GdkRGBA *color = gtk_css_color_value_get_rgba (outline->outline_color ?
- outline->outline_color :
- boxes->style->core->color);
+ const GdkRGBA *color;
+
+ color = outline->outline_color ? &outline->_outline_color : &boxes->style->core->_color;
if (gdk_rgba_is_clear (color))
return;
- border_width[0] = _gtk_css_number_value_get (outline->outline_width, 100);
+ border_width[0] = outline->_outline_width;
if (G_APPROX_VALUE (border_width[0], 0, FLT_EPSILON))
return;
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c
index 637a705f87..5ef9063be6 100644
--- a/gtk/gtksizerequest.c
+++ b/gtk/gtksizerequest.c
@@ -82,52 +82,43 @@ fetch_request_mode (GtkWidget *widget)
return GTK_WIDGET_GET_CLASS (widget)->get_request_mode (widget);
}
-static int
-get_number (GtkCssValue *value)
+static inline int
+ceil_or_floor (float d)
{
- double d = _gtk_css_number_value_get (value, 100);
-
if (d < 1)
- return ceil (d);
+ return ceilf (d);
else
- return floor (d);
-}
-
-/* Special-case min-width|height to round upwards, to avoid underalloc by 1px */
-static int
-get_number_ceil (GtkCssValue *value)
-{
- return ceil (_gtk_css_number_value_get (value, 100));
+ return floorf (d);
}
-static void
+static inline void
get_box_margin (GtkCssStyle *style,
GtkBorder *margin)
{
- margin->top = get_number (style->size->margin_top);
- margin->left = get_number (style->size->margin_left);
- margin->bottom = get_number (style->size->margin_bottom);
- margin->right = get_number (style->size->margin_right);
+ margin->top = ceil_or_floor (style->size->_margin[GTK_CSS_TOP]);
+ margin->right = ceil_or_floor (style->size->_margin[GTK_CSS_RIGHT]);
+ margin->bottom = ceil_or_floor (style->size->_margin[GTK_CSS_BOTTOM]);
+ margin->left = ceil_or_floor (style->size->_margin[GTK_CSS_LEFT]);
}
-static void
+static inline void
get_box_border (GtkCssStyle *style,
GtkBorder *border)
{
- border->top = get_number (style->border->border_top_width);
- border->left = get_number (style->border->border_left_width);
- border->bottom = get_number (style->border->border_bottom_width);
- border->right = get_number (style->border->border_right_width);
+ border->top = ceil_or_floor (style->border->_border_width[GTK_CSS_TOP]);
+ border->right = ceil_or_floor (style->border->_border_width[GTK_CSS_RIGHT]);
+ border->bottom = ceil_or_floor (style->border->_border_width[GTK_CSS_BOTTOM]);
+ border->left = ceil_or_floor (style->border->_border_width[GTK_CSS_LEFT]);
}
-static void
+static inline void
get_box_padding (GtkCssStyle *style,
- GtkBorder *border)
+ GtkBorder *padding)
{
- border->top = get_number (style->size->padding_top);
- border->left = get_number (style->size->padding_left);
- border->bottom = get_number (style->size->padding_bottom);
- border->right = get_number (style->size->padding_right);
+ padding->top = ceil_or_floor (style->size->_padding[GTK_CSS_TOP]);
+ padding->right = ceil_or_floor (style->size->_padding[GTK_CSS_RIGHT]);
+ padding->bottom = ceil_or_floor (style->size->_padding[GTK_CSS_BOTTOM]);
+ padding->left = ceil_or_floor (style->size->_padding[GTK_CSS_LEFT]);
}
static void
@@ -190,20 +181,19 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
widget_class = GTK_WIDGET_GET_CLASS (widget);
+ css_min_size = ceil (style->size->_min_size[orientation]);
+ css_min_for_size = ceil (style->size->_min_size[1 - orientation]);
+
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
css_extra_size = margin.left + margin.right + border.left + border.right + padding.left +
padding.right;
css_extra_for_size = margin.top + margin.bottom + border.top + border.bottom + padding.top +
padding.bottom;
- css_min_size = get_number_ceil (style->size->min_width);
- css_min_for_size = get_number_ceil (style->size->min_height);
widget_margins_for_size = widget->priv->margin.top + widget->priv->margin.bottom;
}
else
{
css_extra_size = margin.top + margin.bottom + border.top + border.bottom + padding.top +
padding.bottom;
css_extra_for_size = margin.left + margin.right + border.left + border.right + padding.left +
padding.right;
- css_min_size = get_number_ceil (style->size->min_height);
- css_min_for_size = get_number_ceil (style->size->min_width);
widget_margins_for_size = widget->priv->margin.left + widget->priv->margin.right;
}
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index afa27b45f1..3dc61b253d 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -2093,9 +2093,9 @@ gtk_snapshot_render_layout (GtkSnapshot *snapshot,
PangoLayout *layout)
{
const bool needs_translate = (x != 0 || y != 0);
- const GdkRGBA *fg_color;
GtkCssValue *shadows_value;
gboolean has_shadow;
+ GtkCssStyle *style;
g_return_if_fail (snapshot != NULL);
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
@@ -2107,12 +2107,12 @@ gtk_snapshot_render_layout (GtkSnapshot *snapshot,
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
}
- fg_color = gtk_css_color_value_get_rgba (_gtk_style_context_peek_property (context,
GTK_CSS_PROPERTY_COLOR));
+ style = gtk_style_context_lookup_style (context);
shadows_value = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_TEXT_SHADOW);
has_shadow = gtk_css_shadow_value_push_snapshot (shadows_value, snapshot);
- gtk_snapshot_append_layout (snapshot, layout, fg_color);
+ gtk_snapshot_append_layout (snapshot, layout, &style->core->_color);
if (has_shadow)
gtk_snapshot_pop (snapshot);
diff --git a/gtk/gtkspinner.c b/gtk/gtkspinner.c
index 4d487e1c4a..6f40c3b972 100644
--- a/gtk/gtkspinner.c
+++ b/gtk/gtkspinner.c
@@ -94,7 +94,7 @@ gtk_spinner_measure (GtkWidget *widget,
GtkCssStyle *style;
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
- *minimum = *natural = _gtk_css_number_value_get (style->icon->icon_size, 100);
+ *minimum = *natural = style->icon->_icon_size;
}
static void
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 5fca489632..85419fe3d8 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -22,7 +22,6 @@
#include <gdk/gdk.h>
#include "gtkcsscolorvalueprivate.h"
-#include "gtkcssnumbervalueprivate.h"
#include "gtkcsstransientnodeprivate.h"
#include "gtkdebug.h"
#include "gtkintl.h"
@@ -856,10 +855,14 @@ void
gtk_style_context_get_color (GtkStyleContext *context,
GdkRGBA *color)
{
+ GtkCssStyle *style;
+
g_return_if_fail (color != NULL);
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
- *color = *gtk_css_color_value_get_rgba (_gtk_style_context_peek_property (context,
GTK_CSS_PROPERTY_COLOR));
+ style = gtk_style_context_lookup_style (context);
+
+ *color = style->core->_color;
}
/**
@@ -880,10 +883,10 @@ gtk_style_context_get_border (GtkStyleContext *context,
style = gtk_style_context_lookup_style (context);
- border->top = round (_gtk_css_number_value_get (style->border->border_top_width, 100));
- border->right = round (_gtk_css_number_value_get (style->border->border_right_width, 100));
- border->bottom = round (_gtk_css_number_value_get (style->border->border_bottom_width, 100));
- border->left = round (_gtk_css_number_value_get (style->border->border_left_width, 100));
+ border->top = round (style->border->_border_width[GTK_CSS_TOP]);
+ border->right = round (style->border->_border_width[GTK_CSS_RIGHT]);
+ border->bottom = round (style->border->_border_width[GTK_CSS_BOTTOM]);
+ border->left = round (style->border->_border_width[GTK_CSS_LEFT]);
}
/**
@@ -904,10 +907,10 @@ gtk_style_context_get_padding (GtkStyleContext *context,
style = gtk_style_context_lookup_style (context);
- padding->top = round (_gtk_css_number_value_get (style->size->padding_top, 100));
- padding->right = round (_gtk_css_number_value_get (style->size->padding_right, 100));
- padding->bottom = round (_gtk_css_number_value_get (style->size->padding_bottom, 100));
- padding->left = round (_gtk_css_number_value_get (style->size->padding_left, 100));
+ padding->top = round (style->size->_padding[GTK_CSS_TOP]);
+ padding->right = round (style->size->_padding[GTK_CSS_RIGHT]);
+ padding->bottom = round (style->size->_padding[GTK_CSS_BOTTOM]);
+ padding->left = round (style->size->_padding[GTK_CSS_LEFT]);
}
/**
@@ -928,10 +931,10 @@ gtk_style_context_get_margin (GtkStyleContext *context,
style = gtk_style_context_lookup_style (context);
- margin->top = round (_gtk_css_number_value_get (style->size->margin_top, 100));
- margin->right = round (_gtk_css_number_value_get (style->size->margin_right, 100));
- margin->bottom = round (_gtk_css_number_value_get (style->size->margin_bottom, 100));
- margin->left = round (_gtk_css_number_value_get (style->size->margin_left, 100));
+ margin->top = round (style->size->_margin[GTK_CSS_TOP]);
+ margin->right = round (style->size->_margin[GTK_CSS_RIGHT]);
+ margin->bottom = round (style->size->_margin[GTK_CSS_BOTTOM]);
+ margin->left = round (style->size->_margin[GTK_CSS_LEFT]);
}
void
diff --git a/gtk/gtktexthandle.c b/gtk/gtktexthandle.c
index 05f6d809aa..70f5ae69e7 100644
--- a/gtk/gtktexthandle.c
+++ b/gtk/gtktexthandle.c
@@ -117,10 +117,10 @@ gtk_text_handle_get_padding (GtkTextHandle *handle,
GtkWidget *widget = GTK_WIDGET (handle);
GtkCssStyle *style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
- padding->left = _gtk_css_number_value_get (style->size->padding_left, 100);
- padding->right = _gtk_css_number_value_get (style->size->padding_right, 100);
- padding->top = _gtk_css_number_value_get (style->size->padding_top, 100);
- padding->bottom = _gtk_css_number_value_get (style->size->padding_bottom, 100);
+ padding->left = style->size->_padding[GTK_CSS_LEFT];
+ padding->right = style->size->_padding[GTK_CSS_RIGHT];
+ padding->top = style->size->_padding[GTK_CSS_TOP];
+ padding->bottom = style->size->_padding[GTK_CSS_BOTTOM];
}
static void
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index ad0570b6b1..d1646815ac 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -4148,6 +4148,7 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
if (have_selection)
{
GtkCssNode *selection_node;
+ GtkCssStyle *style;
GdkRGBA text_color;
selection_start_line = gtk_text_iter_get_line (&selection_start);
@@ -4156,9 +4157,11 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
selection_node = gtk_text_view_get_selection_node ((GtkTextView*)widget);
gtk_style_context_save_to_node (context, selection_node);
- selection = gtk_css_color_value_get_rgba (_gtk_style_context_peek_property (context,
GTK_CSS_PROPERTY_BACKGROUND_COLOR));
+ style = gtk_style_context_lookup_style (context);
+
+ selection = &style->background->_background_color;
+ text_color = style->core->_color;
- gtk_style_context_get_color (context, &text_color);
draw_selection_text = text_color.alpha > 0;
gtk_style_context_restore (context);
diff --git a/gtk/gtktextutil.c b/gtk/gtktextutil.c
index 75f081732a..cf192981a2 100644
--- a/gtk/gtktextutil.c
+++ b/gtk/gtktextutil.c
@@ -133,7 +133,7 @@ gtk_text_util_create_drag_icon (GtkWidget *widget,
snapshot = gtk_snapshot_new ();
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
- color = gtk_css_color_value_get_rgba (style->core->color);
+ color = &style->core->_color;
display = gtk_widget_get_display (widget);
@@ -175,8 +175,8 @@ set_attributes_from_style (GtkWidget *widget,
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
- *values->appearance.bg_rgba = *gtk_css_color_value_get_rgba (style->background->background_color);
- *values->appearance.fg_rgba = *gtk_css_color_value_get_rgba (style->core->color);
+ *values->appearance.bg_rgba = style->background->_background_color;
+ *values->appearance.fg_rgba = style->core->_color;
if (values->font)
pango_font_description_free (values->font);
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 2e600e01bb..c7b1b517b1 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -7714,10 +7714,8 @@ gtk_text_view_set_attributes_from_style (GtkTextView *text_view,
style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (text_view)));
- color = gtk_css_color_value_get_rgba (style->background->background_color);
- *values->appearance.bg_rgba = *color;
- color = gtk_css_color_value_get_rgba (style->core->color);
- *values->appearance.fg_rgba = *color;
+ *values->appearance.bg_rgba = style->background->_background_color;
+ *values->appearance.fg_rgba = style->core->_color;
if (values->font)
pango_font_description_free (values->font);
@@ -7728,9 +7726,7 @@ gtk_text_view_set_attributes_from_style (GtkTextView *text_view,
decoration_line = _gtk_css_text_decoration_line_value_get (style->font_variant->text_decoration_line);
decoration_style = _gtk_css_text_decoration_style_value_get (style->font_variant->text_decoration_style);
- decoration_color = gtk_css_color_value_get_rgba (style->font_variant->text_decoration_color
- ? style->font_variant->text_decoration_color
- : style->core->color);
+ decoration_color = style->font_variant->text_decoration_color ? gtk_css_color_value_get_rgba
(style->font_variant->text_decoration_color) : &style->core->_color;
if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE)
{
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 07e02ee7d4..a1d096d04a 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -2687,8 +2687,8 @@ gtk_tree_view_get_expander_size (GtkTreeView *tree_view)
gtk_style_context_add_class (context, "expander");
style = gtk_style_context_lookup_style (context);
- min_width = _gtk_css_number_value_get (style->size->min_width, 100);
- min_height = _gtk_css_number_value_get (style->size->min_height, 100);
+ min_width = style->size->_min_size[GTK_ORIENTATION_HORIZONTAL];
+ min_height = style->size->_min_size[GTK_ORIENTATION_VERTICAL];
gtk_style_context_restore (context);
@@ -4173,11 +4173,12 @@ gtk_tree_view_snapshot_grid_line (GtkTreeView *tree_view,
{
GtkTreeViewPrivate *priv = gtk_tree_view_get_instance_private (tree_view);
GtkStyleContext *context;
+ GtkCssStyle *style;
const GdkRGBA *grid_line_color;
context = gtk_widget_get_style_context (GTK_WIDGET (tree_view));
- grid_line_color = gtk_css_color_value_get_rgba (_gtk_style_context_peek_property (context,
-
GTK_CSS_PROPERTY_BORDER_TOP_COLOR));
+ style = gtk_style_context_lookup_style (context);
+ grid_line_color = style->border->border_top_color ? &style->border->_border_color[GTK_CSS_TOP] :
&style->core->_color;
if (!gdk_rgba_equal (grid_line_color, &priv->grid_line_color) ||
(orientation == GTK_ORIENTATION_HORIZONTAL && !priv->horizontal_grid_line_texture) ||
@@ -4248,11 +4249,12 @@ gtk_tree_view_snapshot_tree_line (GtkTreeView *tree_view,
{
GtkTreeViewPrivate *priv = gtk_tree_view_get_instance_private (tree_view);
GtkStyleContext *context;
+ GtkCssStyle *style;
const GdkRGBA *tree_line_color;
context = gtk_widget_get_style_context (GTK_WIDGET (tree_view));
- tree_line_color = gtk_css_color_value_get_rgba (_gtk_style_context_peek_property (context,
-
GTK_CSS_PROPERTY_BORDER_LEFT_COLOR));
+ style = gtk_style_context_lookup_style (context);
+ tree_line_color = style->border->border_left_color ? &style->border->_border_color[GTK_CSS_LEFT] :
&style->core->_color;
if (!gdk_rgba_equal (tree_line_color, &priv->tree_line_color) ||
(orientation == GTK_ORIENTATION_HORIZONTAL && !priv->horizontal_tree_line_texture) ||
@@ -5528,7 +5530,7 @@ get_separator_height (GtkTreeView *tree_view)
gtk_style_context_add_class (context, "separator");
style = gtk_style_context_lookup_style (context);
- d = _gtk_css_number_value_get (style->size->min_height, 100);
+ d = style->size->_min_size[GTK_ORIENTATION_VERTICAL];
if (d < 1)
min_size = ceil (d);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index dda5a1f042..ce95278975 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -3671,45 +3671,43 @@ gtk_widget_get_frame_clock (GtkWidget *widget)
}
}
-static int
-get_number (GtkCssValue *value)
+static inline int
+ceil_or_floor (float d)
{
- double d = _gtk_css_number_value_get (value, 100);
-
if (d < 1)
- return ceil (d);
+ return ceilf (d);
else
- return floor (d);
+ return floorf (d);
}
-static void
+static inline void
get_box_margin (GtkCssStyle *style,
GtkBorder *margin)
{
- margin->top = get_number (style->size->margin_top);
- margin->left = get_number (style->size->margin_left);
- margin->bottom = get_number (style->size->margin_bottom);
- margin->right = get_number (style->size->margin_right);
+ margin->top = ceil_or_floor (style->size->_margin[GTK_CSS_TOP]);
+ margin->right = ceil_or_floor (style->size->_margin[GTK_CSS_RIGHT]);
+ margin->bottom = ceil_or_floor (style->size->_margin[GTK_CSS_BOTTOM]);
+ margin->left = ceil_or_floor (style->size->_margin[GTK_CSS_LEFT]);
}
-static void
+static inline void
get_box_border (GtkCssStyle *style,
GtkBorder *border)
{
- border->top = get_number (style->border->border_top_width);
- border->left = get_number (style->border->border_left_width);
- border->bottom = get_number (style->border->border_bottom_width);
- border->right = get_number (style->border->border_right_width);
+ border->top = ceil_or_floor (style->border->_border_width[GTK_CSS_TOP]);
+ border->right = ceil_or_floor (style->border->_border_width[GTK_CSS_RIGHT]);
+ border->bottom = ceil_or_floor (style->border->_border_width[GTK_CSS_BOTTOM]);
+ border->left = ceil_or_floor (style->border->_border_width[GTK_CSS_LEFT]);
}
-static void
+static inline void
get_box_padding (GtkCssStyle *style,
- GtkBorder *border)
+ GtkBorder *padding)
{
- border->top = get_number (style->size->padding_top);
- border->left = get_number (style->size->padding_left);
- border->bottom = get_number (style->size->padding_bottom);
- border->right = get_number (style->size->padding_right);
+ padding->top = ceil_or_floor (style->size->_padding[GTK_CSS_TOP]);
+ padding->right = ceil_or_floor (style->size->_padding[GTK_CSS_RIGHT]);
+ padding->bottom = ceil_or_floor (style->size->_padding[GTK_CSS_BOTTOM]);
+ padding->left = ceil_or_floor (style->size->_padding[GTK_CSS_LEFT]);
}
/**
@@ -6428,7 +6426,7 @@ gtk_widget_update_pango_context (GtkWidget *widget,
? PANGO_DIRECTION_LTR
: PANGO_DIRECTION_RTL);
- pango_cairo_context_set_resolution (context, _gtk_css_number_value_get (style->core->dpi, 100));
+ pango_cairo_context_set_resolution (context, style->core->_dpi);
font_options = (cairo_font_options_t*)g_object_get_qdata (G_OBJECT (widget), quark_font_options);
if (settings && font_options)
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index efd1cff6f0..f9bb413337 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1340,25 +1340,23 @@ constraints_for_edge (GdkSurfaceEdge edge)
}
}
-static int
-get_number (GtkCssValue *value)
+static inline int
+ceil_or_floor (float d)
{
- double d = _gtk_css_number_value_get (value, 100);
-
if (d < 1)
- return ceil (d);
+ return ceilf (d);
else
- return floor (d);
+ return floorf (d);
}
-static void
+static inline void
get_box_border (GtkCssStyle *style,
GtkBorder *border)
{
- border->top = get_number (style->border->border_top_width) + get_number (style->size->padding_top);
- border->left = get_number (style->border->border_left_width) + get_number (style->size->padding_left);
- border->bottom = get_number (style->border->border_bottom_width) + get_number
(style->size->padding_bottom);
- border->right = get_number (style->border->border_right_width) + get_number (style->size->padding_right);
+ border->top = ceil_or_floor (style->border->_border_width[GTK_CSS_TOP]) + ceil_or_floor
(style->size->_padding[GTK_CSS_TOP]);
+ border->right = ceil_or_floor (style->border->_border_width[GTK_CSS_RIGHT]) + ceil_or_floor
(style->size->_padding[GTK_CSS_RIGHT]);
+ border->bottom = ceil_or_floor (style->border->_border_width[GTK_CSS_BOTTOM]) + ceil_or_floor
(style->size->_padding[GTK_CSS_BOTTOM]);
+ border->left = ceil_or_floor (style->border->_border_width[GTK_CSS_LEFT]) + ceil_or_floor
(style->size->_padding[GTK_CSS_LEFT]);
}
static int
diff --git a/gtk/inspector/layoutoverlay.c b/gtk/inspector/layoutoverlay.c
index a72a40940e..b977bd077f 100644
--- a/gtk/inspector/layoutoverlay.c
+++ b/gtk/inspector/layoutoverlay.c
@@ -20,45 +20,43 @@ struct _GtkLayoutOverlayClass
G_DEFINE_TYPE (GtkLayoutOverlay, gtk_layout_overlay, GTK_TYPE_INSPECTOR_OVERLAY)
-static int
-get_number (GtkCssValue *value)
+static inline int
+ceil_or_floor (float d)
{
- double d = _gtk_css_number_value_get (value, 100);
-
if (d < 1)
- return ceil (d);
+ return ceilf (d);
else
- return floor (d);
+ return floorf (d);
}
-static void
+static inline void
get_box_margin (GtkCssStyle *style,
GtkBorder *margin)
{
- margin->top = get_number (style->size->margin_top);
- margin->left = get_number (style->size->margin_left);
- margin->bottom = get_number (style->size->margin_bottom);
- margin->right = get_number (style->size->margin_right);
+ margin->top = ceil_or_floor (style->size->_margin[GTK_CSS_TOP]);
+ margin->right = ceil_or_floor (style->size->_margin[GTK_CSS_RIGHT]);
+ margin->bottom = ceil_or_floor (style->size->_margin[GTK_CSS_BOTTOM]);
+ margin->left = ceil_or_floor (style->size->_margin[GTK_CSS_LEFT]);
}
-static void
+static inline void
get_box_border (GtkCssStyle *style,
GtkBorder *border)
{
- border->top = get_number (style->border->border_top_width);
- border->left = get_number (style->border->border_left_width);
- border->bottom = get_number (style->border->border_bottom_width);
- border->right = get_number (style->border->border_right_width);
+ border->top = ceil_or_floor (style->border->_border_width[GTK_CSS_TOP]);
+ border->right = ceil_or_floor (style->border->_border_width[GTK_CSS_RIGHT]);
+ border->bottom = ceil_or_floor (style->border->_border_width[GTK_CSS_BOTTOM]);
+ border->left = ceil_or_floor (style->border->_border_width[GTK_CSS_LEFT]);
}
-static void
+static inline void
get_box_padding (GtkCssStyle *style,
- GtkBorder *border)
+ GtkBorder *padding)
{
- border->top = get_number (style->size->padding_top);
- border->left = get_number (style->size->padding_left);
- border->bottom = get_number (style->size->padding_bottom);
- border->right = get_number (style->size->padding_right);
+ padding->top = ceil_or_floor (style->size->_padding[GTK_CSS_TOP]);
+ padding->right = ceil_or_floor (style->size->_padding[GTK_CSS_RIGHT]);
+ padding->bottom = ceil_or_floor (style->size->_padding[GTK_CSS_BOTTOM]);
+ padding->left = ceil_or_floor (style->size->_padding[GTK_CSS_LEFT]);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]