Bug 1827009 - Don't assume the textrun has necessarily been created already. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D175108
This commit is contained in:
Jonathan Kew 2023-04-11 15:32:57 +00:00
Родитель 0c01f97c31
Коммит 193a8ba340
1 изменённых файлов: 4 добавлений и 3 удалений

Просмотреть файл

@ -3032,14 +3032,15 @@ nscoord nsLineLayout::GetHangFrom(const PerSpanData* aSpan, bool aLineIsRTL) {
return GetHangFrom(childSpan, aLineIsRTL);
}
if (pfd->mIsTextFrame) {
const auto* lastText = static_cast<const nsTextFrame*>(pfd->mFrame);
auto* lastText = static_cast<nsTextFrame*>(pfd->mFrame);
result = lastText->GetHangableISize();
if (result) {
// If the hangable space will be at the start edge of the line, due to
// its bidi direction being against the line direction, we flag this by
// negating the advance.
if (lastText->GetTextRun(nsTextFrame::eInflated)->IsRightToLeft() !=
aLineIsRTL) {
lastText->EnsureTextRun(nsTextFrame::eInflated);
auto* textRun = lastText->GetTextRun(nsTextFrame::eInflated);
if (textRun && textRun->IsRightToLeft() != aLineIsRTL) {
result = -result;
}
}