mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 14:10:30 +00:00
cssnode: Make parent style change part of GtkCssNode
This commit is contained in:
parent
ceaa594fa4
commit
5833858abf
@ -1848,8 +1848,7 @@ gtk_container_idle_sizer (GdkFrameClock *clock,
|
||||
{
|
||||
container->priv->restyle_pending = FALSE;
|
||||
gtk_css_node_validate (gtk_widget_get_css_node (GTK_WIDGET (container)),
|
||||
gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (GTK_WIDGET (container))),
|
||||
FALSE);
|
||||
gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (GTK_WIDGET (container))));
|
||||
}
|
||||
|
||||
/* we may be invoked with a container_resize_queue of NULL, because
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
/* When these change we do a full restyling. Otherwise we try to figure out
|
||||
* if we need to change things. */
|
||||
#define GTK_CSS_RADICAL_CHANGE (GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_SOURCE)
|
||||
#define GTK_CSS_RADICAL_CHANGE (GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_SOURCE | GTK_CSS_CHANGE_PARENT_STYLE)
|
||||
|
||||
G_DEFINE_TYPE (GtkCssNode, gtk_css_node, G_TYPE_OBJECT)
|
||||
|
||||
@ -253,8 +253,7 @@ static GtkCssStyle *
|
||||
gtk_css_node_real_validate (GtkCssNode *cssnode,
|
||||
GtkCssStyle *current_style,
|
||||
gint64 timestamp,
|
||||
GtkCssChange change,
|
||||
gboolean parent_changed)
|
||||
GtkCssChange change)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -535,20 +534,20 @@ gtk_css_node_set_style (GtkCssNode *cssnode,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_node_propagate_pending_changes (GtkCssNode *cssnode)
|
||||
gtk_css_node_propagate_pending_changes (GtkCssNode *cssnode,
|
||||
gboolean style_changed)
|
||||
{
|
||||
GtkCssChange change, child_change;
|
||||
GtkCssNode *child;
|
||||
|
||||
if (!cssnode->invalid)
|
||||
return;
|
||||
|
||||
change = _gtk_css_change_for_child (cssnode->pending_changes);
|
||||
if (cssnode->children_changed)
|
||||
{
|
||||
change |= GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_ANY_SIBLING;
|
||||
cssnode->children_changed = FALSE;
|
||||
}
|
||||
if (style_changed)
|
||||
change |= GTK_CSS_CHANGE_PARENT_STYLE;
|
||||
|
||||
for (child = gtk_css_node_get_first_child (cssnode);
|
||||
child;
|
||||
@ -579,7 +578,7 @@ gtk_css_node_ensure_style (GtkCssNode *cssnode)
|
||||
cssnode->pending_changes,
|
||||
cssnode->style);
|
||||
|
||||
gtk_css_node_propagate_pending_changes (cssnode);
|
||||
gtk_css_node_propagate_pending_changes (cssnode, new_style != NULL);
|
||||
|
||||
if (new_style)
|
||||
{
|
||||
@ -769,8 +768,7 @@ gtk_css_node_invalidate (GtkCssNode *cssnode,
|
||||
|
||||
void
|
||||
gtk_css_node_validate (GtkCssNode *cssnode,
|
||||
gint64 timestamp,
|
||||
gboolean parent_changed)
|
||||
gint64 timestamp)
|
||||
{
|
||||
GtkCssNode *child;
|
||||
GtkCssStyle *new_style;
|
||||
@ -791,14 +789,14 @@ gtk_css_node_validate (GtkCssNode *cssnode,
|
||||
if (G_UNLIKELY (gtk_get_debug_flags () & GTK_DEBUG_NO_CSS_CACHE))
|
||||
cssnode->pending_changes |= GTK_CSS_CHANGE_ANY;
|
||||
|
||||
if (!cssnode->invalid && cssnode->pending_changes == 0 && !parent_changed)
|
||||
if (!cssnode->invalid && cssnode->pending_changes == 0)
|
||||
return;
|
||||
|
||||
gtk_css_node_set_invalid (cssnode, FALSE);
|
||||
|
||||
cssnode->style_is_invalid = FALSE;
|
||||
|
||||
new_style = GTK_CSS_NODE_GET_CLASS (cssnode)->validate (cssnode, cssnode->style, timestamp, cssnode->pending_changes, parent_changed);
|
||||
new_style = GTK_CSS_NODE_GET_CLASS (cssnode)->validate (cssnode, cssnode->style, timestamp, cssnode->pending_changes);
|
||||
if (new_style)
|
||||
{
|
||||
gtk_css_node_set_style (cssnode, new_style);
|
||||
@ -810,7 +808,7 @@ gtk_css_node_validate (GtkCssNode *cssnode,
|
||||
changed = FALSE;
|
||||
}
|
||||
|
||||
gtk_css_node_propagate_pending_changes (cssnode);
|
||||
gtk_css_node_propagate_pending_changes (cssnode, changed);
|
||||
cssnode->pending_changes = 0;
|
||||
|
||||
for (child = gtk_css_node_get_first_child (cssnode);
|
||||
@ -818,7 +816,7 @@ gtk_css_node_validate (GtkCssNode *cssnode,
|
||||
child = gtk_css_node_get_next_sibling (child))
|
||||
{
|
||||
if (child->visible)
|
||||
gtk_css_node_validate (child, timestamp, changed);
|
||||
gtk_css_node_validate (child, timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,8 +79,7 @@ struct _GtkCssNodeClass
|
||||
GtkCssStyle * (* validate) (GtkCssNode *cssnode,
|
||||
GtkCssStyle *current_style,
|
||||
gint64 timestamp,
|
||||
GtkCssChange change,
|
||||
gboolean parent_changed);
|
||||
GtkCssChange change);
|
||||
};
|
||||
|
||||
GType gtk_css_node_get_type (void) G_GNUC_CONST;
|
||||
@ -144,8 +143,7 @@ void gtk_css_node_invalidate_style_provider
|
||||
void gtk_css_node_invalidate (GtkCssNode *cssnode,
|
||||
GtkCssChange change);
|
||||
void gtk_css_node_validate (GtkCssNode *cssnode,
|
||||
gint64 timestamp,
|
||||
gboolean parent_changed);
|
||||
gint64 timestamp);
|
||||
void gtk_css_node_set_invalid (GtkCssNode *node,
|
||||
gboolean invalid);
|
||||
|
||||
|
@ -57,7 +57,8 @@ _gtk_css_change_for_sibling (GtkCssChange match)
|
||||
{ GTK_CSS_CHANGE_POSITION, GTK_CSS_CHANGE_SIBLING_POSITION },
|
||||
{ GTK_CSS_CHANGE_STATE, GTK_CSS_CHANGE_SIBLING_STATE },
|
||||
{ GTK_CSS_CHANGE_SOURCE, 0 },
|
||||
{ GTK_CSS_CHANGE_ANIMATE, 0 }
|
||||
{ GTK_CSS_CHANGE_ANIMATE, 0 },
|
||||
{ GTK_CSS_CHANGE_PARENT_STYLE, 0 }
|
||||
};
|
||||
|
||||
return gtk_css_change_translate (match, table, G_N_ELEMENTS (table));
|
||||
@ -76,7 +77,8 @@ _gtk_css_change_for_child (GtkCssChange match)
|
||||
{ GTK_CSS_CHANGE_SIBLING_POSITION, GTK_CSS_CHANGE_PARENT_SIBLING_POSITION },
|
||||
{ GTK_CSS_CHANGE_SIBLING_STATE, GTK_CSS_CHANGE_PARENT_SIBLING_STATE },
|
||||
{ GTK_CSS_CHANGE_SOURCE, 0 },
|
||||
{ GTK_CSS_CHANGE_ANIMATE, 0 }
|
||||
{ GTK_CSS_CHANGE_ANIMATE, 0 },
|
||||
{ GTK_CSS_CHANGE_PARENT_STYLE, 0 }
|
||||
};
|
||||
|
||||
return gtk_css_change_translate (match, table, G_N_ELEMENTS (table));
|
||||
|
@ -52,6 +52,7 @@ typedef enum { /*< skip >*/
|
||||
/* add more */
|
||||
GTK_CSS_CHANGE_SOURCE = (1 << 16),
|
||||
GTK_CSS_CHANGE_ANIMATE = (1 << 17),
|
||||
GTK_CSS_CHANGE_PARENT_STYLE = (1 << 18),
|
||||
|
||||
GTK_CSS_CHANGE_RESERVED_BIT = (1 << 31) /* Used internally in gtkcssselector.c */
|
||||
} GtkCssChange;
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
/* When these change we do a full restyling. Otherwise we try to figure out
|
||||
* if we need to change things. */
|
||||
#define GTK_CSS_RADICAL_CHANGE (GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_SOURCE)
|
||||
#define GTK_CSS_RADICAL_CHANGE (GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_SOURCE | GTK_CSS_CHANGE_PARENT_STYLE)
|
||||
|
||||
G_DEFINE_TYPE (GtkCssWidgetNode, gtk_css_widget_node, GTK_TYPE_CSS_NODE)
|
||||
|
||||
@ -87,11 +87,9 @@ gtk_css_static_style_needs_revalidate (GtkCssStaticStyle *style,
|
||||
static GtkCssStyle *
|
||||
validate_static_style (GtkCssNode *node,
|
||||
GtkCssStyle *style,
|
||||
GtkCssChange change,
|
||||
gboolean parent_changed)
|
||||
GtkCssChange change)
|
||||
{
|
||||
if (gtk_css_static_style_needs_revalidate (GTK_CSS_STATIC_STYLE (style), change) ||
|
||||
parent_changed)
|
||||
if (gtk_css_static_style_needs_revalidate (GTK_CSS_STATIC_STYLE (style), change))
|
||||
{
|
||||
return gtk_css_node_create_style (node);
|
||||
}
|
||||
@ -105,8 +103,7 @@ static GtkCssStyle *
|
||||
gtk_css_widget_node_validate (GtkCssNode *node,
|
||||
GtkCssStyle *style,
|
||||
gint64 timestamp,
|
||||
GtkCssChange change,
|
||||
gboolean parent_changed)
|
||||
GtkCssChange change)
|
||||
{
|
||||
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
|
||||
GtkStyleContext *context;
|
||||
@ -129,7 +126,7 @@ gtk_css_widget_node_validate (GtkCssNode *node,
|
||||
static_style = style;
|
||||
}
|
||||
|
||||
new_static_style = validate_static_style (node, static_style, change, parent_changed);
|
||||
new_static_style = validate_static_style (node, static_style, change);
|
||||
|
||||
if (new_static_style != static_style)
|
||||
{
|
||||
|
@ -5848,8 +5848,7 @@ gtk_window_show (GtkWidget *widget)
|
||||
need_resize = _gtk_widget_get_alloc_needed (widget) || !gtk_widget_get_realized (widget);
|
||||
|
||||
gtk_css_node_validate (gtk_widget_get_css_node (widget),
|
||||
g_get_monotonic_time (),
|
||||
FALSE);
|
||||
g_get_monotonic_time ());
|
||||
|
||||
if (need_resize)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user