From db69e8045b6bdf8f6fe196928f2f6ea94b57de46 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 1 Mar 2011 22:14:02 +0000 Subject: When wrapping text, don't duplicate strings. Special case for text inside textareas, since they require it. svn path=/trunk/netsurf/; revision=11881 --- render/layout.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'render') diff --git a/render/layout.c b/render/layout.c index c42de276c..568a4da8b 100644 --- a/render/layout.c +++ b/render/layout.c @@ -1922,6 +1922,7 @@ static bool layout_text_box_split(struct content *content, 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); } @@ -1933,11 +1934,19 @@ static bool layout_text_box_split(struct content *content, return false; c2->clone = 1; - /* Add copy of the split text to c2 */ - c2->text = talloc_strndup(content, split_box->text + new_length + 1, - split_box->length - (new_length + 1)); - if (!c2->text) - return false; + /* Set remaining text in c2 */ + if (split_box->parent->parent->gadget != NULL) { + /* Inside a form text input / textarea, special case */ + /* TODO: Move text inputs to core textarea widget and remove + * this */ + c2->text = talloc_strndup(content, + split_box->text + new_length + 1, + split_box->length - (new_length + 1)); + if (!c2->text) + return false; + } else { + c2->text += new_length + 1; + } /* Set c2 according to the remaining text */ c2->width -= new_width + space_width; -- cgit v1.2.3