summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocumentfragment.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-03-26 12:48:36 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-08-12 17:24:05 +0100
commitd45908e24292a41ff7838366b34be7340bf9fda5 (patch)
tree8ff13569a5946137794f3ec3f6eadacf1407556e /src/gui/text/qtextdocumentfragment.cpp
parenta1609d1603bfaeaa54f691f994c458a6a27e5229 (diff)
Support missing white-space:pre-line CSS
A mode that only preserves new lines. Change-Id: I612347b181c6e6c41dfae0cf60b22a662cba1b7e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/text/qtextdocumentfragment.cpp')
-rw-r--r--src/gui/text/qtextdocumentfragment.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp
index 1905d9a1b10..8ad1300e6cf 100644
--- a/src/gui/text/qtextdocumentfragment.cpp
+++ b/src/gui/text/qtextdocumentfragment.cpp
@@ -576,6 +576,9 @@ bool QTextHtmlImporter::appendNodeText()
&& ch != QChar::Nbsp
&& ch != QChar::ParagraphSeparator) {
+ if (wsm == QTextHtmlParserNode::WhiteSpacePreLine && (ch == QLatin1Char('\n') || ch == QLatin1Char('\r')))
+ compressNextWhitespace = PreserveWhiteSpace;
+
if (compressNextWhitespace == CollapseWhiteSpace)
compressNextWhitespace = RemoveWhiteSpace; // allow this one, and remove the ones coming next.
else if(compressNextWhitespace == RemoveWhiteSpace)
@@ -592,7 +595,9 @@ bool QTextHtmlImporter::appendNodeText()
}
} else if (wsm != QTextHtmlParserNode::WhiteSpacePreWrap) {
compressNextWhitespace = RemoveWhiteSpace;
- if (wsm == QTextHtmlParserNode::WhiteSpaceNoWrap)
+ if (wsm == QTextHtmlParserNode::WhiteSpacePreLine && (ch == QLatin1Char('\n') || ch == QLatin1Char('\r')))
+ { }
+ else if (wsm == QTextHtmlParserNode::WhiteSpaceNoWrap)
ch = QChar::Nbsp;
else
ch = QLatin1Char(' ');
@@ -605,6 +610,8 @@ bool QTextHtmlImporter::appendNodeText()
|| ch == QChar::ParagraphSeparator) {
if (!textToInsert.isEmpty()) {
+ if (wsm == QTextHtmlParserNode::WhiteSpacePreLine && textToInsert.at(textToInsert.length() - 1) == QChar(' '))
+ textToInsert = textToInsert.chopped(1);
cursor.insertText(textToInsert, format);
textToInsert.clear();
}