summaryrefslogtreecommitdiff
path: root/source/html
diff options
context:
space:
mode:
Diffstat (limited to 'source/html')
-rw-r--r--source/html/css-apply.c13
-rw-r--r--source/html/html-layout.c10
2 files changed, 18 insertions, 5 deletions
diff --git a/source/html/css-apply.c b/source/html/css-apply.c
index bf0336eb..a4468bd7 100644
--- a/source/html/css-apply.c
+++ b/source/html/css-apply.c
@@ -708,6 +708,12 @@ number_from_value(fz_css_value *value, float initial, int initial_unit)
return make_number(x, N_NUMBER);
}
+ if (value->type == CSS_KEYWORD)
+ {
+ if (!strcmp(value->data, "auto"))
+ return make_number(0, N_AUTO);
+ }
+
return make_number(initial, initial_unit);
}
@@ -755,6 +761,7 @@ fz_from_css_number(fz_css_number number, float em, float width)
case N_NUMBER: return number.value;
case N_SCALE: return number.value * em;
case N_PERCENT: return number.value * 0.01 * width;
+ case N_AUTO: return width;
}
}
@@ -766,6 +773,7 @@ fz_from_css_number_scale(fz_css_number number, float scale, float em, float widt
case N_NUMBER: return number.value * scale;
case N_SCALE: return number.value * em;
case N_PERCENT: return number.value * 0.01 * width;
+ case N_AUTO: return width;
}
}
@@ -922,6 +930,8 @@ fz_default_css_style(fz_context *ctx, fz_css_style *style)
style->white_space = WS_NORMAL;
style->list_style_type = LST_DISC;
style->font_size = make_number(1, N_SCALE);
+ style->width = make_number(0, N_AUTO);
+ style->height = make_number(0, N_AUTO);
}
void
@@ -999,6 +1009,9 @@ fz_apply_css_style(fz_context *ctx, fz_html_font_set *set, fz_css_style *style,
style->text_indent = number_from_property(match, "text-indent", 0, N_NUMBER);
+ style->width = number_from_property(match, "width", 0, N_AUTO);
+ style->height = number_from_property(match, "height", 0, N_AUTO);
+
style->margin[0] = number_from_property(match, "margin-top", 0, N_NUMBER);
style->margin[1] = number_from_property(match, "margin-right", 0, N_NUMBER);
style->margin[2] = number_from_property(match, "margin-bottom", 0, N_NUMBER);
diff --git a/source/html/html-layout.c b/source/html/html-layout.c
index 39163c00..757289f9 100644
--- a/source/html/html-layout.c
+++ b/source/html/html-layout.c
@@ -369,15 +369,15 @@ static void generate_boxes(fz_context *ctx, fz_html_font_set *set, fz_archive *z
}
}
-static void measure_image(fz_context *ctx, fz_html_flow *node, float w, float h)
+static void measure_image(fz_context *ctx, fz_html_flow *node, float max_w, float max_h)
{
float xs = 1, ys = 1, s = 1;
node->x = 0;
node->y = 0;
- if (node->image->w > w)
- xs = w / node->image->w;
- if (node->image->h > h)
- ys = h / node->image->h;
+ if (node->image->w > max_w)
+ xs = max_w / node->image->w;
+ if (node->image->h > max_h)
+ ys = max_h / node->image->h;
s = fz_min(xs, ys);
node->w = node->image->w * s;
node->h = node->image->h * s;