rendernodeparser: Generate better default child
... for fill and stroke nodes. It's most likely we want the path bounds (or path stroke bounds), so make the parser use those by default.
This commit is contained in:
@@ -1172,10 +1172,16 @@ create_default_texture (void)
|
||||
return texture;
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
create_default_render_node_with_bounds (const graphene_rect_t *rect)
|
||||
{
|
||||
return gsk_color_node_new (&GDK_RGBA("FF00CC"), rect);
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
create_default_render_node (void)
|
||||
{
|
||||
return gsk_color_node_new (&GDK_RGBA("FF00CC"), &GRAPHENE_RECT_INIT (0, 0, 50, 50));
|
||||
return create_default_render_node_with_bounds (&GRAPHENE_RECT_INIT (0, 0, 50, 50));
|
||||
}
|
||||
|
||||
static GskPath *
|
||||
@@ -2254,10 +2260,14 @@ parse_fill_node (GtkCssParser *parser,
|
||||
GskRenderNode *result;
|
||||
|
||||
parse_declarations (parser, context, declarations, G_N_ELEMENTS (declarations));
|
||||
if (child == NULL)
|
||||
child = create_default_render_node ();
|
||||
if (path == NULL)
|
||||
path = create_default_path ();
|
||||
if (child == NULL)
|
||||
{
|
||||
graphene_rect_t bounds;
|
||||
gsk_path_get_bounds (path, &bounds);
|
||||
child = create_default_render_node_with_bounds (&bounds);
|
||||
}
|
||||
|
||||
result = gsk_fill_node_new (child, path, rule);
|
||||
|
||||
@@ -2311,8 +2321,6 @@ parse_stroke_node (GtkCssParser *parser,
|
||||
GskRenderNode *result;
|
||||
|
||||
parse_declarations (parser, context, declarations, G_N_ELEMENTS (declarations));
|
||||
if (child == NULL)
|
||||
child = create_default_render_node ();
|
||||
if (path == NULL)
|
||||
path = create_default_path ();
|
||||
|
||||
@@ -2327,6 +2335,13 @@ parse_stroke_node (GtkCssParser *parser,
|
||||
}
|
||||
gsk_stroke_set_dash_offset (stroke, dash_offset);
|
||||
|
||||
if (child == NULL)
|
||||
{
|
||||
graphene_rect_t bounds;
|
||||
gsk_path_get_stroke_bounds (path, stroke, &bounds);
|
||||
child = create_default_render_node_with_bounds (&bounds);
|
||||
}
|
||||
|
||||
result = gsk_stroke_node_new (child, path, stroke);
|
||||
|
||||
gsk_path_unref (path);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fill {
|
||||
child: color {
|
||||
bounds: 0 0 50 50;
|
||||
bounds: 1.22359 0 47.5528 45.2254;
|
||||
color: rgb(255,0,204);
|
||||
}
|
||||
path: "\
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
stroke {
|
||||
child: color {
|
||||
bounds: 0 0 50 50;
|
||||
bounds: -2.77641 -4 55.5528 53.2254;
|
||||
color: rgb(255,0,204);
|
||||
}
|
||||
path: "\
|
||||
|
||||
Reference in New Issue
Block a user