ParagraphLayout: Bugfixes.

* Fixed off-by-one errors in FirstOffsetOnLine() and LastOffsetOnLine().
 * Fixed GetLineBounds() not returning anything y2 and overwriting y1.
This commit is contained in:
Stephan Aßmus 2014-01-20 00:03:16 +01:00
parent 9fff2ecb3f
commit e809325835

View File

@ -314,7 +314,7 @@ ParagraphLayout::FirstOffsetOnLine(int32 lineIndex)
if (lineIndex < 0)
lineIndex = 0;
if (lineIndex > fLineInfos.CountItems())
if (lineIndex >= fLineInfos.CountItems())
lineIndex = fLineInfos.CountItems() - 1;
return fLineInfos.ItemAt(lineIndex).textOffset;
@ -352,7 +352,7 @@ ParagraphLayout::GetLineBounds(int32 lineIndex, float& x1, float& y1,
if (lineIndex < 0)
lineIndex = 0;
if (lineIndex > fLineInfos.CountItems())
if (lineIndex >= fLineInfos.CountItems())
lineIndex = fLineInfos.CountItems() - 1;
const LineInfo& lineInfo = fLineInfos.ItemAt(lineIndex);
@ -370,7 +370,7 @@ ParagraphLayout::GetLineBounds(int32 lineIndex, float& x1, float& y1,
x1 = firstInfo.x;
y1 = lineInfo.y;
x2 = lastInfo.x + lastInfo.width;
y1 = lineInfo.y + lineInfo.height;
y2 = lineInfo.y + lineInfo.height;
}