summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
Diffstat (limited to 'render')
-rw-r--r--render/box.c24
-rw-r--r--render/box.h1
-rw-r--r--render/html.c42
-rw-r--r--render/layout.c60
4 files changed, 63 insertions, 64 deletions
diff --git a/render/box.c b/render/box.c
index 382429bb1..bbe02c732 100644
--- a/render/box.c
+++ b/render/box.c
@@ -152,6 +152,7 @@ struct box * box_create(struct css_style * style,
/* under RISC OS, xcalloc makes these unnecessary */
box->text = 0;
box->space = 0;
+ box->clone = 0;
box->length = 0;
box->start_column = 0;
box->next = 0;
@@ -590,17 +591,17 @@ struct result box_image(xmlNode *n, struct status *status,
{
struct box *box;
char *s, *url;
- /*xmlChar *s2;*/
+ xmlChar *s2;
box = box_create(style, status->href, status->title);
/* handle alt text */
- /*if ((s2 = xmlGetProp(n, (const xmlChar *) "alt"))) {
+ if ((s2 = xmlGetProp(n, (const xmlChar *) "alt"))) {
box->text = squash_tolat1(s2);
box->length = strlen(box->text);
- box->font = font_open(content->data.html.fonts, style);
+ box->font = font_open(status->content->data.html.fonts, style);
free(s2);
- }*/
+ }
/* img without src is an error */
if (!(s = (char *) xmlGetProp(n, (const xmlChar *) "src")))
@@ -919,12 +920,7 @@ void box_dump(struct box * box, unsigned int depth)
switch (box->type) {
case BOX_BLOCK: fprintf(stderr, "BOX_BLOCK "); break;
case BOX_INLINE_CONTAINER: fprintf(stderr, "BOX_INLINE_CONTAINER "); break;
- case BOX_INLINE: if (box->text != 0)
- fprintf(stderr, "BOX_INLINE '%.*s' ",
- (int) box->length, box->text);
- else
- fprintf(stderr, "BOX_INLINE (special) ");
- break;
+ case BOX_INLINE: fprintf(stderr, "BOX_INLINE "); break;
case BOX_TABLE: fprintf(stderr, "BOX_TABLE "); break;
case BOX_TABLE_ROW: fprintf(stderr, "BOX_TABLE_ROW "); break;
case BOX_TABLE_CELL: fprintf(stderr, "BOX_TABLE_CELL [columns %i] ",
@@ -934,12 +930,16 @@ void box_dump(struct box * box, unsigned int depth)
case BOX_FLOAT_RIGHT: fprintf(stderr, "BOX_FLOAT_RIGHT "); break;
default: fprintf(stderr, "Unknown box type ");
}
+ if (box->text)
+ fprintf(stderr, "'%.*s' ", (int) box->length, box->text);
+ if (box->object)
+ fprintf(stderr, "(object '%s') ", box->object->url);
if (box->style)
css_dump_style(box->style);
if (box->href != 0)
- fprintf(stderr, " -> '%s'", box->href);
+ fprintf(stderr, " -> '%s' ", box->href);
if (box->title != 0)
- fprintf(stderr, " [%s]", box->title);
+ fprintf(stderr, "[%s]", box->title);
fprintf(stderr, "\n");
for (c = box->children; c != 0; c = c->next)
diff --git a/render/box.h b/render/box.h
index 002bb0601..bf56df591 100644
--- a/render/box.h
+++ b/render/box.h
@@ -126,6 +126,7 @@ struct box {
unsigned long min_width, max_width;
char * text;
unsigned int space : 1; /* 1 <=> followed by a space */
+ unsigned int clone : 1;
char * href;
char * title;
unsigned int length;
diff --git a/render/html.c b/render/html.c
index 443d4cd7d..13b4e9bf6 100644
--- a/render/html.c
+++ b/render/html.c
@@ -412,37 +412,33 @@ void html_object_callback(content_msg msg, struct content *object,
box->style->width.value.length.unit = CSS_UNIT_PX;
box->style->width.value.length.value = object->width;
box->min_width = box->max_width = box->width = object->width;
- /* invalidate parent min, max widths */
- if (box->parent->max_width != UNKNOWN_MAX_WIDTH) {
- struct box *b = box->parent;
- if (b->min_width < object->width)
- b->min_width = object->width;
- if (b->max_width < object->width)
- b->max_width = object->width;
- for (b = b->parent; b != 0 &&
- (b->type == BOX_TABLE_ROW_GROUP ||
- b->type == BOX_TABLE_ROW ||
- b->max_width != UNKNOWN_MAX_WIDTH);
- b = b->parent)
- b->max_width = UNKNOWN_MAX_WIDTH;
+ }
+ /* invalidate parent min, max widths */
+ if (box->parent->max_width != UNKNOWN_MAX_WIDTH) {
+ struct box *b = box->parent;
+ if (b->min_width < object->width)
+ b->min_width = object->width;
+ if (b->max_width < object->width)
+ b->max_width = object->width;
+ for (b = b->parent; b != 0 &&
+ (b->type == BOX_TABLE_ROW_GROUP ||
+ b->type == BOX_TABLE_ROW ||
+ b->max_width != UNKNOWN_MAX_WIDTH);
+ b = b->parent) {
+ b->max_width = UNKNOWN_MAX_WIDTH;
}
}
if (box->style->height.height == CSS_HEIGHT_AUTO) {
box->style->height.height = CSS_HEIGHT_LENGTH;
box->style->height.length.unit = CSS_UNIT_PX;
box->style->height.length.value = object->height;
+ box->height = object->height;
}
- /* remove alt text */
- if (box->text != 0) {
- free(box->text);
- box->text = 0;
- box->length = 0;
+ /* delete any clones of this box */
+ while (box->next && box->next->clone) {
+ /* box_free_box(box->next); */
+ box->next = box->next->next;
}
- /*if (box->children != 0) {
- box_free(box->children);
- box->children = 0;
- }*/
- /* TODO: recalculate min, max width */
c->active--;
break;
diff --git a/render/layout.c b/render/layout.c
index 9a6785025..73fb14a41 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -354,30 +354,29 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
for (x = 0, b = first; x < x1 - x0 && b != 0; b = b->next) {
assert(b->type == BOX_INLINE || b->type == BOX_FLOAT_LEFT || b->type == BOX_FLOAT_RIGHT);
if (b->type == BOX_INLINE) {
- if (b->text != 0)
+ if (b->object && b->style && b->style->height.height == CSS_HEIGHT_LENGTH)
+ h = len(&b->style->height.length, b->style);
+ else if (b->text)
h = line_height(b->style ? b->style : b->parent->parent->style);
else if (b->gadget != 0)
h = gadget_height(b->gadget);
- else if (b->style != 0 && b->style->height.height == CSS_HEIGHT_LENGTH)
- h = len(&b->style->height.length, b->style);
else
h = 0;
b->height = h;
if (h > height) height = h;
- if (b->width == UNKNOWN_WIDTH) {
- if (b->text != 0)
+ if (b->object && b->style && b->style->width.width == CSS_WIDTH_LENGTH)
+ b->width = len(&b->style->width.value.length, b->style);
+ else if (b->object && b->style && b->style->width.width == CSS_WIDTH_PERCENT)
+ b->width = width * b->style->width.value.percent / 100;
+ else if (b->text) {
+ if (b->width == UNKNOWN_WIDTH)
b->width = font_width(b->font, b->text, b->length);
- else if (b->gadget != 0)
- b->width = gadget_width(b->gadget);
- else if (b->style != 0 && b->style->width.width == CSS_WIDTH_LENGTH)
- b->width = len(&b->style->width.value.length, b->style);
- else if (b->style != 0 && b->style->width.width == CSS_WIDTH_PERCENT)
- b->width = width * b->style->width.value.percent / 100;
- else
- b->width = 0;
- }
+ } else if (b->gadget != 0)
+ b->width = gadget_width(b->gadget);
+ else
+ b->width = 0;
if (b->text != 0)
x += b->width + b->space ? b->font->space_width : 0;
@@ -399,7 +398,9 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
b->x = x;
x += b->width;
space_before = space_after;
- if (b->text != 0)
+ if (b->object)
+ space_after = 0;
+ else if (b->text)
space_after = b->space ? b->font->space_width : 0;
else
space_after = 0;
@@ -461,7 +462,7 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
x = x_previous;
- if (c->text != 0)
+ if (!c->object && c->text)
space = strchr(c->text, ' ');
if (space != 0 && c->length <= (unsigned int) (space - c->text))
/* space after end of string */
@@ -485,6 +486,7 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
c2->text = xstrdup(space + 1);
c2->length = c->length - ((space + 1) - c->text);
c2->width = UNKNOWN_WIDTH;
+ c2->clone = 1;
c->length = space - c->text;
c->width = w;
c->space = 1;
@@ -510,6 +512,7 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
c2->text = xstrdup(space + 1);
c2->length = c->length - ((space + 1) - c->text);
c2->width = UNKNOWN_WIDTH;
+ c2->clone = 1;
c->length = space - c->text;
c->width = w;
c->space = 1;
@@ -852,8 +855,16 @@ void calculate_inline_container_widths(struct box *box)
for (child = box->children; child != 0; child = child->next) {
switch (child->type) {
case BOX_INLINE:
- if (child->text != 0)
- {
+ if (child->object) {
+ if (child->style->width.width == CSS_WIDTH_LENGTH) {
+ child->width = len(&child->style->width.value.length,
+ child->style);
+ max += child->width;
+ if (min < child->width)
+ min = child->width;
+ }
+
+ } else if (child->text) {
/* max = all one line */
child->width = font_width(child->font,
child->text, child->length);
@@ -872,22 +883,13 @@ void calculate_inline_container_widths(struct box *box)
}
width = font_width(child->font, word, strlen(word));
if (min < width) min = width;
- }
- else if (child->gadget != 0)
- {
+
+ } else if (child->gadget) {
child->width = gadget_width(child->gadget);
max += child->width;
if (min < child->width)
min = child->width;
}
- else if (child->style->width.width == CSS_WIDTH_LENGTH)
- {
- child->width = len(&child->style->width.value.length,
- child->style);
- max += child->width;
- if (min < child->width)
- min = child->width;
- }
break;
case BOX_FLOAT_LEFT: