bug 37037, 37490, and a table paganation problem when captions are present.
git-svn-id: svn://10.0.0.236/trunk@68283 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
2702bf5ff6
commit
a84a1ee61a
@ -490,7 +490,11 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget,
|
||||
PRBool makeCX = PR_FALSE;
|
||||
if (!mPresContext) {
|
||||
// Create presentation context
|
||||
#if 1
|
||||
rv = NS_NewGalleyContext(getter_AddRefs(mPresContext));
|
||||
#else // turn on print preview for debugging until print preview is fixed
|
||||
rv = NS_NewPrintPreviewContext(getter_AddRefs(mPresContext));
|
||||
#endif
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mPresContext->Init(aDeviceContext);
|
||||
|
||||
@ -490,7 +490,11 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget,
|
||||
PRBool makeCX = PR_FALSE;
|
||||
if (!mPresContext) {
|
||||
// Create presentation context
|
||||
#if 1
|
||||
rv = NS_NewGalleyContext(getter_AddRefs(mPresContext));
|
||||
#else // turn on print preview for debugging until print preview is fixed
|
||||
rv = NS_NewPrintPreviewContext(getter_AddRefs(mPresContext));
|
||||
#endif
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mPresContext->Init(aDeviceContext);
|
||||
|
||||
@ -310,8 +310,8 @@ struct nsHTMLReflowState {
|
||||
nscoord& aContainingBlockWidth,
|
||||
nscoord& aContainingBlockHeight);
|
||||
|
||||
void CalculateBlockSideMargins(const nsHTMLReflowState* aContainingBlockRS,
|
||||
nscoord aComputedWidth);
|
||||
void CalculateBlockSideMargins(nscoord aAvailWidth,
|
||||
nscoord aComputedWidth);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -490,7 +490,11 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget,
|
||||
PRBool makeCX = PR_FALSE;
|
||||
if (!mPresContext) {
|
||||
// Create presentation context
|
||||
#if 1
|
||||
rv = NS_NewGalleyContext(getter_AddRefs(mPresContext));
|
||||
#else // turn on print preview for debugging until print preview is fixed
|
||||
rv = NS_NewPrintPreviewContext(getter_AddRefs(mPresContext));
|
||||
#endif
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mPresContext->Init(aDeviceContext);
|
||||
|
||||
@ -1870,7 +1870,7 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext* aPresContext,
|
||||
}
|
||||
|
||||
// Now that we have the computed-width, compute the side margins
|
||||
CalculateBlockSideMargins(cbrs, mComputedWidth);
|
||||
CalculateBlockSideMargins(cbrs->mComputedWidth, mComputedWidth);
|
||||
}
|
||||
|
||||
// Compute the content height
|
||||
@ -1926,20 +1926,20 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext* aPresContext,
|
||||
//
|
||||
// Note: the width unit is not auto when this is called
|
||||
void
|
||||
nsHTMLReflowState::CalculateBlockSideMargins(const nsHTMLReflowState* cbrs,
|
||||
nsHTMLReflowState::CalculateBlockSideMargins(nscoord aAvailWidth,
|
||||
nscoord aComputedWidth)
|
||||
{
|
||||
// We can only provide values for auto side margins in a constrained
|
||||
// reflow. For unconstrained reflow there is no effective width to
|
||||
// compute against...
|
||||
if ((NS_UNCONSTRAINEDSIZE == aComputedWidth) ||
|
||||
(NS_UNCONSTRAINEDSIZE == cbrs->mComputedWidth)) {
|
||||
(NS_UNCONSTRAINEDSIZE == aAvailWidth)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nscoord sum = mComputedMargin.left + mComputedBorderPadding.left +
|
||||
aComputedWidth + mComputedBorderPadding.right + mComputedMargin.right;
|
||||
if (sum == cbrs->mComputedWidth) {
|
||||
if (sum == aAvailWidth) {
|
||||
// The sum is already correct
|
||||
return;
|
||||
}
|
||||
@ -1952,7 +1952,7 @@ nsHTMLReflowState::CalculateBlockSideMargins(const nsHTMLReflowState* cbrs,
|
||||
eStyleUnit_Auto == mStyleSpacing->mMargin.GetRightUnit();
|
||||
|
||||
// Calculate how much space is available for margins
|
||||
nscoord availMarginSpace = cbrs->mComputedWidth - aComputedWidth -
|
||||
nscoord availMarginSpace = aAvailWidth - aComputedWidth -
|
||||
mComputedBorderPadding.left - mComputedBorderPadding.right;
|
||||
|
||||
if (mStyleDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE) {
|
||||
|
||||
@ -310,8 +310,8 @@ struct nsHTMLReflowState {
|
||||
nscoord& aContainingBlockWidth,
|
||||
nscoord& aContainingBlockHeight);
|
||||
|
||||
void CalculateBlockSideMargins(const nsHTMLReflowState* aContainingBlockRS,
|
||||
nscoord aComputedWidth);
|
||||
void CalculateBlockSideMargins(nscoord aAvailWidth,
|
||||
nscoord aComputedWidth);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -1870,7 +1870,7 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext* aPresContext,
|
||||
}
|
||||
|
||||
// Now that we have the computed-width, compute the side margins
|
||||
CalculateBlockSideMargins(cbrs, mComputedWidth);
|
||||
CalculateBlockSideMargins(cbrs->mComputedWidth, mComputedWidth);
|
||||
}
|
||||
|
||||
// Compute the content height
|
||||
@ -1926,20 +1926,20 @@ nsHTMLReflowState::ComputeBlockBoxData(nsIPresContext* aPresContext,
|
||||
//
|
||||
// Note: the width unit is not auto when this is called
|
||||
void
|
||||
nsHTMLReflowState::CalculateBlockSideMargins(const nsHTMLReflowState* cbrs,
|
||||
nsHTMLReflowState::CalculateBlockSideMargins(nscoord aAvailWidth,
|
||||
nscoord aComputedWidth)
|
||||
{
|
||||
// We can only provide values for auto side margins in a constrained
|
||||
// reflow. For unconstrained reflow there is no effective width to
|
||||
// compute against...
|
||||
if ((NS_UNCONSTRAINEDSIZE == aComputedWidth) ||
|
||||
(NS_UNCONSTRAINEDSIZE == cbrs->mComputedWidth)) {
|
||||
(NS_UNCONSTRAINEDSIZE == aAvailWidth)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nscoord sum = mComputedMargin.left + mComputedBorderPadding.left +
|
||||
aComputedWidth + mComputedBorderPadding.right + mComputedMargin.right;
|
||||
if (sum == cbrs->mComputedWidth) {
|
||||
if (sum == aAvailWidth) {
|
||||
// The sum is already correct
|
||||
return;
|
||||
}
|
||||
@ -1952,7 +1952,7 @@ nsHTMLReflowState::CalculateBlockSideMargins(const nsHTMLReflowState* cbrs,
|
||||
eStyleUnit_Auto == mStyleSpacing->mMargin.GetRightUnit();
|
||||
|
||||
// Calculate how much space is available for margins
|
||||
nscoord availMarginSpace = cbrs->mComputedWidth - aComputedWidth -
|
||||
nscoord availMarginSpace = aAvailWidth - aComputedWidth -
|
||||
mComputedBorderPadding.left - mComputedBorderPadding.right;
|
||||
|
||||
if (mStyleDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE) {
|
||||
|
||||
@ -414,19 +414,19 @@ nsTableOuterFrame::ZeroAutoMargin(nsMargin& aMargin)
|
||||
}
|
||||
|
||||
void
|
||||
FixAutoMargins(nsHTMLReflowState& aReflowState)
|
||||
FixAutoMargins(nscoord aAvailWidth,
|
||||
nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
nsMargin margin = aReflowState.mComputedMargin;
|
||||
if ((margin.left == NS_AUTOMARGIN) || (margin.right == NS_AUTOMARGIN)) {
|
||||
// see if there are auto margins. they may have been set to 0 in mComputedMargin
|
||||
PRBool hasAutoMargin = eStyleUnit_Auto == aReflowState.mStyleSpacing->mMargin.GetLeftUnit() ||
|
||||
eStyleUnit_Auto == aReflowState.mStyleSpacing->mMargin.GetRightUnit();
|
||||
if (hasAutoMargin) {
|
||||
nsRect rect;
|
||||
aReflowState.frame->GetRect(rect);
|
||||
nscoord compWidth = rect.width - aReflowState.mComputedBorderPadding.left -
|
||||
aReflowState.mComputedBorderPadding.right;
|
||||
|
||||
const nsHTMLReflowState* containRS =
|
||||
nsHTMLReflowState::GetContainingBlockReflowState(aReflowState.parentReflowState);
|
||||
|
||||
aReflowState.CalculateBlockSideMargins(containRS, compWidth);
|
||||
aReflowState.CalculateBlockSideMargins(aAvailWidth, compWidth);
|
||||
}
|
||||
}
|
||||
|
||||
@ -451,7 +451,7 @@ GetMarginPadding(nsIPresContext* aPresContext,
|
||||
aMargin = adjMargin;
|
||||
}
|
||||
else {
|
||||
FixAutoMargins(childRS);
|
||||
FixAutoMargins(aOuterRS.availableWidth, childRS);
|
||||
aMargin = childRS.mComputedMargin;
|
||||
}
|
||||
aPadding = childRS.mComputedPadding;
|
||||
@ -873,7 +873,7 @@ nsTableOuterFrame::OuterReflowChild(nsIPresContext* aPresContext,
|
||||
childRect.x, childRect.y, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
FixAutoMargins(childRS);
|
||||
FixAutoMargins(aOuterRS.availableWidth, childRS);
|
||||
aMargin = childRS.mComputedMargin;
|
||||
|
||||
aDesiredSize.width = aMetrics.width;
|
||||
@ -982,6 +982,7 @@ nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext* aPresContex
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
PRUint8 captionSide = GetCaptionSide();
|
||||
|
||||
nsSize captionSize, captionMES;
|
||||
@ -989,8 +990,9 @@ nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext* aPresContex
|
||||
// reflow the caption frame, getting it's MES
|
||||
nscoord availWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS);
|
||||
nsHTMLReflowMetrics captionMet(&captionMES);
|
||||
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
||||
OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet, &availWidth, captionSize,
|
||||
captionMargin, captionPadding, eReflowReason_Incremental, aStatus);
|
||||
captionMargin, captionPadding, eReflowReason_Incremental, capStatus);
|
||||
|
||||
nsMargin innerMargin, innerPadding;
|
||||
nsPoint innerOrigin;
|
||||
@ -1148,6 +1150,7 @@ nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aOuterRS,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
PRUint8 captionSide = GetCaptionSide();
|
||||
|
||||
nsRect priorInnerRect;
|
||||
@ -1186,8 +1189,9 @@ nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics captionMet(nsnull); // don't ask for MES, it hasn't changed
|
||||
nscoord availWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS,
|
||||
&innerSize.width, &innerMargin);
|
||||
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
||||
rv = OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet, &availWidth,
|
||||
captionSize, captionMargin, ignorePadding, eReflowReason_Resize, aStatus);
|
||||
captionSize, captionMargin, ignorePadding, eReflowReason_Resize, capStatus);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsPoint captionOrigin;
|
||||
@ -1240,6 +1244,7 @@ nsTableOuterFrame::IR_CaptionInserted(nsIPresContext* aPresContext,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
PRUint8 captionSide = GetCaptionSide();
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
|
||||
// reflow the caption frame, getting it's MES
|
||||
nsSize captionSize;
|
||||
@ -1248,9 +1253,10 @@ nsTableOuterFrame::IR_CaptionInserted(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics captionMet(&maxElementSize);
|
||||
// reflow the caption
|
||||
nscoord availWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS);
|
||||
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
||||
nsresult rv = OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet,
|
||||
&availWidth, captionSize, captionMargin, ignorePadding,
|
||||
eReflowReason_Initial, aStatus);
|
||||
eReflowReason_Initial, capStatus);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
@ -1405,9 +1411,10 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
|
||||
nscoord availWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS,
|
||||
&innerSize.width, &innerMargin);
|
||||
nsHTMLReflowMetrics captionMet(nsnull);
|
||||
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
||||
rv = OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet,
|
||||
&availWidth, captionSize, captionMargin, ignorePadding,
|
||||
aOuterRS.reason, aStatus);
|
||||
aOuterRS.reason, capStatus);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsPoint captionOrigin;
|
||||
|
||||
@ -45,6 +45,58 @@ static NS_DEFINE_IID(kIHTMLTableCellElementIID, NS_IHTMLTABLECELLELEMENT_IID);
|
||||
// end includes for style optimizations that require real content knowledge
|
||||
|
||||
|
||||
struct nsTableCellReflowState : public nsHTMLReflowState
|
||||
{
|
||||
nsTableCellReflowState(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aParentReflowState,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailableSpace,
|
||||
nsReflowReason aReason);
|
||||
|
||||
nsTableCellReflowState(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aParentReflowState,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailableSpace);
|
||||
|
||||
void FixUp(const nsSize& aAvailSpace);
|
||||
};
|
||||
|
||||
nsTableCellReflowState::nsTableCellReflowState(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aParentRS,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailSpace,
|
||||
nsReflowReason aReason)
|
||||
:nsHTMLReflowState(aPresContext, aParentRS, aFrame, aAvailSpace, aReason)
|
||||
{
|
||||
FixUp(aAvailSpace);
|
||||
}
|
||||
|
||||
nsTableCellReflowState::nsTableCellReflowState(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aParentRS,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailSpace)
|
||||
:nsHTMLReflowState(aPresContext, aParentRS, aFrame, aAvailSpace)
|
||||
{
|
||||
FixUp(aAvailSpace);
|
||||
}
|
||||
|
||||
void nsTableCellReflowState::FixUp(const nsSize& aAvailSpace)
|
||||
{
|
||||
// fix the mComputed values during a pass 2 reflow since the cell can be a percentage base
|
||||
if (NS_UNCONSTRAINEDSIZE != aAvailSpace.width) {
|
||||
if (NS_UNCONSTRAINEDSIZE != mComputedWidth) {
|
||||
mComputedWidth = aAvailSpace.width - mComputedBorderPadding.left - mComputedBorderPadding.right;
|
||||
mComputedWidth = PR_MAX(0, mComputedWidth);
|
||||
}
|
||||
if (NS_UNCONSTRAINEDSIZE != mComputedHeight) {
|
||||
if (NS_UNCONSTRAINEDSIZE != aAvailSpace.height) {
|
||||
mComputedHeight = aAvailSpace.height - mComputedBorderPadding.top - mComputedBorderPadding.bottom;
|
||||
mComputedHeight = PR_MAX(0, mComputedHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------- nsTableRowpFrame ---------- */
|
||||
|
||||
nsTableRowFrame::nsTableRowFrame()
|
||||
@ -837,10 +889,9 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
|
||||
}
|
||||
|
||||
// Reflow the child
|
||||
nsHTMLReflowState kidReflowState(aPresContext,
|
||||
aReflowState.reflowState, kidFrame,
|
||||
kidAvailSize,
|
||||
reason);
|
||||
nsTableCellReflowState kidReflowState(aPresContext, aReflowState.reflowState, kidFrame,
|
||||
kidAvailSize, reason);
|
||||
|
||||
nsReflowStatus status;
|
||||
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
|
||||
aReflowState.x, 0, 0, status);
|
||||
@ -904,9 +955,8 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
|
||||
}
|
||||
else
|
||||
{// it's an unknown frame type, give it a generic reflow and ignore the results
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
||||
kidFrame,
|
||||
nsSize(0,0), eReflowReason_Resize);
|
||||
nsTableCellReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
||||
kidFrame, nsSize(0,0), eReflowReason_Resize);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
nsReflowStatus status;
|
||||
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, 0, 0, 0, status);
|
||||
@ -986,10 +1036,8 @@ nsTableRowFrame::InitialReflow(nsIPresContext* aPresContext,
|
||||
kidAvailSize.SizeTo(table->GetColumnWidth(colIndex), NS_UNCONSTRAINEDSIZE);
|
||||
}
|
||||
|
||||
nsHTMLReflowState kidReflowState(aPresContext,
|
||||
aReflowState.reflowState,
|
||||
kidFrame, kidAvailSize,
|
||||
eReflowReason_Initial);
|
||||
nsTableCellReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
||||
kidFrame, kidAvailSize, eReflowReason_Initial);
|
||||
|
||||
rv = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState,
|
||||
x + cellSpacingX, 0, 0, aStatus);
|
||||
@ -1018,8 +1066,8 @@ nsTableRowFrame::InitialReflow(nsIPresContext* aPresContext,
|
||||
}
|
||||
else
|
||||
{// it's an unknown frame type, give it a generic reflow and ignore the results
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
||||
kidFrame, nsSize(0,0), eReflowReason_Initial);
|
||||
nsTableCellReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
||||
kidFrame, nsSize(0,0), eReflowReason_Initial);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, 0, 0, 0, aStatus);
|
||||
kidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
@ -1229,9 +1277,8 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics desiredSize(&kidMaxElementSize,
|
||||
aReflowState.tableFrame->IsAutoLayout() ?
|
||||
NS_REFLOW_CALC_MAX_WIDTH : 0);
|
||||
nsHTMLReflowState kidReflowState(aPresContext,
|
||||
aReflowState.reflowState,
|
||||
aNextFrame, kidAvailSize);
|
||||
nsTableCellReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
||||
aNextFrame, kidAvailSize);
|
||||
|
||||
// Remember the current desired size, we'll need it later
|
||||
nsSize oldMinSize = ((nsTableCellFrame*)aNextFrame)->GetPass1MaxElementSize();
|
||||
@ -1438,8 +1485,8 @@ void nsTableRowFrame::ReflowCellFrame(nsIPresContext* aPresContext,
|
||||
aCellFrame->GetSize(cellSize);
|
||||
|
||||
nsSize availSize(cellSize.width, aAvailableHeight);
|
||||
nsHTMLReflowState cellReflowState(aPresContext, aReflowState, aCellFrame, availSize,
|
||||
eReflowReason_Resize);
|
||||
nsTableCellReflowState cellReflowState(aPresContext, aReflowState, aCellFrame, availSize,
|
||||
eReflowReason_Resize);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
|
||||
ReflowChild(aCellFrame, aPresContext, desiredSize, cellReflowState,
|
||||
|
||||
@ -414,19 +414,19 @@ nsTableOuterFrame::ZeroAutoMargin(nsMargin& aMargin)
|
||||
}
|
||||
|
||||
void
|
||||
FixAutoMargins(nsHTMLReflowState& aReflowState)
|
||||
FixAutoMargins(nscoord aAvailWidth,
|
||||
nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
nsMargin margin = aReflowState.mComputedMargin;
|
||||
if ((margin.left == NS_AUTOMARGIN) || (margin.right == NS_AUTOMARGIN)) {
|
||||
// see if there are auto margins. they may have been set to 0 in mComputedMargin
|
||||
PRBool hasAutoMargin = eStyleUnit_Auto == aReflowState.mStyleSpacing->mMargin.GetLeftUnit() ||
|
||||
eStyleUnit_Auto == aReflowState.mStyleSpacing->mMargin.GetRightUnit();
|
||||
if (hasAutoMargin) {
|
||||
nsRect rect;
|
||||
aReflowState.frame->GetRect(rect);
|
||||
nscoord compWidth = rect.width - aReflowState.mComputedBorderPadding.left -
|
||||
aReflowState.mComputedBorderPadding.right;
|
||||
|
||||
const nsHTMLReflowState* containRS =
|
||||
nsHTMLReflowState::GetContainingBlockReflowState(aReflowState.parentReflowState);
|
||||
|
||||
aReflowState.CalculateBlockSideMargins(containRS, compWidth);
|
||||
aReflowState.CalculateBlockSideMargins(aAvailWidth, compWidth);
|
||||
}
|
||||
}
|
||||
|
||||
@ -451,7 +451,7 @@ GetMarginPadding(nsIPresContext* aPresContext,
|
||||
aMargin = adjMargin;
|
||||
}
|
||||
else {
|
||||
FixAutoMargins(childRS);
|
||||
FixAutoMargins(aOuterRS.availableWidth, childRS);
|
||||
aMargin = childRS.mComputedMargin;
|
||||
}
|
||||
aPadding = childRS.mComputedPadding;
|
||||
@ -873,7 +873,7 @@ nsTableOuterFrame::OuterReflowChild(nsIPresContext* aPresContext,
|
||||
childRect.x, childRect.y, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
FixAutoMargins(childRS);
|
||||
FixAutoMargins(aOuterRS.availableWidth, childRS);
|
||||
aMargin = childRS.mComputedMargin;
|
||||
|
||||
aDesiredSize.width = aMetrics.width;
|
||||
@ -982,6 +982,7 @@ nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext* aPresContex
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
PRUint8 captionSide = GetCaptionSide();
|
||||
|
||||
nsSize captionSize, captionMES;
|
||||
@ -989,8 +990,9 @@ nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext* aPresContex
|
||||
// reflow the caption frame, getting it's MES
|
||||
nscoord availWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS);
|
||||
nsHTMLReflowMetrics captionMet(&captionMES);
|
||||
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
||||
OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet, &availWidth, captionSize,
|
||||
captionMargin, captionPadding, eReflowReason_Incremental, aStatus);
|
||||
captionMargin, captionPadding, eReflowReason_Incremental, capStatus);
|
||||
|
||||
nsMargin innerMargin, innerPadding;
|
||||
nsPoint innerOrigin;
|
||||
@ -1148,6 +1150,7 @@ nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aOuterRS,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
PRUint8 captionSide = GetCaptionSide();
|
||||
|
||||
nsRect priorInnerRect;
|
||||
@ -1186,8 +1189,9 @@ nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics captionMet(nsnull); // don't ask for MES, it hasn't changed
|
||||
nscoord availWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS,
|
||||
&innerSize.width, &innerMargin);
|
||||
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
||||
rv = OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet, &availWidth,
|
||||
captionSize, captionMargin, ignorePadding, eReflowReason_Resize, aStatus);
|
||||
captionSize, captionMargin, ignorePadding, eReflowReason_Resize, capStatus);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsPoint captionOrigin;
|
||||
@ -1240,6 +1244,7 @@ nsTableOuterFrame::IR_CaptionInserted(nsIPresContext* aPresContext,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
PRUint8 captionSide = GetCaptionSide();
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
|
||||
// reflow the caption frame, getting it's MES
|
||||
nsSize captionSize;
|
||||
@ -1248,9 +1253,10 @@ nsTableOuterFrame::IR_CaptionInserted(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics captionMet(&maxElementSize);
|
||||
// reflow the caption
|
||||
nscoord availWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS);
|
||||
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
||||
nsresult rv = OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet,
|
||||
&availWidth, captionSize, captionMargin, ignorePadding,
|
||||
eReflowReason_Initial, aStatus);
|
||||
eReflowReason_Initial, capStatus);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
@ -1405,9 +1411,10 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
|
||||
nscoord availWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS,
|
||||
&innerSize.width, &innerMargin);
|
||||
nsHTMLReflowMetrics captionMet(nsnull);
|
||||
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
||||
rv = OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet,
|
||||
&availWidth, captionSize, captionMargin, ignorePadding,
|
||||
aOuterRS.reason, aStatus);
|
||||
aOuterRS.reason, capStatus);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsPoint captionOrigin;
|
||||
|
||||
@ -45,6 +45,58 @@ static NS_DEFINE_IID(kIHTMLTableCellElementIID, NS_IHTMLTABLECELLELEMENT_IID);
|
||||
// end includes for style optimizations that require real content knowledge
|
||||
|
||||
|
||||
struct nsTableCellReflowState : public nsHTMLReflowState
|
||||
{
|
||||
nsTableCellReflowState(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aParentReflowState,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailableSpace,
|
||||
nsReflowReason aReason);
|
||||
|
||||
nsTableCellReflowState(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aParentReflowState,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailableSpace);
|
||||
|
||||
void FixUp(const nsSize& aAvailSpace);
|
||||
};
|
||||
|
||||
nsTableCellReflowState::nsTableCellReflowState(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aParentRS,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailSpace,
|
||||
nsReflowReason aReason)
|
||||
:nsHTMLReflowState(aPresContext, aParentRS, aFrame, aAvailSpace, aReason)
|
||||
{
|
||||
FixUp(aAvailSpace);
|
||||
}
|
||||
|
||||
nsTableCellReflowState::nsTableCellReflowState(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aParentRS,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailSpace)
|
||||
:nsHTMLReflowState(aPresContext, aParentRS, aFrame, aAvailSpace)
|
||||
{
|
||||
FixUp(aAvailSpace);
|
||||
}
|
||||
|
||||
void nsTableCellReflowState::FixUp(const nsSize& aAvailSpace)
|
||||
{
|
||||
// fix the mComputed values during a pass 2 reflow since the cell can be a percentage base
|
||||
if (NS_UNCONSTRAINEDSIZE != aAvailSpace.width) {
|
||||
if (NS_UNCONSTRAINEDSIZE != mComputedWidth) {
|
||||
mComputedWidth = aAvailSpace.width - mComputedBorderPadding.left - mComputedBorderPadding.right;
|
||||
mComputedWidth = PR_MAX(0, mComputedWidth);
|
||||
}
|
||||
if (NS_UNCONSTRAINEDSIZE != mComputedHeight) {
|
||||
if (NS_UNCONSTRAINEDSIZE != aAvailSpace.height) {
|
||||
mComputedHeight = aAvailSpace.height - mComputedBorderPadding.top - mComputedBorderPadding.bottom;
|
||||
mComputedHeight = PR_MAX(0, mComputedHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------- nsTableRowpFrame ---------- */
|
||||
|
||||
nsTableRowFrame::nsTableRowFrame()
|
||||
@ -837,10 +889,9 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
|
||||
}
|
||||
|
||||
// Reflow the child
|
||||
nsHTMLReflowState kidReflowState(aPresContext,
|
||||
aReflowState.reflowState, kidFrame,
|
||||
kidAvailSize,
|
||||
reason);
|
||||
nsTableCellReflowState kidReflowState(aPresContext, aReflowState.reflowState, kidFrame,
|
||||
kidAvailSize, reason);
|
||||
|
||||
nsReflowStatus status;
|
||||
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
|
||||
aReflowState.x, 0, 0, status);
|
||||
@ -904,9 +955,8 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
|
||||
}
|
||||
else
|
||||
{// it's an unknown frame type, give it a generic reflow and ignore the results
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
||||
kidFrame,
|
||||
nsSize(0,0), eReflowReason_Resize);
|
||||
nsTableCellReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
||||
kidFrame, nsSize(0,0), eReflowReason_Resize);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
nsReflowStatus status;
|
||||
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, 0, 0, 0, status);
|
||||
@ -986,10 +1036,8 @@ nsTableRowFrame::InitialReflow(nsIPresContext* aPresContext,
|
||||
kidAvailSize.SizeTo(table->GetColumnWidth(colIndex), NS_UNCONSTRAINEDSIZE);
|
||||
}
|
||||
|
||||
nsHTMLReflowState kidReflowState(aPresContext,
|
||||
aReflowState.reflowState,
|
||||
kidFrame, kidAvailSize,
|
||||
eReflowReason_Initial);
|
||||
nsTableCellReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
||||
kidFrame, kidAvailSize, eReflowReason_Initial);
|
||||
|
||||
rv = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState,
|
||||
x + cellSpacingX, 0, 0, aStatus);
|
||||
@ -1018,8 +1066,8 @@ nsTableRowFrame::InitialReflow(nsIPresContext* aPresContext,
|
||||
}
|
||||
else
|
||||
{// it's an unknown frame type, give it a generic reflow and ignore the results
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
||||
kidFrame, nsSize(0,0), eReflowReason_Initial);
|
||||
nsTableCellReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
||||
kidFrame, nsSize(0,0), eReflowReason_Initial);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, 0, 0, 0, aStatus);
|
||||
kidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
@ -1229,9 +1277,8 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics desiredSize(&kidMaxElementSize,
|
||||
aReflowState.tableFrame->IsAutoLayout() ?
|
||||
NS_REFLOW_CALC_MAX_WIDTH : 0);
|
||||
nsHTMLReflowState kidReflowState(aPresContext,
|
||||
aReflowState.reflowState,
|
||||
aNextFrame, kidAvailSize);
|
||||
nsTableCellReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
||||
aNextFrame, kidAvailSize);
|
||||
|
||||
// Remember the current desired size, we'll need it later
|
||||
nsSize oldMinSize = ((nsTableCellFrame*)aNextFrame)->GetPass1MaxElementSize();
|
||||
@ -1438,8 +1485,8 @@ void nsTableRowFrame::ReflowCellFrame(nsIPresContext* aPresContext,
|
||||
aCellFrame->GetSize(cellSize);
|
||||
|
||||
nsSize availSize(cellSize.width, aAvailableHeight);
|
||||
nsHTMLReflowState cellReflowState(aPresContext, aReflowState, aCellFrame, availSize,
|
||||
eReflowReason_Resize);
|
||||
nsTableCellReflowState cellReflowState(aPresContext, aReflowState, aCellFrame, availSize,
|
||||
eReflowReason_Resize);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
|
||||
ReflowChild(aCellFrame, aPresContext, desiredSize, cellReflowState,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user