From d0cb1d4e66662b31c3354e20f9ac290153f9bd39 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 5 Nov 2012 18:17:27 +0000 Subject: Don't abort redraw on bad image. --- desktop/plot_style.c | 22 ++++++++++++++++++++++ desktop/plot_style.h | 5 +++++ render/html_redraw.c | 20 ++++++++++++++++++-- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/desktop/plot_style.c b/desktop/plot_style.c index 85b898968..a2b582292 100644 --- a/desktop/plot_style.c +++ b/desktop/plot_style.c @@ -68,6 +68,28 @@ static const plot_style_t plot_style_margin_edge_static = { plot_style_t const * const plot_style_margin_edge = &plot_style_margin_edge_static; +/* Broken object replacement styles */ +static const plot_style_t plot_style_broken_object_static = { + .fill_type = PLOT_OP_TYPE_SOLID, + .fill_colour = 0x008888ff, + .stroke_type = PLOT_OP_TYPE_SOLID, + .stroke_colour = 0x000000ff, + .stroke_width = 1, +}; +plot_style_t const * const plot_style_broken_object = + &plot_style_broken_object_static; + +static const plot_font_style_t plot_fstyle_broken_object_static = { + .family = PLOT_FONT_FAMILY_SANS_SERIF, + .size = 14 * FONT_SIZE_SCALE, + .weight = 400, + .flags = FONTF_NONE, + .background = 0x8888ff, + .foreground = 0x000044, +}; +plot_font_style_t const * const plot_fstyle_broken_object = + &plot_fstyle_broken_object_static; + /* caret style used in html_redraw_caret */ static plot_style_t plot_style_caret_static = { .stroke_type = PLOT_OP_TYPE_SOLID, diff --git a/desktop/plot_style.h b/desktop/plot_style.h index f0cd35420..8f57915a9 100644 --- a/desktop/plot_style.h +++ b/desktop/plot_style.h @@ -147,6 +147,11 @@ extern plot_style_t const * const plot_style_content_edge; extern plot_style_t const * const plot_style_padding_edge; extern plot_style_t const * const plot_style_margin_edge; +/* Broken object replacement styles */ +extern plot_style_t const * const plot_style_broken_object; +extern plot_font_style_t const * const plot_fstyle_broken_object; + + /* other styles */ extern plot_style_t *plot_style_caret; extern plot_style_t *plot_style_stroke_history; diff --git a/render/html_redraw.c b/render/html_redraw.c index c9a163e61..77142c631 100644 --- a/render/html_redraw.c +++ b/render/html_redraw.c @@ -672,8 +672,24 @@ bool html_redraw_box(const html_content *html, struct box *box, obj_data.y /= scale; } - if (!content_redraw(box->object, &obj_data, &r, ctx)) - return false; + if (!content_redraw(box->object, &obj_data, &r, ctx)) { + /* Show image fail */ + if (!plot->rectangle(x + padding_left, + y + padding_top, + x + padding_left + width - 1, + y + padding_top + height - 1, + plot_style_broken_object)) + return false; + /* Show Unicode (U+FFFC) 'OBJECT REPLACEMENT CHARACTER' + */ + if (!plot->text(x + padding_left, + y + padding_top + (int) + (height * 0.75 * scale), + "\xef\xbf\xbc", 3, + plot_fstyle_broken_object)) + return false; + } + } else if (box->iframe) { /* Offset is passed to browser window redraw unscaled */ -- cgit v1.2.3