summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/text/qtextdocumentfragment
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-05-03 12:21:23 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-05-08 09:28:02 +0200
commitf94b0e1dd999a6bb8dfa4471fd63c395fc8e2302 (patch)
treec6de2a617f11fc01fea962e78820cf3a291894ba /tests/auto/gui/text/qtextdocumentfragment
parente3141d5507ba9276a5f154415e013fd66875c390 (diff)
Allow background inheritance between non-body block elements
Most nested block elements are merged together, so while we shouldn't do real inheritance we need to do it when block elements are combined. Pick-to: 6.1 Fixes: QTBUG-91236 Change-Id: I9e37b15f705db92c79a620d0d772f25d0ee72b8d Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'tests/auto/gui/text/qtextdocumentfragment')
-rw-r--r--tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
index 49d0f42be6..c0c52b5c04 100644
--- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
+++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
@@ -142,6 +142,7 @@ private slots:
void html_doNotInheritBackground();
void html_inheritBackgroundToInlineElements();
void html_doNotInheritBackgroundFromBlockElements();
+ void html_inheritBackgroundFromBlockElements();
void html_nobr();
void fromPlainText();
void fromPlainText2();
@@ -2070,7 +2071,7 @@ void tst_QTextDocumentFragment::html_inheritBackgroundToInlineElements()
void tst_QTextDocumentFragment::html_doNotInheritBackgroundFromBlockElements()
{
- const char html[] = "<p style=\"background: blue\"><span>Foo</span></span>";
+ const char html[] = "<p style=\"background: blue\"><span>Foo</span></p>";
doc->setHtml(html);
int fragmentCount = 0;
@@ -2088,6 +2089,31 @@ void tst_QTextDocumentFragment::html_doNotInheritBackgroundFromBlockElements()
QCOMPARE(fragmentCount, 1);
}
+
+void tst_QTextDocumentFragment::html_inheritBackgroundFromBlockElements()
+{
+ const char html[] = "<div style=\"background: blue\"><p>Foo</p><p>Bar</p></div>";
+ doc->setHtml(html);
+
+ int fragmentCount = 0;
+
+ QTextBlock block = doc->begin();
+ for (QTextBlock::Iterator it = block.begin();
+ !it.atEnd(); ++it, ++fragmentCount) {
+
+ const QTextFragment fragment = it.fragment();
+ if (fragmentCount == 0) {
+ QCOMPARE(fragment.text(), QString("Foo"));
+ QVERIFY(fragment.charFormat().hasProperty(QTextFormat::BackgroundBrush));
+ } else {
+ QCOMPARE(fragment.text(), QString("Bar"));
+ QVERIFY(fragment.charFormat().hasProperty(QTextFormat::BackgroundBrush));
+ }
+ }
+
+ QCOMPARE(fragmentCount, 1);
+}
+
void tst_QTextDocumentFragment::html_nobr()
{
const QString input = "Blah Foo Bar";