summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2017-04-10 11:05:51 +0200
committerDavid Faure <david.faure@kdab.com>2017-04-10 09:44:01 +0000
commitc0ecfc08e3bfb8d93136a859808bf713c56b68e3 (patch)
tree466a478a6b23524a60136e9eb04196ab9a618172 /src/gui/text
parent45862976b7566d416aff887b74eb60cb039a3dd6 (diff)
QTextDocument: improve import of DIV tags
<div>1<br/></div>2 was inserting two newlines between 1 and 2, while all tested web browsers only insert one newline - as long as there is nothing between the <br/> and the </div>. This was the cause for extra newlines being inserted in KMail when replying to HTML emails, such as those generated by gmail. Change-Id: I5145d977701e68913264357bba22780e7cdd3f7d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qtextdocumentfragment.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp
index 3a78296c57..ea37695f4e 100644
--- a/src/gui/text/qtextdocumentfragment.cpp
+++ b/src/gui/text/qtextdocumentfragment.cpp
@@ -825,9 +825,13 @@ bool QTextHtmlImporter::closeTag()
break;
case Html_div:
- if (closedNode->children.isEmpty())
- break;
- Q_FALLTHROUGH();
+ if (cursor.position() > 0) {
+ const QChar curChar = cursor.document()->characterAt(cursor.position() - 1);
+ if (!closedNode->children.isEmpty() && curChar != QChar::LineSeparator) {
+ blockTagClosed = true;
+ }
+ }
+ break;
default:
if (closedNode->isBlock())
blockTagClosed = true;