[librsvg/rustification] _rsvg_css_normalize_length(): Use a LengthDir enum instead of chars for the 'dir' argument
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustification] _rsvg_css_normalize_length(): Use a LengthDir enum instead of chars for the 'dir' argument
- Date: Thu, 3 Nov 2016 20:36:38 +0000 (UTC)
commit cb166d90d1b4370108ce57b8651a6a7f61ccd89d
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Nov 3 14:36:21 2016 -0600
_rsvg_css_normalize_length(): Use a LengthDir enum instead of chars for the 'dir' argument
Same as the last commit; we need an enum here. This also fixes a bug where 'w'
was used mistakenly instead of 'h'.
rsvg-cairo-draw.c | 42 +++++++++++++++++++++---------------------
rsvg-css.c | 24 ++++++++++++++++--------
rsvg-filter.c | 38 +++++++++++++++++++-------------------
rsvg-image.c | 8 ++++----
rsvg-marker.c | 14 +++++++-------
rsvg-private.h | 2 +-
rsvg-shapes.c | 34 +++++++++++++++++-----------------
rsvg-structure.c | 16 ++++++++--------
rsvg-text.c | 22 +++++++++++-----------
9 files changed, 104 insertions(+), 96 deletions(-)
---
diff --git a/rsvg-cairo-draw.c b/rsvg-cairo-draw.c
index 4023e22..889502f 100644
--- a/rsvg-cairo-draw.c
+++ b/rsvg-cairo-draw.c
@@ -85,10 +85,10 @@ _set_source_rsvg_linear_gradient (RsvgDrawingCtx * ctx,
if (linear->obj_bbox)
_rsvg_push_view_box (ctx, 1., 1.);
- pattern = cairo_pattern_create_linear (_rsvg_css_normalize_length (&linear->x1, ctx, 'h'),
- _rsvg_css_normalize_length (&linear->y1, ctx, 'v'),
- _rsvg_css_normalize_length (&linear->x2, ctx, 'h'),
- _rsvg_css_normalize_length (&linear->y2, ctx, 'v'));
+ pattern = cairo_pattern_create_linear (_rsvg_css_normalize_length (&linear->x1, ctx,
LENGTH_DIR_HORIZONTAL),
+ _rsvg_css_normalize_length (&linear->y1, ctx,
LENGTH_DIR_VERTICAL),
+ _rsvg_css_normalize_length (&linear->x2, ctx,
LENGTH_DIR_HORIZONTAL),
+ _rsvg_css_normalize_length (&linear->y2, ctx,
LENGTH_DIR_VERTICAL));
if (linear->obj_bbox)
_rsvg_pop_view_box (ctx);
@@ -130,11 +130,11 @@ _set_source_rsvg_radial_gradient (RsvgDrawingCtx * ctx,
if (radial->obj_bbox)
_rsvg_push_view_box (ctx, 1., 1.);
- pattern = cairo_pattern_create_radial (_rsvg_css_normalize_length (&radial->fx, ctx, 'h'),
- _rsvg_css_normalize_length (&radial->fy, ctx, 'v'), 0.0,
- _rsvg_css_normalize_length (&radial->cx, ctx, 'h'),
- _rsvg_css_normalize_length (&radial->cy, ctx, 'v'),
- _rsvg_css_normalize_length (&radial->r, ctx, 'o'));
+ pattern = cairo_pattern_create_radial (_rsvg_css_normalize_length (&radial->fx, ctx,
LENGTH_DIR_HORIZONTAL),
+ _rsvg_css_normalize_length (&radial->fy, ctx,
LENGTH_DIR_VERTICAL), 0.0,
+ _rsvg_css_normalize_length (&radial->cx, ctx,
LENGTH_DIR_HORIZONTAL),
+ _rsvg_css_normalize_length (&radial->cy, ctx,
LENGTH_DIR_VERTICAL),
+ _rsvg_css_normalize_length (&radial->r, ctx, LENGTH_DIR_BOTH));
if (radial->obj_bbox)
_rsvg_pop_view_box (ctx);
@@ -198,10 +198,10 @@ _set_source_rsvg_pattern (RsvgDrawingCtx * ctx,
if (rsvg_pattern->obj_bbox)
_rsvg_push_view_box (ctx, 1., 1.);
- patternx = _rsvg_css_normalize_length (&rsvg_pattern->x, ctx, 'h');
- patterny = _rsvg_css_normalize_length (&rsvg_pattern->y, ctx, 'v');
- patternw = _rsvg_css_normalize_length (&rsvg_pattern->width, ctx, 'h');
- patternh = _rsvg_css_normalize_length (&rsvg_pattern->height, ctx, 'v');
+ patternx = _rsvg_css_normalize_length (&rsvg_pattern->x, ctx, LENGTH_DIR_HORIZONTAL);
+ patterny = _rsvg_css_normalize_length (&rsvg_pattern->y, ctx, LENGTH_DIR_VERTICAL);
+ patternw = _rsvg_css_normalize_length (&rsvg_pattern->width, ctx, LENGTH_DIR_HORIZONTAL);
+ patternh = _rsvg_css_normalize_length (&rsvg_pattern->height, ctx, LENGTH_DIR_VERTICAL);
if (rsvg_pattern->obj_bbox)
_rsvg_pop_view_box (ctx);
@@ -442,12 +442,12 @@ rsvg_cairo_render_pango_layout (RsvgDrawingCtx * ctx, PangoLayout * layout, doub
cairo_rotate (render->cr, -rotation);
pango_cairo_layout_path (render->cr, layout);
- cairo_set_line_width (render->cr, _rsvg_css_normalize_length (&state->stroke_width, ctx, 'h'));
+ cairo_set_line_width (render->cr, _rsvg_css_normalize_length (&state->stroke_width, ctx,
LENGTH_DIR_HORIZONTAL));
cairo_set_miter_limit (render->cr, state->miter_limit);
cairo_set_line_cap (render->cr, (cairo_line_cap_t) state->cap);
cairo_set_line_join (render->cr, (cairo_line_join_t) state->join);
cairo_set_dash (render->cr, state->dash.dash, state->dash.n_dash,
- _rsvg_css_normalize_length (&state->dash.offset, ctx, 'o'));
+ _rsvg_css_normalize_length (&state->dash.offset, ctx, LENGTH_DIR_BOTH));
cairo_stroke (render->cr);
cairo_restore (render->cr);
}
@@ -470,12 +470,12 @@ rsvg_cairo_render_path_builder (RsvgDrawingCtx * ctx, RsvgPathBuilder *builder)
_set_rsvg_affine (render, &state->affine);
- cairo_set_line_width (cr, _rsvg_css_normalize_length (&state->stroke_width, ctx, 'h'));
+ cairo_set_line_width (cr, _rsvg_css_normalize_length (&state->stroke_width, ctx, LENGTH_DIR_HORIZONTAL));
cairo_set_miter_limit (cr, state->miter_limit);
cairo_set_line_cap (cr, (cairo_line_cap_t) state->cap);
cairo_set_line_join (cr, (cairo_line_join_t) state->join);
cairo_set_dash (cr, state->dash.dash, state->dash.n_dash,
- _rsvg_css_normalize_length (&state->dash.offset, ctx, 'o'));
+ _rsvg_css_normalize_length (&state->dash.offset, ctx, LENGTH_DIR_BOTH));
rsvg_path_builder_add_to_cairo_context (builder, cr);
@@ -643,10 +643,10 @@ rsvg_cairo_generate_mask (cairo_t * cr, RsvgMask * self, RsvgDrawingCtx * ctx, R
if (self->maskunits == objectBoundingBox)
_rsvg_push_view_box (ctx, 1, 1);
- sx = _rsvg_css_normalize_length (&self->x, ctx, 'h');
- sy = _rsvg_css_normalize_length (&self->y, ctx, 'v');
- sw = _rsvg_css_normalize_length (&self->width, ctx, 'h');
- sh = _rsvg_css_normalize_length (&self->height, ctx, 'v');
+ sx = _rsvg_css_normalize_length (&self->x, ctx, LENGTH_DIR_HORIZONTAL);
+ sy = _rsvg_css_normalize_length (&self->y, ctx, LENGTH_DIR_VERTICAL);
+ sw = _rsvg_css_normalize_length (&self->width, ctx, LENGTH_DIR_HORIZONTAL);
+ sh = _rsvg_css_normalize_length (&self->height, ctx, LENGTH_DIR_VERTICAL);
if (self->maskunits == objectBoundingBox)
_rsvg_pop_view_box (ctx);
diff --git a/rsvg-css.c b/rsvg-css.c
index 6e33040..8e108b0 100644
--- a/rsvg-css.c
+++ b/rsvg-css.c
@@ -226,7 +226,7 @@ _rsvg_css_normalize_font_size (RsvgState * state, RsvgDrawingCtx * ctx)
}
break;
default:
- return _rsvg_css_normalize_length (&state->font_size, ctx, 'v');
+ return _rsvg_css_normalize_length (&state->font_size, ctx, LENGTH_DIR_VERTICAL);
break;
}
@@ -234,18 +234,22 @@ _rsvg_css_normalize_font_size (RsvgState * state, RsvgDrawingCtx * ctx)
}
double
-_rsvg_css_normalize_length (const RsvgLength * in, RsvgDrawingCtx * ctx, char dir)
+_rsvg_css_normalize_length (const RsvgLength * in, RsvgDrawingCtx * ctx, LengthDir dir)
{
if (in->unit == LENGTH_UNIT_DEFAULT)
return in->length;
else if (in->unit == LENGTH_UNIT_PERCENT) {
- if (dir == 'h')
+ switch (dir) {
+ case LENGTH_DIR_HORIZONTAL:
return in->length * ctx->vb.rect.width;
- if (dir == 'v')
+
+ case LENGTH_DIR_VERTICAL:
return in->length * ctx->vb.rect.height;
- if (dir == 'o')
+
+ case LENGTH_DIR_BOTH:
return in->length * rsvg_viewport_percentage (ctx->vb.rect.width,
ctx->vb.rect.height);
+ }
} else if (in->unit == LENGTH_UNIT_FONT_EM || in->unit == LENGTH_UNIT_FONT_EX) {
double font = _rsvg_css_normalize_font_size (rsvg_current_state (ctx), ctx);
if (in->unit == LENGTH_UNIT_FONT_EM)
@@ -253,12 +257,16 @@ _rsvg_css_normalize_length (const RsvgLength * in, RsvgDrawingCtx * ctx, char di
else
return in->length * font / 2.;
} else if (in->unit == LENGTH_UNIT_INCH) {
- if (dir == 'h')
+ switch (dir) {
+ case LENGTH_DIR_HORIZONTAL:
return in->length * ctx->dpi_x;
- if (dir == 'v')
+
+ case LENGTH_DIR_VERTICAL:
return in->length * ctx->dpi_y;
- if (dir == 'o')
+
+ case LENGTH_DIR_BOTH:
return in->length * rsvg_viewport_percentage (ctx->dpi_x, ctx->dpi_y);
+ }
} else if (in->unit == LENGTH_UNIT_RELATIVE_LARGER) {
/* todo: "larger" */
} else if (in->unit == LENGTH_UNIT_RELATIVE_SMALLER) {
diff --git a/rsvg-filter.c b/rsvg-filter.c
index 4431370..73c6a33 100644
--- a/rsvg-filter.c
+++ b/rsvg-filter.c
@@ -161,10 +161,10 @@ rsvg_filter_primitive_get_bounds (RsvgFilterPrimitive * self, RsvgFilterContext
otherbox.virgin = 0;
if (ctx->filter->filterunits == objectBoundingBox)
_rsvg_push_view_box (ctx->ctx, 1., 1.);
- otherbox.rect.x = _rsvg_css_normalize_length (&ctx->filter->x, ctx->ctx, 'h');
- otherbox.rect.y = _rsvg_css_normalize_length (&ctx->filter->y, ctx->ctx, 'v');
- otherbox.rect.width = _rsvg_css_normalize_length (&ctx->filter->width, ctx->ctx, 'h');
- otherbox.rect.height = _rsvg_css_normalize_length (&ctx->filter->height, ctx->ctx, 'v');
+ otherbox.rect.x = _rsvg_css_normalize_length (&ctx->filter->x, ctx->ctx, LENGTH_DIR_HORIZONTAL);
+ otherbox.rect.y = _rsvg_css_normalize_length (&ctx->filter->y, ctx->ctx, LENGTH_DIR_VERTICAL);
+ otherbox.rect.width = _rsvg_css_normalize_length (&ctx->filter->width, ctx->ctx, LENGTH_DIR_HORIZONTAL);
+ otherbox.rect.height = _rsvg_css_normalize_length (&ctx->filter->height, ctx->ctx, LENGTH_DIR_VERTICAL);
if (ctx->filter->filterunits == objectBoundingBox)
_rsvg_pop_view_box (ctx->ctx);
@@ -179,19 +179,19 @@ rsvg_filter_primitive_get_bounds (RsvgFilterPrimitive * self, RsvgFilterContext
if (ctx->filter->primitiveunits == objectBoundingBox)
_rsvg_push_view_box (ctx->ctx, 1., 1.);
if (self->x_specified)
- otherbox.rect.x = _rsvg_css_normalize_length (&self->x, ctx->ctx, 'h');
+ otherbox.rect.x = _rsvg_css_normalize_length (&self->x, ctx->ctx, LENGTH_DIR_HORIZONTAL);
else
otherbox.rect.x = 0;
if (self->y_specified)
- otherbox.rect.y = _rsvg_css_normalize_length (&self->y, ctx->ctx, 'v');
+ otherbox.rect.y = _rsvg_css_normalize_length (&self->y, ctx->ctx, LENGTH_DIR_VERTICAL);
else
otherbox.rect.y = 0;
if (self->width_specified)
- otherbox.rect.width = _rsvg_css_normalize_length (&self->width, ctx->ctx, 'h');
+ otherbox.rect.width = _rsvg_css_normalize_length (&self->width, ctx->ctx,
LENGTH_DIR_HORIZONTAL);
else
otherbox.rect.width = ctx->ctx->vb.rect.width;
if (self->height_specified)
- otherbox.rect.height = _rsvg_css_normalize_length (&self->height, ctx->ctx, 'v');
+ otherbox.rect.height = _rsvg_css_normalize_length (&self->height, ctx->ctx,
LENGTH_DIR_VERTICAL);
else
otherbox.rect.height = ctx->ctx->vb.rect.height;
if (ctx->filter->primitiveunits == objectBoundingBox)
@@ -2019,8 +2019,8 @@ rsvg_filter_primitive_offset_render (RsvgFilterPrimitive * self, RsvgFilterConte
output_pixels = cairo_image_surface_get_data (output);
- dx = _rsvg_css_normalize_length (&upself->dx, ctx->ctx, 'h');
- dy = _rsvg_css_normalize_length (&upself->dy, ctx->ctx, 'v');
+ dx = _rsvg_css_normalize_length (&upself->dx, ctx->ctx, LENGTH_DIR_HORIZONTAL);
+ dy = _rsvg_css_normalize_length (&upself->dy, ctx->ctx, LENGTH_DIR_VERTICAL);
ox = ctx->paffine.xx * dx + ctx->paffine.xy * dy;
oy = ctx->paffine.yx * dx + ctx->paffine.yy * dy;
@@ -4284,9 +4284,9 @@ get_light_direction (RsvgNodeLightSource * source, gdouble x1, gdouble y1, gdoub
double x, y;
x = affine->xx * x1 + affine->xy * y1 + affine->x0;
y = affine->yx * x1 + affine->yy * y1 + affine->y0;
- output.x = _rsvg_css_normalize_length (&source->x, ctx, 'h') - x;
- output.y = _rsvg_css_normalize_length (&source->y, ctx, 'v') - y;
- output.z = _rsvg_css_normalize_length (&source->z, ctx, 'o') - z;
+ output.x = _rsvg_css_normalize_length (&source->x, ctx, LENGTH_DIR_HORIZONTAL) - x;
+ output.y = _rsvg_css_normalize_length (&source->y, ctx, LENGTH_DIR_VERTICAL) - y;
+ output.z = _rsvg_css_normalize_length (&source->z, ctx, LENGTH_DIR_BOTH) - z;
output = normalise (output);
}
break;
@@ -4307,12 +4307,12 @@ get_light_color (RsvgNodeLightSource * source, vector3 color,
if (source->type != SPOTLIGHT)
return color;
- sx = _rsvg_css_normalize_length (&source->x, ctx, 'h');
- sy = _rsvg_css_normalize_length (&source->y, ctx, 'v');
- sz = _rsvg_css_normalize_length (&source->z, ctx, 'o');
- spx = _rsvg_css_normalize_length (&source->pointsAtX, ctx, 'h');
- spy = _rsvg_css_normalize_length (&source->pointsAtY, ctx, 'v');
- spz = _rsvg_css_normalize_length (&source->pointsAtZ, ctx, 'o');
+ sx = _rsvg_css_normalize_length (&source->x, ctx, LENGTH_DIR_HORIZONTAL);
+ sy = _rsvg_css_normalize_length (&source->y, ctx, LENGTH_DIR_VERTICAL);
+ sz = _rsvg_css_normalize_length (&source->z, ctx, LENGTH_DIR_BOTH);
+ spx = _rsvg_css_normalize_length (&source->pointsAtX, ctx, LENGTH_DIR_HORIZONTAL);
+ spy = _rsvg_css_normalize_length (&source->pointsAtY, ctx, LENGTH_DIR_VERTICAL);
+ spz = _rsvg_css_normalize_length (&source->pointsAtZ, ctx, LENGTH_DIR_BOTH);
x = affine->xx * x1 + affine->xy * y1 + affine->x0;
y = affine->yx * x1 + affine->yy * y1 + affine->y0;
diff --git a/rsvg-image.c b/rsvg-image.c
index b93f5b3..7f9289c 100644
--- a/rsvg-image.c
+++ b/rsvg-image.c
@@ -174,10 +174,10 @@ rsvg_node_image_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
if (surface == NULL)
return;
- x = _rsvg_css_normalize_length (&z->x, ctx, 'h');
- y = _rsvg_css_normalize_length (&z->y, ctx, 'v');
- w = _rsvg_css_normalize_length (&z->w, ctx, 'h');
- h = _rsvg_css_normalize_length (&z->h, ctx, 'v');
+ x = _rsvg_css_normalize_length (&z->x, ctx, LENGTH_DIR_HORIZONTAL);
+ y = _rsvg_css_normalize_length (&z->y, ctx, LENGTH_DIR_VERTICAL);
+ w = _rsvg_css_normalize_length (&z->w, ctx, LENGTH_DIR_HORIZONTAL);
+ h = _rsvg_css_normalize_length (&z->h, ctx, LENGTH_DIR_VERTICAL);
rsvg_state_reinherit_top (ctx, z->super.state, dominate);
diff --git a/rsvg-marker.c b/rsvg-marker.c
index 0ff3317..b74c8ce 100644
--- a/rsvg-marker.c
+++ b/rsvg-marker.c
@@ -143,8 +143,8 @@ rsvg_marker_render (const char * marker_name, gdouble xpos, gdouble ypos, gdoubl
if (self->vbox.active) {
double w, h, x, y;
- w = _rsvg_css_normalize_length (&self->width, ctx, 'h');
- h = _rsvg_css_normalize_length (&self->height, ctx, 'v');
+ w = _rsvg_css_normalize_length (&self->width, ctx, LENGTH_DIR_HORIZONTAL);
+ h = _rsvg_css_normalize_length (&self->height, ctx, LENGTH_DIR_VERTICAL);
x = 0;
y = 0;
@@ -160,8 +160,8 @@ rsvg_marker_render (const char * marker_name, gdouble xpos, gdouble ypos, gdoubl
}
cairo_matrix_init_translate (&taffine,
- -_rsvg_css_normalize_length (&self->refX, ctx, 'h'),
- -_rsvg_css_normalize_length (&self->refY, ctx, 'v'));
+ -_rsvg_css_normalize_length (&self->refX, ctx, LENGTH_DIR_HORIZONTAL),
+ -_rsvg_css_normalize_length (&self->refY, ctx, LENGTH_DIR_VERTICAL));
cairo_matrix_multiply (&affine, &taffine, &affine);
rsvg_state_push (ctx);
@@ -183,8 +183,8 @@ rsvg_marker_render (const char * marker_name, gdouble xpos, gdouble ypos, gdoubl
self->vbox.rect.width, self->vbox.rect.height);
else
rsvg_add_clipping_rect (ctx, 0, 0,
- _rsvg_css_normalize_length (&self->width, ctx, 'h'),
- _rsvg_css_normalize_length (&self->height, ctx, 'v'));
+ _rsvg_css_normalize_length (&self->width, ctx, LENGTH_DIR_HORIZONTAL),
+ _rsvg_css_normalize_length (&self->height, ctx, LENGTH_DIR_VERTICAL));
}
for (i = 0; i < self->super.children->len; i++) {
@@ -219,7 +219,7 @@ rsvg_render_markers (RsvgDrawingCtx *ctx,
state = rsvg_current_state (ctx);
- linewidth = _rsvg_css_normalize_length (&state->stroke_width, ctx, 'o');
+ linewidth = _rsvg_css_normalize_length (&state->stroke_width, ctx, LENGTH_DIR_BOTH);
rsvg_rust_render_markers (ctx,
builder,
diff --git a/rsvg-private.h b/rsvg-private.h
index 51972b9..93514b5 100644
--- a/rsvg-private.h
+++ b/rsvg-private.h
@@ -407,7 +407,7 @@ void rsvg_bbox_insert (RsvgBbox * dst, RsvgBbox * src);
G_GNUC_INTERNAL
void rsvg_bbox_clip (RsvgBbox * dst, RsvgBbox * src);
G_GNUC_INTERNAL
-double _rsvg_css_normalize_length (const RsvgLength * in, RsvgDrawingCtx * ctx, char dir);
+double _rsvg_css_normalize_length (const RsvgLength * in, RsvgDrawingCtx * ctx, LengthDir dir);
G_GNUC_INTERNAL
double _rsvg_css_hand_normalize_length (const RsvgLength * in, gdouble pixels_per_inch,
gdouble width_or_height, gdouble font_size);
diff --git a/rsvg-shapes.c b/rsvg-shapes.c
index bcb7e6f..94424ef 100644
--- a/rsvg-shapes.c
+++ b/rsvg-shapes.c
@@ -284,10 +284,10 @@ _rsvg_node_line_draw (RsvgNode * overself, RsvgDrawingCtx * ctx, int dominate)
builder = rsvg_path_builder_new ();
- x1 = _rsvg_css_normalize_length (&self->x1, ctx, 'h');
- y1 = _rsvg_css_normalize_length (&self->y1, ctx, 'v');
- x2 = _rsvg_css_normalize_length (&self->x2, ctx, 'h');
- y2 = _rsvg_css_normalize_length (&self->y2, ctx, 'v');
+ x1 = _rsvg_css_normalize_length (&self->x1, ctx, LENGTH_DIR_HORIZONTAL);
+ y1 = _rsvg_css_normalize_length (&self->y1, ctx, LENGTH_DIR_VERTICAL);
+ x2 = _rsvg_css_normalize_length (&self->x2, ctx, LENGTH_DIR_HORIZONTAL);
+ y2 = _rsvg_css_normalize_length (&self->y2, ctx, LENGTH_DIR_VERTICAL);
rsvg_path_builder_move_to (builder, x1, y1);
rsvg_path_builder_line_to (builder, x2, y2);
@@ -362,16 +362,16 @@ _rsvg_node_rect_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
RsvgPathBuilder *builder;
RsvgNodeRect *rect = (RsvgNodeRect *) self;
- x = _rsvg_css_normalize_length (&rect->x, ctx, 'h');
- y = _rsvg_css_normalize_length (&rect->y, ctx, 'v');
+ x = _rsvg_css_normalize_length (&rect->x, ctx, LENGTH_DIR_HORIZONTAL);
+ y = _rsvg_css_normalize_length (&rect->y, ctx, LENGTH_DIR_VERTICAL);
/* FIXME: negative w/h/rx/ry is an error, per http://www.w3.org/TR/SVG11/shapes.html#RectElement
* For now we'll just take the absolute value.
*/
- w = fabs (_rsvg_css_normalize_length (&rect->w, ctx, 'h'));
- h = fabs (_rsvg_css_normalize_length (&rect->h, ctx, 'v'));
- rx = fabs (_rsvg_css_normalize_length (&rect->rx, ctx, 'h'));
- ry = fabs (_rsvg_css_normalize_length (&rect->ry, ctx, 'v'));
+ w = fabs (_rsvg_css_normalize_length (&rect->w, ctx, LENGTH_DIR_HORIZONTAL));
+ h = fabs (_rsvg_css_normalize_length (&rect->h, ctx, LENGTH_DIR_VERTICAL));
+ rx = fabs (_rsvg_css_normalize_length (&rect->rx, ctx, LENGTH_DIR_HORIZONTAL));
+ ry = fabs (_rsvg_css_normalize_length (&rect->ry, ctx, LENGTH_DIR_VERTICAL));
if (w == 0. || h == 0.)
return;
@@ -544,9 +544,9 @@ _rsvg_node_circle_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
double cx, cy, r;
RsvgPathBuilder *builder;
- cx = _rsvg_css_normalize_length (&circle->cx, ctx, 'h');
- cy = _rsvg_css_normalize_length (&circle->cy, ctx, 'v');
- r = _rsvg_css_normalize_length (&circle->r, ctx, 'o');
+ cx = _rsvg_css_normalize_length (&circle->cx, ctx, LENGTH_DIR_HORIZONTAL);
+ cy = _rsvg_css_normalize_length (&circle->cy, ctx, LENGTH_DIR_VERTICAL);
+ r = _rsvg_css_normalize_length (&circle->r, ctx, LENGTH_DIR_BOTH);
if (r <= 0)
return;
@@ -638,10 +638,10 @@ _rsvg_node_ellipse_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
double cx, cy, rx, ry;
RsvgPathBuilder *builder;
- cx = _rsvg_css_normalize_length (&ellipse->cx, ctx, 'h');
- cy = _rsvg_css_normalize_length (&ellipse->cy, ctx, 'v');
- rx = _rsvg_css_normalize_length (&ellipse->rx, ctx, 'h');
- ry = _rsvg_css_normalize_length (&ellipse->ry, ctx, 'v');
+ cx = _rsvg_css_normalize_length (&ellipse->cx, ctx, LENGTH_DIR_HORIZONTAL);
+ cy = _rsvg_css_normalize_length (&ellipse->cy, ctx, LENGTH_DIR_VERTICAL);
+ rx = _rsvg_css_normalize_length (&ellipse->rx, ctx, LENGTH_DIR_HORIZONTAL);
+ ry = _rsvg_css_normalize_length (&ellipse->ry, ctx, LENGTH_DIR_VERTICAL);
if (rx <= 0 || ry <= 0)
return;
diff --git a/rsvg-structure.c b/rsvg-structure.c
index 4ab4473..41dc8d3 100644
--- a/rsvg-structure.c
+++ b/rsvg-structure.c
@@ -184,10 +184,10 @@ rsvg_node_use_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
RsvgState *state;
cairo_matrix_t affine;
double x, y, w, h;
- x = _rsvg_css_normalize_length (&use->x, ctx, 'h');
- y = _rsvg_css_normalize_length (&use->y, ctx, 'v');
- w = _rsvg_css_normalize_length (&use->w, ctx, 'h');
- h = _rsvg_css_normalize_length (&use->h, ctx, 'v');
+ x = _rsvg_css_normalize_length (&use->x, ctx, LENGTH_DIR_HORIZONTAL);
+ y = _rsvg_css_normalize_length (&use->y, ctx, LENGTH_DIR_VERTICAL);
+ w = _rsvg_css_normalize_length (&use->w, ctx, LENGTH_DIR_HORIZONTAL);
+ h = _rsvg_css_normalize_length (&use->h, ctx, LENGTH_DIR_VERTICAL);
rsvg_state_reinherit_top (ctx, self->state, dominate);
@@ -261,10 +261,10 @@ rsvg_node_svg_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
double nx, ny, nw, nh;
sself = (RsvgNodeSvg *) self;
- nx = _rsvg_css_normalize_length (&sself->x, ctx, 'h');
- ny = _rsvg_css_normalize_length (&sself->y, ctx, 'v');
- nw = _rsvg_css_normalize_length (&sself->w, ctx, 'h');
- nh = _rsvg_css_normalize_length (&sself->h, ctx, 'v');
+ nx = _rsvg_css_normalize_length (&sself->x, ctx, LENGTH_DIR_HORIZONTAL);
+ ny = _rsvg_css_normalize_length (&sself->y, ctx, LENGTH_DIR_VERTICAL);
+ nw = _rsvg_css_normalize_length (&sself->w, ctx, LENGTH_DIR_HORIZONTAL);
+ nh = _rsvg_css_normalize_length (&sself->h, ctx, LENGTH_DIR_VERTICAL);
rsvg_state_reinherit_top (ctx, self->state, dominate);
diff --git a/rsvg-text.c b/rsvg-text.c
index c61a9d2..1ac6db0 100644
--- a/rsvg-text.c
+++ b/rsvg-text.c
@@ -284,10 +284,10 @@ _rsvg_node_text_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
RsvgNodeText *text = (RsvgNodeText *) self;
rsvg_state_reinherit_top (ctx, self->state, dominate);
- x = _rsvg_css_normalize_length (&text->x, ctx, 'h');
- y = _rsvg_css_normalize_length (&text->y, ctx, 'v');
- dx = _rsvg_css_normalize_length (&text->dx, ctx, 'h');
- dy = _rsvg_css_normalize_length (&text->dy, ctx, 'v');
+ x = _rsvg_css_normalize_length (&text->x, ctx, LENGTH_DIR_HORIZONTAL);
+ y = _rsvg_css_normalize_length (&text->y, ctx, LENGTH_DIR_VERTICAL);
+ dx = _rsvg_css_normalize_length (&text->dx, ctx, LENGTH_DIR_HORIZONTAL);
+ dy = _rsvg_css_normalize_length (&text->dy, ctx, LENGTH_DIR_VERTICAL);
if (rsvg_current_state (ctx)->text_anchor != TEXT_ANCHOR_START) {
_rsvg_node_text_length_children (self, ctx, &length, &lastwasspace, FALSE);
@@ -334,8 +334,8 @@ _rsvg_node_text_type_tspan (RsvgNodeText * self, RsvgDrawingCtx * ctx,
double dx, dy, length = 0;
rsvg_state_reinherit_top (ctx, self->super.state, 0);
- dx = _rsvg_css_normalize_length (&self->dx, ctx, 'h');
- dy = _rsvg_css_normalize_length (&self->dy, ctx, 'v');
+ dx = _rsvg_css_normalize_length (&self->dx, ctx, LENGTH_DIR_HORIZONTAL);
+ dy = _rsvg_css_normalize_length (&self->dy, ctx, LENGTH_DIR_VERTICAL);
if (rsvg_current_state (ctx)->text_anchor != TEXT_ANCHOR_START) {
gboolean lws = *lastwasspace;
@@ -346,7 +346,7 @@ _rsvg_node_text_type_tspan (RsvgNodeText * self, RsvgDrawingCtx * ctx,
}
if (self->x_specified) {
- *x = _rsvg_css_normalize_length (&self->x, ctx, 'h');
+ *x = _rsvg_css_normalize_length (&self->x, ctx, LENGTH_DIR_HORIZONTAL);
if (!PANGO_GRAVITY_IS_VERTICAL (rsvg_current_state (ctx)->text_gravity)) {
*x -= length;
if (rsvg_current_state (ctx)->text_anchor == TEXT_ANCHOR_MIDDLE)
@@ -358,7 +358,7 @@ _rsvg_node_text_type_tspan (RsvgNodeText * self, RsvgDrawingCtx * ctx,
*x += dx;
if (self->y_specified) {
- *y = _rsvg_css_normalize_length (&self->y, ctx, 'v');
+ *y = _rsvg_css_normalize_length (&self->y, ctx, LENGTH_DIR_VERTICAL);
if (PANGO_GRAVITY_IS_VERTICAL (rsvg_current_state (ctx)->text_gravity)) {
*y -= length;
if (rsvg_current_state (ctx)->text_anchor == TEXT_ANCHOR_MIDDLE)
@@ -381,9 +381,9 @@ _rsvg_node_text_length_tspan (RsvgNodeText * self,
return TRUE;
if (PANGO_GRAVITY_IS_VERTICAL (rsvg_current_state (ctx)->text_gravity))
- *length += _rsvg_css_normalize_length (&self->dy, ctx, 'v');
+ *length += _rsvg_css_normalize_length (&self->dy, ctx, LENGTH_DIR_VERTICAL);
else
- *length += _rsvg_css_normalize_length (&self->dx, ctx, 'h');
+ *length += _rsvg_css_normalize_length (&self->dx, ctx, LENGTH_DIR_HORIZONTAL);
return _rsvg_node_text_length_children (&self->super, ctx, length,
lastwasspace, usetextonly);
@@ -548,7 +548,7 @@ rsvg_text_create_layout (RsvgDrawingCtx * ctx,
attr_list = pango_attr_list_new ();
attribute = pango_attr_letter_spacing_new (_rsvg_css_normalize_length (&state->letter_spacing,
- ctx, 'h') * PANGO_SCALE);
+ ctx, LENGTH_DIR_HORIZONTAL) *
PANGO_SCALE);
attribute->start_index = 0;
attribute->end_index = G_MAXINT;
pango_attr_list_insert (attr_list, attribute);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]