diff options
Diffstat (limited to 'render/layout.c')
-rw-r--r-- | render/layout.c | 113 |
1 files changed, 41 insertions, 72 deletions
diff --git a/render/layout.c b/render/layout.c index 9b479da17..4539867d0 100644 --- a/render/layout.c +++ b/render/layout.c @@ -475,7 +475,7 @@ bool layout_block_context(struct box *block, int viewport_height, } #ifdef LAYOUT_DEBUG - LOG(("box %p, cx %i, cy %i", box, cx, cy)); + LOG("box %p, cx %i, cy %i", box, cx, cy); #endif /* Layout (except tables). */ @@ -1021,8 +1021,7 @@ bool layout_block_object(struct box *block) assert(block->object); #ifdef LAYOUT_DEBUG - LOG(("block %p, object %s, width %i", block, - hlcache_handle_get_url(block->object), block->width)); + LOG("block %p, object %s, width %i", block, hlcache_handle_get_url(block->object), block->width); #endif if (content_get_type(block->object) == CONTENT_HTML) { @@ -2058,7 +2057,7 @@ void find_sides(struct box *fl, int y0, int y1, int fy0, fy1, fx0, fx1; #ifdef LAYOUT_DEBUG - LOG(("y0 %i, y1 %i, x0 %i, x1 %i", y0, y1, *x0, *x1)); + LOG("y0 %i, y1 %i, x0 %i, x1 %i", y0, y1, *x0, *x1); #endif *left = *right = 0; @@ -2083,7 +2082,7 @@ void find_sides(struct box *fl, int y0, int y1, } #ifdef LAYOUT_DEBUG - LOG(("x0 %i, x1 %i, left %p, right %p", *x0, *x1, *left, *right)); + LOG("x0 %i, x1 %i, left %p, right %p", *x0, *x1, *left, *right); #endif } @@ -2112,8 +2111,7 @@ bool layout_inline_container(struct box *inline_container, int width, assert(inline_container->type == BOX_INLINE_CONTAINER); #ifdef LAYOUT_DEBUG - LOG(("inline_container %p, width %i, cont %p, cx %i, cy %i", - inline_container, width, cont, cx, cy)); + LOG("inline_container %p, width %i, cont %p, cx %i, cy %i", inline_container, width, cont, cx, cy); #endif has_text_children = false; @@ -2143,7 +2141,7 @@ bool layout_inline_container(struct box *inline_container, int width, */ for (c = inline_container->children; c; ) { #ifdef LAYOUT_DEBUG - LOG(("c %p", c)); + LOG("c %p", c); #endif curwidth = inline_container->width; if (!layout_line(c, &curwidth, &y, cx, cy + y, cont, first_line, @@ -2309,12 +2307,8 @@ static bool layout_text_box_split(html_content *content, else c2->parent->last = c2; #ifdef LAYOUT_DEBUG - LOG(("split_box %p len: %u \"%.*s\"", - split_box, split_box->length, - split_box->length, split_box->text)); - LOG((" new_box %p len: %u \"%.*s\"", - c2, c2->length, - c2->length, c2->text)); + LOG("split_box %p len: %u \"%.*s\"", split_box, split_box->length, split_box->length, split_box->text); + LOG(" new_box %p len: %u \"%.*s\"", c2, c2->length, c2->length, c2->text); #endif return true; } @@ -2362,9 +2356,7 @@ bool layout_line(struct box *first, int *width, int *y, plot_font_style_t fstyle; #ifdef LAYOUT_DEBUG - LOG(("first %p, first->text '%.*s', width %i, y %i, cx %i, cy %i", - first, (int) first->length, first->text, *width, - *y, cx, cy)); + LOG("first %p, first->text '%.*s', width %i, y %i, cx %i, cy %i", first, (int)first->length, first->text, *width, *y, cx, cy); #endif /* find sides at top of line */ @@ -2395,7 +2387,7 @@ bool layout_line(struct box *first, int *width, int *y, * body executed at least once * keep in sync with the loop in layout_minmax_line() */ #ifdef LAYOUT_DEBUG - LOG(("x0 %i, x1 %i, x1 - x0 %i", x0, x1, x1 - x0)); + LOG("x0 %i, x1 %i, x1 - x0 %i", x0, x1, x1 - x0); #endif for (x = 0, b = first; x <= x1 - x0 && b != 0; b = b->next) { @@ -2408,7 +2400,7 @@ bool layout_line(struct box *first, int *width, int *y, b->type == BOX_INLINE_END); #ifdef LAYOUT_DEBUG - LOG(("pass 1: b %p, x %i", b, x)); + LOG("pass 1: b %p, x %i", b, x); #endif if (b->type == BOX_BR) @@ -2621,12 +2613,12 @@ bool layout_line(struct box *first, int *width, int *y, /* pass 2: place boxes in line: loop body executed at least once */ #ifdef LAYOUT_DEBUG - LOG(("x0 %i, x1 %i, x1 - x0 %i", x0, x1, x1 - x0)); + LOG("x0 %i, x1 %i, x1 - x0 %i", x0, x1, x1 - x0); #endif for (x = x_previous = 0, b = first; x <= x1 - x0 && b; b = b->next) { #ifdef LAYOUT_DEBUG - LOG(("pass 2: b %p, x %i", b, x)); + LOG("pass 2: b %p, x %i", b, x); #endif if (b->type == BOX_INLINE_BLOCK && @@ -2696,7 +2688,7 @@ bool layout_line(struct box *first, int *width, int *y, } else { /* float */ #ifdef LAYOUT_DEBUG - LOG(("float %p", b)); + LOG("float %p", b); #endif d = b->children; @@ -2707,8 +2699,7 @@ bool layout_line(struct box *first, int *width, int *y, return false; #ifdef LAYOUT_DEBUG - LOG(("%p : %d %d", d, d->margin[TOP], - d->border[TOP].width)); + LOG("%p : %d %d", d, d->margin[TOP], d->border[TOP].width); #endif d->x = d->margin[LEFT] + d->border[LEFT].width; @@ -2798,7 +2789,7 @@ bool layout_line(struct box *first, int *width, int *y, } if (cont->float_children == b) { #ifdef LAYOUT_DEBUG - LOG(("float %p already placed", b)); + LOG("float %p already placed", b); #endif box_dump(stderr, cont, 0, true); @@ -2842,11 +2833,7 @@ bool layout_line(struct box *first, int *width, int *y, w = split_box->width; #ifdef LAYOUT_DEBUG - LOG(("splitting: split_box %p \"%.*s\", spilt %zu, w %i, " - "left %p, right %p, inline_count %u", - split_box, (int) split_box->length, - split_box->text, split, w, - left, right, inline_count)); + LOG("splitting: split_box %p \"%.*s\", spilt %zu, w %i, ""left %p, right %p, inline_count %u", split_box, (int)split_box->length, split_box->text, split, w, left, right, inline_count); #endif if ((split == 0 || x1 - x0 <= x + space_before + w) && @@ -2866,7 +2853,7 @@ bool layout_line(struct box *first, int *width, int *y, } x += space_before + w; #ifdef LAYOUT_DEBUG - LOG(("forcing")); + LOG("forcing"); #endif } else if ((split == 0 || x1 - x0 <= x + space_before + w) && inline_count == 1) { @@ -2876,12 +2863,11 @@ bool layout_line(struct box *first, int *width, int *y, used_height = 0; if (left) { #ifdef LAYOUT_DEBUG - LOG(("cy %i, left->y %i, left->height %i", - cy, left->y, left->height)); + LOG("cy %i, left->y %i, left->height %i", cy, left->y, left->height); #endif used_height = left->y + left->height - cy + 1; #ifdef LAYOUT_DEBUG - LOG(("used_height %i", used_height)); + LOG("used_height %i", used_height); #endif } if (right && used_height < @@ -2893,21 +2879,20 @@ bool layout_line(struct box *first, int *width, int *y, b = split_box; #ifdef LAYOUT_DEBUG - LOG(("moving below float")); + LOG("moving below float"); #endif } else if (split == 0 || x1 - x0 <= x + space_before + w) { /* first word of box doesn't fit so leave box for next * line */ b = split_box; #ifdef LAYOUT_DEBUG - LOG(("leaving for next line")); + LOG("leaving for next line"); #endif } else { /* fit as many words as possible */ assert(split != 0); #ifdef LAYOUT_DEBUG - LOG(("'%.*s' %i %zu %i", (int) split_box->length, - split_box->text, x1 - x0, split, w)); + LOG("'%.*s' %i %zu %i", (int)split_box->length, split_box->text, x1 - x0, split, w); #endif if (split != split_box->length) { if (!layout_text_box_split(content, &fstyle, @@ -2917,7 +2902,7 @@ bool layout_line(struct box *first, int *width, int *y, } x += space_before + w; #ifdef LAYOUT_DEBUG - LOG(("fitting words")); + LOG("fitting words"); #endif } move_y = true; @@ -3095,7 +3080,7 @@ struct box *layout_minmax_line(struct box *first, b->type == BOX_INLINE_END); #ifdef LAYOUT_DEBUG - LOG(("%p: min %i, max %i", b, min, max)); + LOG("%p: min %i, max %i", b, min, max); #endif if (b->type == BOX_BR) { @@ -3342,7 +3327,7 @@ struct box *layout_minmax_line(struct box *first, *line_max = max; #ifdef LAYOUT_DEBUG - LOG(("line_min %i, line_max %i", min, max)); + LOG("line_min %i, line_max %i", min, max); #endif assert(b != first); @@ -3424,7 +3409,7 @@ void place_float_below(struct box *c, int width, int cx, int y, struct box *right; #ifdef LAYOUT_DEBUG - LOG(("c %p, width %i, cx %i, y %i, cont %p", c, width, cx, y, cont)); + LOG("c %p, width %i, cx %i, y %i, cont %p", c, width, cx, y, cont); #endif do { @@ -3653,11 +3638,13 @@ bool layout_table(struct box *table, int available_width, /* calculate width required by cells */ for (i = 0; i != columns; i++) { #ifdef LAYOUT_DEBUG - LOG(("table %p, column %u: type %s, width %i, min %i, max %i", - table, i, - ((const char *[]) {"UNKNOWN", "FIXED", "AUTO", - "PERCENT", "RELATIVE"})[col[i].type], - col[i].width, col[i].min, col[i].max)); + LOG("table %p, column %u: type %s, width %i, min %i, max %i", table, i, ((const char *[]){ + "UNKNOWN", + "FIXED", + "AUTO", + "PERCENT", + "RELATIVE" + })[col[i].type], col[i].width, col[i].min, col[i].max); #endif if (col[i].positioned) { @@ -3677,16 +3664,14 @@ bool layout_table(struct box *table, int available_width, required_width += col[i].min; #ifdef LAYOUT_DEBUG - LOG(("required_width %i", required_width)); + LOG("required_width %i", required_width); #endif } required_width += (columns + 1 - positioned_columns) * border_spacing_h; #ifdef LAYOUT_DEBUG - LOG(("width %i, min %i, max %i, auto %i, required %i", - table_width, table->min_width, table->max_width, - auto_width, required_width)); + LOG("width %i, min %i, max %i, auto %i, required %i", table_width, table->min_width, table->max_width, auto_width, required_width); #endif if (auto_width < required_width) { @@ -4503,7 +4488,7 @@ void layout_compute_relative_offset(struct box *box, int *x, int *y) } #ifdef LAYOUT_DEBUG - LOG(("left %i, right %i, top %i, bottom %i", left, right, top, bottom)); + LOG("left %i, right %i, top %i, bottom %i", left, right, top, bottom); #endif *x = left; @@ -4640,11 +4625,7 @@ bool layout_absolute(struct box *box, struct box *containing_block, /* 10.3.7 */ #ifdef LAYOUT_DEBUG - LOG(("%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", - left, margin[LEFT], border[LEFT].width, - padding[LEFT], width, padding[RIGHT], - border[RIGHT].width, margin[RIGHT], right, - containing_block->width)); + LOG("%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", left, margin[LEFT], border[LEFT].width, padding[LEFT], width, padding[RIGHT], border[RIGHT].width, margin[RIGHT], right, containing_block->width); #endif if (left == AUTO && width == AUTO && right == AUTO) { @@ -4809,11 +4790,7 @@ bool layout_absolute(struct box *box, struct box *containing_block, } #ifdef LAYOUT_DEBUG - LOG(("%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", - left, margin[LEFT], border[LEFT].width, padding[LEFT], - width, padding[RIGHT], border[RIGHT].width, - margin[RIGHT], right, - containing_block->width)); + LOG("%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", left, margin[LEFT], border[LEFT].width, padding[LEFT], width, padding[RIGHT], border[RIGHT].width, margin[RIGHT], right, containing_block->width); #endif box->x = left + margin[LEFT] + border[LEFT].width - cx; @@ -4847,11 +4824,7 @@ bool layout_absolute(struct box *box, struct box *containing_block, /* 10.6.4 */ #ifdef LAYOUT_DEBUG - LOG(("%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", - top, margin[TOP], border[TOP].width, padding[TOP], - height, padding[BOTTOM], border[BOTTOM].width, - margin[BOTTOM], bottom, - containing_block->height)); + LOG("%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", top, margin[TOP], border[TOP].width, padding[TOP], height, padding[BOTTOM], border[BOTTOM].width, margin[BOTTOM], bottom, containing_block->height); #endif if (top == AUTO && height == AUTO && bottom == AUTO) { @@ -4939,11 +4912,7 @@ bool layout_absolute(struct box *box, struct box *containing_block, } #ifdef LAYOUT_DEBUG - LOG(("%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", - top, margin[TOP], border[TOP].width, padding[TOP], - height, padding[BOTTOM], border[BOTTOM].width, - margin[BOTTOM], bottom, - containing_block->height)); + LOG("%i + %i + %i + %i + %i + %i + %i + %i + %i = %i", top, margin[TOP], border[TOP].width, padding[TOP], height, padding[BOTTOM], border[BOTTOM].width, margin[BOTTOM], bottom, containing_block->height); #endif box->y = top + margin[TOP] + border[TOP].width - cy; |