diff --git a/src/apps/haiku-depot/textview/ParagraphLayout.cpp b/src/apps/haiku-depot/textview/ParagraphLayout.cpp index 1b0992abf6..4d49ba6432 100644 --- a/src/apps/haiku-depot/textview/ParagraphLayout.cpp +++ b/src/apps/haiku-depot/textview/ParagraphLayout.cpp @@ -342,11 +342,7 @@ ParagraphLayout::GetLineBounds(int32 lineIndex, float& x1, float& y1, _ValidateLayout(); if (fGlyphInfos.CountItems() == 0) { - x1 = 0.0f; - y1 = 0.0f; - x2 = 0.0f; - y2 = 0.0f; - + _GetEmptyLayoutBounds(x1, y1, x2, y2); return; } @@ -381,11 +377,7 @@ ParagraphLayout::GetTextBounds(int32 textOffset, float& x1, float& y1, _ValidateLayout(); if (fGlyphInfos.CountItems() == 0) { - x1 = 0.0f; - y1 = 0.0f; - x2 = 0.0f; - y2 = 0.0f; - + _GetEmptyLayoutBounds(x1, y1, x2, y2); return; } @@ -948,3 +940,28 @@ ParagraphLayout::_DrawSpan(BView* view, BPoint offset, view->DrawString(span.Text(), offset, &delta); } + + +void +ParagraphLayout::_GetEmptyLayoutBounds(float& x1, float& y1, float& x2, + float& y2) const +{ + if (fLineInfos.CountItems() == 0) { + x1 = 0.0f; + y1 = 0.0f; + x2 = 0.0f; + y2 = 0.0f; + + return; + } + + // If the paragraph had at least a single empty TextSpan, the layout + // can compute some meaningful bounds. + const Bullet& bullet = fParagraphStyle.Bullet(); + x1 = fParagraphStyle.LineInset() + fParagraphStyle.FirstLineInset() + + bullet.Spacing(); + x2 = x1; + const LineInfo& lineInfo = fLineInfos.ItemAt(0); + y1 = lineInfo.y; + y2 = lineInfo.y + lineInfo.height; +} diff --git a/src/apps/haiku-depot/textview/ParagraphLayout.h b/src/apps/haiku-depot/textview/ParagraphLayout.h index 99bf5b76c6..4cc46df80c 100644 --- a/src/apps/haiku-depot/textview/ParagraphLayout.h +++ b/src/apps/haiku-depot/textview/ParagraphLayout.h @@ -231,6 +231,9 @@ private: const TextSpan& span, int32 textOffset) const; + void _GetEmptyLayoutBounds(float& x1, float& y1, + float& x2, float& y2) const; + private: TextSpanList fTextSpans; ParagraphStyle fParagraphStyle;