Make sure to not have our columns extending under the right-hand scrollbar.

Bug 306990, patch by Nate Nielsen <nielsen@memberwebs.com>, r=jan, r+sr=roc
This commit is contained in:
bzbarsky%mit.edu 2005-10-06 18:18:12 +00:00
Родитель 3672441dd3
Коммит 57c1459ccd
2 изменённых файлов: 56 добавлений и 15 удалений

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

@ -1348,7 +1348,8 @@ nsTreeBodyFrame::GetCellAt(nscoord aX, nscoord aY, PRInt32* aRow,
// Determine the column hit.
for (nsTreeColumn* currCol = mColumns->GetFirstColumn(); currCol;
currCol = currCol->GetNext()) {
nsRect cellRect(currCol->GetX(), mInnerBox.y+mRowHeight*(*aRow-mTopRowIndex), currCol->GetWidth(), mRowHeight);
nsRect cellRect;
CalcColumnRect(cellRect, currCol, mInnerBox.y+mRowHeight*(*aRow-mTopRowIndex), mRowHeight);
if (!OffsetForHorzScroll(cellRect, PR_TRUE))
continue;
@ -1969,22 +1970,25 @@ void nsTreeBodyFrame::CalcInnerBox()
nscoord
nsTreeBodyFrame::CalcHorzWidth()
{
// If no horz scrolling periphery is present, then just
// return the width of the main box
if (!EnsureScrollable(PR_TRUE)) {
CalcInnerBox();
return mInnerBox.width;
}
nscoord width = 0;
nscoord height;
// We calculate this from the scrollable view, so that it
// properly covers all contingencies of what could be
// scrollable (columns, body, etc...)
nscoord height;
nscoord width;
if (NS_FAILED (mColScrollView->GetContainerSize(&width, &height)))
width = 0;
if (EnsureScrollable(PR_TRUE)) {
if (NS_FAILED (mColScrollView->GetContainerSize(&width, &height)))
width = 0;
}
// If no horz scrolling periphery is present, then just
// return the width of the main box
if (width == 0) {
CalcInnerBox();
width = mInnerBox.width;
}
return width;
}
@ -2249,7 +2253,8 @@ nsTreeBodyFrame::Paint(nsPresContext* aPresContext,
currCol = currCol->GetNext()) {
// Don't paint hidden columns.
if (currCol->GetWidth()) {
nsRect colRect(currCol->GetX(), mInnerBox.y, currCol->GetWidth(), mInnerBox.height);
nsRect colRect;
CalcColumnRect(colRect, currCol, mInnerBox.y, mInnerBox.height);
if (OffsetForHorzScroll(colRect, PR_FALSE)) {
nsRect dirtyRect;
if (dirtyRect.IntersectRect(aDirtyRect, colRect)) {
@ -2386,7 +2391,8 @@ nsTreeBodyFrame::PaintRow(PRInt32 aRowIndex,
nsTreeColumn* primaryCol = mColumns->GetPrimaryColumn();
if (primaryCol) {
// Paint the primary cell.
nsRect cellRect(primaryCol->GetX(), rowRect.y, primaryCol->GetWidth(), rowRect.height);
nsRect cellRect;
CalcColumnRect(cellRect, primaryCol, rowRect.y, rowRect.height);
if (OffsetForHorzScroll(cellRect, PR_FALSE)) {
nsRect dirtyRect;
if (dirtyRect.IntersectRect(aDirtyRect, cellRect))
@ -2427,7 +2433,8 @@ nsTreeBodyFrame::PaintRow(PRInt32 aRowIndex,
currCol = currCol->GetNext()) {
// Don't paint cells in hidden columns.
if (currCol->GetWidth()) {
nsRect cellRect(currCol->GetX(), rowRect.y, currCol->GetWidth(), rowRect.height);
nsRect cellRect;
CalcColumnRect(cellRect, currCol, rowRect.y, rowRect.height);
if (OffsetForHorzScroll(cellRect, PR_FALSE)) {
nsRect dirtyRect;
nscoord dummy;
@ -3655,6 +3662,36 @@ nsTreeBodyFrame::ClearStyleAndImageCaches()
return NS_OK;
}
void
nsTreeBodyFrame::CalcColumnRect(nsRect& rect, nsTreeColumn* aCol, nscoord y, nscoord height)
{
rect.x = aCol->GetX();
rect.y = y;
rect.width = aCol->GetWidth();
rect.height = height;
if (aCol->GetNext())
return;
// The treecolpicker and scrollbar:
// - Might not be the same width (usually)
// - Either one or the other may be visible.
//
// The uptake of this is the width of the last column doesn't necessarily
// match the width of the last treecol element. We adjust for that here.
if (!EnsureScrollable(PR_TRUE))
return;
nsRect bounds = mColScrollView->View()->GetBounds();
if (bounds.width == 0)
return;
nscoord diff = bounds.width - mInnerBox.width;
if (diff > 0)
rect.width = PR_MAX(0, rect.width - diff);
}
PRBool
nsTreeBodyFrame::OffsetForHorzScroll(nsRect& rect, PRBool clip)
{

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

@ -290,6 +290,10 @@ protected:
// after projecting both onto the horizontal coordinate axis.
PRBool OffsetForHorzScroll(nsRect& rect, PRBool clip);
// Fills in rect with column args and x/width coords. Does some extra
// calculations for the last column
void CalcColumnRect(nsRect& rect, nsTreeColumn* aCol, nscoord y, nscoord height);
PRBool CanAutoScroll(PRInt32 aRowIndex);
// Calc the row and above/below/on status given where the mouse currently is hovering.