summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2009-04-28 20:13:10 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2009-04-28 20:13:10 +0000
commita99a5bdd707f27c9fb9a92a18f94830d710a7bee (patch)
tree1d12e722ca260012edec5df748c819ac4c08db44
parent044a9534008fd77a2cf8755943f3fe42fa177d54 (diff)
downloadnetsurf-a99a5bdd707f27c9fb9a92a18f94830d710a7bee.tar.gz
netsurf-a99a5bdd707f27c9fb9a92a18f94830d710a7bee.tar.bz2
Move handling of TR height attribute from box construction to layout and add support for height property on TR.
svn path=/trunk/netsurf/; revision=7358
-rw-r--r--render/box_construct.c53
-rw-r--r--render/layout.c9
2 files changed, 13 insertions, 49 deletions
diff --git a/render/box_construct.c b/render/box_construct.c
index f31b51538..1141f75dd 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -562,52 +562,6 @@ bool box_construct_element(xmlNode *n, struct content *content,
xmlFree(s);
}
- /* transfer <tr height="n"> down to the <td> elements */
- /* \todo move this into box_get_style() */
- if (strcmp((const char *) n->name, "tr") == 0) {
- if ((s = (char *) xmlGetProp(n,
- (const xmlChar *) "height"))) {
- float value = atof(s);
- if (value < 0 || strlen(s) == 0) {
- /* ignore negative values and height="" */
- } else if (strrchr(s, '%')) {
- /* the specification doesn't make clear what
- * percentage heights mean, so ignore them */
- } else {
- /* The tree is not normalized yet, so accept
- * cells not in rows and rows not in row
- * groups. */
- struct box *child;
- float current;
- for (child = box->children; child;
- child = child->next) {
- if (child->style->height.height ==
- CSS_HEIGHT_LENGTH)
- current = css_len2px(
- &child->style->height.
- value.length,
- child->style);
- else
- current = 0;
- if (child->type == BOX_TABLE_CELL &&
- value > current) {
- /* Row height exceeds cell
- * height, increase cell height
- * to row height */
- child->style->height.height =
- CSS_HEIGHT_LENGTH;
- child->style->height.value.
- length.unit =
- CSS_UNIT_PX;
- child->style->height.value.
- length.value = value;
- }
- }
- }
- xmlFree(s);
- }
- }
-
/* fetch any background image for this box */
if (style->background_image.type == CSS_BACKGROUND_IMAGE_URI) {
if (!html_fetch_object(content, style->background_image.uri,
@@ -925,6 +879,7 @@ struct css_style * box_get_style(struct content *c,
((strcmp((const char *) n->name, "iframe") == 0) ||
(strcmp((const char *) n->name, "td") == 0) ||
(strcmp((const char *) n->name, "th") == 0) ||
+ (strcmp((const char *) n->name, "tr") == 0) ||
(strcmp((const char *) n->name, "img") == 0) ||
(strcmp((const char *) n->name, "object") == 0) ||
(strcmp((const char *) n->name, "applet") == 0))) {
@@ -932,8 +887,8 @@ struct css_style * box_get_style(struct content *c,
if (value <= 0 || strlen(s) == 0) {
/* ignore negative values and height="" */
} else if (strrchr(s, '%')) {
- /* the specification doesn't make clear what
- * percentage heights mean, so ignore them */
+ style->height.height = CSS_HEIGHT_PERCENT;
+ style->height.value.percent = value;
} else {
style->height.height = CSS_HEIGHT_LENGTH;
style->height.value.length.unit = CSS_UNIT_PX;
@@ -2328,7 +2283,7 @@ bool box_button(BOX_SPECIAL_PARAMS)
gadget->box = box;
box->type = BOX_INLINE_BLOCK;
-
+
/* Just render the contents */
return true;
diff --git a/render/layout.c b/render/layout.c
index 05b668aad..fd53995b8 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -2772,6 +2772,11 @@ bool layout_table(struct box *table, int available_width,
int row_group_height = 0;
for (row = row_group->children; row; row = row->next) {
int row_height = 0;
+ if (row->style->height.height == CSS_HEIGHT_LENGTH) {
+ row_height = (int) css_len2px(&row->style->
+ height.value.length,
+ row->style);
+ }
for (c = row->children; c; c = c->next) {
assert(c->style);
c->width = xs[c->start_column + c->columns] -
@@ -2807,6 +2812,10 @@ bool layout_table(struct box *table, int available_width,
if (c->height < h)
c->height = h;
}
+ /* specified row height is treated as a minimum
+ */
+ if (c->height < row_height)
+ c->height = row_height;
c->x = xs[c->start_column] + c->border[LEFT];
c->y = c->border[TOP];
for (i = 0; i != c->columns; i++) {