From fa64d91d12c94c9aa230cd231b1d2e16054b41f2 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 29 Mar 2021 10:45:59 +0100 Subject: Switch to new libcss API for unit conversion. --- content/handlers/html/redraw.c | 72 +++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'content/handlers/html/redraw.c') diff --git a/content/handlers/html/redraw.c b/content/handlers/html/redraw.c index 9807512b9..f770699bb 100644 --- a/content/handlers/html/redraw.c +++ b/content/handlers/html/redraw.c @@ -528,14 +528,14 @@ static bool html_redraw_radio(int x, int y, int width, int height, * \param box box of input * \param scale scale for redraw * \param background_colour current background colour - * \param len_ctx Length conversion context + * \param unit_len_ctx Length conversion context * \param ctx current redraw context * \return true if successful, false otherwise */ static bool html_redraw_file(int x, int y, int width, int height, struct box *box, float scale, colour background_colour, - const nscss_len_ctx *len_ctx, + const css_unit_ctx *unit_len_ctx, const struct redraw_context *ctx) { int text_width; @@ -544,7 +544,7 @@ static bool html_redraw_file(int x, int y, int width, int height, plot_font_style_t fstyle; nserror res; - font_plot_style_from_css(len_ctx, box->style, &fstyle); + font_plot_style_from_css(unit_len_ctx, box->style, &fstyle); fstyle.background = background_colour; if (box->gadget->value) { @@ -587,7 +587,7 @@ static bool html_redraw_file(int x, int y, int width, int height, * \param clip current clip rectangle * \param background_colour current background colour * \param background box containing background details (usually \a box) - * \param len_ctx Length conversion context + * \param unit_len_ctx Length conversion context * \param ctx current redraw context * \return true if successful, false otherwise */ @@ -595,7 +595,7 @@ static bool html_redraw_file(int x, int y, int width, int height, static bool html_redraw_background(int x, int y, struct box *box, float scale, const struct rect *clip, colour *background_colour, struct box *background, - const nscss_len_ctx *len_ctx, + const css_unit_ctx *unit_len_ctx, const struct redraw_context *ctx) { bool repeat_x = false; @@ -672,8 +672,9 @@ static bool html_redraw_background(int x, int y, struct box *box, float scale, content_get_width(background->background)) * scale * FIXTOFLT(hpos) / 100.; } else { - x += (int) (FIXTOFLT(nscss_len2px(len_ctx, hpos, hunit, - background->style)) * scale); + x += (int) (FIXTOFLT(css_unit_len2device_px( + background->style, unit_len_ctx, + hpos, hunit)) * scale); } if (vunit == CSS_UNIT_PCT) { @@ -681,8 +682,9 @@ static bool html_redraw_background(int x, int y, struct box *box, float scale, content_get_height(background->background)) * scale * FIXTOFLT(vpos) / 100.; } else { - y += (int) (FIXTOFLT(nscss_len2px(len_ctx, vpos, vunit, - background->style)) * scale); + y += (int) (FIXTOFLT(css_unit_len2device_px( + background->style, unit_len_ctx, + vpos, vunit)) * scale); } } @@ -814,7 +816,7 @@ static bool html_redraw_background(int x, int y, struct box *box, float scale, * \param first true if this is the first rectangle associated with the inline * \param last true if this is the last rectangle associated with the inline * \param background_colour updated to current background colour if plotted - * \param len_ctx Length conversion context + * \param unit_len_ctx Length conversion context * \param ctx current redraw context * \return true if successful, false otherwise */ @@ -822,7 +824,7 @@ static bool html_redraw_background(int x, int y, struct box *box, float scale, static bool html_redraw_inline_background(int x, int y, struct box *box, float scale, const struct rect *clip, struct rect b, bool first, bool last, colour *background_colour, - const nscss_len_ctx *len_ctx, + const css_unit_ctx *unit_len_ctx, const struct redraw_context *ctx) { struct rect r = *clip; @@ -883,8 +885,9 @@ static bool html_redraw_inline_background(int x, int y, struct box *box, plot_content = false; } } else { - x += (int) (FIXTOFLT(nscss_len2px(len_ctx, hpos, hunit, - box->style)) * scale); + x += (int) (FIXTOFLT(css_unit_len2device_px( + box->style, unit_len_ctx, + hpos, hunit)) * scale); } if (vunit == CSS_UNIT_PCT) { @@ -892,8 +895,9 @@ static bool html_redraw_inline_background(int x, int y, struct box *box, content_get_height(box->background) * scale) * FIXTOFLT(vpos) / 100.; } else { - y += (int) (FIXTOFLT(nscss_len2px(len_ctx, vpos, vunit, - box->style)) * scale); + y += (int) (FIXTOFLT(css_unit_len2device_px( + box->style, unit_len_ctx, + vpos, vunit)) * scale); } } @@ -1134,7 +1138,7 @@ static bool html_redraw_text_box(const html_content *html, struct box *box, bool excluded = (box->object != NULL); plot_font_style_t fstyle; - font_plot_style_from_css(&html->len_ctx, box->style, &fstyle); + font_plot_style_from_css(&html->unit_len_ctx, box->style, &fstyle); fstyle.background = current_background_color; if (!text_redraw(box->text, @@ -1405,28 +1409,24 @@ bool html_redraw_box(const html_content *html, struct box *box, CSS_CLIP_RECT) { /* We have an absolutly positioned box with a clip rect */ if (css_rect.left_auto == false) - r.x0 = x - border_left + FIXTOINT(nscss_len2px( - &html->len_ctx, - css_rect.left, css_rect.lunit, - box->style)); + r.x0 = x - border_left + FIXTOINT(css_unit_len2device_px( + box->style, &html->unit_len_ctx, + css_rect.left, css_rect.lunit)); if (css_rect.top_auto == false) - r.y0 = y - border_top + FIXTOINT(nscss_len2px( - &html->len_ctx, - css_rect.top, css_rect.tunit, - box->style)); + r.y0 = y - border_top + FIXTOINT(css_unit_len2device_px( + box->style, &html->unit_len_ctx, + css_rect.top, css_rect.tunit)); if (css_rect.right_auto == false) - r.x1 = x - border_left + FIXTOINT(nscss_len2px( - &html->len_ctx, - css_rect.right, css_rect.runit, - box->style)); + r.x1 = x - border_left + FIXTOINT(css_unit_len2device_px( + box->style, &html->unit_len_ctx, + css_rect.right, css_rect.runit)); if (css_rect.bottom_auto == false) - r.y1 = y - border_top + FIXTOINT(nscss_len2px( - &html->len_ctx, - css_rect.bottom, css_rect.bunit, - box->style)); + r.y1 = y - border_top + FIXTOINT(css_unit_len2device_px( + box->style, &html->unit_len_ctx, + css_rect.bottom, css_rect.bunit)); /* find intersection of clip rectangle and box */ if (r.x0 < clip->x0) r.x0 = clip->x0; @@ -1515,7 +1515,7 @@ bool html_redraw_box(const html_content *html, struct box *box, /* plot background */ if (!html_redraw_background(x, y, box, scale, &p, ¤t_background_color, bg_box, - &html->len_ctx, ctx)) + &html->unit_len_ctx, ctx)) return false; /* restore previous graphics window */ if (ctx->plot->clip(ctx, &r) != NSERROR_OK) @@ -1595,7 +1595,7 @@ bool html_redraw_box(const html_content *html, struct box *box, x, y, box, scale, &p, b, first, false, ¤t_background_color, - &html->len_ctx, ctx)) + &html->unit_len_ctx, ctx)) return false; /* restore previous graphics window */ if (ctx->plot->clip(ctx, &r) != NSERROR_OK) @@ -1628,7 +1628,7 @@ bool html_redraw_box(const html_content *html, struct box *box, * the inline */ if (!html_redraw_inline_background(x, ib_y, box, scale, &p, b, first, true, ¤t_background_color, - &html->len_ctx, ctx)) + &html->unit_len_ctx, ctx)) return false; /* restore previous graphics window */ if (ctx->plot->clip(ctx, &r) != NSERROR_OK) @@ -1843,7 +1843,7 @@ bool html_redraw_box(const html_content *html, struct box *box, } else if (box->gadget && box->gadget->type == GADGET_FILE) { if (!html_redraw_file(x + padding_left, y + padding_top, width, height, box, scale, - current_background_color, &html->len_ctx, ctx)) + current_background_color, &html->unit_len_ctx, ctx)) return false; } else if (box->gadget && -- cgit v1.2.3