summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2013-10-09 20:59:45 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-11 12:05:59 +0200
commit6f6546613774a48fe12f13f796ed7115dfe49a27 (patch)
tree2f5f764382e181797d48592a02cd0706b51abd90 /tests
parentc16dbfbdded43de3536695938e0ccb1c8376a80d (diff)
Ensure CSS rules are inherited from the parent tags
When CSS was set in the head tag then it was not being inherited by the child tags. This ensures that the inhertiance happens and that the deeper the CSS is set then it will ensure that it has precedence over the ones set on the parent. A test is added that shows the standard inheritance from the head tag and the precedence from child tags in effect too. Task-number: QTBUG-28770 Change-Id: I30be3ec141b2cd8d6e0db8a92669aed34da93b33 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index 85d4ef7635..10e79065ee 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -185,7 +185,7 @@ private slots:
void htmlExportImportBlockCount();
void QTBUG27354_spaceAndSoftSpace();
-
+ void cssInheritance();
private:
void backgroundImage_checkExpectedHtml(const QTextDocument &doc);
@@ -2925,5 +2925,34 @@ void tst_QTextDocument::QTBUG27354_spaceAndSoftSpace()
}
}
+void tst_QTextDocument::cssInheritance()
+{
+ {
+ QTextDocument td;
+ td.setHtml("<html><head><style type=\"text/css\">body { line-height: 200% }</style></head><body>"
+ "<p>Foo</p><p>Bar</p><p>Baz</p></body></html>");
+ QTextBlock block = td.begin();
+ while (block.isValid()) {
+ QTextBlockFormat fmt = block.blockFormat();
+ QVERIFY(fmt.lineHeightType() == QTextBlockFormat::ProportionalHeight);
+ QVERIFY(fmt.lineHeight() == 200);
+ block = block.next();
+ }
+ }
+ {
+ QTextDocument td;
+ td.setHtml("<html><head><style type=\"text/css\">body { line-height: 200% } p { line-height: 300% }</style></head><body>"
+ "<p style=\"line-height: 40px\">Foo</p><p>Bar</p><p>Baz</p></body></html>");
+ QTextBlock block = td.begin();
+ QTextBlockFormat fmt = block.blockFormat();
+ QVERIFY(fmt.lineHeightType() == QTextBlockFormat::FixedHeight);
+ QVERIFY(fmt.lineHeight() == 40);
+ block = block.next();
+ fmt = block.blockFormat();
+ QVERIFY(fmt.lineHeightType() == QTextBlockFormat::ProportionalHeight);
+ QVERIFY(fmt.lineHeight() == 300);
+ }
+}
+
QTEST_MAIN(tst_QTextDocument)
#include "tst_qtextdocument.moc"