summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2012-10-03 17:14:11 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2012-10-03 17:14:11 +0100
commit391defb1c4cff592aa228ced1c6278d30ea31030 (patch)
treef45db384fd8668b1e5f1ff7e79c6dcbfc2ca7a38 /render
parentb68a138c2c807559ae584bdb0bb5d392fb1f0870 (diff)
downloadnetsurf-391defb1c4cff592aa228ced1c6278d30ea31030.tar.gz
netsurf-391defb1c4cff592aa228ced1c6278d30ea31030.tar.bz2
Don't convert spaces to non-breaking spaces inside white-space:pre. Instead, handle not wrapping in layout.
Diffstat (limited to 'render')
-rw-r--r--render/box_construct.c14
-rw-r--r--render/layout.c4
2 files changed, 16 insertions, 2 deletions
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;
diff --git a/render/layout.c b/render/layout.c
index ead01acf0..0523cf9db 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -2700,7 +2700,9 @@ bool layout_line(struct box *first, int *width, int *y,
size_t space = 0;
int w;
bool no_wrap = css_computed_white_space(
- split_box->style) == CSS_WHITE_SPACE_NOWRAP;
+ split_box->style) == CSS_WHITE_SPACE_NOWRAP ||
+ css_computed_white_space(
+ split_box->style) == CSS_WHITE_SPACE_PRE;
x = x_previous;