summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-03-01 22:14:02 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-03-01 22:14:02 +0000
commitdb69e8045b6bdf8f6fe196928f2f6ea94b57de46 (patch)
tree230766aa82c3756868d1935e2bbd28bfb5a259d3 /render
parent3b366c53f9a94ae5df12f22ca2c9bc78137c3793 (diff)
downloadnetsurf-db69e8045b6bdf8f6fe196928f2f6ea94b57de46.tar.gz
netsurf-db69e8045b6bdf8f6fe196928f2f6ea94b57de46.tar.bz2
When wrapping text, don't duplicate strings. Special case for text inside textareas, since they require it.
svn path=/trunk/netsurf/; revision=11881
Diffstat (limited to 'render')
-rw-r--r--render/layout.c19
1 files changed, 14 insertions, 5 deletions
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;