Prevent margin expansion from interfering with table caption position. Based on patch by Mats Palmgren. b=363248 r+sr=roc a=blocking1.9+

This commit is contained in:
2008-02-26 18:02:50 -08:00
parent 4a9bf486a6
commit 229ecff05b
2 changed files with 23 additions and 1 deletions

View File

@@ -1589,6 +1589,16 @@ static eNormalLineHeightControl GetNormalLineHeightCalcControl(void)
return sNormalLineHeightControl;
}
static inline PRBool
IsSideCaption(nsIFrame* aFrame, const nsStyleDisplay* aStyleDisplay)
{
if (aStyleDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CAPTION)
return PR_FALSE;
PRUint8 captionSide = aFrame->GetStyleTableBorder()->mCaptionSide;
return captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
captionSide == NS_STYLE_CAPTION_SIDE_RIGHT;
}
// XXX refactor this code to have methods for each set of properties
// we are computing: width,height,line-height; margin; offsets
@@ -1798,7 +1808,7 @@ nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext,
NS_ASSERTION(mComputedHeight == NS_UNCONSTRAINEDSIZE ||
mComputedHeight >= 0, "Bogus height");
if (isBlock)
if (isBlock && !IsSideCaption(frame, mStyleDisplay))
CalculateBlockSideMargins(availableWidth, mComputedWidth);
}
}
@@ -2110,6 +2120,9 @@ nsCSSOffsetState::ComputeMargin(nscoord aContainingBlockWidth)
mComputedMargin.bottom);
// XXX We need to include 'auto' horizontal margins in this too!
// ... but if we did that, we'd need to fix nsFrame::GetUsedMargin
// to use it even when the margins are all zero (since sometimes
// they get treated as auto)
frame->SetProperty(nsGkAtoms::usedMarginProperty,
new nsMargin(mComputedMargin),
DestroyMarginFunc);

View File

@@ -718,6 +718,10 @@ public:
* frame has at least *started*.
*
* This doesn't include any margin collapsing that may have occurred.
*
* It also treats 'auto' margins as zero, and treats any margins that
* should have been turned into 'auto' because of overconstraint as
* having their original values.
*/
virtual nsMargin GetUsedMargin() const;
@@ -753,6 +757,11 @@ public:
/**
* Like the frame's rect (see |GetRect|), which is the border rect,
* other rectangles of the frame, in twips, relative to the parent.
*
* Note that GetMarginRect is not meaningful for blocks (anything with
* 'display:block', whether block frame or not) because of both the
* collapsing and 'auto' issues with GetUsedMargin (on which it
* depends).
*/
nsRect GetMarginRect() const;
nsRect GetPaddingRect() const;