Ensuring that content doesn't get drawn OVER the tree widget's scrollbars.

This commit is contained in:
hyatt%netscape.com 2000-01-10 08:49:55 +00:00
Родитель cd9410aa59
Коммит 0f4a9d48e0
2 изменённых файлов: 46 добавлений и 11 удалений

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

@ -986,6 +986,15 @@ nsTreeRowGroupFrame::ReflowBeforeRowLayout(nsIPresContext* aPresContext,
nsresult rv = NS_OK; nsresult rv = NS_OK;
mRowGroupHeight = aReflowState.availSize.height; mRowGroupHeight = aReflowState.availSize.height;
mRowGroupWidth = aReflowState.availSize.width;
// Lose the width of the scrollbar if we've got one.
if (mScrollbar) {
nsRect rect;
mScrollbar->GetRect(rect);
aReflowState.availSize.width -= rect.width;
}
return rv; return rv;
} }
@ -998,8 +1007,9 @@ nsTreeRowGroupFrame::ReflowAfterRowLayout(nsIPresContext* aPresContext,
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
mRowCount = 0; PRInt32 count = 0;
ComputeTotalRowCount(mRowCount, mContent); // XXX This sucks! Needs to be cheap! ComputeTotalRowCount(count, mContent); // XXX This sucks! Needs to be cheap!
// Our page size is the # of rows instantiated. // Our page size is the # of rows instantiated.
PRInt32 pageRowCount; PRInt32 pageRowCount;
GetRowCount(pageRowCount); GetRowCount(pageRowCount);
@ -1011,7 +1021,7 @@ nsTreeRowGroupFrame::ReflowAfterRowLayout(nsIPresContext* aPresContext,
nsCOMPtr<nsIContent> scrollbarContent; nsCOMPtr<nsIContent> scrollbarContent;
mScrollbar->GetContent(getter_AddRefs(scrollbarContent)); mScrollbar->GetContent(getter_AddRefs(scrollbarContent));
if (mRowCount <= pageRowCount) { if (count < pageRowCount) {
// first set the position to 0 so that all visible content // first set the position to 0 so that all visible content
// scrolls into view // scrolls into view
value.Append(0); value.Append(0);
@ -1040,20 +1050,31 @@ nsTreeRowGroupFrame::ReflowAfterRowLayout(nsIPresContext* aPresContext,
mFrameConstructor->RemoveMappingsForFrameSubtree(aPresContext, mScrollbar, nsnull); mFrameConstructor->RemoveMappingsForFrameSubtree(aPresContext, mScrollbar, nsnull);
mScrollbarList.DestroyFrames(aPresContext); mScrollbarList.DestroyFrames(aPresContext);
mScrollbar = nsnull; mScrollbar = nsnull;
// Dirty the tree for another reflow.
nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(this, tableFrame);
MarkTreeAsDirty(aPresContext, (nsTreeFrame*)tableFrame);
} }
} }
if (mShouldHaveScrollbar && (mRowGroupHeight != NS_UNCONSTRAINEDSIZE) && if (mShouldHaveScrollbar && (mRowGroupHeight != NS_UNCONSTRAINEDSIZE) &&
(mIsFull || mScrollbar)) { (mIsFull || mScrollbar)) {
PRBool createdScrollbar = PR_FALSE;
// Ensure the scrollbar has been created. // Ensure the scrollbar has been created.
if (!mScrollbar) if (!mScrollbar) {
CreateScrollbar(aPresContext); CreateScrollbar(aPresContext);
createdScrollbar = PR_TRUE;
}
// Set the maxpos of the scrollbar. // Set the maxpos of the scrollbar.
nsCOMPtr<nsIContent> scrollbarContent; nsCOMPtr<nsIContent> scrollbarContent;
mScrollbar->GetContent(getter_AddRefs(scrollbarContent)); mScrollbar->GetContent(getter_AddRefs(scrollbarContent));
PRInt32 rowCount = mRowCount-1; PRInt32 rowCount = count-1;
if (rowCount < 0) if (rowCount < 0)
rowCount = 0; rowCount = 0;
@ -1100,17 +1121,30 @@ nsTreeRowGroupFrame::ReflowAfterRowLayout(nsIPresContext* aPresContext,
nscoord xpos = 0; nscoord xpos = 0;
// Lose the width of the scrollbar as far as the rows are concerned.
if (aReflowState.availSize.width != NS_UNCONSTRAINEDSIZE) { if (aReflowState.availSize.width != NS_UNCONSTRAINEDSIZE) {
xpos = aReflowState.availSize.width - desiredSize.width; xpos = aReflowState.availSize.width;
/*aReflowState.availSize.width -= desiredSize.width;
if (aReflowState.availSize.width < 0) if (mRowGroupWidth == aReflowState.availSize.width) {
aReflowState.availSize.width = 0;*/ // Never had a scrollbar before. Move it over.
xpos -= desiredSize.width;
}
} }
// Place the child // Place the child
FinishReflowChild(mScrollbar, aPresContext, desiredSize, xpos, 0, 0); FinishReflowChild(mScrollbar, aPresContext, desiredSize, xpos, 0, 0);
if (createdScrollbar) {
// Let another reflow happen.
// Dirty the tree for another reflow.
nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(this, tableFrame);
MarkTreeAsDirty(aPresContext, (nsTreeFrame*)tableFrame);
}
} }
mRowCount = count;
return rv; return rv;
} }

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

@ -215,6 +215,7 @@ protected: // Data Members
nsCSSFrameConstructor* mFrameConstructor; // We don't own this. (No addref/release allowed, punk.) nsCSSFrameConstructor* mFrameConstructor; // We don't own this. (No addref/release allowed, punk.)
nscoord mRowGroupHeight; // The height of the row group. nscoord mRowGroupHeight; // The height of the row group.
nscoord mRowGroupWidth; // The width of the row group.
PRInt32 mCurrentIndex; // Our current scrolled index. PRInt32 mCurrentIndex; // Our current scrolled index.
PRInt32 mRowCount; // The current number of visible rows. PRInt32 mRowCount; // The current number of visible rows.