summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-03-05 22:55:52 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-03-05 22:55:52 +0000
commit8c8ef2268d3a921565d7a2f28ab633c604823c09 (patch)
tree5a7fbf91c049ec705fc9891c5fa66d92c36be045 /render
parent9be22ab5908a50fef1f53c366fd68204a15f939c (diff)
downloadnetsurf-8c8ef2268d3a921565d7a2f28ab633c604823c09.tar.gz
netsurf-8c8ef2268d3a921565d7a2f28ab633c604823c09.tar.bz2
Ensure box has appropriate space before cloning.
svn path=/trunk/netsurf/; revision=11921
Diffstat (limited to 'render')
-rw-r--r--render/layout.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/render/layout.c b/render/layout.c
index 1c0d68111..d6e47257b 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -1918,15 +1918,22 @@ static bool layout_text_box_split(struct content *content,
plot_font_style_t *fstyle, struct box *split_box,
size_t new_length, int new_width)
{
- int space_width;
+ int space_width = split_box->space;
struct box *c2;
const struct font_functions *font_func = content->data.html.font_func;
- /* Find the width of a space, using fstyle, if currently unknown */
- if (split_box->space == 0 || split_box->space == UNKNOWN_WIDTH) {
- font_func->font_width(fstyle, " ", 1, &split_box->space);
+ if (space_width == 0) {
+ /* Currently split_box has no space. */
+ /* Get the space width because the split_box will need it */
+ /* Don't set it in split_box yet, or it will get cloned. */
+ font_func->font_width(fstyle, " ", 1, &space_width);
+ } else if (space_width == UNKNOWN_WIDTH) {
+ /* Split_box has a space but its width is unknown. */
+ /* Get the space width because the split_box will need it */
+ /* Set it in split_box, so it gets cloned. */
+ font_func->font_width(fstyle, " ", 1, &space_width);
+ split_box->space = space_width;
}
- space_width = split_box->space;
/* Create clone of split_box, c2 */
c2 = talloc_memdup(content, split_box, sizeof *c2);
@@ -1954,9 +1961,10 @@ static bool layout_text_box_split(struct content *content,
c2->length = split_box->length - (new_length + 1);
/* Update split_box for its reduced text */
- split_box->length = new_length;
split_box->width = new_width;
split_box->flags |= MEASURED;
+ split_box->length = new_length;
+ split_box->space = space_width;
/* Insert c2 into box list */
c2->next = split_box->next;