summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/html.h2
-rw-r--r--source/html/css-apply.c15
-rw-r--r--source/html/html-layout.c56
3 files changed, 50 insertions, 23 deletions
diff --git a/include/mupdf/html.h b/include/mupdf/html.h
index d1519284..8f4e5073 100644
--- a/include/mupdf/html.h
+++ b/include/mupdf/html.h
@@ -94,6 +94,7 @@ enum { POS_STATIC, POS_RELATIVE, POS_ABSOLUTE, POS_FIXED };
enum { TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY };
enum { VA_BASELINE, VA_SUB, VA_SUPER, VA_TOP, VA_BOTTOM };
enum { BS_NONE, BS_SOLID };
+enum { V_VISIBLE, V_HIDDEN, V_COLLAPSE };
enum {
WS_COLLAPSE = 1,
@@ -138,6 +139,7 @@ struct fz_css_style_s
fz_css_number padding[4];
fz_css_number border_width[4];
fz_css_number text_indent;
+ char visibility;
char white_space;
char text_align;
char vertical_align;
diff --git a/source/html/css-apply.c b/source/html/css-apply.c
index 551dc2d8..acb19244 100644
--- a/source/html/css-apply.c
+++ b/source/html/css-apply.c
@@ -944,10 +944,24 @@ white_space_from_property(fz_css_match *match)
return WS_NORMAL;
}
+static int
+visibility_from_property(fz_css_match *match)
+{
+ fz_css_value *value = value_from_property(match, "visibility");
+ if (value)
+ {
+ if (!strcmp(value->data, "visible")) return V_VISIBLE;
+ else if (!strcmp(value->data, "hidden")) return V_HIDDEN;
+ else if (!strcmp(value->data, "collapse")) return V_COLLAPSE;
+ }
+ return V_VISIBLE;
+}
+
void
fz_default_css_style(fz_context *ctx, fz_css_style *style)
{
memset(style, 0, sizeof *style);
+ style->visibility = V_VISIBLE;
style->text_align = TA_LEFT;
style->vertical_align = VA_BASELINE;
style->white_space = WS_NORMAL;
@@ -967,6 +981,7 @@ fz_apply_css_style(fz_context *ctx, fz_html_font_set *set, fz_css_style *style,
fz_default_css_style(ctx, style);
+ style->visibility = visibility_from_property(match);
style->white_space = white_space_from_property(match);
value = value_from_property(match, "text-align");
diff --git a/source/html/html-layout.c b/source/html/html-layout.c
index 3ee6808b..f742969c 100644
--- a/source/html/html-layout.c
+++ b/source/html/html-layout.c
@@ -865,9 +865,12 @@ static void draw_flow_box(fz_context *ctx, fz_html *box, float page_top, float p
g = fz_encode_character(ctx, node->style->font, c);
if (g)
{
- if (!text)
- text = fz_new_text(ctx, node->style->font, &trm, 0);
- fz_add_text(ctx, text, g, c, x, y);
+ if (node->style->visibility == V_VISIBLE)
+ {
+ if (!text)
+ text = fz_new_text(ctx, node->style->font, &trm, 0);
+ fz_add_text(ctx, text, g, c, x, y);
+ }
x += fz_advance_glyph(ctx, node->style->font, g) * node->em;
}
else
@@ -875,9 +878,12 @@ static void draw_flow_box(fz_context *ctx, fz_html *box, float page_top, float p
g = fz_encode_character(ctx, node->style->fallback, c);
if (g)
{
- if (!falltext)
- falltext = fz_new_text(ctx, node->style->fallback, &trm, 0);
- fz_add_text(ctx, falltext, g, c, x, y);
+ if (node->style->visibility == V_VISIBLE)
+ {
+ if (!falltext)
+ falltext = fz_new_text(ctx, node->style->fallback, &trm, 0);
+ fz_add_text(ctx, falltext, g, c, x, y);
+ }
}
x += fz_advance_glyph(ctx, node->style->fallback, g) * node->em;
}
@@ -896,10 +902,13 @@ static void draw_flow_box(fz_context *ctx, fz_html *box, float page_top, float p
}
else if (node->type == FLOW_IMAGE)
{
- fz_matrix local_ctm = *ctm;
- fz_pre_translate(&local_ctm, node->x, node->y);
- fz_pre_scale(&local_ctm, node->w, node->h);
- fz_fill_image(ctx, dev, node->image, &local_ctm, 1);
+ if (node->style->visibility == V_VISIBLE)
+ {
+ fz_matrix local_ctm = *ctm;
+ fz_pre_translate(&local_ctm, node->x, node->y);
+ fz_pre_scale(&local_ctm, node->w, node->h);
+ fz_fill_image(ctx, dev, node->image, &local_ctm, 1);
+ }
}
}
}
@@ -1102,20 +1111,21 @@ static void draw_block_box(fz_context *ctx, fz_html *box, float page_top, float
if (y0 > page_bot || y1 < page_top)
return;
- draw_rect(ctx, dev, ctm, box->style.background_color, x0, y0, x1, y1);
-
- if (border[T] > 0)
- draw_rect(ctx, dev, ctm, box->style.border_color[T], x0 - border[L], y0 - border[T], x1 + border[R], y0);
- if (border[B] > 0)
- draw_rect(ctx, dev, ctm, box->style.border_color[B], x0 - border[L], y1, x1 + border[R], y1 + border[B]);
- if (border[L] > 0)
- draw_rect(ctx, dev, ctm, box->style.border_color[L], x0 - border[L], y0 - border[T], x0, y1 + border[B]);
- if (border[R] > 0)
- draw_rect(ctx, dev, ctm, box->style.border_color[R], x1, y0 - border[T], x1 + border[R], y1 + border[B]);
-
- if (box->list_item)
+ if (box->style.visibility == V_VISIBLE)
{
- draw_list_mark(ctx, box, page_top, page_bot, dev, ctm, box->list_item);
+ draw_rect(ctx, dev, ctm, box->style.background_color, x0, y0, x1, y1);
+
+ if (border[T] > 0)
+ draw_rect(ctx, dev, ctm, box->style.border_color[T], x0 - border[L], y0 - border[T], x1 + border[R], y0);
+ if (border[B] > 0)
+ draw_rect(ctx, dev, ctm, box->style.border_color[B], x0 - border[L], y1, x1 + border[R], y1 + border[B]);
+ if (border[L] > 0)
+ draw_rect(ctx, dev, ctm, box->style.border_color[L], x0 - border[L], y0 - border[T], x0, y1 + border[B]);
+ if (border[R] > 0)
+ draw_rect(ctx, dev, ctm, box->style.border_color[R], x1, y0 - border[T], x1 + border[R], y1 + border[B]);
+
+ if (box->list_item)
+ draw_list_mark(ctx, box, page_top, page_bot, dev, ctm, box->list_item);
}
for (box = box->down; box; box = box->next)