aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2010-04-07 22:07:07 +0000
committercorvid <corvid@lavabit.com>2010-04-07 22:07:07 +0000
commit7a6266b40e3b340883d1f7fb22c0099a8253cc88 (patch)
treec770fe8c0e8d4fb95bf270409cf855c5ee373fef
parent865148221562ff526c12a0805c0ab5ea5c859b29 (diff)
white-space: pre-line
-rw-r--r--ChangeLog2
-rw-r--r--src/html.cc26
2 files changed, 27 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d999c9fa..3074a16f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,7 +16,7 @@ dillo-2.2.1 [not released yet]
- Use the suffix/subdomain field in cookies.txt.
- Follow most specific matching rule in cookiesrc.
- Fix segfault with form inputs and repush for stylesheets.
- - Handle white-space: pre-wrap.
+ - Handle white-space: pre-wrap and pre-line.
Patches: corvid
+- Implement line-height.
Patch: Johannes Hofmann, corvid
diff --git a/src/html.cc b/src/html.cc
index 9e72c5f2..361f127a 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -1033,6 +1033,29 @@ char *a_Html_parse_entities(DilloHtml *html, const char *token, int toksize)
}
/*
+ * For white-space: pre-line, we must break the line if encountering a newline.
+ * Otherwise, collapse whitespace as usual.
+ */
+static void Html_process_space_pre_line(DilloHtml *html, const char *space,
+ int spacesize)
+{
+ int i, breakCnt = 0;
+
+ for (i = 0; i < spacesize; i++) {
+ /* Support for "\r", "\n" and "\r\n" line breaks */
+ if (space[i] == '\r' || (space[i] == '\n' && !html->PrevWasCR)) {
+ breakCnt++;
+ html->PrevWasCR = (space[i] == '\r');
+
+ HT2TB(html)->addLinebreak (html->styleEngine->wordStyle ());
+ }
+ }
+ if (breakCnt == 0) {
+ HT2TB(html)->addSpace(html->styleEngine->wordStyle ());
+ }
+}
+
+/*
* Parse spaces
*/
static void Html_process_space(DilloHtml *html, const char *space,
@@ -1099,6 +1122,9 @@ static void Html_process_space(DilloHtml *html, const char *space,
} else {
if (SGML_SPCDEL) {
/* SGML_SPCDEL ignores white space immediately after an open tag */
+ } else if (html->styleEngine->wordStyle ()->whiteSpace ==
+ WHITE_SPACE_PRE_LINE) {
+ Html_process_space_pre_line(html, space, spacesize);
} else {
HT2TB(html)->addSpace(html->styleEngine->wordStyle ());
}