summaryrefslogtreecommitdiff
path: root/css
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2008-10-12 21:22:28 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2008-10-12 21:22:28 +0000
commitb7a1b3999e2b9790bbd070b8e0cdef3abdc6f096 (patch)
treedf39e841ab8524c2ccc8e4d69ca4088e0e4e05b4 /css
parentc1db0e90cca4a4b7fd7fc9ccbaf679554875bee1 (diff)
downloadnetsurf-b7a1b3999e2b9790bbd070b8e0cdef3abdc6f096.tar.gz
netsurf-b7a1b3999e2b9790bbd070b8e0cdef3abdc6f096.tar.bz2
Implement percentage heights for block level elements in normal flow, floats and positioned boxes. Percentage min/max-height not yet handled.
svn path=/trunk/netsurf/; revision=5550
Diffstat (limited to 'css')
-rw-r--r--css/css.c12
-rw-r--r--css/css.h6
-rw-r--r--css/ruleset.c7
3 files changed, 18 insertions, 7 deletions
diff --git a/css/css.c b/css/css.c
index 76c7e6ca5..aeeec4084 100644
--- a/css/css.c
+++ b/css/css.c
@@ -180,7 +180,7 @@ const struct css_style css_base_style = {
CSS_FONT_STYLE_NORMAL,
CSS_FONT_VARIANT_NORMAL,
CSS_FONT_WEIGHT_NORMAL,
- { CSS_HEIGHT_AUTO, { 1, CSS_UNIT_EM } },
+ { CSS_HEIGHT_AUTO, { { 1, CSS_UNIT_EM } } },
{ CSS_LETTER_SPACING_NORMAL, { 0, CSS_UNIT_PX } },
{ CSS_LINE_HEIGHT_ABSOLUTE, { 1.33 } },
{ CSS_LIST_STYLE_IMAGE_NONE, 0 },
@@ -265,7 +265,7 @@ const struct css_style css_empty_style = {
CSS_FONT_STYLE_NOT_SET,
CSS_FONT_VARIANT_NOT_SET,
CSS_FONT_WEIGHT_NOT_SET,
- { CSS_HEIGHT_NOT_SET, { 1, CSS_UNIT_EM } },
+ { CSS_HEIGHT_NOT_SET, { { 1, CSS_UNIT_EM } } },
{ CSS_LETTER_SPACING_NOT_SET, { 0, CSS_UNIT_PX } },
{ CSS_LINE_HEIGHT_NOT_SET, { 1.33 } },
{ CSS_LIST_STYLE_IMAGE_NOT_SET, 0 },
@@ -351,7 +351,7 @@ const struct css_style css_blank_style = {
CSS_FONT_STYLE_INHERIT,
CSS_FONT_VARIANT_INHERIT,
CSS_FONT_WEIGHT_INHERIT,
- { CSS_HEIGHT_AUTO, { 1, CSS_UNIT_EM } },
+ { CSS_HEIGHT_AUTO, { { 1, CSS_UNIT_EM } } },
{ CSS_LETTER_SPACING_INHERIT, { 0, CSS_UNIT_PX } },
{ CSS_LINE_HEIGHT_INHERIT, { 1.33 } },
{ CSS_LIST_STYLE_IMAGE_INHERIT, 0 },
@@ -1903,7 +1903,11 @@ void css_dump_style(FILE *stream, const struct css_style * const style)
fprintf(stream, "auto");
break;
case CSS_HEIGHT_LENGTH:
- css_dump_length(stream, &style->height.length);
+ css_dump_length(stream, &style->height.value.length);
+ break;
+ case CSS_HEIGHT_PERCENT:
+ fprintf(stream, "%g%%",
+ style->height.value.percent);
break;
default:
fprintf(stream, "UNKNOWN");
diff --git a/css/css.h b/css/css.h
index a48d97ef8..b3ff34ea0 100644
--- a/css/css.h
+++ b/css/css.h
@@ -279,8 +279,12 @@ struct css_style {
enum { CSS_HEIGHT_INHERIT,
CSS_HEIGHT_AUTO,
CSS_HEIGHT_LENGTH,
+ CSS_HEIGHT_PERCENT,
CSS_HEIGHT_NOT_SET } height;
- struct css_length length;
+ union {
+ struct css_length length;
+ float percent;
+ } value;
} height;
struct {
diff --git a/css/ruleset.c b/css/ruleset.c
index 4529fba8d..d04f62359 100644
--- a/css/ruleset.c
+++ b/css/ruleset.c
@@ -2228,8 +2228,11 @@ void parse_height(struct css_style * const s, const struct css_node * const v)
if (v->type == CSS_NODE_IDENT && v->data_length == 4 &&
strncasecmp(v->data, "auto", 4) == 0)
s->height.height = CSS_HEIGHT_AUTO;
- else if ((v->type == CSS_NODE_DIMENSION || v->type == CSS_NODE_NUMBER) &&
- parse_length(&s->height.length, v, true) == 0)
+ else if (v->type == CSS_NODE_PERCENTAGE) {
+ s->height.height = CSS_HEIGHT_PERCENT;
+ s->height.value.percent = atof(v->data);
+ } else if ((v->type == CSS_NODE_DIMENSION || v->type == CSS_NODE_NUMBER) &&
+ parse_length(&s->height.value.length, v, true) == 0)
s->height.height = CSS_HEIGHT_LENGTH;
}