Fix build with QT_NO_CSSPARSER / -no-feature-cssparser

Some parts of the new QTextDocument table border logic depend on the QCss
namespace which is not available with -no-feature-cssparser.

Change-Id: Ib8396894dc35872f22c634e1d6c38968d3dd4756
Reviewed-by: Timo Aarnipuro <timo.aarnipuro@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Nils Jeisecke 2019-10-04 10:47:51 +02:00
parent 0118e2e915
commit 332232682e
2 changed files with 30 additions and 0 deletions

View File

@ -1062,6 +1062,7 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processBlockNode()
fmt.setLeftPadding(leftPadding(currentNodeIdx));
if (rightPadding(currentNodeIdx) >= 0)
fmt.setRightPadding(rightPadding(currentNodeIdx));
#ifndef QT_NO_CSSPARSER
if (tableCellBorder(currentNodeIdx, QCss::TopEdge) > 0)
fmt.setTopBorder(tableCellBorder(currentNodeIdx, QCss::TopEdge));
if (tableCellBorder(currentNodeIdx, QCss::RightEdge) > 0)
@ -1086,6 +1087,7 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processBlockNode()
fmt.setBottomBorderBrush(tableCellBorderBrush(currentNodeIdx, QCss::BottomEdge));
if (tableCellBorderBrush(currentNodeIdx, QCss::LeftEdge) != Qt::NoBrush)
fmt.setLeftBorderBrush(tableCellBorderBrush(currentNodeIdx, QCss::LeftEdge));
#endif
cell.setFormat(fmt);

View File

@ -265,6 +265,9 @@ public:
inline QFixed topPadding(QTextTable *table, const QTextTableCell &cell) const
{
#ifdef QT_NO_CSSPARSER
Q_UNUSED(table);
#endif
return paddingProperty(cell.format(), QTextFormat::TableCellTopPadding)
#ifndef QT_NO_CSSPARSER
+ cellBorderWidth(table, cell, QCss::TopEdge)
@ -274,6 +277,9 @@ public:
inline QFixed bottomPadding(QTextTable *table, const QTextTableCell &cell) const
{
#ifdef QT_NO_CSSPARSER
Q_UNUSED(table);
#endif
return paddingProperty(cell.format(), QTextFormat::TableCellBottomPadding)
#ifndef QT_NO_CSSPARSER
+ cellBorderWidth(table, cell, QCss::BottomEdge)
@ -283,6 +289,9 @@ public:
inline QFixed leftPadding(QTextTable *table, const QTextTableCell &cell) const
{
#ifdef QT_NO_CSSPARSER
Q_UNUSED(table);
#endif
return paddingProperty(cell.format(), QTextFormat::TableCellLeftPadding)
#ifndef QT_NO_CSSPARSER
+ cellBorderWidth(table, cell, QCss::LeftEdge)
@ -292,6 +301,9 @@ public:
inline QFixed rightPadding(QTextTable *table, const QTextTableCell &cell) const
{
#ifdef QT_NO_CSSPARSER
Q_UNUSED(table);
#endif
return paddingProperty(cell.format(), QTextFormat::TableCellRightPadding)
#ifndef QT_NO_CSSPARSER
+ cellBorderWidth(table, cell, QCss::RightEdge)
@ -1034,15 +1046,22 @@ static bool cellClipTest(QTextTable *table, QTextTableData *td,
const QTextTableCell &cell,
QRectF cellRect)
{
#ifdef QT_NO_CSSPARSER
Q_UNUSED(table);
Q_UNUSED(cell);
#endif
if (!cell_context.clip.isValid())
return false;
if (td->borderCollapse) {
// we need to account for the cell borders in the clipping test
#ifndef QT_NO_CSSPARSER
cellRect.adjust(-axisEdgeData(table, td, cell, QCss::LeftEdge).width / 2,
-axisEdgeData(table, td, cell, QCss::TopEdge).width / 2,
axisEdgeData(table, td, cell, QCss::RightEdge).width / 2,
axisEdgeData(table, td, cell, QCss::BottomEdge).width / 2);
#endif
} else {
qreal border = td->border.toReal();
cellRect.adjust(-border, -border, border, border);
@ -1798,6 +1817,13 @@ void QTextDocumentLayoutPrivate::drawTableCellBorder(const QRectF &cellRect, QPa
if (turn_off_antialiasing)
painter->setRenderHint(QPainter::Antialiasing, false);
#else
Q_UNUSED(cell);
Q_UNUSED(cellRect);
Q_UNUSED(painter);
Q_UNUSED(table);
Q_UNUSED(td);
Q_UNUSED(cell);
#endif
}
@ -2285,12 +2311,14 @@ QTextLayoutStruct QTextDocumentLayoutPrivate::layoutCell(QTextTable *t, const QT
+ td->border
+ td->paddingProperty(cell.format(), QTextFormat::TableCellTopPadding); // top cell-border is not repeated
#ifndef QT_NO_CSSPARSER
const int headerRowCount = t->format().headerRowCount();
if (td->borderCollapse && headerRowCount > 0) {
// consider the header row's bottom edge width
qreal headerRowBottomBorderWidth = axisEdgeData(t, td, t->cellAt(headerRowCount - 1, cell.column()), QCss::BottomEdge).width;
layoutStruct.pageTopMargin += QFixed::fromReal(scaleToDevice(headerRowBottomBorderWidth) / 2);
}
#endif
layoutStruct.pageBottomMargin = td->effectiveBottomMargin + td->cellSpacing + td->effectiveBottomBorder + td->bottomPadding(t, cell);
layoutStruct.pageBottom = (currentPage + 1) * layoutStruct.pageHeight - layoutStruct.pageBottomMargin;