Support background-color CSS styling on <hr/>
[ChangeLog][QtGui][CSS] The background-color style can now be applied to <hr/> to set the rule color. Task-number: QTBUG-74342 Change-Id: Ib960ce4d38caa225f258b6d228fb794cef43e1b7 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
f83a3c4b6e
commit
5c436365f5
@ -1,6 +1,8 @@
|
||||
<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>QTextEdit Example</title><style type="text/css">
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><title>QTextEdit Example</title><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
|
||||
hr { height: 1px; border-width: 0; }
|
||||
</style></head><body style=" font-family:'Helvetica'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<h1 align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:20pt; font-weight:600;">QTextEdit</span></h1>
|
||||
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">The QTextEdit widget is an advanced editor that supports formatted rich text. It can be used to display HTML and other rich document formats. Internally, QTextEdit uses the QTextDocument class to describe both the high-level structure of each document and the low-level formatting of paragraphs.</span></p>
|
||||
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">If you are viewing this document in the <span style=" font-style:italic;">textedit</span> example, you can edit this document to explore Qt's rich text editing features. We have included some comments in each of the following sections to encourage you to experiment. </p>
|
||||
@ -27,6 +29,9 @@ p, li { white-space: pre-wrap; }
|
||||
<h2 style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Images</span></h2>
|
||||
<p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"><span style=" font-size:11pt; font-weight:400;">Inline images are treated like ordinary ranges of characters in the text editor, so they flow with the surrounding text. Images can also be selected in the same way as text, making it easy to cut, copy, and paste them. </span></p>
|
||||
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><img src=":/images/logo32.png" /><span style=" font-style:italic;"> Try to select this image by clicking and dragging over it with the mouse, or use the text cursor to select it by holding down Shift and using the arrow keys. You can then cut or copy it, and paste it into different parts of this document.</span></p>
|
||||
<h2 align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt; font-weight:600;">Horizontal Rule</span></h2>
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Here is an example:</p>
|
||||
<hr width="50%" style=" background-color:green;"/>
|
||||
<h2 align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Tables</span></h2>
|
||||
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"><span style=" font-size:11pt; font-weight:400;">QTextEdit can arrange and format tables, supporting features such as row and column spans, text formatting within cells, and size constraints for columns. </span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
|
||||
|
@ -2359,6 +2359,7 @@ QString QTextHtmlExporter::toHtml(ExportMode mode)
|
||||
html += QString::fromLatin1("<title>") + title + QString::fromLatin1("</title>");
|
||||
html += QLatin1String("<style type=\"text/css\">\n");
|
||||
html += QLatin1String("p, li { white-space: pre-wrap; }\n");
|
||||
html += QLatin1String("hr { height: 1px; border-width: 0; }\n");
|
||||
html += QLatin1String("</style>");
|
||||
html += QLatin1String("</head><body");
|
||||
|
||||
@ -3047,8 +3048,15 @@ void QTextHtmlExporter::emitBlock(const QTextBlock &block)
|
||||
QTextLength width = blockFormat.lengthProperty(QTextFormat::BlockTrailingHorizontalRulerWidth);
|
||||
if (width.type() != QTextLength::VariableLength)
|
||||
emitTextLength("width", width);
|
||||
else
|
||||
html += QLatin1Char(' ');
|
||||
html += QLatin1Char(' ');
|
||||
|
||||
if (blockFormat.hasProperty(QTextFormat::BackgroundBrush)) {
|
||||
html += QLatin1String("style=\"");
|
||||
html += QLatin1String("background-color:");
|
||||
html += colorValue(qvariant_cast<QBrush>(blockFormat.property(QTextFormat::BackgroundBrush)).color());
|
||||
html += QLatin1Char(';');
|
||||
html += QLatin1Char('\"');
|
||||
}
|
||||
|
||||
html += QLatin1String("/>");
|
||||
return;
|
||||
|
@ -2044,7 +2044,9 @@ void QTextDocumentLayoutPrivate::drawBlock(const QPointF &offset, QPainter *pain
|
||||
rect.setRight((fd->size.width - fd->rightMargin).toReal());
|
||||
}
|
||||
|
||||
fillBackground(painter, rect, bg, r.topLeft());
|
||||
// in the case of <hr>, the background-color CSS style fills only the rule's thickness instead of the whole line
|
||||
if (!blockFormat.hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth))
|
||||
fillBackground(painter, rect, bg, r.topLeft());
|
||||
}
|
||||
|
||||
QList<QTextLayout::FormatRange> selections;
|
||||
@ -2104,7 +2106,10 @@ void QTextDocumentLayoutPrivate::drawBlock(const QPointF &offset, QPainter *pain
|
||||
|
||||
if (blockFormat.hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)) {
|
||||
const qreal width = blockFormat.lengthProperty(QTextFormat::BlockTrailingHorizontalRulerWidth).value(r.width());
|
||||
painter->setPen(context.palette.color(QPalette::Dark));
|
||||
const auto color = blockFormat.hasProperty(QTextFormat::BackgroundBrush)
|
||||
? qvariant_cast<QBrush>(blockFormat.property(QTextFormat::BackgroundBrush)).color()
|
||||
: context.palette.color(QPalette::Dark);
|
||||
painter->setPen(color);
|
||||
qreal y = r.bottom();
|
||||
if (bl.length() == 1)
|
||||
y = r.top() + r.height() / 2;
|
||||
|
@ -1453,6 +1453,8 @@ void QTextHtmlParserNode::applyCssDeclarations(const QList<QCss::Declaration> &d
|
||||
applyBackgroundImage(bgImage, resourceProvider);
|
||||
} else if (bgBrush.style() != Qt::NoBrush) {
|
||||
charFormat.setBackground(bgBrush);
|
||||
if (id == Html_hr)
|
||||
blockFormat.setProperty(QTextFormat::BackgroundBrush, bgBrush);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -289,6 +289,7 @@ void tst_QTextDocument::init()
|
||||
"\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"hr { height: 1px; border-width: 0; }\n"
|
||||
"</style></head>"
|
||||
"<body style=\" font-family:'%1'; font-size:%2; font-weight:%3; font-style:%4;\">\n");
|
||||
htmlHead = htmlHead.arg(defaultFont.family())
|
||||
@ -1501,7 +1502,19 @@ void tst_QTextDocument::toHtml_data()
|
||||
QTest::newRow("horizontal-ruler-with-width") << QTextDocumentFragment::fromHtml("<hr width=\"50%\"/>")
|
||||
<<
|
||||
QString("EMPTYBLOCK") +
|
||||
QString("<hr width=\"50%\"/>");
|
||||
QString("<hr width=\"50%\" />");
|
||||
}
|
||||
{
|
||||
QTest::newRow("horizontal-ruler-with-color") << QTextDocumentFragment::fromHtml("<hr style=\"background-color:green;\"/>")
|
||||
<<
|
||||
QString("EMPTYBLOCK") +
|
||||
QString("<hr style=\"background-color:#008000;\"/>");
|
||||
}
|
||||
{
|
||||
QTest::newRow("horizontal-ruler-with-width-and-color") << QTextDocumentFragment::fromHtml("<hr width=\"50%\" style=\"background-color:green;\"/>")
|
||||
<<
|
||||
QString("EMPTYBLOCK") +
|
||||
QString("<hr width=\"50%\" style=\"background-color:#008000;\"/>");
|
||||
}
|
||||
{
|
||||
CREATE_DOC_AND_CURSOR();
|
||||
@ -1904,20 +1917,12 @@ void tst_QTextDocument::toHtmlBodyBgColor()
|
||||
fmt.setBackground(QColor("#0000ff"));
|
||||
doc.rootFrame()->setFrameFormat(fmt);
|
||||
|
||||
QString expectedHtml("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" "
|
||||
"\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"</style></head>"
|
||||
"<body style=\" font-family:'%1'; font-size:%2; font-weight:%3; font-style:%4;\""
|
||||
" bgcolor=\"#0000ff\">\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>"
|
||||
"</body></html>");
|
||||
QString expectedHtml = htmlHead;
|
||||
expectedHtml.insert(htmlHead.length() - 2, " bgcolor=\"#0000ff\"");
|
||||
expectedHtml += "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>"
|
||||
+ htmlTail;
|
||||
|
||||
expectedHtml = expectedHtml.arg(defaultFont.family())
|
||||
.arg(cssFontSizeString(defaultFont))
|
||||
.arg(defaultFont.weight())
|
||||
.arg((defaultFont.italic() ? "italic" : "normal"));
|
||||
writeActualAndExpected(QTest::currentDataTag(), doc.toHtml(), expectedHtml);
|
||||
|
||||
QCOMPARE(doc.toHtml(), expectedHtml);
|
||||
}
|
||||
@ -1932,20 +1937,12 @@ void tst_QTextDocument::toHtmlBodyBgColorRgba()
|
||||
fmt.setBackground(QColor(255, 0, 0, 51));
|
||||
doc.rootFrame()->setFrameFormat(fmt);
|
||||
|
||||
QString expectedHtml("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" "
|
||||
"\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"</style></head>"
|
||||
"<body style=\" font-family:'%1'; font-size:%2; font-weight:%3; font-style:%4;\""
|
||||
" bgcolor=\"rgba(255,0,0,0.2)\">\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>"
|
||||
"</body></html>");
|
||||
QString expectedHtml = htmlHead;
|
||||
expectedHtml.insert(htmlHead.length() - 2, " bgcolor=\"rgba(255,0,0,0.2)\"");
|
||||
expectedHtml += "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>"
|
||||
+ htmlTail;
|
||||
|
||||
expectedHtml = expectedHtml.arg(defaultFont.family())
|
||||
.arg(cssFontSizeString(defaultFont))
|
||||
.arg(defaultFont.weight())
|
||||
.arg((defaultFont.italic() ? "italic" : "normal"));
|
||||
writeActualAndExpected(QTest::currentDataTag(), doc.toHtml(), expectedHtml);
|
||||
|
||||
QCOMPARE(doc.toHtml(), expectedHtml);
|
||||
}
|
||||
@ -1960,20 +1957,12 @@ void tst_QTextDocument::toHtmlBodyBgColorTransparent()
|
||||
fmt.setBackground(QColor(255, 0, 0, 0));
|
||||
doc.rootFrame()->setFrameFormat(fmt);
|
||||
|
||||
QString expectedHtml("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" "
|
||||
"\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"</style></head>"
|
||||
"<body style=\" font-family:'%1'; font-size:%2; font-weight:%3; font-style:%4;\""
|
||||
" bgcolor=\"transparent\">\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>"
|
||||
"</body></html>");
|
||||
QString expectedHtml = htmlHead;
|
||||
expectedHtml.insert(htmlHead.length() - 2, " bgcolor=\"transparent\"");
|
||||
expectedHtml += "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>"
|
||||
+ htmlTail;
|
||||
|
||||
expectedHtml = expectedHtml.arg(defaultFont.family())
|
||||
.arg(cssFontSizeString(defaultFont))
|
||||
.arg(defaultFont.weight())
|
||||
.arg((defaultFont.italic() ? "italic" : "normal"));
|
||||
writeActualAndExpected(QTest::currentDataTag(), doc.toHtml(), expectedHtml);
|
||||
|
||||
QCOMPARE(doc.toHtml(), expectedHtml);
|
||||
}
|
||||
@ -2034,21 +2023,13 @@ void tst_QTextDocument::toHtmlDefaultFontSpacingProperties()
|
||||
fnt.setWordSpacing(15);
|
||||
doc.setDefaultFont(fnt);
|
||||
|
||||
QString expectedOutput = QString("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" "
|
||||
"\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html><head><meta name=\"qrichtext\" content=\"1\" />"
|
||||
"<meta charset=\"utf-8\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"</style></head>"
|
||||
"<body style=\" font-family:'%1'; font-size:%2; "
|
||||
"font-weight:%3; font-style:%4; letter-spacing:13px; "
|
||||
"word-spacing:15px;\">\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>"
|
||||
"</body></html>");
|
||||
expectedOutput = expectedOutput.arg(defaultFont.family())
|
||||
.arg(cssFontSizeString(defaultFont))
|
||||
.arg(defaultFont.weight())
|
||||
.arg((defaultFont.italic() ? "italic" : "normal"));
|
||||
QString expectedOutput = htmlHead;
|
||||
expectedOutput.insert(htmlHead.length() - 3, " letter-spacing:13px; word-spacing:15px;");
|
||||
expectedOutput +=
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>"
|
||||
+ htmlTail;
|
||||
|
||||
writeActualAndExpected(QTest::currentTestFunction(), doc.toHtml(), expectedOutput);
|
||||
|
||||
QCOMPARE(doc.toHtml(), expectedOutput);
|
||||
}
|
||||
@ -2062,23 +2043,13 @@ void tst_QTextDocument::toHtmlTextDecorationUnderline()
|
||||
fnt.setUnderline(true);
|
||||
doc.setDefaultFont(fnt);
|
||||
|
||||
QString expectedOutput =
|
||||
QString("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" "
|
||||
"\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html><head><meta name=\"qrichtext\" content=\"1\" />"
|
||||
"<meta charset=\"utf-8\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"</style></head>"
|
||||
"<body style=\" font-family:'%1'; font-size:%2; "
|
||||
"font-weight:%3; font-style:%4; text-decoration: underline;\">\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
|
||||
"margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Some text</p>"
|
||||
"</body></html>");
|
||||
QString expectedOutput = htmlHead;
|
||||
expectedOutput.insert(htmlHead.length() - 3, " text-decoration: underline;");
|
||||
expectedOutput +=
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Some text</p>"
|
||||
+ htmlTail;
|
||||
|
||||
expectedOutput = expectedOutput.arg(doc.defaultFont().family())
|
||||
.arg(cssFontSizeString(doc.defaultFont()))
|
||||
.arg(doc.defaultFont().weight())
|
||||
.arg((doc.defaultFont().italic() ? "italic" : "normal"));
|
||||
writeActualAndExpected("toHtmlTextDecorationUnderline1", doc.toHtml(), expectedOutput);
|
||||
|
||||
QCOMPARE(doc.toHtml(), expectedOutput);
|
||||
|
||||
@ -2087,26 +2058,17 @@ void tst_QTextDocument::toHtmlTextDecorationUnderline()
|
||||
cursor.select(QTextCursor::Document);
|
||||
cursor.mergeCharFormat(format);
|
||||
|
||||
QString expectedOutput2 =
|
||||
QString("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" "
|
||||
"\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html><head><meta name=\"qrichtext\" content=\"1\" />"
|
||||
"<meta charset=\"utf-8\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"</style></head>"
|
||||
"<body style=\" font-family:'%1'; font-size:%2; "
|
||||
"font-weight:%3; font-style:%4; text-decoration: underline;\">\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
|
||||
"margin-right:0px; -qt-block-indent:0; text-indent:0px;\">"
|
||||
"<span style=\" text-decoration:none;\">Some text</span></p>"
|
||||
"</body></html>");
|
||||
expectedOutput = htmlHead;
|
||||
expectedOutput.insert(htmlHead.length() - 3, " text-decoration: underline;");
|
||||
expectedOutput +=
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
|
||||
"margin-right:0px; -qt-block-indent:0; text-indent:0px;\">"
|
||||
"<span style=\" text-decoration:none;\">Some text</span></p>"
|
||||
+ htmlTail;
|
||||
|
||||
expectedOutput2 = expectedOutput2.arg(doc.defaultFont().family())
|
||||
.arg(cssFontSizeString(doc.defaultFont()))
|
||||
.arg(doc.defaultFont().weight())
|
||||
.arg((doc.defaultFont().italic() ? "italic" : "normal"));
|
||||
writeActualAndExpected("toHtmlTextDecorationUnderline2", doc.toHtml(), expectedOutput);
|
||||
|
||||
QCOMPARE(doc.toHtml(), expectedOutput2);
|
||||
QCOMPARE(doc.toHtml(), expectedOutput);
|
||||
}
|
||||
|
||||
void tst_QTextDocument::capitalizationHtmlInExport()
|
||||
@ -2985,21 +2947,11 @@ const QString backgroundImage_html("<body><table><tr><td background=\"foo.png\">
|
||||
|
||||
void tst_QTextDocument::backgroundImage_checkExpectedHtml(const QTextDocument &doc)
|
||||
{
|
||||
QString expectedHtml("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" "
|
||||
"\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"</style></head>"
|
||||
"<body style=\" font-family:'%1'; font-size:%2; font-weight:%3; font-style:%4;\">\n"
|
||||
QString expectedHtml = htmlHead +
|
||||
"<table border=\"0\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;\" cellspacing=\"2\" cellpadding=\"0\">"
|
||||
"\n<tr>\n<td background=\"foo.png\">"
|
||||
"\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Blah</p>"
|
||||
"</td></tr></table></body></html>");
|
||||
|
||||
expectedHtml = expectedHtml.arg(defaultFont.family())
|
||||
.arg(cssFontSizeString(defaultFont))
|
||||
.arg(defaultFont.weight())
|
||||
.arg((defaultFont.italic() ? "italic" : "normal"));
|
||||
"</td></tr></table>" + htmlTail;
|
||||
|
||||
writeActualAndExpected(QTest::currentTestFunction(), doc.toHtml(), expectedHtml);
|
||||
|
||||
|
@ -3499,6 +3499,12 @@ void tst_QTextDocumentFragment::html_hr()
|
||||
doc->setHtml("<hr />");
|
||||
QCOMPARE(doc->blockCount(), 1);
|
||||
QVERIFY(doc->begin().blockFormat().hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth));
|
||||
doc->setHtml("<hr style=\"background-color:green;\"/>");
|
||||
QCOMPARE(doc->blockCount(), 1);
|
||||
QVERIFY(doc->begin().blockFormat().hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth));
|
||||
QVERIFY(doc->begin().blockFormat().hasProperty(QTextFormat::BackgroundBrush));
|
||||
const auto brush = qvariant_cast<QBrush>(doc->begin().blockFormat().property(QTextFormat::BackgroundBrush));
|
||||
QCOMPARE(brush.color(), QColor("green"));
|
||||
}
|
||||
|
||||
void tst_QTextDocumentFragment::html_hrMargins()
|
||||
|
Loading…
x
Reference in New Issue
Block a user