Revert "QTextLayout: fix maximumWidth() for a text containing line separator"

This reverts commit 013c346a8dcbd618febb07884c64c740daf9754d. It was
determined to cause a regression in Qt Quick: QTBUG-106899.

In order to unblock integrations, we need to revert the change. It
can be re-committed later when the problem has been analyzed and
addressed.

Fixes: QTBUG-106899
Task-number: QTBUG-89557
Task-number: QTBUG-104986
Change-Id: I04054587f68ab39fdb038b02fc69ebfa3dc7d197
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit ce4c26c8d16fbc9fdafd8325b8a0b32bacd8cd93)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2022-09-23 10:31:32 +02:00 committed by Qt Cherry-pick Bot
parent f34693408f
commit 034b500f09
4 changed files with 1 additions and 40 deletions

View File

@ -2603,7 +2603,6 @@ QTextEngine::LayoutData::LayoutData()
hasBidi = false;
layoutState = LayoutEmpty;
haveCharAttributes = false;
previousLineManuallyWrapped = false;
logClustersPtr = nullptr;
available_glyphs = 0;
}
@ -2638,7 +2637,6 @@ QTextEngine::LayoutData::LayoutData(const QString &str, void **stack_memory, int
hasBidi = false;
layoutState = LayoutEmpty;
haveCharAttributes = false;
previousLineManuallyWrapped = false;
}
QTextEngine::LayoutData::~LayoutData()
@ -2724,7 +2722,6 @@ void QTextEngine::freeMemory()
layoutData->hasBidi = false;
layoutData->layoutState = LayoutEmpty;
layoutData->haveCharAttributes = false;
layoutData->previousLineManuallyWrapped = false;
layoutData->items.clear();
}
if (specialData)

View File

@ -385,7 +385,6 @@ public:
uint layoutState : 2;
uint memory_on_stack : 1;
uint haveCharAttributes : 1;
uint previousLineManuallyWrapped : 1;
QString string;
bool reallocate(int totalGlyphs);
};

View File

@ -1808,7 +1808,6 @@ void QTextLine::layout_helper(int maxGlyphs)
lbh.logClusters = eng->layoutData->logClustersPtr;
lbh.previousGlyph = 0;
bool manuallyWrapped = false;
bool hasInlineObject = false;
QFixed maxInlineObjectHeight = 0;
@ -1884,7 +1883,6 @@ void QTextLine::layout_helper(int maxGlyphs)
lbh.calculateRightBearingForPreviousGlyph();
}
line += lbh.tmpData;
manuallyWrapped = true;
goto found;
} else if (current.analysis.flags == QScriptAnalysis::Object) {
lbh.whiteSpaceOrObject = true;
@ -2107,9 +2105,6 @@ found:
eng->maxWidth = qMax(eng->maxWidth, line.textWidth);
} else {
eng->minWidth = qMax(eng->minWidth, lbh.minw);
if (eng->layoutData->previousLineManuallyWrapped)
eng->maxWidth = qMax(eng->maxWidth, line.textWidth);
else
eng->maxWidth += line.textWidth;
}
@ -2124,8 +2119,6 @@ found:
line.justified = false;
line.gridfitted = false;
eng->layoutData->previousLineManuallyWrapped = manuallyWrapped;
}
/*!

View File

@ -125,7 +125,6 @@ private slots:
void softHyphens_data();
void softHyphens();
void min_maximumWidth();
void min_maximumWidthWithLineSeparator();
private:
QFont testFont;
@ -2684,32 +2683,5 @@ void tst_QTextLayout::min_maximumWidth()
}
}
void tst_QTextLayout::min_maximumWidthWithLineSeparator()
{
QTextLayout referenceLayout("text", testFont);
QString multilineText("text\ntext\ntext");
multilineText.replace('\n', QChar::LineSeparator);
QTextLayout layout(multilineText, testFont);
for (int wrapMode = QTextOption::NoWrap; wrapMode <= QTextOption::WrapAtWordBoundaryOrAnywhere; ++wrapMode) {
QTextOption opt;
opt.setWrapMode((QTextOption::WrapMode)wrapMode);
referenceLayout.setTextOption(opt);
referenceLayout.beginLayout();
while (referenceLayout.createLine().isValid()) { }
referenceLayout.endLayout();
layout.setTextOption(opt);
layout.beginLayout();
while (layout.createLine().isValid()) { }
layout.endLayout();
QCOMPARE(layout.minimumWidth(), referenceLayout.minimumWidth());
QCOMPARE(layout.maximumWidth(), referenceLayout.maximumWidth());
}
}
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"