More savory tree widget goodness.

This commit is contained in:
hyatt%netscape.com 1999-06-23 09:07:59 +00:00
Родитель c42b0d7fb6
Коммит e1000eaca3
8 изменённых файлов: 154 добавлений и 58 удалений

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

@ -3027,7 +3027,7 @@ nsCSSFrameConstructor::CreateAnonymousXULContent(nsIPresContext* aPresContext,
nsCOMPtr<nsIContent> content = do_QueryInterface(node); nsCOMPtr<nsIContent> content = do_QueryInterface(node);
content->SetParent(aContent); content->SetParent(aContent);
nsCOMPtr<nsIAtom> vertical = dont_AddRef(NS_NewAtom("align")); nsCOMPtr<nsIAtom> vertical = dont_AddRef(NS_NewAtom("align"));
nsCOMPtr<nsIAtom> style = dont_AddRef(NS_NewAtom("style")); nsCOMPtr<nsIAtom> style = dont_AddRef(NS_NewAtom("style"));

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

@ -3027,7 +3027,7 @@ nsCSSFrameConstructor::CreateAnonymousXULContent(nsIPresContext* aPresContext,
nsCOMPtr<nsIContent> content = do_QueryInterface(node); nsCOMPtr<nsIContent> content = do_QueryInterface(node);
content->SetParent(aContent); content->SetParent(aContent);
nsCOMPtr<nsIAtom> vertical = dont_AddRef(NS_NewAtom("align")); nsCOMPtr<nsIAtom> vertical = dont_AddRef(NS_NewAtom("align"));
nsCOMPtr<nsIAtom> style = dont_AddRef(NS_NewAtom("style")); nsCOMPtr<nsIAtom> style = dont_AddRef(NS_NewAtom("style"));

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

@ -4205,8 +4205,8 @@ void nsTableFrame::DistributeSpaceToCells(nsIPresContext& aPresContext,
nsIFrame* aRowGroupFrame) nsIFrame* aRowGroupFrame)
{ {
// now that all of the rows have been resized, resize the cells // now that all of the rows have been resized, resize the cells
nsTableIterator iter2(*aRowGroupFrame, eTableLTR); nsTableRowGroupFrame* rowGroupFrame = (nsTableRowGroupFrame*)aRowGroupFrame;
nsIFrame* rowFrame = iter2.First(); nsIFrame * rowFrame = rowGroupFrame->GetFirstFrame();
while (nsnull!=rowFrame) { while (nsnull!=rowFrame) {
const nsStyleDisplay *rowDisplay; const nsStyleDisplay *rowDisplay;
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay)); rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
@ -4216,7 +4216,7 @@ void nsTableFrame::DistributeSpaceToCells(nsIPresContext& aPresContext,
// The calling function, DistributeSpaceToRows, takes care of the recursive row // The calling function, DistributeSpaceToRows, takes care of the recursive row
// group descent, which is why there's no NS_STYLE_DISPLAY_TABLE_ROW_GROUP case // group descent, which is why there's no NS_STYLE_DISPLAY_TABLE_ROW_GROUP case
// here. // here.
rowFrame = iter2.Next(); rowGroupFrame->GetNextFrame(rowFrame, &rowFrame);
} }
} }
@ -4229,9 +4229,8 @@ void nsTableFrame::DistributeSpaceToRows(nsIPresContext& aPresContext,
{ {
// the rows in rowGroupFrame need to be expanded by rowHeightDelta[i] // the rows in rowGroupFrame need to be expanded by rowHeightDelta[i]
// and the rowgroup itself needs to be expanded by SUM(row height deltas) // and the rowgroup itself needs to be expanded by SUM(row height deltas)
nsIFrame * rowFrame=nsnull; nsTableRowGroupFrame* rowGroupFrame = (nsTableRowGroupFrame*)aRowGroupFrame;
nsTableIterator iter(*aRowGroupFrame, eTableLTR); nsIFrame * rowFrame = rowGroupFrame->GetFirstFrame();
rowFrame = iter.First();
nscoord y = 0; nscoord y = 0;
while (nsnull!=rowFrame) while (nsnull!=rowFrame)
{ {
@ -4247,19 +4246,23 @@ void nsTableFrame::DistributeSpaceToRows(nsIPresContext& aPresContext,
rowFrame->GetRect(rowRect); rowFrame->GetRect(rowRect);
float percent = ((float)(rowRect.height)) / ((float)(aSumOfRowHeights)); float percent = ((float)(rowRect.height)) / ((float)(aSumOfRowHeights));
nscoord excessForRow = NSToCoordRound((float)aExcess*percent); nscoord excessForRow = NSToCoordRound((float)aExcess*percent);
nsRect newRowRect(rowRect.x, y, rowRect.width, excessForRow+rowRect.height);
rowFrame->SetRect(newRowRect); if (rowGroupFrame->RowsDesireExcessSpace()) {
if (NS_STYLE_BORDER_COLLAPSE==aTableStyle->mBorderCollapse) nsRect newRowRect(rowRect.x, y, rowRect.width, excessForRow+rowRect.height);
{ rowFrame->SetRect(newRowRect);
nsBorderEdge *border = (nsBorderEdge *) if (NS_STYLE_BORDER_COLLAPSE==aTableStyle->mBorderCollapse)
(mBorderEdges.mEdges[NS_SIDE_LEFT].ElementAt(((nsTableRowFrame*)rowFrame)->GetRowIndex())); {
border->mLength=newRowRect.height; nsBorderEdge *border = (nsBorderEdge *)
border = (nsBorderEdge *) (mBorderEdges.mEdges[NS_SIDE_LEFT].ElementAt(((nsTableRowFrame*)rowFrame)->GetRowIndex()));
(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(((nsTableRowFrame*)rowFrame)->GetRowIndex())); border->mLength=newRowRect.height;
border->mLength=newRowRect.height; border = (nsBorderEdge *)
(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(((nsTableRowFrame*)rowFrame)->GetRowIndex()));
border->mLength=newRowRect.height;
}
// better if this were part of an overloaded row::SetRect
y += excessForRow+rowRect.height;
} }
// better if this were part of an overloaded row::SetRect
y += excessForRow+rowRect.height;
aExcessForRowGroup += excessForRow; aExcessForRowGroup += excessForRow;
} }
else else
@ -4269,14 +4272,17 @@ void nsTableFrame::DistributeSpaceToRows(nsIPresContext& aPresContext,
y += rowRect.height; y += rowRect.height;
} }
rowFrame = iter.Next(); rowGroupFrame->GetNextFrame(rowFrame, &rowFrame);
} }
nsRect rowGroupRect;
aRowGroupFrame->GetRect(rowGroupRect);
nsRect newRowGroupRect(rowGroupRect.x, aRowGroupYPos, rowGroupRect.width, aExcessForRowGroup+rowGroupRect.height);
aRowGroupFrame->SetRect(newRowGroupRect);
aRowGroupYPos += aExcessForRowGroup + rowGroupRect.height; nsRect rowGroupRect;
aRowGroupFrame->GetRect(rowGroupRect);
if (rowGroupFrame->RowGroupDesiresExcessSpace()) {
nsRect newRowGroupRect(rowGroupRect.x, aRowGroupYPos, rowGroupRect.width, aExcessForRowGroup+rowGroupRect.height);
aRowGroupFrame->SetRect(newRowGroupRect);
aRowGroupYPos += aExcessForRowGroup + rowGroupRect.height;
}
else aRowGroupYPos += rowGroupRect.height;
DistributeSpaceToCells(aPresContext, aReflowState, aRowGroupFrame); DistributeSpaceToCells(aPresContext, aReflowState, aRowGroupFrame);
} }

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

@ -298,10 +298,14 @@ protected:
virtual PRBool ExcludeFrameFromReflow(nsIFrame* aFrame) { return PR_FALSE; }; virtual PRBool ExcludeFrameFromReflow(nsIFrame* aFrame) { return PR_FALSE; };
virtual nsIFrame* GetFirstFrameForReflow(nsIPresContext& aPresContext) { return mFrames.FirstChild(); }; virtual nsIFrame* GetFirstFrameForReflow(nsIPresContext& aPresContext) { return mFrames.FirstChild(); };
virtual void GetNextFrameForReflow(nsIPresContext& aPresContext, nsIFrame* aFrame, nsIFrame** aResult) { aFrame->GetNextSibling(aResult); }; virtual void GetNextFrameForReflow(nsIPresContext& aPresContext, nsIFrame* aFrame, nsIFrame** aResult) { aFrame->GetNextSibling(aResult); };
void GetNextRowSibling(nsIFrame** aRowFrame);
public:
virtual nsIFrame* GetFirstFrame() { return mFrames.FirstChild(); }; virtual nsIFrame* GetFirstFrame() { return mFrames.FirstChild(); };
virtual nsIFrame* GetLastFrame() { return mFrames.LastChild(); }; virtual nsIFrame* GetLastFrame() { return mFrames.LastChild(); };
virtual void GetNextFrame(nsIFrame* aFrame, nsIFrame** aResult) { aFrame->GetNextSibling(aResult); }; virtual void GetNextFrame(nsIFrame* aFrame, nsIFrame** aResult) { aFrame->GetNextSibling(aResult); };
void GetNextRowSibling(nsIFrame** aRowFrame); virtual PRBool RowsDesireExcessSpace() { return PR_TRUE; };
virtual PRBool RowGroupDesiresExcessSpace() { return PR_TRUE; };
private: private:
nsIAtom *mType; nsIAtom *mType;

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

@ -4205,8 +4205,8 @@ void nsTableFrame::DistributeSpaceToCells(nsIPresContext& aPresContext,
nsIFrame* aRowGroupFrame) nsIFrame* aRowGroupFrame)
{ {
// now that all of the rows have been resized, resize the cells // now that all of the rows have been resized, resize the cells
nsTableIterator iter2(*aRowGroupFrame, eTableLTR); nsTableRowGroupFrame* rowGroupFrame = (nsTableRowGroupFrame*)aRowGroupFrame;
nsIFrame* rowFrame = iter2.First(); nsIFrame * rowFrame = rowGroupFrame->GetFirstFrame();
while (nsnull!=rowFrame) { while (nsnull!=rowFrame) {
const nsStyleDisplay *rowDisplay; const nsStyleDisplay *rowDisplay;
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay)); rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
@ -4216,7 +4216,7 @@ void nsTableFrame::DistributeSpaceToCells(nsIPresContext& aPresContext,
// The calling function, DistributeSpaceToRows, takes care of the recursive row // The calling function, DistributeSpaceToRows, takes care of the recursive row
// group descent, which is why there's no NS_STYLE_DISPLAY_TABLE_ROW_GROUP case // group descent, which is why there's no NS_STYLE_DISPLAY_TABLE_ROW_GROUP case
// here. // here.
rowFrame = iter2.Next(); rowGroupFrame->GetNextFrame(rowFrame, &rowFrame);
} }
} }
@ -4229,9 +4229,8 @@ void nsTableFrame::DistributeSpaceToRows(nsIPresContext& aPresContext,
{ {
// the rows in rowGroupFrame need to be expanded by rowHeightDelta[i] // the rows in rowGroupFrame need to be expanded by rowHeightDelta[i]
// and the rowgroup itself needs to be expanded by SUM(row height deltas) // and the rowgroup itself needs to be expanded by SUM(row height deltas)
nsIFrame * rowFrame=nsnull; nsTableRowGroupFrame* rowGroupFrame = (nsTableRowGroupFrame*)aRowGroupFrame;
nsTableIterator iter(*aRowGroupFrame, eTableLTR); nsIFrame * rowFrame = rowGroupFrame->GetFirstFrame();
rowFrame = iter.First();
nscoord y = 0; nscoord y = 0;
while (nsnull!=rowFrame) while (nsnull!=rowFrame)
{ {
@ -4247,19 +4246,23 @@ void nsTableFrame::DistributeSpaceToRows(nsIPresContext& aPresContext,
rowFrame->GetRect(rowRect); rowFrame->GetRect(rowRect);
float percent = ((float)(rowRect.height)) / ((float)(aSumOfRowHeights)); float percent = ((float)(rowRect.height)) / ((float)(aSumOfRowHeights));
nscoord excessForRow = NSToCoordRound((float)aExcess*percent); nscoord excessForRow = NSToCoordRound((float)aExcess*percent);
nsRect newRowRect(rowRect.x, y, rowRect.width, excessForRow+rowRect.height);
rowFrame->SetRect(newRowRect); if (rowGroupFrame->RowsDesireExcessSpace()) {
if (NS_STYLE_BORDER_COLLAPSE==aTableStyle->mBorderCollapse) nsRect newRowRect(rowRect.x, y, rowRect.width, excessForRow+rowRect.height);
{ rowFrame->SetRect(newRowRect);
nsBorderEdge *border = (nsBorderEdge *) if (NS_STYLE_BORDER_COLLAPSE==aTableStyle->mBorderCollapse)
(mBorderEdges.mEdges[NS_SIDE_LEFT].ElementAt(((nsTableRowFrame*)rowFrame)->GetRowIndex())); {
border->mLength=newRowRect.height; nsBorderEdge *border = (nsBorderEdge *)
border = (nsBorderEdge *) (mBorderEdges.mEdges[NS_SIDE_LEFT].ElementAt(((nsTableRowFrame*)rowFrame)->GetRowIndex()));
(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(((nsTableRowFrame*)rowFrame)->GetRowIndex())); border->mLength=newRowRect.height;
border->mLength=newRowRect.height; border = (nsBorderEdge *)
(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(((nsTableRowFrame*)rowFrame)->GetRowIndex()));
border->mLength=newRowRect.height;
}
// better if this were part of an overloaded row::SetRect
y += excessForRow+rowRect.height;
} }
// better if this were part of an overloaded row::SetRect
y += excessForRow+rowRect.height;
aExcessForRowGroup += excessForRow; aExcessForRowGroup += excessForRow;
} }
else else
@ -4269,14 +4272,17 @@ void nsTableFrame::DistributeSpaceToRows(nsIPresContext& aPresContext,
y += rowRect.height; y += rowRect.height;
} }
rowFrame = iter.Next(); rowGroupFrame->GetNextFrame(rowFrame, &rowFrame);
} }
nsRect rowGroupRect;
aRowGroupFrame->GetRect(rowGroupRect);
nsRect newRowGroupRect(rowGroupRect.x, aRowGroupYPos, rowGroupRect.width, aExcessForRowGroup+rowGroupRect.height);
aRowGroupFrame->SetRect(newRowGroupRect);
aRowGroupYPos += aExcessForRowGroup + rowGroupRect.height; nsRect rowGroupRect;
aRowGroupFrame->GetRect(rowGroupRect);
if (rowGroupFrame->RowGroupDesiresExcessSpace()) {
nsRect newRowGroupRect(rowGroupRect.x, aRowGroupYPos, rowGroupRect.width, aExcessForRowGroup+rowGroupRect.height);
aRowGroupFrame->SetRect(newRowGroupRect);
aRowGroupYPos += aExcessForRowGroup + rowGroupRect.height;
}
else aRowGroupYPos += rowGroupRect.height;
DistributeSpaceToCells(aPresContext, aReflowState, aRowGroupFrame); DistributeSpaceToCells(aPresContext, aReflowState, aRowGroupFrame);
} }

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

@ -298,10 +298,14 @@ protected:
virtual PRBool ExcludeFrameFromReflow(nsIFrame* aFrame) { return PR_FALSE; }; virtual PRBool ExcludeFrameFromReflow(nsIFrame* aFrame) { return PR_FALSE; };
virtual nsIFrame* GetFirstFrameForReflow(nsIPresContext& aPresContext) { return mFrames.FirstChild(); }; virtual nsIFrame* GetFirstFrameForReflow(nsIPresContext& aPresContext) { return mFrames.FirstChild(); };
virtual void GetNextFrameForReflow(nsIPresContext& aPresContext, nsIFrame* aFrame, nsIFrame** aResult) { aFrame->GetNextSibling(aResult); }; virtual void GetNextFrameForReflow(nsIPresContext& aPresContext, nsIFrame* aFrame, nsIFrame** aResult) { aFrame->GetNextSibling(aResult); };
void GetNextRowSibling(nsIFrame** aRowFrame);
public:
virtual nsIFrame* GetFirstFrame() { return mFrames.FirstChild(); }; virtual nsIFrame* GetFirstFrame() { return mFrames.FirstChild(); };
virtual nsIFrame* GetLastFrame() { return mFrames.LastChild(); }; virtual nsIFrame* GetLastFrame() { return mFrames.LastChild(); };
virtual void GetNextFrame(nsIFrame* aFrame, nsIFrame** aResult) { aFrame->GetNextSibling(aResult); }; virtual void GetNextFrame(nsIFrame* aFrame, nsIFrame** aResult) { aFrame->GetNextSibling(aResult); };
void GetNextRowSibling(nsIFrame** aRowFrame); virtual PRBool RowsDesireExcessSpace() { return PR_TRUE; };
virtual PRBool RowGroupDesiresExcessSpace() { return PR_TRUE; };
private: private:
nsIAtom *mType; nsIAtom *mType;

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

@ -65,6 +65,74 @@ nsTreeRowGroupFrame::~nsTreeRowGroupFrame()
{ {
} }
PRBool nsTreeRowGroupFrame::RowGroupDesiresExcessSpace()
{
nsIFrame* parentFrame;
GetParent(&parentFrame);
const nsStyleDisplay *display;
parentFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
if (display->mDisplay == NS_STYLE_DISPLAY_TABLE_ROW_GROUP)
return PR_FALSE; // Nested groups don't grow.
else return PR_TRUE; // The outermost group can grow.
}
PRBool nsTreeRowGroupFrame::RowGroupReceivesExcessSpace()
{
const nsStyleDisplay *display;
GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == display->mDisplay)
return PR_TRUE;
else return PR_FALSE; // Headers and footers don't get excess space.
}
NS_IMETHODIMP
nsTreeRowGroupFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame)
{
nsPoint tmp;
nsRect kidRect;
if (mScrollbar) {
mScrollbar->GetRect(kidRect);
if (kidRect.Contains(aPoint)) {
tmp.MoveTo(aPoint.x - kidRect.x, aPoint.y - kidRect.y);
return mScrollbar->GetFrameForPoint(tmp, aFrame);
}
}
return nsTableRowGroupFrame::GetFrameForPoint(aPoint, aFrame);
}
void nsTreeRowGroupFrame::PaintChildren(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
{
nsTableRowGroupFrame::PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
if (mScrollbar) {
nsIView *pView;
mScrollbar->GetView(&pView);
if (nsnull == pView) {
PRBool clipState;
nsRect kidRect;
mScrollbar->GetRect(kidRect);
nsRect damageArea(aDirtyRect);
// Translate damage area into kid's coordinate system
nsRect kidDamageArea(damageArea.x - kidRect.x, damageArea.y - kidRect.y,
damageArea.width, damageArea.height);
aRenderingContext.PushState();
aRenderingContext.Translate(kidRect.x, kidRect.y);
mScrollbar->Paint(aPresContext, aRenderingContext, kidDamageArea, aWhichLayer);
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) &&
GetShowFrameBorders()) {
aRenderingContext.SetColor(NS_RGB(255,0,0));
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
}
aRenderingContext.PopState(clipState);
}
}
}
NS_IMETHODIMP NS_IMETHODIMP
nsTreeRowGroupFrame::ReflowBeforeRowLayout(nsIPresContext& aPresContext, nsTreeRowGroupFrame::ReflowBeforeRowLayout(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize, nsHTMLReflowMetrics& aDesiredSize,

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

@ -41,6 +41,12 @@ public:
NS_IMETHOD TreeInsertFrames(nsIFrame* aPrevFrame, NS_IMETHOD TreeInsertFrames(nsIFrame* aPrevFrame,
nsIFrame* aFrameList); nsIFrame* aFrameList);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame);
void PaintChildren(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
PRBool ContinueReflow(nscoord y, nscoord height); PRBool ContinueReflow(nscoord y, nscoord height);
PRBool IsFull() { return mIsFull; }; PRBool IsFull() { return mIsFull; };
@ -48,12 +54,18 @@ public:
// Responses to changes // Responses to changes
void OnContentAdded(nsIPresContext& aPresContext); void OnContentAdded(nsIPresContext& aPresContext);
virtual nsIFrame* GetFirstFrame();
virtual nsIFrame* GetLastFrame();
virtual void GetNextFrame(nsIFrame* aFrame, nsIFrame** aResult);
virtual PRBool RowsDesireExcessSpace() { return PR_FALSE; };
virtual PRBool RowGroupDesiresExcessSpace();
protected: protected:
nsTreeRowGroupFrame(); nsTreeRowGroupFrame();
virtual ~nsTreeRowGroupFrame(); virtual ~nsTreeRowGroupFrame();
virtual PRBool RowGroupReceivesExcessSpace() { return PR_FALSE; }; virtual PRBool RowGroupReceivesExcessSpace();
NS_IMETHOD ReflowBeforeRowLayout(nsIPresContext& aPresContext, NS_IMETHOD ReflowBeforeRowLayout(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize, nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState, RowGroupReflowState& aReflowState,
@ -63,10 +75,6 @@ protected:
virtual nsIFrame* GetFirstFrameForReflow(nsIPresContext& aPresContext); virtual nsIFrame* GetFirstFrameForReflow(nsIPresContext& aPresContext);
virtual void GetNextFrameForReflow(nsIPresContext& aPresContext, nsIFrame* aFrame, nsIFrame** aResult); virtual void GetNextFrameForReflow(nsIPresContext& aPresContext, nsIFrame* aFrame, nsIFrame** aResult);
virtual nsIFrame* GetFirstFrame();
virtual nsIFrame* GetLastFrame();
virtual void GetNextFrame(nsIFrame* aFrame, nsIFrame** aResult);
void LocateFrame(nsIFrame* aStartFrame, nsIFrame** aResult); void LocateFrame(nsIFrame* aStartFrame, nsIFrame** aResult);
protected: // Data Members protected: // Data Members