Support empty inline elements in block tags in QTextDocument
This fixes the following case: <blockquote> <span />Foobar </blockquote> Qt would see the end of <span>, and consider the current block tag as closed, thus resetting the block format, thus losing the margin set for the current block (due to blockquote). If you do <blockquote> <span>Foo</span>Foobar </blockquote> instead, then the same would not happen, since hasBlock is set to false when we append text to the current inline node. [ChangeLog][QTextDocument] Add support for empty inline elements in block tags. Task-number: QTBUG-33336 Change-Id: Ic566edfec96cb8d44d1c02932bb195bc921d1580 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
This commit is contained in:
parent
11189af016
commit
35579f6fe7
@ -489,7 +489,7 @@ void QTextHtmlImporter::import()
|
||||
&& currentNode->id != Html_unknown)
|
||||
{
|
||||
hasBlock = false;
|
||||
} else if (hasBlock) {
|
||||
} else if (blockTagClosed && hasBlock) {
|
||||
// when collapsing subsequent block tags we need to clear the block format
|
||||
QTextBlockFormat blockFormat = currentNode->blockFormat;
|
||||
blockFormat.setIndent(indent);
|
||||
|
@ -266,6 +266,7 @@ private slots:
|
||||
void html_metaInBody();
|
||||
void html_importImageWithoutAspectRatio();
|
||||
void html_fromFirefox();
|
||||
void html_emptyInlineInsideBlock();
|
||||
|
||||
private:
|
||||
inline void setHtml(const QString &html)
|
||||
@ -4004,5 +4005,11 @@ void tst_QTextDocumentFragment::html_fromFirefox()
|
||||
QCOMPARE(doc->toPlainText(), QString::fromLatin1("Test Text "));
|
||||
}
|
||||
|
||||
void tst_QTextDocumentFragment::html_emptyInlineInsideBlock()
|
||||
{
|
||||
doc->setHtml(QString::fromLatin1("<!--StartFragment--><blockquote><span/>Foobar</blockquote><!--EndFragment-->"));
|
||||
QVERIFY(doc->firstBlock().blockFormat().leftMargin() > 0);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QTextDocumentFragment)
|
||||
#include "tst_qtextdocumentfragment.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user