summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-02-28 13:18:27 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-02-28 13:18:27 +0000
commite35aecb9aa4765e1ec9ee0472152befa57eb38cf (patch)
tree673b9a61160d5164903931cd5a67108b0f3eced7 /render
parent6d118815756c1433b6ef815300c2950379d02de7 (diff)
downloadnetsurf-e35aecb9aa4765e1ec9ee0472152befa57eb38cf.tar.gz
netsurf-e35aecb9aa4765e1ec9ee0472152befa57eb38cf.tar.bz2
Optimise wrapped text layout.
svn path=/trunk/netsurf/; revision=11852
Diffstat (limited to 'render')
-rw-r--r--render/layout.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/render/layout.c b/render/layout.c
index f8f7e16ed..32ed2eaef 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -2409,21 +2409,34 @@ bool layout_line(struct box *first, int *width, int *y,
b = split_box->next;
} else {
/* cut off first word for this line */
+ int space_width;
+
+ /* Create clone of split_box, c2 */
c2 = talloc_memdup(content, split_box,
sizeof *c2);
if (!c2)
return false;
+ c2->clone = 1;
+
+ /* Add copy of the split text to c2 */
c2->text = talloc_strndup(content,
split_box->text + space + 1,
split_box->length -(space + 1));
if (!c2->text)
return false;
+
+ /* Set c2 according to the remaining text */
+ font_func->font_width(&fstyle, " ", 1,
+ &space_width);
+ c2->width -= w + space_width;
c2->length = split_box->length - (space + 1);
- c2->width = UNKNOWN_WIDTH;
- c2->clone = 1;
+
+ /* Update split_box for its reduced text */
split_box->length = space;
split_box->width = w;
split_box->space = 1;
+
+ /* Insert c2 into box list */
c2->next = split_box->next;
split_box->next = c2;
c2->prev = split_box;
@@ -2471,21 +2484,34 @@ bool layout_line(struct box *first, int *width, int *y,
if (space == 0)
space = 1;
if (space != split_box->length) {
+ int space_width;
+
+ /* Create clone of split_box, c2 */
c2 = talloc_memdup(content, split_box,
sizeof *c2);
if (!c2)
return false;
+ c2->clone = 1;
+
+ /* Add copy of the split text to c2 */
c2->text = talloc_strndup(content,
split_box->text + space + 1,
split_box->length -(space + 1));
if (!c2->text)
return false;
+
+ /* Set c2 according to the remaining text */
+ font_func->font_width(&fstyle, " ", 1,
+ &space_width);
+ c2->width -= w + space_width;
c2->length = split_box->length - (space + 1);
- c2->width = UNKNOWN_WIDTH;
- c2->clone = 1;
+
+ /* Update split_box for its reduced text */
split_box->length = space;
split_box->width = w;
split_box->space = 1;
+
+ /* Insert c2 into box list */
c2->next = split_box->next;
split_box->next = c2;
c2->prev = split_box;