QTextDocumentLayout: remove multiple calls to lineHeightType

Get LineHeightType once and reuse the value. There still are 2 calls
to lineHeightType from inside the QTextBlockFormat::lineHeight but
leaving them cause they need a bigger change.

Change-Id: I4016a5e483a0358d43f73d174a74545d4f3be338
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Waqar Ahmed 2021-08-29 22:33:53 +05:00 committed by Waqar Ahmed
parent 643b58a429
commit b21403992e

View File

@ -3415,19 +3415,21 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout
static inline void getLineHeightParams(const QTextBlockFormat &blockFormat, const QTextLine &line, qreal scaling,
QFixed *lineAdjustment, QFixed *lineBreakHeight, QFixed *lineHeight, QFixed *lineBottom)
{
const qreal height = line.height();
const int lineHeightType = blockFormat.lineHeightType();
qreal rawHeight = qCeil(line.ascent() + line.descent() + line.leading());
*lineHeight = QFixed::fromReal(blockFormat.lineHeight(rawHeight, scaling));
*lineBottom = QFixed::fromReal(blockFormat.lineHeight(line.height(), scaling));
*lineBottom = QFixed::fromReal(blockFormat.lineHeight(height, scaling));
if (blockFormat.lineHeightType() == QTextBlockFormat::FixedHeight || blockFormat.lineHeightType() == QTextBlockFormat::MinimumHeight) {
if (lineHeightType == QTextBlockFormat::FixedHeight || lineHeightType == QTextBlockFormat::MinimumHeight) {
*lineBreakHeight = *lineBottom;
if (blockFormat.lineHeightType() == QTextBlockFormat::FixedHeight)
if (lineHeightType == QTextBlockFormat::FixedHeight)
*lineAdjustment = QFixed::fromReal(line.ascent() + qMax(line.leading(), qreal(0.0))) - ((*lineHeight * 4) / 5);
else
*lineAdjustment = QFixed::fromReal(line.height()) - *lineHeight;
*lineAdjustment = QFixed::fromReal(height) - *lineHeight;
}
else {
*lineBreakHeight = QFixed::fromReal(line.height());
*lineBreakHeight = QFixed::fromReal(height);
*lineAdjustment = 0;
}
}