From 391defb1c4cff592aa228ced1c6278d30ea31030 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 3 Oct 2012 17:14:11 +0100 Subject: Don't convert spaces to non-breaking spaces inside white-space:pre. Instead, handle not wrapping in layout. --- render/box_construct.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'render/box_construct.c') diff --git a/render/box_construct.c b/render/box_construct.c index 2580b67d9..7732f4445 100644 --- a/render/box_construct.c +++ b/render/box_construct.c @@ -1261,7 +1261,9 @@ bool box_construct_text(struct box_construct_ctx *ctx) } } else { /* white-space: pre */ - char *text = cnv_space2nbsp(dom_string_data(content)); + char *text; + size_t text_len = dom_string_byte_length(content); + size_t i; char *current; enum css_white_space_e white_space = css_computed_white_space(props.parent_style); @@ -1271,11 +1273,20 @@ bool box_construct_text(struct box_construct_ctx *ctx) white_space == CSS_WHITE_SPACE_PRE_LINE || white_space == CSS_WHITE_SPACE_PRE_WRAP); + text = malloc(text_len + 1); dom_string_unref(content); if (text == NULL) return false; + memcpy(text, dom_string_data(content), text_len); + text[text_len] = '\0'; + + /* TODO: Handle tabs properly */ + for (int i = 0; i < text_len; i++) + if (text[i] == '\t') + text[i] = ' '; + if (css_computed_text_transform(props.parent_style) != CSS_TEXT_TRANSFORM_NONE) box_text_transform(text, strlen(text), @@ -1301,6 +1312,7 @@ bool box_construct_text(struct box_construct_ctx *ctx) do { size_t len = strcspn(current, "\r\n"); + char old = current[len]; current[len] = 0; -- cgit v1.2.3