Supplementary patch to bug 120410 fixing bugs exposed by the previous patch - listboxes didn't scroll properly if they were less than one row tall or adjust properly if they were resized r=varga sr=mscott

This commit is contained in:
neil%parkwaycc.co.uk 2004-02-26 22:56:15 +00:00
parent 2ee3043f21
commit 49d7e94122

View File

@ -402,6 +402,15 @@ nsListBoxBodyFrame::PositionChanged(PRInt32 aOldIndex, PRInt32& aNewIndex)
NS_IMETHODIMP
nsListBoxBodyFrame::VisibilityChanged(PRBool aVisible)
{
PRInt32 lastPageTopRow = GetRowCount() - (GetAvailableHeight() / mRowHeight);
if (lastPageTopRow < 0)
lastPageTopRow = 0;
PRInt32 delta = mCurrentIndex - lastPageTopRow;
if (delta > 0) {
mCurrentIndex = lastPageTopRow;
InternalPositionChanged(PR_TRUE, delta, PR_FALSE);
}
return NS_OK;
}
@ -495,6 +504,8 @@ nsListBoxBodyFrame::EnsureIndexIsVisible(PRInt32 aRowIndex)
PRInt32 rows = 0;
if (mRowHeight)
rows = GetAvailableHeight()/mRowHeight;
if (rows <= 0)
rows = 1;
PRInt32 bottomIndex = mCurrentIndex + rows;
// if row is visible, ignore