summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
Diffstat (limited to 'render')
-rw-r--r--render/box.c30
-rw-r--r--render/box.h6
-rw-r--r--render/layout.c32
3 files changed, 38 insertions, 30 deletions
diff --git a/render/box.c b/render/box.c
index 59c7f0f5a..7ee7e712b 100644
--- a/render/box.c
+++ b/render/box.c
@@ -1,5 +1,5 @@
/**
- * $Id: box.c,v 1.16 2002/09/19 19:54:43 bursa Exp $
+ * $Id: box.c,v 1.17 2002/09/26 21:38:32 bursa Exp $
*/
#include <assert.h>
@@ -10,7 +10,7 @@
#include "libxml/HTMLparser.h"
#include "utf-8.h"
#include "netsurf/render/css.h"
-#include "netsurf/render/font.h"
+#include "netsurf/riscos/font.h"
#include "netsurf/render/box.h"
#include "netsurf/render/utils.h"
@@ -25,7 +25,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
struct css_stylesheet * stylesheet,
struct css_selector ** selector, unsigned int depth,
struct box * parent, struct box * inline_container,
- const char *href);
+ const char *href, struct font_set *fonts);
struct css_style * box_get_style(struct css_stylesheet * stylesheet, struct css_style * parent_style,
xmlNode * n, struct css_selector * selector, unsigned int depth);
void box_normalise_block(struct box *block);
@@ -74,6 +74,7 @@ struct box * box_create(xmlNode * node, box_type type, struct css_style * style,
box->float_children = 0;
box->next_float = 0;
box->col = 0;
+ box->font = 0;
return box;
}
@@ -120,10 +121,10 @@ void xml_to_box(xmlNode * n, struct css_style * parent_style,
struct css_stylesheet * stylesheet,
struct css_selector ** selector, unsigned int depth,
struct box * parent, struct box * inline_container,
- const char *href)
+ const char *href, struct font_set *fonts)
{
convert_xml_to_box(n, parent_style, stylesheet,
- selector, depth, parent, inline_container, href);
+ selector, depth, parent, inline_container, href, fonts);
box_normalise_block(parent->children);
}
@@ -132,7 +133,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
struct css_stylesheet * stylesheet,
struct css_selector ** selector, unsigned int depth,
struct box * parent, struct box * inline_container,
- const char *href)
+ const char *href, struct font_set *fonts)
{
struct box * box;
struct box * inline_container_c;
@@ -174,8 +175,9 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
}
if (n->type == XML_TEXT_NODE) {
box = box_create(n, BOX_INLINE, parent_style, href);
- box->text = squash_whitespace(tolat1(n->content));
+ box->text = squash_whitespace(n->content);
box->length = strlen(box->text);
+ box->font = font_open(fonts, box->style);
box_add_child(inline_container, box);
} else {
box = box_create(0, BOX_FLOAT_LEFT, 0, href);
@@ -197,14 +199,14 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
for (c = n->children; c != 0; c = c->next)
inline_container_c = convert_xml_to_box(c, style, stylesheet,
selector, depth + 1, box, inline_container_c,
- href);
+ href, fonts);
inline_container = 0;
break;
case CSS_DISPLAY_INLINE: /* inline elements get no box, but their children do */
for (c = n->children; c != 0; c = c->next)
inline_container = convert_xml_to_box(c, style, stylesheet,
selector, depth + 1, parent, inline_container,
- href);
+ href, fonts);
break;
case CSS_DISPLAY_TABLE:
box = box_create(n, BOX_TABLE, style, href);
@@ -212,7 +214,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
for (c = n->children; c != 0; c = c->next)
convert_xml_to_box(c, style, stylesheet,
selector, depth + 1, box, 0,
- href);
+ href, fonts);
inline_container = 0;
break;
case CSS_DISPLAY_TABLE_ROW_GROUP:
@@ -224,7 +226,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
for (c = n->children; c != 0; c = c->next)
inline_container_c = convert_xml_to_box(c, style, stylesheet,
selector, depth + 1, box, inline_container_c,
- href);
+ href, fonts);
inline_container = 0;
break;
case CSS_DISPLAY_TABLE_ROW:
@@ -233,7 +235,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
for (c = n->children; c != 0; c = c->next)
convert_xml_to_box(c, style, stylesheet,
selector, depth + 1, box, 0,
- href);
+ href, fonts);
inline_container = 0;
break;
case CSS_DISPLAY_TABLE_CELL:
@@ -248,7 +250,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
for (c = n->children; c != 0; c = c->next)
inline_container_c = convert_xml_to_box(c, style, stylesheet,
selector, depth + 1, box, inline_container_c,
- href);
+ href, fonts);
inline_container = 0;
break;
default:
@@ -446,7 +448,7 @@ void box_normalise_table(struct box *table)
case BOX_TABLE_ROW:
case BOX_TABLE_CELL:
/* insert implied table row group */
- fprintf(stderr, "inserting implied table row group\n");
+/* fprintf(stderr, "inserting implied table row group\n"); */
style = xcalloc(1, sizeof(struct css_style));
memcpy(style, table->style, sizeof(struct css_style));
css_cascade(style, &css_blank_style);
diff --git a/render/box.h b/render/box.h
index 5165945b5..3df758a60 100644
--- a/render/box.h
+++ b/render/box.h
@@ -1,5 +1,5 @@
/**
- * $Id: box.h,v 1.10 2002/09/19 19:54:43 bursa Exp $
+ * $Id: box.h,v 1.11 2002/09/26 21:38:33 bursa Exp $
*/
#ifndef _NETSURF_RENDER_BOX_H_
@@ -8,6 +8,7 @@
#include <limits.h>
#include "libxml/HTMLparser.h"
#include "netsurf/render/css.h"
+#include "netsurf/riscos/font.h"
/**
* structures
@@ -43,6 +44,7 @@ struct box {
struct box * float_children;
struct box * next_float;
struct column *col;
+ struct font_data *font;
};
#define UNKNOWN_WIDTH ULONG_MAX
@@ -55,7 +57,7 @@ struct box {
void xml_to_box(xmlNode * n, struct css_style * parent_style, struct css_stylesheet * stylesheet,
struct css_selector ** selector, unsigned int depth,
struct box * parent, struct box * inline_container,
- const char *href);
+ const char *href, struct font_set *fonts);
void box_dump(struct box * box, unsigned int depth);
void box_free(struct box *box);
diff --git a/render/layout.c b/render/layout.c
index f3f25b50b..44baa4cef 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -1,5 +1,5 @@
/**
- * $Id: layout.c,v 1.18 2002/09/19 19:54:43 bursa Exp $
+ * $Id: layout.c,v 1.19 2002/09/26 21:38:33 bursa Exp $
*/
#include <assert.h>
@@ -9,7 +9,7 @@
#include <string.h>
#include "libxml/HTMLparser.h"
#include "netsurf/render/css.h"
-#include "netsurf/render/font.h"
+#include "netsurf/riscos/font.h"
#include "netsurf/render/box.h"
#include "netsurf/render/utils.h"
#include "netsurf/render/layout.h"
@@ -308,7 +308,7 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
b->height = h;
if (h > height) height = h;
if (b->width == UNKNOWN_WIDTH)
- b->width = font_width(b->style, b->text, b->length);
+ b->width = font_width(b->font, b->text, b->length);
x += b->width;
}
}
@@ -369,7 +369,7 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
if (space == 0)
wp = w = c->width;
else
- wp = w = font_width(c->style, c->text, space - c->text);
+ wp = w = font_width(c->font, c->text, space - c->text);
if (x1 - x0 < xp + w && left == 0 && right == 0 && c == first) {
/* first word doesn't fit, but no floats and first on line so force in */
@@ -385,6 +385,8 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
c->next = c2;
b = c2;
}
+ c->width = wp;
+ x = xp + wp;
/* fprintf(stderr, "layout_line: overflow, forcing\n"); */
} else if (x1 - x0 < xp + w) {
/* first word doesn't fit, but full width not available so leave for later */
@@ -393,13 +395,15 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
} else {
/* fit as many words as possible */
assert(space != 0);
- while (xp + w < x1 - x0) {
+ while (xp + w < x1 - x0 && space2 != 0) {
/* fprintf(stderr, "%li + %li = %li < %li = %li - %li\n", */
/* xp, w, xp + w, x1 - x0, x1, x0); */
space = space2;
wp = w;
space2 = strchr(space + 1, ' ');
- w = font_width(c->style, c->text, space2 - c->text);
+ if (space2 == 0)
+ space2 = c->text + c->length;
+ w = font_width(c->font, c->text, space2 - c->text);
}
c2 = memcpy(xcalloc(1, sizeof(struct box)), c, sizeof(struct box));
c2->text = xstrdup(space + 1);
@@ -409,10 +413,10 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
c2->next = c->next;
c->next = c2;
b = c2;
+ c->width = wp;
+ x = xp + wp;
/* fprintf(stderr, "layout_line: overflow, fit\n"); */
}
- c->width = wp;
- x = xp + wp;
move_y = 1;
}
@@ -509,7 +513,7 @@ void layout_table(struct box * table, unsigned long width, struct box * cont,
break;
}
- fprintf(stderr, "table width %lu, min %lu, max %lu\n", table_width, table->min_width, table->max_width);
+/* fprintf(stderr, "table width %lu, min %lu, max %lu\n", table_width, table->min_width, table->max_width); */
/* percentage width columns give an upper bound if possible */
for (i = 0; i < table->columns; i++) {
@@ -537,7 +541,7 @@ void layout_table(struct box * table, unsigned long width, struct box * cont,
/* space between min and max: fill it exactly */
float scale = (float) (table_width - table->min_width) /
(float) (max_width - table->min_width);
- fprintf(stderr, "filling, scale %f\n", scale);
+/* fprintf(stderr, "filling, scale %f\n", scale); */
for (i = 0; i < table->columns; i++) {
table->col[i].width = table->col[i].min +
(table->col[i].max - table->col[i].min) * scale;
@@ -651,7 +655,7 @@ void calculate_inline_container_widths(struct box *box)
switch (child->type) {
case BOX_INLINE:
/* max = all one line */
- child->width = font_width(child->style,
+ child->width = font_width(child->font,
child->text, child->length);
max += child->width;
@@ -659,10 +663,10 @@ void calculate_inline_container_widths(struct box *box)
for (word = child->text, space = strchr(child->text, ' ');
space != 0;
word = space + 1, space = strchr(word, ' ')) {
- width = font_width(child->style, word, space - word);
+ width = font_width(child->font, word, space - word);
if (min < width) min = width;
}
- width = font_width(child->style, word, strlen(word));
+ width = font_width(child->font, word, strlen(word));
if (min < width) min = width;
break;
@@ -741,7 +745,7 @@ void calculate_table_widths(struct box *table)
for (i = 0; i < table->columns; i++) {
min_width += col[i].min;
max_width += col[i].max;
- fprintf(stderr, "col %u, min %lu, max %lu\n", i, col[i].min, col[i].max);
+/* fprintf(stderr, "col %u, min %lu, max %lu\n", i, col[i].min, col[i].max); */
}
table->min_width = min_width;
table->max_width = max_width;