зеркало из https://github.com/mozilla/pjs.git
Work-in-progress for splitting of table row frames
This commit is contained in:
Родитель
2e1488cb9a
Коммит
ae329c5c12
|
@ -434,6 +434,15 @@ nsTableCellFrame::CreateContinuingFrame(nsIPresContext& aPresContext,
|
|||
cf->Init(aPresContext, mContent, aParent, aStyleContext);
|
||||
cf->AppendToFlow(this);
|
||||
aContinuingFrame = cf;
|
||||
|
||||
// Create a continuing body frame
|
||||
nsIFrame* childList;
|
||||
nsIStyleContext* kidSC;
|
||||
|
||||
mFirstChild->GetStyleContext(kidSC);
|
||||
mFirstChild->CreateContinuingFrame(aPresContext, cf, kidSC, childList);
|
||||
NS_RELEASE(kidSC);
|
||||
cf->SetInitialChildList(aPresContext, nsnull, childList);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -483,6 +483,7 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
|
|||
RowReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
if (nsnull == mFirstChild)
|
||||
return NS_OK;
|
||||
|
||||
|
@ -555,13 +556,21 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
|
|||
// If the available width is the same as last time we reflowed the cell,
|
||||
// then just use the previous desired size and max element size.
|
||||
// if we need the max-element-size we don't need to reflow.
|
||||
// we just grab it from the cell frame which remembers it (see the else clause below)
|
||||
if (availWidth != ((nsTableCellFrame *)kidFrame)->GetPriorAvailWidth())
|
||||
// we just grab it from the cell frame which remembers it (see the else clause below).
|
||||
// Note: we can't do that optimization if our height is constrained
|
||||
if ((aReflowState.reflowState.maxSize.height != NS_UNCONSTRAINEDSIZE) ||
|
||||
(availWidth != ((nsTableCellFrame *)kidFrame)->GetPriorAvailWidth()))
|
||||
{
|
||||
// XXX TROY
|
||||
#if 0
|
||||
// Always let the cell be as high as it wants. We ignore the height that's
|
||||
// passed in and always place the entire row. Let the row group decide
|
||||
// whether we fit or wehther the entire row is pushed
|
||||
nsSize kidAvailSize(availWidth, NS_UNCONSTRAINEDSIZE);
|
||||
#else
|
||||
// Reflow the cell to fit the available height
|
||||
nsSize kidAvailSize(availWidth, aReflowState.reflowState.maxSize.height);
|
||||
#endif
|
||||
|
||||
// Reflow the child
|
||||
nsHTMLReflowState kidReflowState(aPresContext, kidFrame,
|
||||
|
@ -578,7 +587,15 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
|
|||
desiredSize.width, availWidth);
|
||||
}
|
||||
#endif
|
||||
// XXX TROY
|
||||
#if 0
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected reflow status");
|
||||
#else
|
||||
// If any of the cells are not complete, then we're not complete
|
||||
if (NS_FRAME_IS_NOT_COMPLETE(status)) {
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gsDebug)
|
||||
{
|
||||
|
@ -646,7 +663,8 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
|
|||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
if (PR_TRUE==gsDebug) printf("\nRow: Resize Reflow of unknown frame %p of type %d with reason=%d\n",
|
||||
kidFrame, kidDisplay->mDisplay, eReflowReason_Resize);
|
||||
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus);
|
||||
nsReflowStatus status;
|
||||
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, status);
|
||||
}
|
||||
|
||||
// Get the next child
|
||||
|
@ -1363,6 +1381,7 @@ nsTableRowFrame::Reflow(nsIPresContext& aPresContext,
|
|||
rv = InitialReflow(aPresContext, aDesiredSize, state, aStatus, nsnull, PR_TRUE);
|
||||
GetMinRowSpan(tableFrame);
|
||||
FixMinCellHeight(tableFrame);
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
break;
|
||||
|
||||
case eReflowReason_Resize:
|
||||
|
@ -1374,7 +1393,10 @@ nsTableRowFrame::Reflow(nsIPresContext& aPresContext,
|
|||
break;
|
||||
}
|
||||
|
||||
// XXX TROY
|
||||
#if 0
|
||||
aStatus = NS_FRAME_COMPLETE; // we're never continued
|
||||
#endif
|
||||
|
||||
if (gsDebug==PR_TRUE)
|
||||
{
|
||||
|
@ -1398,10 +1420,42 @@ nsTableRowFrame::CreateContinuingFrame(nsIPresContext& aPresContext,
|
|||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aContinuingFrame)
|
||||
{
|
||||
// Because rows are always complete we should never be asked to create
|
||||
// a continuing frame
|
||||
NS_ERROR("Unexpected request");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsTableRowFrame* cf = new nsTableRowFrame;
|
||||
if (nsnull == cf) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
cf->Init(aPresContext, mContent, aParent, aStyleContext);
|
||||
cf->AppendToFlow(this);
|
||||
|
||||
// Create a continuing frame for each table cell
|
||||
nsIFrame* newChildList;
|
||||
for (nsIFrame* kidFrame = mFirstChild;
|
||||
nsnull != kidFrame;
|
||||
kidFrame->GetNextSibling(kidFrame)) {
|
||||
|
||||
const nsStyleDisplay *kidDisplay;
|
||||
kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)kidDisplay));
|
||||
if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay) {
|
||||
nsIFrame* contCellFrame;
|
||||
nsIStyleContext* kidSC;
|
||||
|
||||
// Create a continuing cell frame
|
||||
kidFrame->GetStyleContext(kidSC);
|
||||
kidFrame->CreateContinuingFrame(aPresContext, cf, kidSC, contCellFrame);
|
||||
NS_RELEASE(kidSC);
|
||||
|
||||
// Link it into the list of child frames
|
||||
if (nsnull == cf->mFirstChild) {
|
||||
cf->mFirstChild = contCellFrame;
|
||||
} else {
|
||||
newChildList->SetNextSibling(contCellFrame);
|
||||
}
|
||||
newChildList = contCellFrame;
|
||||
}
|
||||
}
|
||||
|
||||
aContinuingFrame = cf;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* we overload this here because rows have children that can span outside of themselves.
|
||||
|
|
|
@ -850,6 +850,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext& aPresContext,
|
|||
nsReflowStatus& aStatus)
|
||||
{
|
||||
nsIFrame* prevKidFrame = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Walk each of the row frames looking for the first row frame that
|
||||
// doesn't fit in the available space
|
||||
|
@ -857,21 +858,22 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext& aPresContext,
|
|||
nsRect bounds;
|
||||
|
||||
kidFrame->GetRect(bounds);
|
||||
// XXX This check isn't correct if there's a footer...
|
||||
if (bounds.YMost() > aReflowState.maxSize.height) {
|
||||
// If this is the first row frame then we need to split it
|
||||
if (nsnull == prevKidFrame) {
|
||||
// Reflow the row in the available space and have it split
|
||||
// XXX Account for horizontal margins...
|
||||
#if 0
|
||||
nsSize kidAvailSize(aReflowState.maxSize.width,
|
||||
aReflowState.maxSize.height - bounds.y);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState,
|
||||
kidAvailSize, eReflowReason_Resize);
|
||||
nsReflowMetrics desiredSize;
|
||||
nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState,
|
||||
kidAvailSize, eReflowReason_Resize);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
|
||||
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus);
|
||||
kidFrame->SizeTo(desiredSize.width, desiredSize.height);
|
||||
NS_ASSERTION(NS_FRAME_IS_NOT_COMPLETE(aStatus), "unexpected status");
|
||||
((nsTableRowFrame *)kidFrame)->DidResize(aPresContext, aReflowState);
|
||||
|
||||
// Create a continuing frame, add it to the child list, and then push it
|
||||
// and the frames that follow
|
||||
|
@ -892,8 +894,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext& aPresContext,
|
|||
|
||||
// Push it and the frames that follow
|
||||
PushChildren(continuingFrame, kidFrame);
|
||||
aDesiredSize.height = bounds.y;
|
||||
#endif
|
||||
aDesiredSize.height = desiredSize.height;
|
||||
|
||||
} else {
|
||||
// See whether the row frame has cells that span into it or across it
|
||||
|
|
|
@ -434,6 +434,15 @@ nsTableCellFrame::CreateContinuingFrame(nsIPresContext& aPresContext,
|
|||
cf->Init(aPresContext, mContent, aParent, aStyleContext);
|
||||
cf->AppendToFlow(this);
|
||||
aContinuingFrame = cf;
|
||||
|
||||
// Create a continuing body frame
|
||||
nsIFrame* childList;
|
||||
nsIStyleContext* kidSC;
|
||||
|
||||
mFirstChild->GetStyleContext(kidSC);
|
||||
mFirstChild->CreateContinuingFrame(aPresContext, cf, kidSC, childList);
|
||||
NS_RELEASE(kidSC);
|
||||
cf->SetInitialChildList(aPresContext, nsnull, childList);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -483,6 +483,7 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
|
|||
RowReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
if (nsnull == mFirstChild)
|
||||
return NS_OK;
|
||||
|
||||
|
@ -555,13 +556,21 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
|
|||
// If the available width is the same as last time we reflowed the cell,
|
||||
// then just use the previous desired size and max element size.
|
||||
// if we need the max-element-size we don't need to reflow.
|
||||
// we just grab it from the cell frame which remembers it (see the else clause below)
|
||||
if (availWidth != ((nsTableCellFrame *)kidFrame)->GetPriorAvailWidth())
|
||||
// we just grab it from the cell frame which remembers it (see the else clause below).
|
||||
// Note: we can't do that optimization if our height is constrained
|
||||
if ((aReflowState.reflowState.maxSize.height != NS_UNCONSTRAINEDSIZE) ||
|
||||
(availWidth != ((nsTableCellFrame *)kidFrame)->GetPriorAvailWidth()))
|
||||
{
|
||||
// XXX TROY
|
||||
#if 0
|
||||
// Always let the cell be as high as it wants. We ignore the height that's
|
||||
// passed in and always place the entire row. Let the row group decide
|
||||
// whether we fit or wehther the entire row is pushed
|
||||
nsSize kidAvailSize(availWidth, NS_UNCONSTRAINEDSIZE);
|
||||
#else
|
||||
// Reflow the cell to fit the available height
|
||||
nsSize kidAvailSize(availWidth, aReflowState.reflowState.maxSize.height);
|
||||
#endif
|
||||
|
||||
// Reflow the child
|
||||
nsHTMLReflowState kidReflowState(aPresContext, kidFrame,
|
||||
|
@ -578,7 +587,15 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
|
|||
desiredSize.width, availWidth);
|
||||
}
|
||||
#endif
|
||||
// XXX TROY
|
||||
#if 0
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected reflow status");
|
||||
#else
|
||||
// If any of the cells are not complete, then we're not complete
|
||||
if (NS_FRAME_IS_NOT_COMPLETE(status)) {
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gsDebug)
|
||||
{
|
||||
|
@ -646,7 +663,8 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
|
|||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
if (PR_TRUE==gsDebug) printf("\nRow: Resize Reflow of unknown frame %p of type %d with reason=%d\n",
|
||||
kidFrame, kidDisplay->mDisplay, eReflowReason_Resize);
|
||||
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus);
|
||||
nsReflowStatus status;
|
||||
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, status);
|
||||
}
|
||||
|
||||
// Get the next child
|
||||
|
@ -1363,6 +1381,7 @@ nsTableRowFrame::Reflow(nsIPresContext& aPresContext,
|
|||
rv = InitialReflow(aPresContext, aDesiredSize, state, aStatus, nsnull, PR_TRUE);
|
||||
GetMinRowSpan(tableFrame);
|
||||
FixMinCellHeight(tableFrame);
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
break;
|
||||
|
||||
case eReflowReason_Resize:
|
||||
|
@ -1374,7 +1393,10 @@ nsTableRowFrame::Reflow(nsIPresContext& aPresContext,
|
|||
break;
|
||||
}
|
||||
|
||||
// XXX TROY
|
||||
#if 0
|
||||
aStatus = NS_FRAME_COMPLETE; // we're never continued
|
||||
#endif
|
||||
|
||||
if (gsDebug==PR_TRUE)
|
||||
{
|
||||
|
@ -1398,10 +1420,42 @@ nsTableRowFrame::CreateContinuingFrame(nsIPresContext& aPresContext,
|
|||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aContinuingFrame)
|
||||
{
|
||||
// Because rows are always complete we should never be asked to create
|
||||
// a continuing frame
|
||||
NS_ERROR("Unexpected request");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsTableRowFrame* cf = new nsTableRowFrame;
|
||||
if (nsnull == cf) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
cf->Init(aPresContext, mContent, aParent, aStyleContext);
|
||||
cf->AppendToFlow(this);
|
||||
|
||||
// Create a continuing frame for each table cell
|
||||
nsIFrame* newChildList;
|
||||
for (nsIFrame* kidFrame = mFirstChild;
|
||||
nsnull != kidFrame;
|
||||
kidFrame->GetNextSibling(kidFrame)) {
|
||||
|
||||
const nsStyleDisplay *kidDisplay;
|
||||
kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)kidDisplay));
|
||||
if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay) {
|
||||
nsIFrame* contCellFrame;
|
||||
nsIStyleContext* kidSC;
|
||||
|
||||
// Create a continuing cell frame
|
||||
kidFrame->GetStyleContext(kidSC);
|
||||
kidFrame->CreateContinuingFrame(aPresContext, cf, kidSC, contCellFrame);
|
||||
NS_RELEASE(kidSC);
|
||||
|
||||
// Link it into the list of child frames
|
||||
if (nsnull == cf->mFirstChild) {
|
||||
cf->mFirstChild = contCellFrame;
|
||||
} else {
|
||||
newChildList->SetNextSibling(contCellFrame);
|
||||
}
|
||||
newChildList = contCellFrame;
|
||||
}
|
||||
}
|
||||
|
||||
aContinuingFrame = cf;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* we overload this here because rows have children that can span outside of themselves.
|
||||
|
|
|
@ -850,6 +850,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext& aPresContext,
|
|||
nsReflowStatus& aStatus)
|
||||
{
|
||||
nsIFrame* prevKidFrame = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Walk each of the row frames looking for the first row frame that
|
||||
// doesn't fit in the available space
|
||||
|
@ -857,21 +858,22 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext& aPresContext,
|
|||
nsRect bounds;
|
||||
|
||||
kidFrame->GetRect(bounds);
|
||||
// XXX This check isn't correct if there's a footer...
|
||||
if (bounds.YMost() > aReflowState.maxSize.height) {
|
||||
// If this is the first row frame then we need to split it
|
||||
if (nsnull == prevKidFrame) {
|
||||
// Reflow the row in the available space and have it split
|
||||
// XXX Account for horizontal margins...
|
||||
#if 0
|
||||
nsSize kidAvailSize(aReflowState.maxSize.width,
|
||||
aReflowState.maxSize.height - bounds.y);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState,
|
||||
kidAvailSize, eReflowReason_Resize);
|
||||
nsReflowMetrics desiredSize;
|
||||
nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState,
|
||||
kidAvailSize, eReflowReason_Resize);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
|
||||
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus);
|
||||
kidFrame->SizeTo(desiredSize.width, desiredSize.height);
|
||||
NS_ASSERTION(NS_FRAME_IS_NOT_COMPLETE(aStatus), "unexpected status");
|
||||
((nsTableRowFrame *)kidFrame)->DidResize(aPresContext, aReflowState);
|
||||
|
||||
// Create a continuing frame, add it to the child list, and then push it
|
||||
// and the frames that follow
|
||||
|
@ -892,8 +894,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext& aPresContext,
|
|||
|
||||
// Push it and the frames that follow
|
||||
PushChildren(continuingFrame, kidFrame);
|
||||
aDesiredSize.height = bounds.y;
|
||||
#endif
|
||||
aDesiredSize.height = desiredSize.height;
|
||||
|
||||
} else {
|
||||
// See whether the row frame has cells that span into it or across it
|
||||
|
|
Загрузка…
Ссылка в новой задаче