forked from AuroraMiddleware/gtk
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;
|
container->priv->restyle_pending = FALSE;
|
||||||
gtk_css_node_validate (gtk_widget_get_css_node (GTK_WIDGET (container)),
|
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))),
|
gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (GTK_WIDGET (container))));
|
||||||
FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we may be invoked with a container_resize_queue of NULL, because
|
/* 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
|
/* When these change we do a full restyling. Otherwise we try to figure out
|
||||||
* if we need to change things. */
|
* 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)
|
G_DEFINE_TYPE (GtkCssNode, gtk_css_node, G_TYPE_OBJECT)
|
||||||
|
|
||||||
@ -253,8 +253,7 @@ static GtkCssStyle *
|
|||||||
gtk_css_node_real_validate (GtkCssNode *cssnode,
|
gtk_css_node_real_validate (GtkCssNode *cssnode,
|
||||||
GtkCssStyle *current_style,
|
GtkCssStyle *current_style,
|
||||||
gint64 timestamp,
|
gint64 timestamp,
|
||||||
GtkCssChange change,
|
GtkCssChange change)
|
||||||
gboolean parent_changed)
|
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -535,20 +534,20 @@ gtk_css_node_set_style (GtkCssNode *cssnode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
GtkCssChange change, child_change;
|
||||||
GtkCssNode *child;
|
GtkCssNode *child;
|
||||||
|
|
||||||
if (!cssnode->invalid)
|
|
||||||
return;
|
|
||||||
|
|
||||||
change = _gtk_css_change_for_child (cssnode->pending_changes);
|
change = _gtk_css_change_for_child (cssnode->pending_changes);
|
||||||
if (cssnode->children_changed)
|
if (cssnode->children_changed)
|
||||||
{
|
{
|
||||||
change |= GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_ANY_SIBLING;
|
change |= GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_ANY_SIBLING;
|
||||||
cssnode->children_changed = FALSE;
|
cssnode->children_changed = FALSE;
|
||||||
}
|
}
|
||||||
|
if (style_changed)
|
||||||
|
change |= GTK_CSS_CHANGE_PARENT_STYLE;
|
||||||
|
|
||||||
for (child = gtk_css_node_get_first_child (cssnode);
|
for (child = gtk_css_node_get_first_child (cssnode);
|
||||||
child;
|
child;
|
||||||
@ -579,7 +578,7 @@ gtk_css_node_ensure_style (GtkCssNode *cssnode)
|
|||||||
cssnode->pending_changes,
|
cssnode->pending_changes,
|
||||||
cssnode->style);
|
cssnode->style);
|
||||||
|
|
||||||
gtk_css_node_propagate_pending_changes (cssnode);
|
gtk_css_node_propagate_pending_changes (cssnode, new_style != NULL);
|
||||||
|
|
||||||
if (new_style)
|
if (new_style)
|
||||||
{
|
{
|
||||||
@ -769,8 +768,7 @@ gtk_css_node_invalidate (GtkCssNode *cssnode,
|
|||||||
|
|
||||||
void
|
void
|
||||||
gtk_css_node_validate (GtkCssNode *cssnode,
|
gtk_css_node_validate (GtkCssNode *cssnode,
|
||||||
gint64 timestamp,
|
gint64 timestamp)
|
||||||
gboolean parent_changed)
|
|
||||||
{
|
{
|
||||||
GtkCssNode *child;
|
GtkCssNode *child;
|
||||||
GtkCssStyle *new_style;
|
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))
|
if (G_UNLIKELY (gtk_get_debug_flags () & GTK_DEBUG_NO_CSS_CACHE))
|
||||||
cssnode->pending_changes |= GTK_CSS_CHANGE_ANY;
|
cssnode->pending_changes |= GTK_CSS_CHANGE_ANY;
|
||||||
|
|
||||||
if (!cssnode->invalid && cssnode->pending_changes == 0 && !parent_changed)
|
if (!cssnode->invalid && cssnode->pending_changes == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gtk_css_node_set_invalid (cssnode, FALSE);
|
gtk_css_node_set_invalid (cssnode, FALSE);
|
||||||
|
|
||||||
cssnode->style_is_invalid = 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)
|
if (new_style)
|
||||||
{
|
{
|
||||||
gtk_css_node_set_style (cssnode, new_style);
|
gtk_css_node_set_style (cssnode, new_style);
|
||||||
@ -810,7 +808,7 @@ gtk_css_node_validate (GtkCssNode *cssnode,
|
|||||||
changed = FALSE;
|
changed = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_css_node_propagate_pending_changes (cssnode);
|
gtk_css_node_propagate_pending_changes (cssnode, changed);
|
||||||
cssnode->pending_changes = 0;
|
cssnode->pending_changes = 0;
|
||||||
|
|
||||||
for (child = gtk_css_node_get_first_child (cssnode);
|
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))
|
child = gtk_css_node_get_next_sibling (child))
|
||||||
{
|
{
|
||||||
if (child->visible)
|
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 * (* validate) (GtkCssNode *cssnode,
|
||||||
GtkCssStyle *current_style,
|
GtkCssStyle *current_style,
|
||||||
gint64 timestamp,
|
gint64 timestamp,
|
||||||
GtkCssChange change,
|
GtkCssChange change);
|
||||||
gboolean parent_changed);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gtk_css_node_get_type (void) G_GNUC_CONST;
|
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,
|
void gtk_css_node_invalidate (GtkCssNode *cssnode,
|
||||||
GtkCssChange change);
|
GtkCssChange change);
|
||||||
void gtk_css_node_validate (GtkCssNode *cssnode,
|
void gtk_css_node_validate (GtkCssNode *cssnode,
|
||||||
gint64 timestamp,
|
gint64 timestamp);
|
||||||
gboolean parent_changed);
|
|
||||||
void gtk_css_node_set_invalid (GtkCssNode *node,
|
void gtk_css_node_set_invalid (GtkCssNode *node,
|
||||||
gboolean invalid);
|
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_POSITION, GTK_CSS_CHANGE_SIBLING_POSITION },
|
||||||
{ GTK_CSS_CHANGE_STATE, GTK_CSS_CHANGE_SIBLING_STATE },
|
{ GTK_CSS_CHANGE_STATE, GTK_CSS_CHANGE_SIBLING_STATE },
|
||||||
{ GTK_CSS_CHANGE_SOURCE, 0 },
|
{ 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));
|
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_POSITION, GTK_CSS_CHANGE_PARENT_SIBLING_POSITION },
|
||||||
{ GTK_CSS_CHANGE_SIBLING_STATE, GTK_CSS_CHANGE_PARENT_SIBLING_STATE },
|
{ GTK_CSS_CHANGE_SIBLING_STATE, GTK_CSS_CHANGE_PARENT_SIBLING_STATE },
|
||||||
{ GTK_CSS_CHANGE_SOURCE, 0 },
|
{ 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));
|
return gtk_css_change_translate (match, table, G_N_ELEMENTS (table));
|
||||||
|
@ -52,6 +52,7 @@ typedef enum { /*< skip >*/
|
|||||||
/* add more */
|
/* add more */
|
||||||
GTK_CSS_CHANGE_SOURCE = (1 << 16),
|
GTK_CSS_CHANGE_SOURCE = (1 << 16),
|
||||||
GTK_CSS_CHANGE_ANIMATE = (1 << 17),
|
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 */
|
GTK_CSS_CHANGE_RESERVED_BIT = (1 << 31) /* Used internally in gtkcssselector.c */
|
||||||
} GtkCssChange;
|
} GtkCssChange;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
/* When these change we do a full restyling. Otherwise we try to figure out
|
/* When these change we do a full restyling. Otherwise we try to figure out
|
||||||
* if we need to change things. */
|
* 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)
|
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 *
|
static GtkCssStyle *
|
||||||
validate_static_style (GtkCssNode *node,
|
validate_static_style (GtkCssNode *node,
|
||||||
GtkCssStyle *style,
|
GtkCssStyle *style,
|
||||||
GtkCssChange change,
|
GtkCssChange change)
|
||||||
gboolean parent_changed)
|
|
||||||
{
|
{
|
||||||
if (gtk_css_static_style_needs_revalidate (GTK_CSS_STATIC_STYLE (style), change) ||
|
if (gtk_css_static_style_needs_revalidate (GTK_CSS_STATIC_STYLE (style), change))
|
||||||
parent_changed)
|
|
||||||
{
|
{
|
||||||
return gtk_css_node_create_style (node);
|
return gtk_css_node_create_style (node);
|
||||||
}
|
}
|
||||||
@ -105,8 +103,7 @@ static GtkCssStyle *
|
|||||||
gtk_css_widget_node_validate (GtkCssNode *node,
|
gtk_css_widget_node_validate (GtkCssNode *node,
|
||||||
GtkCssStyle *style,
|
GtkCssStyle *style,
|
||||||
gint64 timestamp,
|
gint64 timestamp,
|
||||||
GtkCssChange change,
|
GtkCssChange change)
|
||||||
gboolean parent_changed)
|
|
||||||
{
|
{
|
||||||
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
|
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
@ -129,7 +126,7 @@ gtk_css_widget_node_validate (GtkCssNode *node,
|
|||||||
static_style = style;
|
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)
|
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);
|
need_resize = _gtk_widget_get_alloc_needed (widget) || !gtk_widget_get_realized (widget);
|
||||||
|
|
||||||
gtk_css_node_validate (gtk_widget_get_css_node (widget),
|
gtk_css_node_validate (gtk_widget_get_css_node (widget),
|
||||||
g_get_monotonic_time (),
|
g_get_monotonic_time ());
|
||||||
FALSE);
|
|
||||||
|
|
||||||
if (need_resize)
|
if (need_resize)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user