зеркало из https://github.com/mozilla/pjs.git
sync to new spacing apis
This commit is contained in:
Родитель
f5413b1108
Коммит
a97ac241a7
|
@ -518,11 +518,13 @@ nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
|
|||
availBand.width = 0;
|
||||
}
|
||||
|
||||
nsStyleSpacing* spacing;
|
||||
aKidFrame->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)spacing);
|
||||
if (aMaxSize.width != NS_UNCONSTRAINEDSIZE) {
|
||||
nsStyleSpacing* spacing;
|
||||
aKidFrame->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)spacing);
|
||||
nsMargin margin;
|
||||
spacing->CalcMarginFor(this, margin);
|
||||
// Reduce the available width by the kid's left/right margin
|
||||
availSize.width -= spacing->mMargin.left + spacing->mMargin.right;
|
||||
availSize.width -= margin.left + margin.right;
|
||||
}
|
||||
|
||||
// Does the child frame support interface nsIRunaround?
|
||||
|
|
|
@ -166,14 +166,16 @@ nsresult nsBlockReflowState::RecoverState(nsLineData* aLine)
|
|||
|
||||
// If the previous line is a block, then factor in its bottom margin
|
||||
if (prevLine->mIsBlock) {
|
||||
nsStyleSpacing* spacing;
|
||||
nsStyleSpacing* kidSpacing;
|
||||
nsIFrame* kid = prevLine->mFirstChild;
|
||||
|
||||
kid->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)spacing);
|
||||
if (spacing->mMargin.bottom < 0) {
|
||||
mPrevMaxNegBottomMargin = -spacing->mMargin.bottom;
|
||||
kid->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)kidSpacing);
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kid, kidMargin);
|
||||
if (kidMargin.bottom < 0) {
|
||||
mPrevMaxNegBottomMargin = -kidMargin.bottom;
|
||||
} else {
|
||||
mPrevMaxPosBottomMargin = spacing->mMargin.bottom;
|
||||
mPrevMaxPosBottomMargin = kidMargin.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -554,27 +556,29 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
|
|||
case NS_STYLE_DISPLAY_BLOCK:
|
||||
case NS_STYLE_DISPLAY_LIST_ITEM:
|
||||
isBlockLine = PR_TRUE;
|
||||
nsStyleSpacing* spacing = (nsStyleSpacing*)
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kid, kidMargin);
|
||||
|
||||
// Calculate top margin by collapsing with previous bottom margin
|
||||
// if any.
|
||||
nscoord maxNegTopMargin = 0;
|
||||
nscoord maxPosTopMargin = 0;
|
||||
if (spacing->mMargin.top < 0) {
|
||||
maxNegTopMargin = -spacing->mMargin.top;
|
||||
if (kidMargin.top < 0) {
|
||||
maxNegTopMargin = -kidMargin.top;
|
||||
} else {
|
||||
maxPosTopMargin = spacing->mMargin.top;
|
||||
maxPosTopMargin = kidMargin.top;
|
||||
}
|
||||
nscoord maxPos = PR_MAX(aState.mPrevMaxPosBottomMargin, maxPosTopMargin);
|
||||
nscoord maxNeg = PR_MAX(aState.mPrevMaxNegBottomMargin, maxNegTopMargin);
|
||||
topMargin = maxPos - maxNeg;
|
||||
|
||||
// Save away bottom information for later promotion into aState
|
||||
if (spacing->mMargin.bottom < 0) {
|
||||
maxNegBottomMargin = -spacing->mMargin.bottom;
|
||||
if (kidMargin.bottom < 0) {
|
||||
maxNegBottomMargin = -kidMargin.bottom;
|
||||
} else {
|
||||
maxPosBottomMargin = spacing->mMargin.bottom;
|
||||
maxPosBottomMargin = kidMargin.bottom;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1005,9 +1009,9 @@ nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
|
|||
nsStylePosition* myPosition = (nsStylePosition*)
|
||||
mStyleContext->GetData(kStylePositionSID);
|
||||
|
||||
aState.mY = mySpacing->mBorderPadding.top;
|
||||
aState.mX = mySpacing->mBorderPadding.left;
|
||||
aState.mBorderPadding = mySpacing->mBorderPadding;
|
||||
mySpacing->CalcBorderPaddingFor(this, aState.mBorderPadding);
|
||||
aState.mY = aState.mBorderPadding.top;
|
||||
aState.mX = aState.mBorderPadding.left;
|
||||
|
||||
if (aState.mUnconstrainedWidth) {
|
||||
// If our width is unconstrained don't bother futzing with the
|
||||
|
@ -1021,9 +1025,9 @@ nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
|
|||
// doesn't include the border+padding so we have to add that in
|
||||
// instead of subtracting it out of our maxsize.
|
||||
nscoord lr =
|
||||
mySpacing->mBorderPadding.left + mySpacing->mBorderPadding.right;
|
||||
aState.mBorderPadding.left + aState.mBorderPadding.right;
|
||||
nscoord tb =
|
||||
mySpacing->mBorderPadding.top + mySpacing->mBorderPadding.bottom;
|
||||
aState.mBorderPadding.top + aState.mBorderPadding.bottom;
|
||||
|
||||
// Get and apply the stylistic size. Note: do not limit the
|
||||
// height until we are done reflowing.
|
||||
|
|
|
@ -166,14 +166,16 @@ nsresult nsBlockReflowState::RecoverState(nsLineData* aLine)
|
|||
|
||||
// If the previous line is a block, then factor in its bottom margin
|
||||
if (prevLine->mIsBlock) {
|
||||
nsStyleSpacing* spacing;
|
||||
nsStyleSpacing* kidSpacing;
|
||||
nsIFrame* kid = prevLine->mFirstChild;
|
||||
|
||||
kid->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)spacing);
|
||||
if (spacing->mMargin.bottom < 0) {
|
||||
mPrevMaxNegBottomMargin = -spacing->mMargin.bottom;
|
||||
kid->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)kidSpacing);
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kid, kidMargin);
|
||||
if (kidMargin.bottom < 0) {
|
||||
mPrevMaxNegBottomMargin = -kidMargin.bottom;
|
||||
} else {
|
||||
mPrevMaxPosBottomMargin = spacing->mMargin.bottom;
|
||||
mPrevMaxPosBottomMargin = kidMargin.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -554,27 +556,29 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
|
|||
case NS_STYLE_DISPLAY_BLOCK:
|
||||
case NS_STYLE_DISPLAY_LIST_ITEM:
|
||||
isBlockLine = PR_TRUE;
|
||||
nsStyleSpacing* spacing = (nsStyleSpacing*)
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kid, kidMargin);
|
||||
|
||||
// Calculate top margin by collapsing with previous bottom margin
|
||||
// if any.
|
||||
nscoord maxNegTopMargin = 0;
|
||||
nscoord maxPosTopMargin = 0;
|
||||
if (spacing->mMargin.top < 0) {
|
||||
maxNegTopMargin = -spacing->mMargin.top;
|
||||
if (kidMargin.top < 0) {
|
||||
maxNegTopMargin = -kidMargin.top;
|
||||
} else {
|
||||
maxPosTopMargin = spacing->mMargin.top;
|
||||
maxPosTopMargin = kidMargin.top;
|
||||
}
|
||||
nscoord maxPos = PR_MAX(aState.mPrevMaxPosBottomMargin, maxPosTopMargin);
|
||||
nscoord maxNeg = PR_MAX(aState.mPrevMaxNegBottomMargin, maxNegTopMargin);
|
||||
topMargin = maxPos - maxNeg;
|
||||
|
||||
// Save away bottom information for later promotion into aState
|
||||
if (spacing->mMargin.bottom < 0) {
|
||||
maxNegBottomMargin = -spacing->mMargin.bottom;
|
||||
if (kidMargin.bottom < 0) {
|
||||
maxNegBottomMargin = -kidMargin.bottom;
|
||||
} else {
|
||||
maxPosBottomMargin = spacing->mMargin.bottom;
|
||||
maxPosBottomMargin = kidMargin.bottom;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1005,9 +1009,9 @@ nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
|
|||
nsStylePosition* myPosition = (nsStylePosition*)
|
||||
mStyleContext->GetData(kStylePositionSID);
|
||||
|
||||
aState.mY = mySpacing->mBorderPadding.top;
|
||||
aState.mX = mySpacing->mBorderPadding.left;
|
||||
aState.mBorderPadding = mySpacing->mBorderPadding;
|
||||
mySpacing->CalcBorderPaddingFor(this, aState.mBorderPadding);
|
||||
aState.mY = aState.mBorderPadding.top;
|
||||
aState.mX = aState.mBorderPadding.left;
|
||||
|
||||
if (aState.mUnconstrainedWidth) {
|
||||
// If our width is unconstrained don't bother futzing with the
|
||||
|
@ -1021,9 +1025,9 @@ nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
|
|||
// doesn't include the border+padding so we have to add that in
|
||||
// instead of subtracting it out of our maxsize.
|
||||
nscoord lr =
|
||||
mySpacing->mBorderPadding.left + mySpacing->mBorderPadding.right;
|
||||
aState.mBorderPadding.left + aState.mBorderPadding.right;
|
||||
nscoord tb =
|
||||
mySpacing->mBorderPadding.top + mySpacing->mBorderPadding.bottom;
|
||||
aState.mBorderPadding.top + aState.mBorderPadding.bottom;
|
||||
|
||||
// Get and apply the stylistic size. Note: do not limit the
|
||||
// height until we are done reflowing.
|
||||
|
|
|
@ -166,14 +166,16 @@ nsresult nsBlockReflowState::RecoverState(nsLineData* aLine)
|
|||
|
||||
// If the previous line is a block, then factor in its bottom margin
|
||||
if (prevLine->mIsBlock) {
|
||||
nsStyleSpacing* spacing;
|
||||
nsStyleSpacing* kidSpacing;
|
||||
nsIFrame* kid = prevLine->mFirstChild;
|
||||
|
||||
kid->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)spacing);
|
||||
if (spacing->mMargin.bottom < 0) {
|
||||
mPrevMaxNegBottomMargin = -spacing->mMargin.bottom;
|
||||
kid->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)kidSpacing);
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kid, kidMargin);
|
||||
if (kidMargin.bottom < 0) {
|
||||
mPrevMaxNegBottomMargin = -kidMargin.bottom;
|
||||
} else {
|
||||
mPrevMaxPosBottomMargin = spacing->mMargin.bottom;
|
||||
mPrevMaxPosBottomMargin = kidMargin.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -554,27 +556,29 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
|
|||
case NS_STYLE_DISPLAY_BLOCK:
|
||||
case NS_STYLE_DISPLAY_LIST_ITEM:
|
||||
isBlockLine = PR_TRUE;
|
||||
nsStyleSpacing* spacing = (nsStyleSpacing*)
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kid, kidMargin);
|
||||
|
||||
// Calculate top margin by collapsing with previous bottom margin
|
||||
// if any.
|
||||
nscoord maxNegTopMargin = 0;
|
||||
nscoord maxPosTopMargin = 0;
|
||||
if (spacing->mMargin.top < 0) {
|
||||
maxNegTopMargin = -spacing->mMargin.top;
|
||||
if (kidMargin.top < 0) {
|
||||
maxNegTopMargin = -kidMargin.top;
|
||||
} else {
|
||||
maxPosTopMargin = spacing->mMargin.top;
|
||||
maxPosTopMargin = kidMargin.top;
|
||||
}
|
||||
nscoord maxPos = PR_MAX(aState.mPrevMaxPosBottomMargin, maxPosTopMargin);
|
||||
nscoord maxNeg = PR_MAX(aState.mPrevMaxNegBottomMargin, maxNegTopMargin);
|
||||
topMargin = maxPos - maxNeg;
|
||||
|
||||
// Save away bottom information for later promotion into aState
|
||||
if (spacing->mMargin.bottom < 0) {
|
||||
maxNegBottomMargin = -spacing->mMargin.bottom;
|
||||
if (kidMargin.bottom < 0) {
|
||||
maxNegBottomMargin = -kidMargin.bottom;
|
||||
} else {
|
||||
maxPosBottomMargin = spacing->mMargin.bottom;
|
||||
maxPosBottomMargin = kidMargin.bottom;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1005,9 +1009,9 @@ nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
|
|||
nsStylePosition* myPosition = (nsStylePosition*)
|
||||
mStyleContext->GetData(kStylePositionSID);
|
||||
|
||||
aState.mY = mySpacing->mBorderPadding.top;
|
||||
aState.mX = mySpacing->mBorderPadding.left;
|
||||
aState.mBorderPadding = mySpacing->mBorderPadding;
|
||||
mySpacing->CalcBorderPaddingFor(this, aState.mBorderPadding);
|
||||
aState.mY = aState.mBorderPadding.top;
|
||||
aState.mX = aState.mBorderPadding.left;
|
||||
|
||||
if (aState.mUnconstrainedWidth) {
|
||||
// If our width is unconstrained don't bother futzing with the
|
||||
|
@ -1021,9 +1025,9 @@ nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
|
|||
// doesn't include the border+padding so we have to add that in
|
||||
// instead of subtracting it out of our maxsize.
|
||||
nscoord lr =
|
||||
mySpacing->mBorderPadding.left + mySpacing->mBorderPadding.right;
|
||||
aState.mBorderPadding.left + aState.mBorderPadding.right;
|
||||
nscoord tb =
|
||||
mySpacing->mBorderPadding.top + mySpacing->mBorderPadding.bottom;
|
||||
aState.mBorderPadding.top + aState.mBorderPadding.bottom;
|
||||
|
||||
// Get and apply the stylistic size. Note: do not limit the
|
||||
// height until we are done reflowing.
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "nsPlaceholderFrame.h"
|
||||
#include "nsIContentDelegate.h"
|
||||
|
||||
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
|
||||
static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
|
||||
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
|
||||
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
|
||||
static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
|
||||
|
@ -61,12 +61,12 @@ NS_METHOD nsHTMLContainerFrame::Paint(nsIPresContext& aPresContext,
|
|||
PRIntn skipSides = GetSkipSides();
|
||||
nsStyleColor* color =
|
||||
(nsStyleColor*)mStyleContext->GetData(kStyleColorSID);
|
||||
nsStyleBorder* border =
|
||||
(nsStyleBorder*)mStyleContext->GetData(kStyleBorderSID);
|
||||
nsStyleSpacing* spacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *color);
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *border, skipSides);
|
||||
aDirtyRect, mRect, *spacing, skipSides);
|
||||
}
|
||||
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect);
|
||||
|
|
|
@ -58,7 +58,7 @@ class nsInlineState
|
|||
{
|
||||
public:
|
||||
nsStyleFont* font; // style font
|
||||
nsStyleSpacing* spacing; // style spacing
|
||||
nsMargin borderPadding; // inner margin
|
||||
nsSize mStyleSize;
|
||||
PRIntn mStyleSizeFlags;
|
||||
nsSize availSize; // available space in which to reflow (starts as max size minus insets)
|
||||
|
@ -73,14 +73,14 @@ public:
|
|||
|
||||
// Constructor
|
||||
nsInlineState(nsStyleFont* aStyleFont,
|
||||
nsStyleSpacing* aSpacing,
|
||||
const nsMargin& aBorderPadding,
|
||||
const nsSize& aMaxSize,
|
||||
nsSize* aMaxElementSize)
|
||||
: x(aSpacing->mBorderPadding.left), // determined by inner edge
|
||||
y(aSpacing->mBorderPadding.top) // determined by inner edge
|
||||
: x(aBorderPadding.left), // determined by inner edge
|
||||
y(aBorderPadding.top) // determined by inner edge
|
||||
{
|
||||
font = aStyleFont;
|
||||
spacing = aSpacing;
|
||||
borderPadding = aBorderPadding;
|
||||
|
||||
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE);
|
||||
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE);
|
||||
|
@ -89,11 +89,11 @@ public:
|
|||
// needed for border/padding
|
||||
availSize.width = aMaxSize.width;
|
||||
if (PR_FALSE == unconstrainedWidth) {
|
||||
availSize.width -= aSpacing->mBorderPadding.left + aSpacing->mBorderPadding.right;
|
||||
availSize.width -= aBorderPadding.left + aBorderPadding.right;
|
||||
}
|
||||
availSize.height = aMaxSize.height;
|
||||
if (PR_FALSE == unconstrainedHeight) {
|
||||
availSize.height -= aSpacing->mBorderPadding.top + aSpacing->mBorderPadding.bottom;
|
||||
availSize.height -= aBorderPadding.top + aBorderPadding.bottom;
|
||||
}
|
||||
|
||||
// Initialize max element size
|
||||
|
@ -725,7 +725,9 @@ NS_METHOD nsInlineFrame::ResizeReflow(nsIPresContext* aPresContext,
|
|||
|
||||
// Initialize our reflow state. We must wait until after we've processed
|
||||
// the overflow list, because our first content offset might change
|
||||
nsInlineState state(styleFont, styleSpacing, aMaxSize, aMaxElementSize);
|
||||
nsMargin borderPadding;
|
||||
styleSpacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
nsInlineState state(styleFont, borderPadding, aMaxSize, aMaxElementSize);
|
||||
InitializeState(aPresContext, state);
|
||||
state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset);
|
||||
|
||||
|
@ -766,7 +768,7 @@ NS_METHOD nsInlineFrame::ResizeReflow(nsIPresContext* aPresContext,
|
|||
// Vertically align the children
|
||||
nscoord lineHeight =
|
||||
nsCSSLayout::VerticallyAlignChildren(aPresContext, this, styleFont,
|
||||
styleSpacing->mBorderPadding.top,
|
||||
borderPadding.top,
|
||||
mFirstChild, mChildCount,
|
||||
state.ascents, state.maxAscent);
|
||||
|
||||
|
@ -789,23 +791,21 @@ nsInlineFrame::ComputeFinalSize(nsIPresContext* aPresContext,
|
|||
nsInlineState& aState,
|
||||
nsReflowMetrics& aDesiredSize)
|
||||
{
|
||||
nsStyleSpacing* s = aState.spacing;
|
||||
|
||||
// Compute default size
|
||||
aDesiredSize.width = aState.x + s->mBorderPadding.right;
|
||||
aDesiredSize.ascent = s->mBorderPadding.top + aState.maxAscent;
|
||||
aDesiredSize.descent = aState.maxDescent + s->mBorderPadding.bottom;
|
||||
aDesiredSize.width = aState.x + aState.borderPadding.right;
|
||||
aDesiredSize.ascent = aState.borderPadding.top + aState.maxAscent;
|
||||
aDesiredSize.descent = aState.maxDescent + aState.borderPadding.bottom;
|
||||
aDesiredSize.height = aDesiredSize.ascent + aDesiredSize.descent;
|
||||
|
||||
// Apply width/height style properties
|
||||
PRIntn ss = aState.mStyleSizeFlags;
|
||||
if (0 != (ss & NS_SIZE_HAS_WIDTH)) {
|
||||
aDesiredSize.width = s->mBorderPadding.left + aState.mStyleSize.width +
|
||||
s->mBorderPadding.right;
|
||||
aDesiredSize.width = aState.borderPadding.left + aState.mStyleSize.width +
|
||||
aState.borderPadding.right;
|
||||
}
|
||||
if (0 != (ss & NS_SIZE_HAS_HEIGHT)) {
|
||||
aDesiredSize.height = s->mBorderPadding.top + aState.mStyleSize.height +
|
||||
s->mBorderPadding.bottom;
|
||||
aDesiredSize.height = aState.borderPadding.top + aState.mStyleSize.height +
|
||||
aState.borderPadding.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -974,10 +974,11 @@ NS_METHOD nsInlineFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
|
||||
nscoord lineHeight;
|
||||
nsIFrame* kidFrame;
|
||||
PRInt32 kidIndex;
|
||||
|
||||
nsInlineState state(styleFont, styleSpacing, aMaxSize, nsnull);
|
||||
nsMargin borderPadding;
|
||||
styleSpacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
nsInlineState state(styleFont, borderPadding, aMaxSize, nsnull);
|
||||
InitializeState(aPresContext, state);
|
||||
state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset);
|
||||
|
||||
|
@ -990,7 +991,7 @@ NS_METHOD nsInlineFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|||
|
||||
// Vertically align the children
|
||||
lineHeight = nsCSSLayout::VerticallyAlignChildren(aPresContext, this,
|
||||
styleFont, styleSpacing->mBorderPadding.top, mFirstChild,
|
||||
styleFont, borderPadding.top, mFirstChild,
|
||||
mChildCount, state.ascents, state.maxAscent);
|
||||
|
||||
ComputeFinalSize(aPresContext, state, aDesiredSize);
|
||||
|
@ -1005,7 +1006,7 @@ NS_METHOD nsInlineFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|||
|
||||
// Vertically align the children
|
||||
lineHeight = nsCSSLayout::VerticallyAlignChildren(aPresContext, this,
|
||||
styleFont, styleSpacing->mBorderPadding.top, mFirstChild,
|
||||
styleFont, borderPadding.top, mFirstChild,
|
||||
mChildCount, state.ascents, state.maxAscent);
|
||||
|
||||
ComputeFinalSize(aPresContext, state, aDesiredSize);
|
||||
|
@ -1091,7 +1092,7 @@ NS_METHOD nsInlineFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|||
|
||||
// Vertically align the children
|
||||
lineHeight = nsCSSLayout::VerticallyAlignChildren(aPresContext, this,
|
||||
styleFont, styleSpacing->mBorderPadding.top, mFirstChild,
|
||||
styleFont, borderPadding.top, mFirstChild,
|
||||
mChildCount, state.ascents, state.maxAscent);
|
||||
|
||||
ComputeFinalSize(aPresContext, state, aDesiredSize);
|
||||
|
@ -1128,8 +1129,7 @@ nsInlineFrame::AdjustChildren(nsIPresContext* aPresContext,
|
|||
nsReflowMetrics& aKidMetrics,
|
||||
ReflowStatus aKidReflowStatus)
|
||||
{
|
||||
nsStyleSpacing* spacing = aState.spacing;
|
||||
nscoord xr = aState.availSize.width + spacing->mBorderPadding.left;
|
||||
nscoord xr = aState.availSize.width + aState.borderPadding.left;
|
||||
nscoord remainingSpace = xr - aState.x;
|
||||
nscoord x = aState.x;
|
||||
|
||||
|
@ -1147,7 +1147,7 @@ nsInlineFrame::AdjustChildren(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
// Vertically align the children
|
||||
const nsMargin& insets = spacing->mBorderPadding;
|
||||
const nsMargin& insets = aState.borderPadding;
|
||||
nsCSSLayout::VerticallyAlignChildren(aPresContext, this, aState.font,
|
||||
insets.top, mFirstChild, mChildCount,
|
||||
aState.ascents, aState.maxAscent);
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsCSSRendering.h"
|
||||
|
||||
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
|
||||
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
|
||||
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
|
||||
static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
|
||||
|
@ -39,12 +38,12 @@ NS_METHOD nsLeafFrame::Paint(nsIPresContext& aPresContext,
|
|||
{
|
||||
nsStyleColor* myColor =
|
||||
(nsStyleColor*)mStyleContext->GetData(kStyleColorSID);
|
||||
nsStyleBorder* myBorder =
|
||||
(nsStyleBorder*)mStyleContext->GetData(kStyleBorderSID);
|
||||
nsStyleSpacing* mySpacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *myColor);
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *myBorder, 0);
|
||||
aDirtyRect, mRect, *mySpacing, 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -93,8 +92,10 @@ void nsLeafFrame::AddBordersAndPadding(nsIPresContext* aPresContext,
|
|||
{
|
||||
nsStyleSpacing* space =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
aDesiredSize.width += space->mBorderPadding.left + space->mBorderPadding.right;
|
||||
aDesiredSize.height += space->mBorderPadding.top + space->mBorderPadding.bottom;
|
||||
nsMargin borderPadding;
|
||||
space->CalcBorderPaddingFor(this, borderPadding);
|
||||
aDesiredSize.width += borderPadding.left + borderPadding.right;
|
||||
aDesiredSize.height += borderPadding.top + borderPadding.bottom;
|
||||
aDesiredSize.ascent = aDesiredSize.height;
|
||||
aDesiredSize.descent = 0;
|
||||
}
|
||||
|
@ -104,12 +105,14 @@ void nsLeafFrame::GetInnerArea(nsIPresContext* aPresContext,
|
|||
{
|
||||
nsStyleSpacing* space =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
aInnerArea.x = space->mBorderPadding.left;
|
||||
aInnerArea.y = space->mBorderPadding.top;
|
||||
nsMargin borderPadding;
|
||||
space->CalcBorderPaddingFor(this, borderPadding);
|
||||
aInnerArea.x = borderPadding.left;
|
||||
aInnerArea.y = borderPadding.top;
|
||||
aInnerArea.width = mRect.width -
|
||||
(space->mBorderPadding.left + space->mBorderPadding.right);
|
||||
(borderPadding.left + borderPadding.right);
|
||||
aInnerArea.height = mRect.height -
|
||||
(space->mBorderPadding.top + space->mBorderPadding.bottom);
|
||||
(borderPadding.top + borderPadding.bottom);
|
||||
}
|
||||
|
||||
NS_METHOD nsLeafFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
|
||||
|
|
|
@ -333,7 +333,9 @@ nsLineLayout::WordBreakReflow()
|
|||
}
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
kidAvailSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(frame, kidMargin);
|
||||
kidAvailSize.width -= kidMargin.left + kidMargin.right;
|
||||
}
|
||||
|
||||
// Reflow that child of the block having set the reflow type so that
|
||||
|
@ -395,8 +397,10 @@ nsLineLayout::ReflowChild(nsReflowCommand* aReflowCommand)
|
|||
kidAvailSize.height = mMaxHeight;
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(mKidFrame, kidMargin);
|
||||
if (!mUnconstrainedWidth) {
|
||||
kidAvailSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
|
||||
kidAvailSize.width -= kidMargin.left + kidMargin.right;
|
||||
if (!isFirstChild && (kidAvailSize.width <= 0)) {
|
||||
// No room.
|
||||
return NS_LINE_LAYOUT_BREAK_BEFORE;
|
||||
|
@ -413,7 +417,7 @@ nsLineLayout::ReflowChild(nsReflowCommand* aReflowCommand)
|
|||
kidMaxElementSize = &maxElementSize;
|
||||
}
|
||||
mReflowResult = NS_LINE_LAYOUT_REFLOW_RESULT_NOT_AWARE;
|
||||
nscoord dx = mReflowData.mX + kidSpacing->mMargin.left;
|
||||
nscoord dx = mReflowData.mX + kidMargin.left;
|
||||
if (aReflowCommand) {
|
||||
nsIFrame* nextFrame;
|
||||
|
||||
|
@ -488,8 +492,8 @@ nsLineLayout::ReflowChild(nsReflowCommand* aReflowCommand)
|
|||
|
||||
// Advance
|
||||
// XXX RTL
|
||||
nscoord horizontalMargins = kidSpacing->mMargin.left +
|
||||
kidSpacing->mMargin.right;
|
||||
nscoord horizontalMargins = kidMargin.left +
|
||||
kidMargin.right;
|
||||
nscoord totalWidth = kidSize.width + horizontalMargins;
|
||||
mReflowData.mX += totalWidth;
|
||||
if (!mUnconstrainedWidth) {
|
||||
|
|
|
@ -166,14 +166,16 @@ nsresult nsBlockReflowState::RecoverState(nsLineData* aLine)
|
|||
|
||||
// If the previous line is a block, then factor in its bottom margin
|
||||
if (prevLine->mIsBlock) {
|
||||
nsStyleSpacing* spacing;
|
||||
nsStyleSpacing* kidSpacing;
|
||||
nsIFrame* kid = prevLine->mFirstChild;
|
||||
|
||||
kid->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)spacing);
|
||||
if (spacing->mMargin.bottom < 0) {
|
||||
mPrevMaxNegBottomMargin = -spacing->mMargin.bottom;
|
||||
kid->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)kidSpacing);
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kid, kidMargin);
|
||||
if (kidMargin.bottom < 0) {
|
||||
mPrevMaxNegBottomMargin = -kidMargin.bottom;
|
||||
} else {
|
||||
mPrevMaxPosBottomMargin = spacing->mMargin.bottom;
|
||||
mPrevMaxPosBottomMargin = kidMargin.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -554,27 +556,29 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
|
|||
case NS_STYLE_DISPLAY_BLOCK:
|
||||
case NS_STYLE_DISPLAY_LIST_ITEM:
|
||||
isBlockLine = PR_TRUE;
|
||||
nsStyleSpacing* spacing = (nsStyleSpacing*)
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kid, kidMargin);
|
||||
|
||||
// Calculate top margin by collapsing with previous bottom margin
|
||||
// if any.
|
||||
nscoord maxNegTopMargin = 0;
|
||||
nscoord maxPosTopMargin = 0;
|
||||
if (spacing->mMargin.top < 0) {
|
||||
maxNegTopMargin = -spacing->mMargin.top;
|
||||
if (kidMargin.top < 0) {
|
||||
maxNegTopMargin = -kidMargin.top;
|
||||
} else {
|
||||
maxPosTopMargin = spacing->mMargin.top;
|
||||
maxPosTopMargin = kidMargin.top;
|
||||
}
|
||||
nscoord maxPos = PR_MAX(aState.mPrevMaxPosBottomMargin, maxPosTopMargin);
|
||||
nscoord maxNeg = PR_MAX(aState.mPrevMaxNegBottomMargin, maxNegTopMargin);
|
||||
topMargin = maxPos - maxNeg;
|
||||
|
||||
// Save away bottom information for later promotion into aState
|
||||
if (spacing->mMargin.bottom < 0) {
|
||||
maxNegBottomMargin = -spacing->mMargin.bottom;
|
||||
if (kidMargin.bottom < 0) {
|
||||
maxNegBottomMargin = -kidMargin.bottom;
|
||||
} else {
|
||||
maxPosBottomMargin = spacing->mMargin.bottom;
|
||||
maxPosBottomMargin = kidMargin.bottom;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1005,9 +1009,9 @@ nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
|
|||
nsStylePosition* myPosition = (nsStylePosition*)
|
||||
mStyleContext->GetData(kStylePositionSID);
|
||||
|
||||
aState.mY = mySpacing->mBorderPadding.top;
|
||||
aState.mX = mySpacing->mBorderPadding.left;
|
||||
aState.mBorderPadding = mySpacing->mBorderPadding;
|
||||
mySpacing->CalcBorderPaddingFor(this, aState.mBorderPadding);
|
||||
aState.mY = aState.mBorderPadding.top;
|
||||
aState.mX = aState.mBorderPadding.left;
|
||||
|
||||
if (aState.mUnconstrainedWidth) {
|
||||
// If our width is unconstrained don't bother futzing with the
|
||||
|
@ -1021,9 +1025,9 @@ nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
|
|||
// doesn't include the border+padding so we have to add that in
|
||||
// instead of subtracting it out of our maxsize.
|
||||
nscoord lr =
|
||||
mySpacing->mBorderPadding.left + mySpacing->mBorderPadding.right;
|
||||
aState.mBorderPadding.left + aState.mBorderPadding.right;
|
||||
nscoord tb =
|
||||
mySpacing->mBorderPadding.top + mySpacing->mBorderPadding.bottom;
|
||||
aState.mBorderPadding.top + aState.mBorderPadding.bottom;
|
||||
|
||||
// Get and apply the stylistic size. Note: do not limit the
|
||||
// height until we are done reflowing.
|
||||
|
|
|
@ -166,14 +166,16 @@ nsresult nsBlockReflowState::RecoverState(nsLineData* aLine)
|
|||
|
||||
// If the previous line is a block, then factor in its bottom margin
|
||||
if (prevLine->mIsBlock) {
|
||||
nsStyleSpacing* spacing;
|
||||
nsStyleSpacing* kidSpacing;
|
||||
nsIFrame* kid = prevLine->mFirstChild;
|
||||
|
||||
kid->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)spacing);
|
||||
if (spacing->mMargin.bottom < 0) {
|
||||
mPrevMaxNegBottomMargin = -spacing->mMargin.bottom;
|
||||
kid->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)kidSpacing);
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kid, kidMargin);
|
||||
if (kidMargin.bottom < 0) {
|
||||
mPrevMaxNegBottomMargin = -kidMargin.bottom;
|
||||
} else {
|
||||
mPrevMaxPosBottomMargin = spacing->mMargin.bottom;
|
||||
mPrevMaxPosBottomMargin = kidMargin.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -554,27 +556,29 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
|
|||
case NS_STYLE_DISPLAY_BLOCK:
|
||||
case NS_STYLE_DISPLAY_LIST_ITEM:
|
||||
isBlockLine = PR_TRUE;
|
||||
nsStyleSpacing* spacing = (nsStyleSpacing*)
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kid, kidMargin);
|
||||
|
||||
// Calculate top margin by collapsing with previous bottom margin
|
||||
// if any.
|
||||
nscoord maxNegTopMargin = 0;
|
||||
nscoord maxPosTopMargin = 0;
|
||||
if (spacing->mMargin.top < 0) {
|
||||
maxNegTopMargin = -spacing->mMargin.top;
|
||||
if (kidMargin.top < 0) {
|
||||
maxNegTopMargin = -kidMargin.top;
|
||||
} else {
|
||||
maxPosTopMargin = spacing->mMargin.top;
|
||||
maxPosTopMargin = kidMargin.top;
|
||||
}
|
||||
nscoord maxPos = PR_MAX(aState.mPrevMaxPosBottomMargin, maxPosTopMargin);
|
||||
nscoord maxNeg = PR_MAX(aState.mPrevMaxNegBottomMargin, maxNegTopMargin);
|
||||
topMargin = maxPos - maxNeg;
|
||||
|
||||
// Save away bottom information for later promotion into aState
|
||||
if (spacing->mMargin.bottom < 0) {
|
||||
maxNegBottomMargin = -spacing->mMargin.bottom;
|
||||
if (kidMargin.bottom < 0) {
|
||||
maxNegBottomMargin = -kidMargin.bottom;
|
||||
} else {
|
||||
maxPosBottomMargin = spacing->mMargin.bottom;
|
||||
maxPosBottomMargin = kidMargin.bottom;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1005,9 +1009,9 @@ nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
|
|||
nsStylePosition* myPosition = (nsStylePosition*)
|
||||
mStyleContext->GetData(kStylePositionSID);
|
||||
|
||||
aState.mY = mySpacing->mBorderPadding.top;
|
||||
aState.mX = mySpacing->mBorderPadding.left;
|
||||
aState.mBorderPadding = mySpacing->mBorderPadding;
|
||||
mySpacing->CalcBorderPaddingFor(this, aState.mBorderPadding);
|
||||
aState.mY = aState.mBorderPadding.top;
|
||||
aState.mX = aState.mBorderPadding.left;
|
||||
|
||||
if (aState.mUnconstrainedWidth) {
|
||||
// If our width is unconstrained don't bother futzing with the
|
||||
|
@ -1021,9 +1025,9 @@ nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
|
|||
// doesn't include the border+padding so we have to add that in
|
||||
// instead of subtracting it out of our maxsize.
|
||||
nscoord lr =
|
||||
mySpacing->mBorderPadding.left + mySpacing->mBorderPadding.right;
|
||||
aState.mBorderPadding.left + aState.mBorderPadding.right;
|
||||
nscoord tb =
|
||||
mySpacing->mBorderPadding.top + mySpacing->mBorderPadding.bottom;
|
||||
aState.mBorderPadding.top + aState.mBorderPadding.bottom;
|
||||
|
||||
// Get and apply the stylistic size. Note: do not limit the
|
||||
// height until we are done reflowing.
|
||||
|
|
|
@ -166,14 +166,16 @@ nsresult nsBlockReflowState::RecoverState(nsLineData* aLine)
|
|||
|
||||
// If the previous line is a block, then factor in its bottom margin
|
||||
if (prevLine->mIsBlock) {
|
||||
nsStyleSpacing* spacing;
|
||||
nsStyleSpacing* kidSpacing;
|
||||
nsIFrame* kid = prevLine->mFirstChild;
|
||||
|
||||
kid->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)spacing);
|
||||
if (spacing->mMargin.bottom < 0) {
|
||||
mPrevMaxNegBottomMargin = -spacing->mMargin.bottom;
|
||||
kid->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)kidSpacing);
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kid, kidMargin);
|
||||
if (kidMargin.bottom < 0) {
|
||||
mPrevMaxNegBottomMargin = -kidMargin.bottom;
|
||||
} else {
|
||||
mPrevMaxPosBottomMargin = spacing->mMargin.bottom;
|
||||
mPrevMaxPosBottomMargin = kidMargin.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -554,27 +556,29 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
|
|||
case NS_STYLE_DISPLAY_BLOCK:
|
||||
case NS_STYLE_DISPLAY_LIST_ITEM:
|
||||
isBlockLine = PR_TRUE;
|
||||
nsStyleSpacing* spacing = (nsStyleSpacing*)
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kid, kidMargin);
|
||||
|
||||
// Calculate top margin by collapsing with previous bottom margin
|
||||
// if any.
|
||||
nscoord maxNegTopMargin = 0;
|
||||
nscoord maxPosTopMargin = 0;
|
||||
if (spacing->mMargin.top < 0) {
|
||||
maxNegTopMargin = -spacing->mMargin.top;
|
||||
if (kidMargin.top < 0) {
|
||||
maxNegTopMargin = -kidMargin.top;
|
||||
} else {
|
||||
maxPosTopMargin = spacing->mMargin.top;
|
||||
maxPosTopMargin = kidMargin.top;
|
||||
}
|
||||
nscoord maxPos = PR_MAX(aState.mPrevMaxPosBottomMargin, maxPosTopMargin);
|
||||
nscoord maxNeg = PR_MAX(aState.mPrevMaxNegBottomMargin, maxNegTopMargin);
|
||||
topMargin = maxPos - maxNeg;
|
||||
|
||||
// Save away bottom information for later promotion into aState
|
||||
if (spacing->mMargin.bottom < 0) {
|
||||
maxNegBottomMargin = -spacing->mMargin.bottom;
|
||||
if (kidMargin.bottom < 0) {
|
||||
maxNegBottomMargin = -kidMargin.bottom;
|
||||
} else {
|
||||
maxPosBottomMargin = spacing->mMargin.bottom;
|
||||
maxPosBottomMargin = kidMargin.bottom;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1005,9 +1009,9 @@ nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
|
|||
nsStylePosition* myPosition = (nsStylePosition*)
|
||||
mStyleContext->GetData(kStylePositionSID);
|
||||
|
||||
aState.mY = mySpacing->mBorderPadding.top;
|
||||
aState.mX = mySpacing->mBorderPadding.left;
|
||||
aState.mBorderPadding = mySpacing->mBorderPadding;
|
||||
mySpacing->CalcBorderPaddingFor(this, aState.mBorderPadding);
|
||||
aState.mY = aState.mBorderPadding.top;
|
||||
aState.mX = aState.mBorderPadding.left;
|
||||
|
||||
if (aState.mUnconstrainedWidth) {
|
||||
// If our width is unconstrained don't bother futzing with the
|
||||
|
@ -1021,9 +1025,9 @@ nsBlockFrame::InitializeState(nsIPresContext* aPresContext,
|
|||
// doesn't include the border+padding so we have to add that in
|
||||
// instead of subtracting it out of our maxsize.
|
||||
nscoord lr =
|
||||
mySpacing->mBorderPadding.left + mySpacing->mBorderPadding.right;
|
||||
aState.mBorderPadding.left + aState.mBorderPadding.right;
|
||||
nscoord tb =
|
||||
mySpacing->mBorderPadding.top + mySpacing->mBorderPadding.bottom;
|
||||
aState.mBorderPadding.top + aState.mBorderPadding.bottom;
|
||||
|
||||
// Get and apply the stylistic size. Note: do not limit the
|
||||
// height until we are done reflowing.
|
||||
|
|
|
@ -102,7 +102,7 @@ void nsBodyFrame::CreateColumnFrame(nsIPresContext* aPresContext)
|
|||
}
|
||||
|
||||
nsSize nsBodyFrame::GetColumnAvailSpace(nsIPresContext* aPresContext,
|
||||
nsStyleSpacing* aSpacing,
|
||||
const nsMargin& aBorderPadding,
|
||||
const nsSize& aMaxSize)
|
||||
{
|
||||
nsSize result(aMaxSize);
|
||||
|
@ -112,8 +112,8 @@ nsSize nsBodyFrame::GetColumnAvailSpace(nsIPresContext* aPresContext,
|
|||
if (!IsPseudoFrame()) {
|
||||
// If our width is constrained then subtract for the border/padding
|
||||
if (aMaxSize.width != NS_UNCONSTRAINEDSIZE) {
|
||||
result.width -= aSpacing->mBorderPadding.left +
|
||||
aSpacing->mBorderPadding.right;
|
||||
result.width -= aBorderPadding.left +
|
||||
aBorderPadding.right;
|
||||
if (! aPresContext->IsPaginated()) {
|
||||
nsIDeviceContext* dc = aPresContext->GetDeviceContext();
|
||||
result.width -= NS_TO_INT_ROUND(dc->GetScrollBarWidth());
|
||||
|
@ -122,8 +122,8 @@ nsSize nsBodyFrame::GetColumnAvailSpace(nsIPresContext* aPresContext,
|
|||
}
|
||||
// If our height is constrained then subtract for the border/padding
|
||||
if (aMaxSize.height != NS_UNCONSTRAINEDSIZE) {
|
||||
result.height -= aSpacing->mBorderPadding.top +
|
||||
aSpacing->mBorderPadding.bottom;
|
||||
result.height -= aBorderPadding.top +
|
||||
aBorderPadding.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,17 +152,19 @@ NS_METHOD nsBodyFrame::ResizeReflow(nsIPresContext* aPresContext,
|
|||
// Get our border/padding info
|
||||
nsStyleSpacing* mySpacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nsMargin borderPadding;
|
||||
mySpacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
|
||||
// Compute the column's max size
|
||||
nsSize columnMaxSize = GetColumnAvailSpace(aPresContext, mySpacing,
|
||||
nsSize columnMaxSize = GetColumnAvailSpace(aPresContext, borderPadding,
|
||||
aMaxSize);
|
||||
|
||||
// XXX Style code should be dealing with this...
|
||||
PRBool isPseudoFrame = IsPseudoFrame();
|
||||
nscoord leftInset = 0, topInset = 0;
|
||||
if (!isPseudoFrame) {
|
||||
leftInset = mySpacing->mBorderPadding.left;
|
||||
topInset = mySpacing->mBorderPadding.top;
|
||||
leftInset = borderPadding.left;
|
||||
topInset = borderPadding.top;
|
||||
}
|
||||
|
||||
// Get the column's desired rect
|
||||
|
@ -197,7 +199,7 @@ NS_METHOD nsBodyFrame::ResizeReflow(nsIPresContext* aPresContext,
|
|||
SetLastContentOffset(mFirstChild);
|
||||
|
||||
// Return our desired size. Take into account the y-most floater
|
||||
ComputeDesiredSize(desiredRect, aMaxSize, mySpacing,
|
||||
ComputeDesiredSize(desiredRect, aMaxSize, borderPadding,
|
||||
isPseudoFrame, aDesiredSize);
|
||||
}
|
||||
|
||||
|
@ -254,13 +256,15 @@ NS_METHOD nsBodyFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|||
// Get our border/padding info
|
||||
nsStyleSpacing* mySpacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nsMargin borderPadding;
|
||||
mySpacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
|
||||
// XXX Style code should be dealing with this...
|
||||
PRBool isPseudoFrame = IsPseudoFrame();
|
||||
nscoord leftInset = 0, topInset = 0;
|
||||
if (!isPseudoFrame) {
|
||||
leftInset = mySpacing->mBorderPadding.left;
|
||||
topInset = mySpacing->mBorderPadding.top;
|
||||
leftInset = borderPadding.left;
|
||||
topInset = borderPadding.top;
|
||||
}
|
||||
|
||||
mSpaceManager->Translate(leftInset, topInset);
|
||||
|
@ -269,7 +273,7 @@ NS_METHOD nsBodyFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|||
NS_ASSERTION(aReflowCommand.GetTarget() != this, "bad reflow command target");
|
||||
|
||||
// Compute the child frame's max size
|
||||
nsSize columnMaxSize = GetColumnAvailSpace(aPresContext, mySpacing,
|
||||
nsSize columnMaxSize = GetColumnAvailSpace(aPresContext, borderPadding,
|
||||
aMaxSize);
|
||||
|
||||
// Pass the command along to our column pseudo frame
|
||||
|
@ -290,7 +294,7 @@ NS_METHOD nsBodyFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|||
SetLastContentOffset(mFirstChild);
|
||||
|
||||
// Return our desired size
|
||||
ComputeDesiredSize(desiredRect, aMaxSize, mySpacing,
|
||||
ComputeDesiredSize(desiredRect, aMaxSize, borderPadding,
|
||||
isPseudoFrame, aDesiredSize);
|
||||
|
||||
mSpaceManager->Translate(-leftInset, -topInset);
|
||||
|
@ -300,7 +304,7 @@ NS_METHOD nsBodyFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|||
void
|
||||
nsBodyFrame::ComputeDesiredSize(const nsRect& aDesiredRect,
|
||||
const nsSize& aMaxSize,
|
||||
nsStyleSpacing* aSpacing,
|
||||
const nsMargin& aBorderPadding,
|
||||
PRBool aIsPseudoFrame,
|
||||
nsReflowMetrics& aDesiredSize)
|
||||
{
|
||||
|
@ -309,8 +313,8 @@ nsBodyFrame::ComputeDesiredSize(const nsRect& aDesiredRect,
|
|||
aDesiredSize.width = aDesiredRect.XMost();
|
||||
if (!aIsPseudoFrame) {
|
||||
aDesiredSize.width = PR_MAX(aDesiredSize.width, aMaxSize.width);
|
||||
aDesiredSize.height += aSpacing->mBorderPadding.top +
|
||||
aSpacing->mBorderPadding.bottom;
|
||||
aDesiredSize.height += aBorderPadding.top +
|
||||
aBorderPadding.bottom;
|
||||
}
|
||||
aDesiredSize.ascent = aDesiredSize.height;
|
||||
aDesiredSize.descent = 0;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
struct nsBodyReflowState;
|
||||
class SpaceManager;
|
||||
struct nsStyleSpacing;
|
||||
|
||||
class nsBodyFrame : public nsHTMLContainerFrame, public nsIAnchoredItems {
|
||||
public:
|
||||
|
@ -76,7 +75,7 @@ protected:
|
|||
|
||||
void ComputeDesiredSize(const nsRect& aDesiredRect,
|
||||
const nsSize& aMaxSize,
|
||||
nsStyleSpacing* aSpacing,
|
||||
const nsMargin& aBorderPadding,
|
||||
PRBool aIsPseudoFrame,
|
||||
nsReflowMetrics& aDesiredSize);
|
||||
|
||||
|
@ -87,7 +86,7 @@ private:
|
|||
|
||||
void CreateColumnFrame(nsIPresContext* aPresContext);
|
||||
nsSize GetColumnAvailSpace(nsIPresContext* aPresContext,
|
||||
nsStyleSpacing* aSpacing,
|
||||
const nsMargin& aBorderPadding,
|
||||
const nsSize& aMaxSize);
|
||||
};
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,92 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsColumnFrame_h___
|
||||
#define nsColumnFrame_h___
|
||||
|
||||
#include "nsHTMLContainerFrame.h"
|
||||
#include "nsIRunaround.h"
|
||||
|
||||
struct nsStyleSpacing;
|
||||
|
||||
struct ColumnReflowState;
|
||||
|
||||
class ColumnFrame : public nsHTMLContainerFrame, public nsIRunaround {
|
||||
public:
|
||||
ColumnFrame(nsIContent* aContent,
|
||||
PRInt32 aIndexInParent,
|
||||
nsIFrame* aParentFrame);
|
||||
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
|
||||
nsISpaceManager* aSpaceManager,
|
||||
const nsSize& aMaxSize,
|
||||
nsRect& aDesiredRect,
|
||||
nsSize* aMaxElementSize,
|
||||
ReflowStatus& aStatus);
|
||||
|
||||
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
|
||||
nsISpaceManager* aSpaceManager,
|
||||
const nsSize& aMaxSize,
|
||||
nsRect& aDesiredRect,
|
||||
nsReflowCommand& aReflowCommand,
|
||||
ReflowStatus& aStatus);
|
||||
|
||||
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
|
||||
nsIFrame* aParent,
|
||||
nsIFrame*& aContinuingFrame);
|
||||
|
||||
NS_IMETHOD ColumnFrame::ContentAppended(nsIPresShell* aShell,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIContent* aContainer);
|
||||
|
||||
// Debugging
|
||||
NS_IMETHOD ListTag(FILE* out = stdout) const;
|
||||
|
||||
protected:
|
||||
~ColumnFrame();
|
||||
|
||||
virtual PRIntn GetSkipSides() const;
|
||||
|
||||
nscoord GetTopMarginFor(nsIPresContext* aCX,
|
||||
ColumnReflowState& aState,
|
||||
nsIFrame* aKidFrame,
|
||||
nsStyleSpacing* aKidSpacing);
|
||||
|
||||
void PlaceChild(nsIPresContext* aPresContext,
|
||||
ColumnReflowState& aState,
|
||||
nsIFrame* aKidFrame,
|
||||
nsStyleSpacing* aKidSpacing,
|
||||
const nsRect& aKidRect,
|
||||
nsSize* aMaxElementSize,
|
||||
nsSize& aKidMaxElementSize);
|
||||
|
||||
PRBool ReflowMappedChildren(nsIPresContext* aPresContext,
|
||||
ColumnReflowState& aState,
|
||||
nsSize* aMaxElementSize);
|
||||
|
||||
PRBool PullUpChildren(nsIPresContext* aPresContext,
|
||||
ColumnReflowState& aState,
|
||||
nsSize* aMaxElementSize);
|
||||
|
||||
ReflowStatus ReflowUnmappedChildren(nsIPresContext* aPresContext,
|
||||
ColumnReflowState& aState,
|
||||
nsSize* aMaxElementSize);
|
||||
};
|
||||
|
||||
#endif /* nsColumnFrame_h___ */
|
|
@ -121,12 +121,14 @@ NS_METHOD HRuleFrame::Paint(nsIPresContext& aPresContext,
|
|||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nsStyleColor* color =
|
||||
(nsStyleColor*)mStyleContext->GetData(kStyleColorSID);
|
||||
nscoord x0 = spacing->mBorderPadding.left;
|
||||
nscoord y0 = spacing->mBorderPadding.top;
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
nscoord x0 = borderPadding.left;
|
||||
nscoord y0 = borderPadding.top;
|
||||
nscoord width = mRect.width -
|
||||
(spacing->mBorderPadding.left + spacing->mBorderPadding.right);
|
||||
(borderPadding.left + borderPadding.right);
|
||||
nscoord height = mRect.height -
|
||||
(spacing->mBorderPadding.top + spacing->mBorderPadding.bottom);
|
||||
(borderPadding.top + borderPadding.bottom);
|
||||
|
||||
// Center hrule vertically within the available space
|
||||
y0 += (height - thickness) / 2;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "nsPlaceholderFrame.h"
|
||||
#include "nsIContentDelegate.h"
|
||||
|
||||
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
|
||||
static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
|
||||
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
|
||||
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
|
||||
static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
|
||||
|
@ -61,12 +61,12 @@ NS_METHOD nsHTMLContainerFrame::Paint(nsIPresContext& aPresContext,
|
|||
PRIntn skipSides = GetSkipSides();
|
||||
nsStyleColor* color =
|
||||
(nsStyleColor*)mStyleContext->GetData(kStyleColorSID);
|
||||
nsStyleBorder* border =
|
||||
(nsStyleBorder*)mStyleContext->GetData(kStyleBorderSID);
|
||||
nsStyleSpacing* spacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *color);
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *border, skipSides);
|
||||
aDirtyRect, mRect, *spacing, skipSides);
|
||||
}
|
||||
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect);
|
||||
|
|
|
@ -58,7 +58,7 @@ class nsInlineState
|
|||
{
|
||||
public:
|
||||
nsStyleFont* font; // style font
|
||||
nsStyleSpacing* spacing; // style spacing
|
||||
nsMargin borderPadding; // inner margin
|
||||
nsSize mStyleSize;
|
||||
PRIntn mStyleSizeFlags;
|
||||
nsSize availSize; // available space in which to reflow (starts as max size minus insets)
|
||||
|
@ -73,14 +73,14 @@ public:
|
|||
|
||||
// Constructor
|
||||
nsInlineState(nsStyleFont* aStyleFont,
|
||||
nsStyleSpacing* aSpacing,
|
||||
const nsMargin& aBorderPadding,
|
||||
const nsSize& aMaxSize,
|
||||
nsSize* aMaxElementSize)
|
||||
: x(aSpacing->mBorderPadding.left), // determined by inner edge
|
||||
y(aSpacing->mBorderPadding.top) // determined by inner edge
|
||||
: x(aBorderPadding.left), // determined by inner edge
|
||||
y(aBorderPadding.top) // determined by inner edge
|
||||
{
|
||||
font = aStyleFont;
|
||||
spacing = aSpacing;
|
||||
borderPadding = aBorderPadding;
|
||||
|
||||
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE);
|
||||
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE);
|
||||
|
@ -89,11 +89,11 @@ public:
|
|||
// needed for border/padding
|
||||
availSize.width = aMaxSize.width;
|
||||
if (PR_FALSE == unconstrainedWidth) {
|
||||
availSize.width -= aSpacing->mBorderPadding.left + aSpacing->mBorderPadding.right;
|
||||
availSize.width -= aBorderPadding.left + aBorderPadding.right;
|
||||
}
|
||||
availSize.height = aMaxSize.height;
|
||||
if (PR_FALSE == unconstrainedHeight) {
|
||||
availSize.height -= aSpacing->mBorderPadding.top + aSpacing->mBorderPadding.bottom;
|
||||
availSize.height -= aBorderPadding.top + aBorderPadding.bottom;
|
||||
}
|
||||
|
||||
// Initialize max element size
|
||||
|
@ -725,7 +725,9 @@ NS_METHOD nsInlineFrame::ResizeReflow(nsIPresContext* aPresContext,
|
|||
|
||||
// Initialize our reflow state. We must wait until after we've processed
|
||||
// the overflow list, because our first content offset might change
|
||||
nsInlineState state(styleFont, styleSpacing, aMaxSize, aMaxElementSize);
|
||||
nsMargin borderPadding;
|
||||
styleSpacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
nsInlineState state(styleFont, borderPadding, aMaxSize, aMaxElementSize);
|
||||
InitializeState(aPresContext, state);
|
||||
state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset);
|
||||
|
||||
|
@ -766,7 +768,7 @@ NS_METHOD nsInlineFrame::ResizeReflow(nsIPresContext* aPresContext,
|
|||
// Vertically align the children
|
||||
nscoord lineHeight =
|
||||
nsCSSLayout::VerticallyAlignChildren(aPresContext, this, styleFont,
|
||||
styleSpacing->mBorderPadding.top,
|
||||
borderPadding.top,
|
||||
mFirstChild, mChildCount,
|
||||
state.ascents, state.maxAscent);
|
||||
|
||||
|
@ -789,23 +791,21 @@ nsInlineFrame::ComputeFinalSize(nsIPresContext* aPresContext,
|
|||
nsInlineState& aState,
|
||||
nsReflowMetrics& aDesiredSize)
|
||||
{
|
||||
nsStyleSpacing* s = aState.spacing;
|
||||
|
||||
// Compute default size
|
||||
aDesiredSize.width = aState.x + s->mBorderPadding.right;
|
||||
aDesiredSize.ascent = s->mBorderPadding.top + aState.maxAscent;
|
||||
aDesiredSize.descent = aState.maxDescent + s->mBorderPadding.bottom;
|
||||
aDesiredSize.width = aState.x + aState.borderPadding.right;
|
||||
aDesiredSize.ascent = aState.borderPadding.top + aState.maxAscent;
|
||||
aDesiredSize.descent = aState.maxDescent + aState.borderPadding.bottom;
|
||||
aDesiredSize.height = aDesiredSize.ascent + aDesiredSize.descent;
|
||||
|
||||
// Apply width/height style properties
|
||||
PRIntn ss = aState.mStyleSizeFlags;
|
||||
if (0 != (ss & NS_SIZE_HAS_WIDTH)) {
|
||||
aDesiredSize.width = s->mBorderPadding.left + aState.mStyleSize.width +
|
||||
s->mBorderPadding.right;
|
||||
aDesiredSize.width = aState.borderPadding.left + aState.mStyleSize.width +
|
||||
aState.borderPadding.right;
|
||||
}
|
||||
if (0 != (ss & NS_SIZE_HAS_HEIGHT)) {
|
||||
aDesiredSize.height = s->mBorderPadding.top + aState.mStyleSize.height +
|
||||
s->mBorderPadding.bottom;
|
||||
aDesiredSize.height = aState.borderPadding.top + aState.mStyleSize.height +
|
||||
aState.borderPadding.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -974,10 +974,11 @@ NS_METHOD nsInlineFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
|
||||
nscoord lineHeight;
|
||||
nsIFrame* kidFrame;
|
||||
PRInt32 kidIndex;
|
||||
|
||||
nsInlineState state(styleFont, styleSpacing, aMaxSize, nsnull);
|
||||
nsMargin borderPadding;
|
||||
styleSpacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
nsInlineState state(styleFont, borderPadding, aMaxSize, nsnull);
|
||||
InitializeState(aPresContext, state);
|
||||
state.SetNumAscents(mContent->ChildCount() - mFirstContentOffset);
|
||||
|
||||
|
@ -990,7 +991,7 @@ NS_METHOD nsInlineFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|||
|
||||
// Vertically align the children
|
||||
lineHeight = nsCSSLayout::VerticallyAlignChildren(aPresContext, this,
|
||||
styleFont, styleSpacing->mBorderPadding.top, mFirstChild,
|
||||
styleFont, borderPadding.top, mFirstChild,
|
||||
mChildCount, state.ascents, state.maxAscent);
|
||||
|
||||
ComputeFinalSize(aPresContext, state, aDesiredSize);
|
||||
|
@ -1005,7 +1006,7 @@ NS_METHOD nsInlineFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|||
|
||||
// Vertically align the children
|
||||
lineHeight = nsCSSLayout::VerticallyAlignChildren(aPresContext, this,
|
||||
styleFont, styleSpacing->mBorderPadding.top, mFirstChild,
|
||||
styleFont, borderPadding.top, mFirstChild,
|
||||
mChildCount, state.ascents, state.maxAscent);
|
||||
|
||||
ComputeFinalSize(aPresContext, state, aDesiredSize);
|
||||
|
@ -1091,7 +1092,7 @@ NS_METHOD nsInlineFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|||
|
||||
// Vertically align the children
|
||||
lineHeight = nsCSSLayout::VerticallyAlignChildren(aPresContext, this,
|
||||
styleFont, styleSpacing->mBorderPadding.top, mFirstChild,
|
||||
styleFont, borderPadding.top, mFirstChild,
|
||||
mChildCount, state.ascents, state.maxAscent);
|
||||
|
||||
ComputeFinalSize(aPresContext, state, aDesiredSize);
|
||||
|
@ -1128,8 +1129,7 @@ nsInlineFrame::AdjustChildren(nsIPresContext* aPresContext,
|
|||
nsReflowMetrics& aKidMetrics,
|
||||
ReflowStatus aKidReflowStatus)
|
||||
{
|
||||
nsStyleSpacing* spacing = aState.spacing;
|
||||
nscoord xr = aState.availSize.width + spacing->mBorderPadding.left;
|
||||
nscoord xr = aState.availSize.width + aState.borderPadding.left;
|
||||
nscoord remainingSpace = xr - aState.x;
|
||||
nscoord x = aState.x;
|
||||
|
||||
|
@ -1147,7 +1147,7 @@ nsInlineFrame::AdjustChildren(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
// Vertically align the children
|
||||
const nsMargin& insets = spacing->mBorderPadding;
|
||||
const nsMargin& insets = aState.borderPadding;
|
||||
nsCSSLayout::VerticallyAlignChildren(aPresContext, this, aState.font,
|
||||
insets.top, mFirstChild, mChildCount,
|
||||
aState.ascents, aState.maxAscent);
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsCSSRendering.h"
|
||||
|
||||
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
|
||||
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
|
||||
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
|
||||
static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
|
||||
|
@ -39,12 +38,12 @@ NS_METHOD nsLeafFrame::Paint(nsIPresContext& aPresContext,
|
|||
{
|
||||
nsStyleColor* myColor =
|
||||
(nsStyleColor*)mStyleContext->GetData(kStyleColorSID);
|
||||
nsStyleBorder* myBorder =
|
||||
(nsStyleBorder*)mStyleContext->GetData(kStyleBorderSID);
|
||||
nsStyleSpacing* mySpacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *myColor);
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *myBorder, 0);
|
||||
aDirtyRect, mRect, *mySpacing, 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -93,8 +92,10 @@ void nsLeafFrame::AddBordersAndPadding(nsIPresContext* aPresContext,
|
|||
{
|
||||
nsStyleSpacing* space =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
aDesiredSize.width += space->mBorderPadding.left + space->mBorderPadding.right;
|
||||
aDesiredSize.height += space->mBorderPadding.top + space->mBorderPadding.bottom;
|
||||
nsMargin borderPadding;
|
||||
space->CalcBorderPaddingFor(this, borderPadding);
|
||||
aDesiredSize.width += borderPadding.left + borderPadding.right;
|
||||
aDesiredSize.height += borderPadding.top + borderPadding.bottom;
|
||||
aDesiredSize.ascent = aDesiredSize.height;
|
||||
aDesiredSize.descent = 0;
|
||||
}
|
||||
|
@ -104,12 +105,14 @@ void nsLeafFrame::GetInnerArea(nsIPresContext* aPresContext,
|
|||
{
|
||||
nsStyleSpacing* space =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
aInnerArea.x = space->mBorderPadding.left;
|
||||
aInnerArea.y = space->mBorderPadding.top;
|
||||
nsMargin borderPadding;
|
||||
space->CalcBorderPaddingFor(this, borderPadding);
|
||||
aInnerArea.x = borderPadding.left;
|
||||
aInnerArea.y = borderPadding.top;
|
||||
aInnerArea.width = mRect.width -
|
||||
(space->mBorderPadding.left + space->mBorderPadding.right);
|
||||
(borderPadding.left + borderPadding.right);
|
||||
aInnerArea.height = mRect.height -
|
||||
(space->mBorderPadding.top + space->mBorderPadding.bottom);
|
||||
(borderPadding.top + borderPadding.bottom);
|
||||
}
|
||||
|
||||
NS_METHOD nsLeafFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
|
||||
|
|
|
@ -333,7 +333,9 @@ nsLineLayout::WordBreakReflow()
|
|||
}
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
kidAvailSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(frame, kidMargin);
|
||||
kidAvailSize.width -= kidMargin.left + kidMargin.right;
|
||||
}
|
||||
|
||||
// Reflow that child of the block having set the reflow type so that
|
||||
|
@ -395,8 +397,10 @@ nsLineLayout::ReflowChild(nsReflowCommand* aReflowCommand)
|
|||
kidAvailSize.height = mMaxHeight;
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(mKidFrame, kidMargin);
|
||||
if (!mUnconstrainedWidth) {
|
||||
kidAvailSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
|
||||
kidAvailSize.width -= kidMargin.left + kidMargin.right;
|
||||
if (!isFirstChild && (kidAvailSize.width <= 0)) {
|
||||
// No room.
|
||||
return NS_LINE_LAYOUT_BREAK_BEFORE;
|
||||
|
@ -413,7 +417,7 @@ nsLineLayout::ReflowChild(nsReflowCommand* aReflowCommand)
|
|||
kidMaxElementSize = &maxElementSize;
|
||||
}
|
||||
mReflowResult = NS_LINE_LAYOUT_REFLOW_RESULT_NOT_AWARE;
|
||||
nscoord dx = mReflowData.mX + kidSpacing->mMargin.left;
|
||||
nscoord dx = mReflowData.mX + kidMargin.left;
|
||||
if (aReflowCommand) {
|
||||
nsIFrame* nextFrame;
|
||||
|
||||
|
@ -488,8 +492,8 @@ nsLineLayout::ReflowChild(nsReflowCommand* aReflowCommand)
|
|||
|
||||
// Advance
|
||||
// XXX RTL
|
||||
nscoord horizontalMargins = kidSpacing->mMargin.left +
|
||||
kidSpacing->mMargin.right;
|
||||
nscoord horizontalMargins = kidMargin.left +
|
||||
kidMargin.right;
|
||||
nscoord totalWidth = kidSize.width + horizontalMargins;
|
||||
mReflowData.mX += totalWidth;
|
||||
if (!mUnconstrainedWidth) {
|
||||
|
|
|
@ -31,7 +31,6 @@ NS_DEF_PTR(nsTableCol);
|
|||
NS_DEF_PTR(nsTableCell);
|
||||
NS_DEF_PTR(nsIStyleContext);
|
||||
|
||||
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
|
||||
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
|
||||
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
|
||||
static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
|
||||
|
|
|
@ -27,9 +27,6 @@
|
|||
|
||||
|
||||
static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
|
||||
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
|
||||
|
||||
NS_DEF_PTR(nsIStyleContext);
|
||||
|
||||
nsCellLayoutData::nsCellLayoutData(nsTableCellFrame *aCellFrame,
|
||||
nsReflowMetrics * aDesiredSize, nsSize * aMaxElementSize)
|
||||
|
@ -40,7 +37,7 @@ nsCellLayoutData::nsCellLayoutData(nsTableCellFrame *aCellFrame,
|
|||
mMargin.top = mMargin.bottom = mMargin.left = mMargin.right = 0;
|
||||
|
||||
for (PRInt32 i = 0; i < 4; i++)
|
||||
mBorderStyle[i] = nsnull;
|
||||
mBorderFrame[i] = nsnull;
|
||||
|
||||
// IMPORTANT: call setters: this
|
||||
// guarentees addrefs/releases are called if needed - gpk
|
||||
|
@ -104,15 +101,15 @@ nsIStyleContext* nsCellLayoutData::GetStyleContext()
|
|||
* that element in the list
|
||||
*
|
||||
**/
|
||||
nsIStyleContext* nsCellLayoutData::GetStyleContextAt(nsVoidArray* aList, PRInt32 aIndex)
|
||||
nsIFrame* nsCellLayoutData::GetFrameAt(nsVoidArray* aList, PRInt32 aIndex)
|
||||
{
|
||||
nsIStyleContext* result = nsnull;
|
||||
nsIFrame* result = nsnull;
|
||||
|
||||
if (aList != nsnull)
|
||||
{
|
||||
nsCellLayoutData* data = (nsCellLayoutData*)aList->ElementAt(aIndex);
|
||||
if (data != nsnull)
|
||||
result = data->GetStyleContext();
|
||||
result = data->GetCellFrame();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -121,31 +118,32 @@ nsIStyleContext* nsCellLayoutData::GetStyleContextAt(nsVoidArray* aList, PRInt3
|
|||
* Given a style context and an edge, find the margin
|
||||
*
|
||||
**/
|
||||
nscoord nsCellLayoutData::GetMargin(nsIStyleContext* aStyle,PRUint8 aEdge)
|
||||
nscoord nsCellLayoutData::GetMargin(nsIFrame* aFrame, PRUint8 aEdge) const
|
||||
{
|
||||
nscoord result = 0;
|
||||
|
||||
if (aStyle)
|
||||
if (aFrame)
|
||||
{
|
||||
nsStyleSpacing* spacing = (nsStyleSpacing*)aStyle->GetData(kStyleSpacingSID);
|
||||
nsStyleSpacing* spacing;
|
||||
aFrame->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)spacing);
|
||||
nsMargin margin;
|
||||
spacing->CalcMarginFor(aFrame, margin);
|
||||
switch (aEdge)
|
||||
{
|
||||
|
||||
case NS_SIDE_TOP:
|
||||
result = spacing->mMargin.top;
|
||||
result = margin.top;
|
||||
break;
|
||||
|
||||
case NS_SIDE_RIGHT:
|
||||
result = spacing->mMargin.right;
|
||||
result = margin.right;
|
||||
break;
|
||||
|
||||
|
||||
case NS_SIDE_BOTTOM:
|
||||
result = spacing->mMargin.bottom;
|
||||
result = margin.bottom;
|
||||
break;
|
||||
|
||||
case NS_SIDE_LEFT:
|
||||
result = spacing->mMargin.left;
|
||||
result = margin.left;
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -158,30 +156,32 @@ nscoord nsCellLayoutData::GetMargin(nsIStyleContext* aStyle,PRUint8 aEdge)
|
|||
* Given a style context and an edge, find the border width
|
||||
*
|
||||
**/
|
||||
nscoord nsCellLayoutData::GetBorderWidth(nsIStyleContext* aStyle,PRUint8 aEdge)
|
||||
nscoord nsCellLayoutData::GetBorderWidth(nsIFrame* aFrame, PRUint8 aEdge) const
|
||||
{
|
||||
nscoord result = 0;
|
||||
|
||||
if (aStyle)
|
||||
if (aFrame)
|
||||
{
|
||||
nsStyleSpacing* spacing = (nsStyleSpacing*)aStyle->GetData(kStyleSpacingSID);
|
||||
nsStyleSpacing* spacing;
|
||||
aFrame->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)spacing);
|
||||
nsMargin border;
|
||||
spacing->CalcBorderFor(aFrame, border);
|
||||
switch (aEdge)
|
||||
{
|
||||
case NS_SIDE_TOP:
|
||||
result = spacing->mBorder.top;
|
||||
result = border.top;
|
||||
break;
|
||||
|
||||
case NS_SIDE_RIGHT:
|
||||
result = spacing->mBorder.right;
|
||||
result = border.right;
|
||||
break;
|
||||
|
||||
|
||||
case NS_SIDE_BOTTOM:
|
||||
result = spacing->mBorder.bottom;
|
||||
result = border.bottom;
|
||||
break;
|
||||
|
||||
case NS_SIDE_LEFT:
|
||||
result = spacing->mBorder.left;
|
||||
result = border.left;
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -194,29 +194,32 @@ nscoord nsCellLayoutData::GetBorderWidth(nsIStyleContext* aStyle,PRUint8 aEdge)
|
|||
* Given a style context and an edge, find the padding
|
||||
*
|
||||
**/
|
||||
nscoord nsCellLayoutData::GetPadding(nsIStyleContext* aStyle,PRUint8 aEdge)
|
||||
nscoord nsCellLayoutData::GetPadding(nsIFrame* aFrame, PRUint8 aEdge) const
|
||||
{
|
||||
nscoord result = 0;
|
||||
|
||||
if (aStyle)
|
||||
if (aFrame)
|
||||
{
|
||||
nsStyleSpacing* spacing = (nsStyleSpacing*)aStyle->GetData(kStyleSpacingSID);
|
||||
nsStyleSpacing* spacing;
|
||||
aFrame->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)spacing);
|
||||
nsMargin padding;
|
||||
spacing->CalcPaddingFor(aFrame, padding);
|
||||
switch (aEdge)
|
||||
{
|
||||
case NS_SIDE_TOP:
|
||||
result = spacing->mPadding.top;
|
||||
result = padding.top;
|
||||
break;
|
||||
|
||||
case NS_SIDE_RIGHT:
|
||||
result = spacing->mPadding.right;
|
||||
result = padding.right;
|
||||
break;
|
||||
|
||||
case NS_SIDE_BOTTOM:
|
||||
result = spacing->mPadding.bottom;
|
||||
result = padding.bottom;
|
||||
break;
|
||||
|
||||
case NS_SIDE_LEFT:
|
||||
result = spacing->mPadding.left;
|
||||
result = padding.left;
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -282,28 +285,30 @@ PRUint8 nsCellLayoutData::GetOpposingEdge(PRUint8 aEdge)
|
|||
*/
|
||||
|
||||
|
||||
nsIStyleContext* nsCellLayoutData::CompareCellBorders(nsIStyleContext* aStyle1,
|
||||
PRUint8 aEdge1,
|
||||
nsIStyleContext* aStyle2,
|
||||
PRUint8 aEdge2)
|
||||
nsIFrame* nsCellLayoutData::CompareCellBorders(nsIFrame* aFrame1,
|
||||
PRUint8 aEdge1,
|
||||
nsIFrame* aFrame2,
|
||||
PRUint8 aEdge2)
|
||||
{
|
||||
PRInt32 width1 = GetBorderWidth(aStyle1,aEdge1);
|
||||
PRInt32 width2 = GetBorderWidth(aStyle2,aEdge2);
|
||||
PRInt32 width1 = GetBorderWidth(aFrame1,aEdge1);
|
||||
PRInt32 width2 = GetBorderWidth(aFrame2,aEdge2);
|
||||
|
||||
nsIStyleContext* result = nsnull;
|
||||
nsIFrame* result = nsnull;
|
||||
|
||||
if (width1 > width2)
|
||||
result = aStyle1;
|
||||
result = aFrame1;
|
||||
else if (width1 < width2)
|
||||
result = aStyle2;
|
||||
result = aFrame2;
|
||||
else // width1 == width2
|
||||
{
|
||||
nsStyleBorder* border1 = (nsStyleBorder*)aStyle1->GetData(kStyleBorderSID);
|
||||
nsStyleBorder* border2 = (nsStyleBorder*)aStyle2->GetData(kStyleBorderSID);
|
||||
if (border1->mStyle[aEdge1] >= border2->mStyle[aEdge2])
|
||||
result = aStyle1;
|
||||
nsStyleSpacing* border1;
|
||||
nsStyleSpacing* border2;
|
||||
aFrame1->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)border1);
|
||||
aFrame2->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)border2);
|
||||
if (border1->mBorderStyle[aEdge1] >= border2->mBorderStyle[aEdge2])
|
||||
result = aFrame1;
|
||||
else
|
||||
result = aStyle2;
|
||||
result = aFrame2;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -315,10 +320,10 @@ nsIStyleContext* nsCellLayoutData::CompareCellBorders(nsIStyleContext* aStyle1,
|
|||
*
|
||||
**/
|
||||
|
||||
nsIStyleContext* nsCellLayoutData::FindHighestPrecedentBorder(nsVoidArray* aList,
|
||||
PRUint8 aEdge)
|
||||
nsIFrame* nsCellLayoutData::FindHighestPrecedentBorder(nsVoidArray* aList,
|
||||
PRUint8 aEdge)
|
||||
{
|
||||
nsIStyleContext* result = nsnull;
|
||||
nsIFrame* result = nsnull;
|
||||
PRInt32 index = 0;
|
||||
PRInt32 count = 0;
|
||||
|
||||
|
@ -327,19 +332,19 @@ nsIStyleContext* nsCellLayoutData::FindHighestPrecedentBorder(nsVoidArray* aList
|
|||
count = aList->Count();
|
||||
if (count)
|
||||
{
|
||||
nsIStyleContextPtr style;
|
||||
nsIStyleContextPtr style2;
|
||||
nsIFrame* frame1;
|
||||
nsIFrame* frame2;
|
||||
|
||||
style = GetStyleContextAt(aList,index++);
|
||||
frame1 = GetFrameAt(aList,index++);
|
||||
while (index < count)
|
||||
{
|
||||
style2 = GetStyleContextAt(aList,index++);
|
||||
if (GetMargin(style2,aEdge) == 0) {
|
||||
style.SetAddRef(CompareCellBorders(style,aEdge, style2,aEdge));
|
||||
frame2 = GetFrameAt(aList,index++);
|
||||
if (GetMargin(frame2,aEdge) == 0) {
|
||||
frame1 = CompareCellBorders(frame1, aEdge, frame2, aEdge);
|
||||
}
|
||||
}
|
||||
if (style.IsNotNull() && (GetMargin(style,aEdge) != 0))
|
||||
result = style.AddRef();
|
||||
if ((nsnull != frame1) && (GetMargin(frame1, aEdge) != 0))
|
||||
result = frame1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -347,22 +352,18 @@ nsIStyleContext* nsCellLayoutData::FindHighestPrecedentBorder(nsVoidArray* aList
|
|||
|
||||
|
||||
|
||||
nsStyleSpacing* nsCellLayoutData::FindInnerBorder( nsIStyleContext* aStyle,
|
||||
nsVoidArray* aList,
|
||||
PRUint8 aEdge)
|
||||
nsIFrame* nsCellLayoutData::FindInnerBorder(nsVoidArray* aList, PRUint8 aEdge)
|
||||
{
|
||||
nsStyleSpacing* result = nsnull;
|
||||
PRUint8 opposite = GetOpposingEdge(aEdge);
|
||||
nsIFrame* result = nsnull;
|
||||
PRUint8 opposite = GetOpposingEdge(aEdge);
|
||||
|
||||
if (GetMargin(aStyle,aEdge) == 0)
|
||||
if (GetMargin(mCellFrame, aEdge) == 0)
|
||||
{
|
||||
nsIStyleContextPtr style;
|
||||
nsIStyleContextPtr altStyle = FindHighestPrecedentBorder(aList,opposite);
|
||||
if (altStyle.IsNotNull())
|
||||
style.SetAddRef(CompareCellBorders(aStyle,aEdge,altStyle,opposite));
|
||||
nsIFrame* altFrame = FindHighestPrecedentBorder(aList,opposite);
|
||||
if (nsnull != altFrame)
|
||||
result = CompareCellBorders(mCellFrame, aEdge, altFrame, opposite);
|
||||
else
|
||||
style.SetAddRef(aStyle);
|
||||
result = (nsStyleSpacing*)style->GetData(kStyleSpacingSID);
|
||||
result = mCellFrame;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -389,41 +390,34 @@ nsStyleSpacing* nsCellLayoutData::FindInnerBorder( nsIStyleContext* aStyle,
|
|||
*
|
||||
*
|
||||
*/
|
||||
nsStyleSpacing* nsCellLayoutData::FindOuterBorder( nsTableFrame* aTableFrame,
|
||||
nsIFrame* aFrame,
|
||||
nsIStyleContext* aStyle,
|
||||
PRUint8 aEdge)
|
||||
nsIFrame* nsCellLayoutData::FindOuterBorder( nsTableFrame* aTableFrame,
|
||||
PRUint8 aEdge)
|
||||
{
|
||||
nsIStyleContextPtr style;
|
||||
nsIFrame* frame = aFrame;
|
||||
PRBool done = PR_FALSE;
|
||||
nsIFrame* frame = mCellFrame; // By default, return our frame
|
||||
PRBool done = PR_FALSE;
|
||||
|
||||
// By default, return the passed in style
|
||||
style.SetAddRef(aStyle);
|
||||
|
||||
// The table frame is the outer most frame we test against
|
||||
while (done == PR_FALSE)
|
||||
{
|
||||
done = PR_TRUE; // where done unless the frame's margin is zero
|
||||
// and the parent's padding is zero
|
||||
|
||||
nscoord margin = GetMargin(style,aEdge);
|
||||
nscoord margin = GetMargin(frame,aEdge);
|
||||
|
||||
// if the margin for this style is zero then check to see if the paddding
|
||||
// for the parent frame is also zero
|
||||
if (margin == 0)
|
||||
{
|
||||
nsIFrame* parentFrame;
|
||||
nsIStyleContextPtr parentStyle;
|
||||
nsIFrame* parentFrame;
|
||||
|
||||
aFrame->GetGeometricParent(parentFrame);
|
||||
aFrame->GetStyleContext(nsnull, parentStyle.AssignRef());
|
||||
frame->GetGeometricParent(parentFrame);
|
||||
|
||||
// if the padding for the parent style is zero just
|
||||
// recursively call this routine
|
||||
PRInt32 padding = GetPadding(parentStyle,aEdge);
|
||||
if (parentStyle.IsNotNull() && (padding == 0))
|
||||
PRInt32 padding = GetPadding(parentFrame,aEdge);
|
||||
if ((nsnull != parentFrame) && (padding == 0))
|
||||
{
|
||||
style = parentStyle;
|
||||
frame = parentFrame;
|
||||
// If this frame represents the table frame then
|
||||
// the table style is used
|
||||
|
@ -433,8 +427,7 @@ nsStyleSpacing* nsCellLayoutData::FindOuterBorder( nsTableFrame* aTableFrame,
|
|||
|
||||
}
|
||||
}
|
||||
nsStyleSpacing* result = (nsStyleSpacing*)style->GetData(kStyleSpacingSID);
|
||||
return result;
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
|
@ -468,32 +461,30 @@ nsStyleSpacing* nsCellLayoutData::FindOuterBorder( nsTableFrame* aTableFrame,
|
|||
* @param aIsBottom -- TRUE if this is the last cell in the column
|
||||
*/
|
||||
|
||||
nsStyleSpacing* nsCellLayoutData::FindBorderStyle(nsTableFrame* aTableFrame,
|
||||
nsIStyleContext* aCellStyle,
|
||||
nsVoidArray* aList,
|
||||
PRUint8 aEdge)
|
||||
nsIFrame* nsCellLayoutData::FindBorderFrame(nsTableFrame* aTableFrame,
|
||||
nsVoidArray* aList,
|
||||
PRUint8 aEdge)
|
||||
{
|
||||
nsStyleSpacing* style = nsnull;
|
||||
nsIFrame* frame = nsnull;
|
||||
|
||||
if (aList && aList->Count() == 0)
|
||||
style = FindOuterBorder(aTableFrame,mCellFrame,aCellStyle,aEdge);
|
||||
frame = FindOuterBorder(aTableFrame, aEdge);
|
||||
else
|
||||
style = FindInnerBorder(aCellStyle,aList, aEdge);
|
||||
frame = FindInnerBorder(aList, aEdge);
|
||||
|
||||
if (!style)
|
||||
style = (nsStyleSpacing*)aCellStyle->GetData(kStyleSpacingSID);
|
||||
if (! frame)
|
||||
frame = mCellFrame;
|
||||
|
||||
return style;
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
void nsCellLayoutData::CalculateBorders(nsTableFrame* aTableFrame,
|
||||
nsIStyleContext* aCellStyle,
|
||||
nsVoidArray* aBoundaryCells[4])
|
||||
{
|
||||
|
||||
for (PRInt32 edge = 0; edge < 4; edge++)
|
||||
mBorderStyle[edge] = FindBorderStyle(aTableFrame,aCellStyle,aBoundaryCells[edge],edge);
|
||||
mBorderFrame[edge] = FindBorderFrame(aTableFrame, aBoundaryCells[edge], edge);
|
||||
}
|
||||
|
||||
|
||||
|
@ -514,13 +505,13 @@ nscoord nsCellLayoutData::FindLargestMargin(nsVoidArray* aList,PRUint8 aEdge)
|
|||
count = aList->Count();
|
||||
if (count)
|
||||
{
|
||||
nsIStyleContextPtr style;
|
||||
nsIFrame* frame;
|
||||
|
||||
nscoord value = 0;
|
||||
while (index < count)
|
||||
{
|
||||
style = GetStyleContextAt(aList,index++);
|
||||
value = GetMargin(style,aEdge);
|
||||
frame = GetFrameAt(aList,index++);
|
||||
value = GetMargin(frame, aEdge);
|
||||
if (value > result)
|
||||
result = value;
|
||||
}
|
||||
|
@ -532,13 +523,13 @@ nscoord nsCellLayoutData::FindLargestMargin(nsVoidArray* aList,PRUint8 aEdge)
|
|||
|
||||
|
||||
void nsCellLayoutData::CalculateMargins(nsTableFrame* aTableFrame,
|
||||
nsIStyleContext* aCellStyle,
|
||||
nsVoidArray* aBoundaryCells[4])
|
||||
{
|
||||
// By default the margin is just the margin found in the
|
||||
// table cells style
|
||||
nsStyleSpacing* spacing = (nsStyleSpacing*)aCellStyle->GetData(kStyleSpacingSID);
|
||||
mMargin = spacing->mMargin;
|
||||
nsStyleSpacing* spacing;
|
||||
mCellFrame->GetStyleData(kStyleSpacingSID, (nsStyleStruct*&)spacing);
|
||||
spacing->CalcMarginFor(mCellFrame, mMargin);
|
||||
|
||||
// Left and Top Margins are collapsed with their neightbors
|
||||
// Right and Bottom Margins are simple left as they are
|
||||
|
@ -566,12 +557,8 @@ void nsCellLayoutData::RecalcLayoutData(nsTableFrame* aTableFrame,
|
|||
nsVoidArray* aBoundaryCells[4])
|
||||
|
||||
{
|
||||
nsIStyleContextPtr cellStyle;
|
||||
|
||||
mCellFrame->GetStyleContext(nsnull, cellStyle.AssignRef());
|
||||
|
||||
CalculateBorders(aTableFrame,cellStyle,aBoundaryCells);
|
||||
CalculateMargins(aTableFrame,cellStyle,aBoundaryCells);
|
||||
CalculateBorders(aTableFrame, aBoundaryCells);
|
||||
CalculateMargins(aTableFrame, aBoundaryCells);
|
||||
}
|
||||
|
||||
|
||||
|
@ -599,10 +586,10 @@ void nsCellLayoutData::List(FILE* out, PRInt32 aIndent) const
|
|||
|
||||
nscoord top,left,bottom,right;
|
||||
|
||||
top = (mBorderStyle[NS_SIDE_TOP] ? mBorderStyle[NS_SIDE_TOP]->mBorder.top : 0);
|
||||
left = (mBorderStyle[NS_SIDE_LEFT] ? mBorderStyle[NS_SIDE_LEFT]->mBorder.left : 0);
|
||||
bottom = (mBorderStyle[NS_SIDE_BOTTOM] ? mBorderStyle[NS_SIDE_BOTTOM]->mBorder.bottom : 0);
|
||||
right = (mBorderStyle[NS_SIDE_RIGHT] ? mBorderStyle[NS_SIDE_RIGHT]->mBorder.right : 0);
|
||||
top = (mBorderFrame[NS_SIDE_TOP] ? GetBorderWidth((nsIFrame*)mBorderFrame[NS_SIDE_TOP], NS_SIDE_TOP) : 0);
|
||||
left = (mBorderFrame[NS_SIDE_LEFT] ? GetBorderWidth((nsIFrame*)mBorderFrame[NS_SIDE_LEFT], NS_SIDE_LEFT) : 0);
|
||||
bottom = (mBorderFrame[NS_SIDE_BOTTOM] ? GetBorderWidth((nsIFrame*)mBorderFrame[NS_SIDE_BOTTOM], NS_SIDE_BOTTOM) : 0);
|
||||
right = (mBorderFrame[NS_SIDE_RIGHT] ? GetBorderWidth((nsIFrame*)mBorderFrame[NS_SIDE_RIGHT], NS_SIDE_RIGHT) : 0);
|
||||
|
||||
|
||||
fprintf(out,"Border -- Top: %d Left: %d Bottom: %d Right: %d \n",
|
||||
|
|
|
@ -83,50 +83,44 @@ public:
|
|||
private:
|
||||
|
||||
// All these methods are support methods for RecalcLayoutData
|
||||
nsIStyleContext* GetStyleContextAt(nsVoidArray* aList, PRInt32 aIndex);
|
||||
nsIFrame* GetFrameAt(nsVoidArray* aList, PRInt32 aIndex);
|
||||
|
||||
nscoord GetMargin(nsIStyleContext* aStyle,PRUint8 aEdge);
|
||||
nscoord GetMargin(nsIFrame* aFrame, PRUint8 aEdge) const;
|
||||
|
||||
nscoord GetBorderWidth(nsIStyleContext* aStyle,PRUint8 aEdge);
|
||||
nscoord GetBorderWidth(nsIFrame* aFrame, PRUint8 aEdge) const;
|
||||
|
||||
nscoord GetPadding(nsIStyleContext* aStyle,PRUint8 aEdge);
|
||||
nscoord GetPadding(nsIFrame* aFrame, PRUint8 aEdge) const;
|
||||
|
||||
PRUint8 GetOpposingEdge(PRUint8 aEdge);
|
||||
|
||||
nsIStyleContext* CompareCellBorders(nsIStyleContext* aStyle1,
|
||||
PRUint8 aEdge1,
|
||||
nsIStyleContext* aStyle2,
|
||||
PRUint8 aEdge2);
|
||||
nsIFrame* CompareCellBorders(nsIFrame* aFrame1,
|
||||
PRUint8 aEdge1,
|
||||
nsIFrame* aFrame2,
|
||||
PRUint8 aEdge2);
|
||||
|
||||
|
||||
nsIStyleContext* FindHighestPrecedentBorder(nsVoidArray* aList,
|
||||
PRUint8 aEdge);
|
||||
nsIFrame* FindHighestPrecedentBorder(nsVoidArray* aList,
|
||||
PRUint8 aEdge);
|
||||
|
||||
|
||||
|
||||
nsStyleSpacing* FindInnerBorder( nsIStyleContext* aStyle,
|
||||
nsVoidArray* aList,
|
||||
PRUint8 aEdge);
|
||||
nsIFrame* FindInnerBorder( nsVoidArray* aList,
|
||||
PRUint8 aEdge);
|
||||
|
||||
nsStyleSpacing* FindOuterBorder( nsTableFrame* aTableFrame,
|
||||
nsIFrame* aFrame,
|
||||
nsIStyleContext* aStyle,
|
||||
PRUint8 aEdge);
|
||||
nsIFrame* FindOuterBorder( nsTableFrame* aTableFrame,
|
||||
PRUint8 aEdge);
|
||||
|
||||
nsStyleSpacing* FindBorderStyle(nsTableFrame* aTableFrame,
|
||||
nsIStyleContext* aCellStyle,
|
||||
nsVoidArray* aCellList,
|
||||
PRUint8 aEdge);
|
||||
nsIFrame* FindBorderFrame(nsTableFrame* aTableFrame,
|
||||
nsVoidArray* aCellList,
|
||||
PRUint8 aEdge);
|
||||
|
||||
void CalculateBorders(nsTableFrame* aTableFrame,
|
||||
nsIStyleContext* aCellStyle,
|
||||
nsVoidArray* aBoundaryCells[4]);
|
||||
|
||||
nscoord FindLargestMargin(nsVoidArray* aList,PRUint8 aEdge);
|
||||
|
||||
|
||||
void CalculateMargins(nsTableFrame* aTableFrame,
|
||||
nsIStyleContext* aCellStyle,
|
||||
nsVoidArray* aBoundaryCells[4]);
|
||||
|
||||
public:
|
||||
|
@ -149,7 +143,7 @@ private:
|
|||
nsSize mMaxElementSize;
|
||||
|
||||
nsMargin mMargin;
|
||||
nsStyleSpacing* mBorderStyle[4];
|
||||
nsIFrame* mBorderFrame[4]; // the frame whose border is used
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,7 +33,6 @@ static PRBool gsDebug = PR_FALSE;
|
|||
static const PRBool gsDebug = PR_FALSE;
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
|
||||
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
|
||||
static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
|
||||
static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
|
||||
|
@ -103,18 +102,18 @@ NS_METHOD nsTableCaptionFrame::Paint(nsIPresContext& aPresContext,
|
|||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
nsStyleBorder* myBorder =
|
||||
(nsStyleBorder*)mStyleContext->GetData(kStyleBorderSID);
|
||||
nsStyleSpacing* mySpacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nsStyleColor* myColor =
|
||||
(nsStyleColor*)mStyleContext->GetData(kStyleColorSID);
|
||||
NS_ASSERTION(nsnull!=myColor, "bad style color");
|
||||
NS_ASSERTION(nsnull!=myBorder, "bad style border");
|
||||
if (nsnull==myBorder) return NS_OK;
|
||||
NS_ASSERTION(nsnull!=mySpacing, "bad style spacing");
|
||||
if (nsnull==mySpacing) return NS_OK;
|
||||
|
||||
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *myColor);
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *myBorder, 0);
|
||||
aDirtyRect, mRect, *mySpacing, 0);
|
||||
|
||||
|
||||
// for debug...
|
||||
|
@ -137,9 +136,11 @@ void nsTableCaptionFrame::VerticallyAlignChild(nsIPresContext* aPresContext)
|
|||
(nsStyleText*)mStyleContext->GetData(kStyleTextSID);
|
||||
nsStyleSpacing* spacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
|
||||
nscoord topInset = spacing->mBorderPadding.top;
|
||||
nscoord bottomInset = spacing->mBorderPadding.bottom;
|
||||
nscoord topInset = borderPadding.top;
|
||||
nscoord bottomInset = borderPadding.bottom;
|
||||
PRUint8 verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_MIDDLE;
|
||||
|
||||
if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) {
|
||||
|
@ -212,10 +213,12 @@ NS_METHOD nsTableCaptionFrame::ResizeReflow(nsIPresContext* aPresContext,
|
|||
// Compute the insets (sum of border and padding)
|
||||
nsStyleSpacing* spacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nscoord topInset = spacing->mBorderPadding.top;
|
||||
nscoord rightInset = spacing->mBorderPadding.right;
|
||||
nscoord bottomInset = spacing->mBorderPadding.bottom;
|
||||
nscoord leftInset = spacing->mBorderPadding.left;
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
nscoord topInset = borderPadding.top;
|
||||
nscoord rightInset = borderPadding.right;
|
||||
nscoord bottomInset = borderPadding.bottom;
|
||||
nscoord leftInset = borderPadding.left;
|
||||
|
||||
// reduce available space by insets
|
||||
if (NS_UNCONSTRAINEDSIZE!=availSize.width)
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
#include "nsTableContent.h"
|
||||
#include "nsTableRow.h"
|
||||
|
||||
struct nsStyleBorder;
|
||||
|
||||
/**
|
||||
* nsTableCell is the content object that represents table cells
|
||||
* (HTML tags TD and TH). This class cannot be reused
|
||||
|
|
|
@ -37,7 +37,6 @@ static const PRBool gsDebug = PR_FALSE;
|
|||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
|
||||
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
|
||||
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
|
||||
static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
|
||||
|
||||
|
@ -59,16 +58,16 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext& aPresContext,
|
|||
{
|
||||
nsStyleColor* myColor =
|
||||
(nsStyleColor*)mStyleContext->GetData(kStyleColorSID);
|
||||
nsStyleBorder* myBorder =
|
||||
(nsStyleBorder*)mStyleContext->GetData(kStyleBorderSID);
|
||||
nsStyleSpacing* mySpacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
NS_ASSERTION(nsnull!=myColor, "bad style color");
|
||||
NS_ASSERTION(nsnull!=myBorder, "bad style border");
|
||||
NS_ASSERTION(nsnull!=mySpacing, "bad style spacing");
|
||||
|
||||
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *myColor);
|
||||
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *myBorder, 0);
|
||||
aDirtyRect, mRect, *mySpacing, 0);
|
||||
/*
|
||||
printf("painting borders, size = %d %d %d %d\n",
|
||||
myBorder->mSize.left, myBorder->mSize.top,
|
||||
|
@ -97,9 +96,11 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext)
|
|||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nsStyleText* textStyle =
|
||||
(nsStyleText*)mStyleContext->GetData(kStyleTextSID);
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
|
||||
nscoord topInset = spacing->mBorderPadding.top;
|
||||
nscoord bottomInset = spacing->mBorderPadding.bottom;
|
||||
nscoord topInset = borderPadding.top;
|
||||
nscoord bottomInset = borderPadding.bottom;
|
||||
PRUint8 verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_MIDDLE;
|
||||
if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) {
|
||||
verticalAlignFlags = textStyle->mVerticalAlign.GetIntValue();
|
||||
|
@ -235,10 +236,13 @@ NS_METHOD nsTableCellFrame::ResizeReflow(nsIPresContext* aPresContext,
|
|||
// Compute the insets (sum of border and padding)
|
||||
nsStyleSpacing* spacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nscoord topInset = spacing->mBorderPadding.top;
|
||||
nscoord rightInset = spacing->mBorderPadding.right;
|
||||
nscoord bottomInset = spacing->mBorderPadding.bottom;
|
||||
nscoord leftInset = spacing->mBorderPadding.left;
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
|
||||
nscoord topInset = borderPadding.top;
|
||||
nscoord rightInset = borderPadding.right;
|
||||
nscoord bottomInset = borderPadding.bottom;
|
||||
nscoord leftInset = borderPadding.left;
|
||||
|
||||
// reduce available space by insets
|
||||
if (NS_UNCONSTRAINEDSIZE!=availSize.width)
|
||||
|
@ -358,29 +362,27 @@ nsTableCellFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
|
|||
* Update the border style to map to the HTML border style
|
||||
*
|
||||
*/
|
||||
void nsTableCellFrame::MapHTMLBorderStyle(nsStyleBorder& aBorderStyle, nscoord aBorderWidth)
|
||||
void nsTableCellFrame::MapHTMLBorderStyle(nsStyleSpacing& aSpacingStyle, nscoord aBorderWidth)
|
||||
{
|
||||
for (PRInt32 index = 0; index < 4; index++)
|
||||
aBorderStyle.mSizeFlag[index] = NS_STYLE_BORDER_WIDTH_LENGTH_VALUE;
|
||||
nsStyleCoord width;
|
||||
width.SetCoordValue(aBorderWidth);
|
||||
aSpacingStyle.mBorder.SetTop(width);
|
||||
aSpacingStyle.mBorder.SetLeft(width);
|
||||
aSpacingStyle.mBorder.SetBottom(width);
|
||||
aSpacingStyle.mBorder.SetRight(width);
|
||||
|
||||
aBorderStyle.mSize.top =
|
||||
aBorderStyle.mSize.left =
|
||||
aBorderStyle.mSize.bottom =
|
||||
aBorderStyle.mSize.right = aBorderWidth;
|
||||
|
||||
|
||||
aBorderStyle.mStyle[NS_SIDE_TOP] = NS_STYLE_BORDER_STYLE_INSET;
|
||||
aBorderStyle.mStyle[NS_SIDE_LEFT] = NS_STYLE_BORDER_STYLE_INSET;
|
||||
aBorderStyle.mStyle[NS_SIDE_BOTTOM] = NS_STYLE_BORDER_STYLE_OUTSET;
|
||||
aBorderStyle.mStyle[NS_SIDE_RIGHT] = NS_STYLE_BORDER_STYLE_OUTSET;
|
||||
aSpacingStyle.mBorderStyle[NS_SIDE_TOP] = NS_STYLE_BORDER_STYLE_INSET;
|
||||
aSpacingStyle.mBorderStyle[NS_SIDE_LEFT] = NS_STYLE_BORDER_STYLE_INSET;
|
||||
aSpacingStyle.mBorderStyle[NS_SIDE_BOTTOM] = NS_STYLE_BORDER_STYLE_OUTSET;
|
||||
aSpacingStyle.mBorderStyle[NS_SIDE_RIGHT] = NS_STYLE_BORDER_STYLE_OUTSET;
|
||||
|
||||
NS_ColorNameToRGB("white",&aBorderStyle.mColor[NS_SIDE_TOP]);
|
||||
NS_ColorNameToRGB("white",&aBorderStyle.mColor[NS_SIDE_LEFT]);
|
||||
NS_ColorNameToRGB("white",&aSpacingStyle.mBorderColor[NS_SIDE_TOP]);
|
||||
NS_ColorNameToRGB("white",&aSpacingStyle.mBorderColor[NS_SIDE_LEFT]);
|
||||
|
||||
// This should be the background color of the tables
|
||||
// container
|
||||
NS_ColorNameToRGB("gray",&aBorderStyle.mColor[NS_SIDE_BOTTOM]);
|
||||
NS_ColorNameToRGB("gray",&aBorderStyle.mColor[NS_SIDE_RIGHT]);
|
||||
NS_ColorNameToRGB("gray",&aSpacingStyle.mBorderColor[NS_SIDE_BOTTOM]);
|
||||
NS_ColorNameToRGB("gray",&aSpacingStyle.mBorderColor[NS_SIDE_RIGHT]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -431,24 +433,30 @@ void nsTableCellFrame::MapBorderMarginPadding(nsIPresContext* aPresContext)
|
|||
spacing_result = table->GetAttribute(nsHTMLAtoms::cellspacing,spacing_value);
|
||||
border_result = table->GetAttribute(nsHTMLAtoms::border,border_value);
|
||||
|
||||
nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
|
||||
// check to see if cellpadding or cellspacing is defined
|
||||
if (spacing_result == eContentAttr_HasValue || padding_result == eContentAttr_HasValue)
|
||||
{
|
||||
|
||||
PRInt32 value;
|
||||
nsStyleCoord padding(0, eStyleUnit_Coord);
|
||||
nsStyleCoord spacing(0, eStyleUnit_Coord);
|
||||
|
||||
if (padding_result == eContentAttr_HasValue && ConvertToIntValue(padding_value,0,value))
|
||||
padding = (nscoord)(p2t*(float)value);
|
||||
padding.SetCoordValue((nscoord)(p2t*(float)value));
|
||||
|
||||
if (spacing_result == eContentAttr_HasValue && ConvertToIntValue(spacing_value,0,value))
|
||||
spacing = (nscoord)(p2t*(float)value);
|
||||
spacing.SetCoordValue((nscoord)(p2t*(float)value));
|
||||
|
||||
nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
spacingData->mMargin.SizeTo(spacing,spacing,spacing,spacing);
|
||||
spacingData->mPadding.top =
|
||||
spacingData->mPadding.left =
|
||||
spacingData->mPadding.bottom =
|
||||
spacingData->mPadding.right = padding;
|
||||
spacingData->mMargin.SetTop(spacing);
|
||||
spacingData->mMargin.SetLeft(spacing);
|
||||
spacingData->mMargin.SetBottom(spacing);
|
||||
spacingData->mMargin.SetRight(spacing);
|
||||
spacingData->mPadding.SetTop(padding);
|
||||
spacingData->mPadding.SetLeft(padding);
|
||||
spacingData->mPadding.SetBottom(padding);
|
||||
spacingData->mPadding.SetRight(padding);
|
||||
|
||||
}
|
||||
if (border_result == eContentAttr_HasValue)
|
||||
|
@ -462,8 +470,7 @@ void nsTableCellFrame::MapBorderMarginPadding(nsIPresContext* aPresContext)
|
|||
border = nscoord(p2t*(float)intValue);
|
||||
}
|
||||
}
|
||||
nsStyleBorder& borderData = *(nsStyleBorder*)mStyleContext->GetData(kStyleBorderSID);
|
||||
MapHTMLBorderStyle(borderData,border);
|
||||
MapHTMLBorderStyle(*spacingData,border);
|
||||
}
|
||||
|
||||
void nsTableCellFrame::MapTextAttributes(nsIPresContext* aPresContext)
|
||||
|
@ -489,7 +496,7 @@ NS_METHOD nsTableCellFrame::DidSetStyleContext(nsIPresContext* aPresContext)
|
|||
|
||||
MapTextAttributes(aPresContext);
|
||||
MapBorderMarginPadding(aPresContext);
|
||||
mStyleContext->RecalcAutomaticData();
|
||||
mStyleContext->RecalcAutomaticData(aPresContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "nsContainerFrame.h"
|
||||
#include "nsTableCell.h"
|
||||
|
||||
struct nsStyleSpacing;
|
||||
|
||||
/**
|
||||
* nsTableCellFrame
|
||||
* data structure to maintain information about a single table cell's frame
|
||||
|
@ -89,7 +91,7 @@ protected:
|
|||
NS_METHOD DidSetStyleContext(nsIPresContext* aPresContext);
|
||||
void MapTextAttributes(nsIPresContext* aPresContext);
|
||||
void MapBorderMarginPadding(nsIPresContext* aPresContext);
|
||||
void MapHTMLBorderStyle(nsStyleBorder& aBorderStyle, nscoord aBorderWidth);
|
||||
void MapHTMLBorderStyle(nsStyleSpacing& aSpacingStyle, nscoord aBorderWidth);
|
||||
PRBool ConvertToIntValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult);
|
||||
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ static const PRBool gsDebugMBP = PR_FALSE;
|
|||
#define max(x, y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
|
||||
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
|
||||
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
|
||||
static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
|
||||
|
@ -104,7 +103,7 @@ struct InnerTableReflowState {
|
|||
|
||||
InnerTableReflowState(nsIPresContext* aPresContext,
|
||||
const nsSize& aMaxSize,
|
||||
nsStyleSpacing* aStyleSpacing)
|
||||
const nsMargin& aBorderPadding)
|
||||
{
|
||||
prevMaxPosBottomMargin = 0;
|
||||
prevMaxNegBottomMargin = 0;
|
||||
|
@ -113,18 +112,16 @@ struct InnerTableReflowState {
|
|||
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE);
|
||||
availSize.width = aMaxSize.width;
|
||||
if (!unconstrainedWidth) {
|
||||
availSize.width -= aStyleSpacing->mBorderPadding.left +
|
||||
aStyleSpacing->mBorderPadding.right;
|
||||
availSize.width -= aBorderPadding.left + aBorderPadding.right;
|
||||
}
|
||||
leftInset = aStyleSpacing->mBorderPadding.left;
|
||||
leftInset = aBorderPadding.left;
|
||||
|
||||
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE);
|
||||
availSize.height = aMaxSize.height;
|
||||
if (!unconstrainedHeight) {
|
||||
availSize.height -= aStyleSpacing->mBorderPadding.top +
|
||||
aStyleSpacing->mBorderPadding.bottom;
|
||||
availSize.height -= aBorderPadding.top + aBorderPadding.bottom;
|
||||
}
|
||||
topInset = aStyleSpacing->mBorderPadding.top;
|
||||
topInset = aBorderPadding.top;
|
||||
|
||||
firstRowGroup = PR_TRUE;
|
||||
footerHeight = 0;
|
||||
|
@ -432,16 +429,16 @@ NS_METHOD nsTableFrame::Paint(nsIPresContext& aPresContext,
|
|||
// table paint code is concerned primarily with borders and bg color
|
||||
nsStyleColor* myColor =
|
||||
(nsStyleColor*)mStyleContext->GetData(kStyleColorSID);
|
||||
nsStyleBorder* myBorder =
|
||||
(nsStyleBorder*)mStyleContext->GetData(kStyleBorderSID);
|
||||
nsStyleSpacing* mySpacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
NS_ASSERTION(nsnull != myColor, "null style color");
|
||||
NS_ASSERTION(nsnull != myBorder, "null style border");
|
||||
if (nsnull!=myBorder)
|
||||
NS_ASSERTION(nsnull != mySpacing, "null style spacing");
|
||||
if (nsnull!=mySpacing)
|
||||
{
|
||||
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *myColor);
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *myBorder, 0);
|
||||
aDirtyRect, mRect, *mySpacing, 0);
|
||||
}
|
||||
|
||||
// for debug...
|
||||
|
@ -594,10 +591,12 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
|||
// Compute the insets (sum of border and padding)
|
||||
nsStyleSpacing* spacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nscoord topInset = spacing->mBorderPadding.top;
|
||||
nscoord rightInset = spacing->mBorderPadding.right;
|
||||
nscoord bottomInset =spacing->mBorderPadding.bottom;
|
||||
nscoord leftInset = spacing->mBorderPadding.left;
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
nscoord topInset = borderPadding.top;
|
||||
nscoord rightInset = borderPadding.right;
|
||||
nscoord bottomInset = borderPadding.bottom;
|
||||
nscoord leftInset = borderPadding.left;
|
||||
|
||||
/* assumes that Table's children are in the following order:
|
||||
* Captions
|
||||
|
@ -756,7 +755,10 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
|||
|
||||
nsStyleSpacing* mySpacing = (nsStyleSpacing*)
|
||||
mStyleContext->GetData(kStyleSpacingSID);
|
||||
InnerTableReflowState state(aPresContext, aMaxSize, mySpacing);
|
||||
nsMargin myBorderPadding;
|
||||
mySpacing->CalcBorderPaddingFor(this, myBorderPadding);
|
||||
|
||||
InnerTableReflowState state(aPresContext, aMaxSize, myBorderPadding);
|
||||
|
||||
// Reflow the existing frames
|
||||
if (nsnull != mFirstChild) {
|
||||
|
@ -835,12 +837,12 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
|||
// Collapse child's top margin with previous bottom margin
|
||||
nscoord nsTableFrame::GetTopMarginFor(nsIPresContext* aCX,
|
||||
InnerTableReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing)
|
||||
const nsMargin& aKidMargin)
|
||||
{
|
||||
nscoord margin;
|
||||
nscoord maxNegTopMargin = 0;
|
||||
nscoord maxPosTopMargin = 0;
|
||||
if ((margin = aKidSpacing->mMargin.top) < 0) {
|
||||
if ((margin = aKidMargin.top) < 0) {
|
||||
maxNegTopMargin = -margin;
|
||||
} else {
|
||||
maxPosTopMargin = margin;
|
||||
|
@ -993,8 +995,11 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
|
|||
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
|
||||
nscoord bottomMargin = kidSpacing->mMargin.bottom;
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kidFrame, kidMargin);
|
||||
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMargin);
|
||||
nscoord bottomMargin = kidMargin.bottom;
|
||||
|
||||
// Figure out the amount of available size for the child (subtract
|
||||
// off the top margin we are going to apply to it)
|
||||
|
@ -1003,8 +1008,7 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
|
|||
}
|
||||
// Subtract off for left and right margin
|
||||
if (PR_FALSE == aState.unconstrainedWidth) {
|
||||
kidAvailSize.width -= kidSpacing->mMargin.left +
|
||||
kidSpacing->mMargin.right;
|
||||
kidAvailSize.width -= kidMargin.left + kidMargin.right;
|
||||
}
|
||||
|
||||
// Reflow the child into the available space
|
||||
|
@ -1030,7 +1034,7 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
|
|||
// Place the child after taking into account it's margin
|
||||
aState.y += topMargin;
|
||||
nsRect kidRect (0, 0, desiredSize.width, desiredSize.height);
|
||||
kidRect.x += aState.leftInset + kidSpacing->mMargin.left;
|
||||
kidRect.x += aState.leftInset + kidMargin.left;
|
||||
kidRect.y += aState.topInset + aState.y ;
|
||||
PlaceChild(aPresContext, aState, kidFrame, kidRect,
|
||||
aMaxElementSize, kidMaxElementSize);
|
||||
|
@ -1521,6 +1525,8 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
|
|||
|
||||
nsStyleSpacing* spacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
|
||||
// need to figure out the overall table width constraint
|
||||
// default case, get 100% of available space
|
||||
|
@ -1546,7 +1552,7 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
|
|||
// and padding
|
||||
if (NS_UNCONSTRAINEDSIZE!=maxWidth)
|
||||
{
|
||||
maxWidth -= spacing->mBorderPadding.left + spacing->mBorderPadding.right;
|
||||
maxWidth -= borderPadding.left + borderPadding.right;
|
||||
if (0>maxWidth) // nonsense style specification
|
||||
maxWidth = 0;
|
||||
}
|
||||
|
@ -1586,8 +1592,11 @@ void nsTableFrame::SetTableWidth(nsIPresContext* aPresContext)
|
|||
// Compute the insets (sum of border and padding)
|
||||
nsStyleSpacing* spacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nscoord rightInset = spacing->mBorderPadding.right;
|
||||
nscoord leftInset = spacing->mBorderPadding.left;
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
|
||||
nscoord rightInset = borderPadding.right;
|
||||
nscoord leftInset = borderPadding.left;
|
||||
tableWidth += (leftInset + rightInset);
|
||||
nsRect tableSize = mRect;
|
||||
tableSize.width = tableWidth;
|
||||
|
@ -1616,8 +1625,10 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
|||
|
||||
nsStyleSpacing* spacing = (nsStyleSpacing*)
|
||||
mStyleContext->GetData(kStyleSpacingSID);
|
||||
tableHeight +=
|
||||
spacing->mBorderPadding.top + spacing->mBorderPadding.bottom;
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
|
||||
tableHeight += borderPadding.top + borderPadding.bottom;
|
||||
|
||||
PRInt32 childCount = mChildCount;
|
||||
nsIFrame * kidFrame;
|
||||
|
|
|
@ -29,7 +29,6 @@ class CellData;
|
|||
class nsITableLayoutStrategy;
|
||||
struct InnerTableReflowState;
|
||||
struct nsStylePosition;
|
||||
struct nsStyleSpacing;
|
||||
|
||||
/** nsTableFrame maps the inner portion of a table (everything except captions.)
|
||||
* Used as a pseudo-frame within nsTableOuterFrame,
|
||||
|
@ -216,7 +215,7 @@ protected:
|
|||
|
||||
nscoord GetTopMarginFor(nsIPresContext* aCX,
|
||||
InnerTableReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing);
|
||||
const nsMargin& aKidMargin);
|
||||
|
||||
void PlaceChild(nsIPresContext* aPresContext,
|
||||
InnerTableReflowState& aState,
|
||||
|
|
|
@ -343,12 +343,12 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
|
|||
// Collapse child's top margin with previous bottom margin
|
||||
nscoord nsTableOuterFrame::GetTopMarginFor(nsIPresContext* aCX,
|
||||
OuterTableReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing)
|
||||
const nsMargin& aKidMargin)
|
||||
{
|
||||
nscoord margin;
|
||||
nscoord maxNegTopMargin = 0;
|
||||
nscoord maxPosTopMargin = 0;
|
||||
if ((margin = aKidSpacing->mMargin.top) < 0) {
|
||||
if ((margin = aKidMargin.top) < 0) {
|
||||
maxNegTopMargin = -margin;
|
||||
} else {
|
||||
maxPosTopMargin = margin;
|
||||
|
@ -463,8 +463,10 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
|
|||
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
|
||||
nsStyleSpacing* kidSpacing =
|
||||
(nsStyleSpacing*)kidSC->GetData(kStyleSpacingSID);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
|
||||
nscoord bottomMargin = kidSpacing->mMargin.bottom;
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kidFrame, kidMargin);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMargin);
|
||||
nscoord bottomMargin = kidMargin.bottom;
|
||||
|
||||
// Figure out the amount of available size for the child (subtract
|
||||
// off the top margin we are going to apply to it)
|
||||
|
@ -473,7 +475,7 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
|
|||
}
|
||||
// Subtract off for left and right margin
|
||||
if (PR_FALSE == aState.unconstrainedWidth) {
|
||||
aState.availSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
|
||||
aState.availSize.width -= kidMargin.left + kidMargin.right;
|
||||
}
|
||||
|
||||
// Only skip the reflow if this is not our first child and we are
|
||||
|
@ -503,7 +505,7 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
|
|||
// Place the child after taking into account it's margin
|
||||
aState.y += topMargin;
|
||||
nsRect kidRect (0, 0, kidSize.width, kidSize.height);
|
||||
kidRect.x += kidSpacing->mMargin.left;
|
||||
kidRect.x += kidMargin.left;
|
||||
kidRect.y += aState.y;
|
||||
PlaceChild(aState, kidFrame, kidRect, aMaxElementSize, kidMaxElementSize);
|
||||
if (bottomMargin < 0) {
|
||||
|
|
|
@ -25,7 +25,6 @@ class nsTableFrame;
|
|||
class nsVoidArray;
|
||||
class nsTableCaptionFrame;
|
||||
struct OuterTableReflowState;
|
||||
struct nsStyleSpacing;
|
||||
|
||||
/**
|
||||
* main frame for an nsTable content object,
|
||||
|
@ -157,7 +156,7 @@ protected:
|
|||
|
||||
nscoord GetTopMarginFor(nsIPresContext* aCX,
|
||||
OuterTableReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing);
|
||||
const nsMargin& aKidMargin);
|
||||
|
||||
void PlaceChild( OuterTableReflowState& aState,
|
||||
nsIFrame* aKidFrame,
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kITableContentIID, NS_ITABLECONTENT_IID);
|
||||
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
|
||||
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
|
||||
static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
|
||||
static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
|
||||
|
||||
|
@ -1123,37 +1122,39 @@ void nsTablePart::GetTableBorder(nsIHTMLContent* aContent,
|
|||
aContent->GetAttribute(nsHTMLAtoms::border, value);
|
||||
if ((value.GetUnit() == eHTMLUnit_Pixel) ||
|
||||
(value.GetUnit() == eHTMLUnit_Empty)) {
|
||||
nsStyleBorder* border = (nsStyleBorder*)
|
||||
aContext->GetData(kStyleBorderSID);
|
||||
nsStyleSpacing* spacing = (nsStyleSpacing*)
|
||||
aContext->GetData(kStyleSpacingSID);
|
||||
float p2t = aPresContext->GetPixelsToTwips();
|
||||
nscoord twips = (aForCell || (value.GetUnit() == eHTMLUnit_Empty))
|
||||
? nscoord(NS_INT_PIXELS_TO_TWIPS(1, p2t))
|
||||
: nscoord(NS_INT_PIXELS_TO_TWIPS(value.GetPixelValue(), p2t));
|
||||
nscoord two = nscoord(NS_INT_PIXELS_TO_TWIPS(2,p2t));
|
||||
|
||||
spacing->mPadding.top = two;
|
||||
spacing->mPadding.right = two;
|
||||
spacing->mPadding.bottom = two;
|
||||
spacing->mPadding.left = two;
|
||||
|
||||
border->mSize.top = twips;
|
||||
border->mSize.right = twips;
|
||||
border->mSize.bottom = twips;
|
||||
border->mSize.left = twips;
|
||||
|
||||
if (border->mStyle[0] == NS_STYLE_BORDER_STYLE_NONE) {
|
||||
border->mStyle[0] = NS_STYLE_BORDER_STYLE_SOLID;
|
||||
nsStyleCoord twips;
|
||||
if (aForCell || (value.GetUnit() == eHTMLUnit_Empty)) {
|
||||
twips.SetCoordValue(nscoord(NS_INT_PIXELS_TO_TWIPS(1, p2t)));
|
||||
}
|
||||
if (border->mStyle[1] == NS_STYLE_BORDER_STYLE_NONE) {
|
||||
border->mStyle[1] = NS_STYLE_BORDER_STYLE_SOLID;
|
||||
else {
|
||||
twips.SetCoordValue(nscoord(NS_INT_PIXELS_TO_TWIPS(value.GetPixelValue(), p2t)));
|
||||
}
|
||||
if (border->mStyle[2] == NS_STYLE_BORDER_STYLE_NONE) {
|
||||
border->mStyle[2] = NS_STYLE_BORDER_STYLE_SOLID;
|
||||
nsStyleCoord two(nscoord(NS_INT_PIXELS_TO_TWIPS(2,p2t)));
|
||||
|
||||
spacing->mPadding.SetTop(two);
|
||||
spacing->mPadding.SetRight(two);
|
||||
spacing->mPadding.SetBottom(two);
|
||||
spacing->mPadding.SetLeft(two);
|
||||
|
||||
spacing->mBorder.SetTop(twips);
|
||||
spacing->mBorder.SetRight(twips);
|
||||
spacing->mBorder.SetBottom(twips);
|
||||
spacing->mBorder.SetLeft(twips);
|
||||
|
||||
if (spacing->mBorderStyle[0] == NS_STYLE_BORDER_STYLE_NONE) {
|
||||
spacing->mBorderStyle[0] = NS_STYLE_BORDER_STYLE_SOLID;
|
||||
}
|
||||
if (border->mStyle[3] == NS_STYLE_BORDER_STYLE_NONE) {
|
||||
border->mStyle[3] = NS_STYLE_BORDER_STYLE_SOLID;
|
||||
if (spacing->mBorderStyle[1] == NS_STYLE_BORDER_STYLE_NONE) {
|
||||
spacing->mBorderStyle[1] = NS_STYLE_BORDER_STYLE_SOLID;
|
||||
}
|
||||
if (spacing->mBorderStyle[2] == NS_STYLE_BORDER_STYLE_NONE) {
|
||||
spacing->mBorderStyle[2] = NS_STYLE_BORDER_STYLE_SOLID;
|
||||
}
|
||||
if (spacing->mBorderStyle[3] == NS_STYLE_BORDER_STYLE_NONE) {
|
||||
spacing->mBorderStyle[3] = NS_STYLE_BORDER_STYLE_SOLID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,12 +170,12 @@ PRInt32 nsTableRowFrame::GetTallestChild() const
|
|||
// Collapse child's top margin with previous bottom margin
|
||||
nscoord nsTableRowFrame::GetTopMarginFor( nsIPresContext* aCX,
|
||||
RowReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing)
|
||||
const nsMargin& aKidMargin)
|
||||
{
|
||||
nscoord margin;
|
||||
nscoord maxNegTopMargin = 0;
|
||||
nscoord maxPosTopMargin = 0;
|
||||
if ((margin = aKidSpacing->mMargin.top) < 0) {
|
||||
if ((margin = aKidMargin.top) < 0) {
|
||||
maxNegTopMargin = -margin;
|
||||
} else {
|
||||
maxPosTopMargin = margin;
|
||||
|
@ -281,8 +281,10 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
|||
kidFrame->GetStyleContext(aPresContext, kidSC);
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
|
||||
nscoord bottomMargin = kidSpacing->mMargin.bottom;
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kidFrame, kidMargin);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMargin);
|
||||
nscoord bottomMargin = kidMargin.bottom;
|
||||
NS_RELEASE(kidSC);
|
||||
|
||||
// Figure out the amount of available size for the child (subtract
|
||||
|
@ -292,7 +294,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
|||
}
|
||||
// Subtract off for left and right margin
|
||||
if (PR_FALSE == aState.unconstrainedWidth) {
|
||||
kidAvailSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
|
||||
kidAvailSize.width -= kidMargin.left + kidMargin.right;
|
||||
}
|
||||
|
||||
if (NS_UNCONSTRAINEDSIZE == aState.availSize.width)
|
||||
|
@ -426,7 +428,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
|||
// Add back in the left and right margins, because one row does not
|
||||
// impact another row's width
|
||||
if (PR_FALSE == aState.unconstrainedWidth) {
|
||||
kidAvailSize.width += kidSpacing->mMargin.left + kidSpacing->mMargin.right;
|
||||
kidAvailSize.width += kidMargin.left + kidMargin.right;
|
||||
}
|
||||
|
||||
// Get the next child
|
||||
|
@ -805,8 +807,10 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
|
|||
aPresContext->ResolveStyleContextFor(cell, this);
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidStyleContext->GetData(kStyleSpacingSID);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
|
||||
nscoord bottomMargin = kidSpacing->mMargin.bottom;
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(this, kidMargin);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMargin);
|
||||
nscoord bottomMargin = kidMargin.bottom;
|
||||
|
||||
nsIFrame* kidFrame;
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "nsContainerFrame.h"
|
||||
|
||||
struct RowReflowState;
|
||||
struct nsStyleSpacing;
|
||||
|
||||
/**
|
||||
* nsTableRowFrame is the frame that maps table rows
|
||||
|
@ -118,7 +117,7 @@ protected:
|
|||
|
||||
nscoord GetTopMarginFor(nsIPresContext* aCX,
|
||||
RowReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing);
|
||||
const nsMargin& aKidMargin);
|
||||
|
||||
void PlaceChild( nsIPresContext* aPresContext,
|
||||
RowReflowState& aState,
|
||||
|
|
|
@ -164,12 +164,12 @@ void nsTableRowGroupFrame::PaintChildren(nsIPresContext& aPresContext,
|
|||
// Collapse child's top margin with previous bottom margin
|
||||
nscoord nsTableRowGroupFrame::GetTopMarginFor(nsIPresContext* aCX,
|
||||
RowGroupReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing)
|
||||
const nsMargin& aKidMargin)
|
||||
{
|
||||
nscoord margin;
|
||||
nscoord maxNegTopMargin = 0;
|
||||
nscoord maxPosTopMargin = 0;
|
||||
if ((margin = aKidSpacing->mMargin.top) < 0) {
|
||||
if ((margin = aKidMargin.top) < 0) {
|
||||
maxNegTopMargin = -margin;
|
||||
} else {
|
||||
maxPosTopMargin = margin;
|
||||
|
@ -282,8 +282,10 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
|
|||
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
|
||||
nscoord bottomMargin = kidSpacing->mMargin.bottom;
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(this, kidMargin);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMargin);
|
||||
nscoord bottomMargin = kidMargin.bottom;
|
||||
|
||||
// Figure out the amount of available size for the child (subtract
|
||||
// off the top margin we are going to apply to it)
|
||||
|
@ -292,7 +294,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
|
|||
}
|
||||
// Subtract off for left and right margin
|
||||
if (PR_FALSE == aState.unconstrainedWidth) {
|
||||
kidAvailSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
|
||||
kidAvailSize.width -= kidMargin.left + kidMargin.right;
|
||||
}
|
||||
|
||||
// Reflow the child into the available space
|
||||
|
@ -325,7 +327,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
|
|||
// Place the child after taking into account it's margin
|
||||
aState.y += topMargin;
|
||||
nsRect kidRect (0, 0, desiredSize.width, desiredSize.height);
|
||||
kidRect.x += kidSpacing->mMargin.left;
|
||||
kidRect.x += kidMargin.left;
|
||||
kidRect.y += aState.y;
|
||||
PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize,
|
||||
kidMaxElementSize);
|
||||
|
@ -394,7 +396,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
|
|||
// Add back in the left and right margins, because one row does not
|
||||
// impact another row's width
|
||||
if (PR_FALSE == aState.unconstrainedWidth) {
|
||||
kidAvailSize.width += kidSpacing->mMargin.left + kidSpacing->mMargin.right;
|
||||
kidAvailSize.width += kidMargin.left + kidMargin.right;
|
||||
}
|
||||
|
||||
// Get the next child
|
||||
|
@ -736,8 +738,10 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
|
|||
aPresContext->ResolveStyleContextFor(kid, this);
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
|
||||
nscoord bottomMargin = kidSpacing->mMargin.bottom;
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(this, kidMargin);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMargin);
|
||||
nscoord bottomMargin = kidMargin.bottom;
|
||||
|
||||
nsIFrame* kidFrame;
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "nsIAtom.h"
|
||||
|
||||
struct RowGroupReflowState;
|
||||
struct nsStyleSpacing;
|
||||
|
||||
/**
|
||||
* nsTableRowGroupFrame is the frame that maps row groups
|
||||
|
@ -111,7 +110,7 @@ protected:
|
|||
|
||||
nscoord GetTopMarginFor(nsIPresContext* aCX,
|
||||
RowGroupReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing);
|
||||
const nsMargin& aKidMargin);
|
||||
|
||||
void PlaceChild( nsIPresContext* aPresContext,
|
||||
RowGroupReflowState& aState,
|
||||
|
|
|
@ -31,7 +31,6 @@ NS_DEF_PTR(nsTableCol);
|
|||
NS_DEF_PTR(nsTableCell);
|
||||
NS_DEF_PTR(nsIStyleContext);
|
||||
|
||||
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
|
||||
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
|
||||
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
|
||||
static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
|
||||
|
|
|
@ -37,7 +37,6 @@ static const PRBool gsDebug = PR_FALSE;
|
|||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
|
||||
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
|
||||
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
|
||||
static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID);
|
||||
|
||||
|
@ -59,16 +58,16 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext& aPresContext,
|
|||
{
|
||||
nsStyleColor* myColor =
|
||||
(nsStyleColor*)mStyleContext->GetData(kStyleColorSID);
|
||||
nsStyleBorder* myBorder =
|
||||
(nsStyleBorder*)mStyleContext->GetData(kStyleBorderSID);
|
||||
nsStyleSpacing* mySpacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
NS_ASSERTION(nsnull!=myColor, "bad style color");
|
||||
NS_ASSERTION(nsnull!=myBorder, "bad style border");
|
||||
NS_ASSERTION(nsnull!=mySpacing, "bad style spacing");
|
||||
|
||||
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *myColor);
|
||||
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *myBorder, 0);
|
||||
aDirtyRect, mRect, *mySpacing, 0);
|
||||
/*
|
||||
printf("painting borders, size = %d %d %d %d\n",
|
||||
myBorder->mSize.left, myBorder->mSize.top,
|
||||
|
@ -97,9 +96,11 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext)
|
|||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nsStyleText* textStyle =
|
||||
(nsStyleText*)mStyleContext->GetData(kStyleTextSID);
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
|
||||
nscoord topInset = spacing->mBorderPadding.top;
|
||||
nscoord bottomInset = spacing->mBorderPadding.bottom;
|
||||
nscoord topInset = borderPadding.top;
|
||||
nscoord bottomInset = borderPadding.bottom;
|
||||
PRUint8 verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_MIDDLE;
|
||||
if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) {
|
||||
verticalAlignFlags = textStyle->mVerticalAlign.GetIntValue();
|
||||
|
@ -235,10 +236,13 @@ NS_METHOD nsTableCellFrame::ResizeReflow(nsIPresContext* aPresContext,
|
|||
// Compute the insets (sum of border and padding)
|
||||
nsStyleSpacing* spacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nscoord topInset = spacing->mBorderPadding.top;
|
||||
nscoord rightInset = spacing->mBorderPadding.right;
|
||||
nscoord bottomInset = spacing->mBorderPadding.bottom;
|
||||
nscoord leftInset = spacing->mBorderPadding.left;
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
|
||||
nscoord topInset = borderPadding.top;
|
||||
nscoord rightInset = borderPadding.right;
|
||||
nscoord bottomInset = borderPadding.bottom;
|
||||
nscoord leftInset = borderPadding.left;
|
||||
|
||||
// reduce available space by insets
|
||||
if (NS_UNCONSTRAINEDSIZE!=availSize.width)
|
||||
|
@ -358,29 +362,27 @@ nsTableCellFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
|
|||
* Update the border style to map to the HTML border style
|
||||
*
|
||||
*/
|
||||
void nsTableCellFrame::MapHTMLBorderStyle(nsStyleBorder& aBorderStyle, nscoord aBorderWidth)
|
||||
void nsTableCellFrame::MapHTMLBorderStyle(nsStyleSpacing& aSpacingStyle, nscoord aBorderWidth)
|
||||
{
|
||||
for (PRInt32 index = 0; index < 4; index++)
|
||||
aBorderStyle.mSizeFlag[index] = NS_STYLE_BORDER_WIDTH_LENGTH_VALUE;
|
||||
nsStyleCoord width;
|
||||
width.SetCoordValue(aBorderWidth);
|
||||
aSpacingStyle.mBorder.SetTop(width);
|
||||
aSpacingStyle.mBorder.SetLeft(width);
|
||||
aSpacingStyle.mBorder.SetBottom(width);
|
||||
aSpacingStyle.mBorder.SetRight(width);
|
||||
|
||||
aBorderStyle.mSize.top =
|
||||
aBorderStyle.mSize.left =
|
||||
aBorderStyle.mSize.bottom =
|
||||
aBorderStyle.mSize.right = aBorderWidth;
|
||||
|
||||
|
||||
aBorderStyle.mStyle[NS_SIDE_TOP] = NS_STYLE_BORDER_STYLE_INSET;
|
||||
aBorderStyle.mStyle[NS_SIDE_LEFT] = NS_STYLE_BORDER_STYLE_INSET;
|
||||
aBorderStyle.mStyle[NS_SIDE_BOTTOM] = NS_STYLE_BORDER_STYLE_OUTSET;
|
||||
aBorderStyle.mStyle[NS_SIDE_RIGHT] = NS_STYLE_BORDER_STYLE_OUTSET;
|
||||
aSpacingStyle.mBorderStyle[NS_SIDE_TOP] = NS_STYLE_BORDER_STYLE_INSET;
|
||||
aSpacingStyle.mBorderStyle[NS_SIDE_LEFT] = NS_STYLE_BORDER_STYLE_INSET;
|
||||
aSpacingStyle.mBorderStyle[NS_SIDE_BOTTOM] = NS_STYLE_BORDER_STYLE_OUTSET;
|
||||
aSpacingStyle.mBorderStyle[NS_SIDE_RIGHT] = NS_STYLE_BORDER_STYLE_OUTSET;
|
||||
|
||||
NS_ColorNameToRGB("white",&aBorderStyle.mColor[NS_SIDE_TOP]);
|
||||
NS_ColorNameToRGB("white",&aBorderStyle.mColor[NS_SIDE_LEFT]);
|
||||
NS_ColorNameToRGB("white",&aSpacingStyle.mBorderColor[NS_SIDE_TOP]);
|
||||
NS_ColorNameToRGB("white",&aSpacingStyle.mBorderColor[NS_SIDE_LEFT]);
|
||||
|
||||
// This should be the background color of the tables
|
||||
// container
|
||||
NS_ColorNameToRGB("gray",&aBorderStyle.mColor[NS_SIDE_BOTTOM]);
|
||||
NS_ColorNameToRGB("gray",&aBorderStyle.mColor[NS_SIDE_RIGHT]);
|
||||
NS_ColorNameToRGB("gray",&aSpacingStyle.mBorderColor[NS_SIDE_BOTTOM]);
|
||||
NS_ColorNameToRGB("gray",&aSpacingStyle.mBorderColor[NS_SIDE_RIGHT]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -431,24 +433,30 @@ void nsTableCellFrame::MapBorderMarginPadding(nsIPresContext* aPresContext)
|
|||
spacing_result = table->GetAttribute(nsHTMLAtoms::cellspacing,spacing_value);
|
||||
border_result = table->GetAttribute(nsHTMLAtoms::border,border_value);
|
||||
|
||||
nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
|
||||
// check to see if cellpadding or cellspacing is defined
|
||||
if (spacing_result == eContentAttr_HasValue || padding_result == eContentAttr_HasValue)
|
||||
{
|
||||
|
||||
PRInt32 value;
|
||||
nsStyleCoord padding(0, eStyleUnit_Coord);
|
||||
nsStyleCoord spacing(0, eStyleUnit_Coord);
|
||||
|
||||
if (padding_result == eContentAttr_HasValue && ConvertToIntValue(padding_value,0,value))
|
||||
padding = (nscoord)(p2t*(float)value);
|
||||
padding.SetCoordValue((nscoord)(p2t*(float)value));
|
||||
|
||||
if (spacing_result == eContentAttr_HasValue && ConvertToIntValue(spacing_value,0,value))
|
||||
spacing = (nscoord)(p2t*(float)value);
|
||||
spacing.SetCoordValue((nscoord)(p2t*(float)value));
|
||||
|
||||
nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
spacingData->mMargin.SizeTo(spacing,spacing,spacing,spacing);
|
||||
spacingData->mPadding.top =
|
||||
spacingData->mPadding.left =
|
||||
spacingData->mPadding.bottom =
|
||||
spacingData->mPadding.right = padding;
|
||||
spacingData->mMargin.SetTop(spacing);
|
||||
spacingData->mMargin.SetLeft(spacing);
|
||||
spacingData->mMargin.SetBottom(spacing);
|
||||
spacingData->mMargin.SetRight(spacing);
|
||||
spacingData->mPadding.SetTop(padding);
|
||||
spacingData->mPadding.SetLeft(padding);
|
||||
spacingData->mPadding.SetBottom(padding);
|
||||
spacingData->mPadding.SetRight(padding);
|
||||
|
||||
}
|
||||
if (border_result == eContentAttr_HasValue)
|
||||
|
@ -462,8 +470,7 @@ void nsTableCellFrame::MapBorderMarginPadding(nsIPresContext* aPresContext)
|
|||
border = nscoord(p2t*(float)intValue);
|
||||
}
|
||||
}
|
||||
nsStyleBorder& borderData = *(nsStyleBorder*)mStyleContext->GetData(kStyleBorderSID);
|
||||
MapHTMLBorderStyle(borderData,border);
|
||||
MapHTMLBorderStyle(*spacingData,border);
|
||||
}
|
||||
|
||||
void nsTableCellFrame::MapTextAttributes(nsIPresContext* aPresContext)
|
||||
|
@ -489,7 +496,7 @@ NS_METHOD nsTableCellFrame::DidSetStyleContext(nsIPresContext* aPresContext)
|
|||
|
||||
MapTextAttributes(aPresContext);
|
||||
MapBorderMarginPadding(aPresContext);
|
||||
mStyleContext->RecalcAutomaticData();
|
||||
mStyleContext->RecalcAutomaticData(aPresContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "nsContainerFrame.h"
|
||||
#include "nsTableCell.h"
|
||||
|
||||
struct nsStyleSpacing;
|
||||
|
||||
/**
|
||||
* nsTableCellFrame
|
||||
* data structure to maintain information about a single table cell's frame
|
||||
|
@ -89,7 +91,7 @@ protected:
|
|||
NS_METHOD DidSetStyleContext(nsIPresContext* aPresContext);
|
||||
void MapTextAttributes(nsIPresContext* aPresContext);
|
||||
void MapBorderMarginPadding(nsIPresContext* aPresContext);
|
||||
void MapHTMLBorderStyle(nsStyleBorder& aBorderStyle, nscoord aBorderWidth);
|
||||
void MapHTMLBorderStyle(nsStyleSpacing& aSpacingStyle, nscoord aBorderWidth);
|
||||
PRBool ConvertToIntValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult);
|
||||
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ static const PRBool gsDebugMBP = PR_FALSE;
|
|||
#define max(x, y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
|
||||
static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID);
|
||||
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
|
||||
static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
|
||||
|
@ -104,7 +103,7 @@ struct InnerTableReflowState {
|
|||
|
||||
InnerTableReflowState(nsIPresContext* aPresContext,
|
||||
const nsSize& aMaxSize,
|
||||
nsStyleSpacing* aStyleSpacing)
|
||||
const nsMargin& aBorderPadding)
|
||||
{
|
||||
prevMaxPosBottomMargin = 0;
|
||||
prevMaxNegBottomMargin = 0;
|
||||
|
@ -113,18 +112,16 @@ struct InnerTableReflowState {
|
|||
unconstrainedWidth = PRBool(aMaxSize.width == NS_UNCONSTRAINEDSIZE);
|
||||
availSize.width = aMaxSize.width;
|
||||
if (!unconstrainedWidth) {
|
||||
availSize.width -= aStyleSpacing->mBorderPadding.left +
|
||||
aStyleSpacing->mBorderPadding.right;
|
||||
availSize.width -= aBorderPadding.left + aBorderPadding.right;
|
||||
}
|
||||
leftInset = aStyleSpacing->mBorderPadding.left;
|
||||
leftInset = aBorderPadding.left;
|
||||
|
||||
unconstrainedHeight = PRBool(aMaxSize.height == NS_UNCONSTRAINEDSIZE);
|
||||
availSize.height = aMaxSize.height;
|
||||
if (!unconstrainedHeight) {
|
||||
availSize.height -= aStyleSpacing->mBorderPadding.top +
|
||||
aStyleSpacing->mBorderPadding.bottom;
|
||||
availSize.height -= aBorderPadding.top + aBorderPadding.bottom;
|
||||
}
|
||||
topInset = aStyleSpacing->mBorderPadding.top;
|
||||
topInset = aBorderPadding.top;
|
||||
|
||||
firstRowGroup = PR_TRUE;
|
||||
footerHeight = 0;
|
||||
|
@ -432,16 +429,16 @@ NS_METHOD nsTableFrame::Paint(nsIPresContext& aPresContext,
|
|||
// table paint code is concerned primarily with borders and bg color
|
||||
nsStyleColor* myColor =
|
||||
(nsStyleColor*)mStyleContext->GetData(kStyleColorSID);
|
||||
nsStyleBorder* myBorder =
|
||||
(nsStyleBorder*)mStyleContext->GetData(kStyleBorderSID);
|
||||
nsStyleSpacing* mySpacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
NS_ASSERTION(nsnull != myColor, "null style color");
|
||||
NS_ASSERTION(nsnull != myBorder, "null style border");
|
||||
if (nsnull!=myBorder)
|
||||
NS_ASSERTION(nsnull != mySpacing, "null style spacing");
|
||||
if (nsnull!=mySpacing)
|
||||
{
|
||||
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *myColor);
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, mRect, *myBorder, 0);
|
||||
aDirtyRect, mRect, *mySpacing, 0);
|
||||
}
|
||||
|
||||
// for debug...
|
||||
|
@ -594,10 +591,12 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
|||
// Compute the insets (sum of border and padding)
|
||||
nsStyleSpacing* spacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nscoord topInset = spacing->mBorderPadding.top;
|
||||
nscoord rightInset = spacing->mBorderPadding.right;
|
||||
nscoord bottomInset =spacing->mBorderPadding.bottom;
|
||||
nscoord leftInset = spacing->mBorderPadding.left;
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
nscoord topInset = borderPadding.top;
|
||||
nscoord rightInset = borderPadding.right;
|
||||
nscoord bottomInset = borderPadding.bottom;
|
||||
nscoord leftInset = borderPadding.left;
|
||||
|
||||
/* assumes that Table's children are in the following order:
|
||||
* Captions
|
||||
|
@ -756,7 +755,10 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
|||
|
||||
nsStyleSpacing* mySpacing = (nsStyleSpacing*)
|
||||
mStyleContext->GetData(kStyleSpacingSID);
|
||||
InnerTableReflowState state(aPresContext, aMaxSize, mySpacing);
|
||||
nsMargin myBorderPadding;
|
||||
mySpacing->CalcBorderPaddingFor(this, myBorderPadding);
|
||||
|
||||
InnerTableReflowState state(aPresContext, aMaxSize, myBorderPadding);
|
||||
|
||||
// Reflow the existing frames
|
||||
if (nsnull != mFirstChild) {
|
||||
|
@ -835,12 +837,12 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
|||
// Collapse child's top margin with previous bottom margin
|
||||
nscoord nsTableFrame::GetTopMarginFor(nsIPresContext* aCX,
|
||||
InnerTableReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing)
|
||||
const nsMargin& aKidMargin)
|
||||
{
|
||||
nscoord margin;
|
||||
nscoord maxNegTopMargin = 0;
|
||||
nscoord maxPosTopMargin = 0;
|
||||
if ((margin = aKidSpacing->mMargin.top) < 0) {
|
||||
if ((margin = aKidMargin.top) < 0) {
|
||||
maxNegTopMargin = -margin;
|
||||
} else {
|
||||
maxPosTopMargin = margin;
|
||||
|
@ -993,8 +995,11 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
|
|||
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
|
||||
nscoord bottomMargin = kidSpacing->mMargin.bottom;
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kidFrame, kidMargin);
|
||||
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMargin);
|
||||
nscoord bottomMargin = kidMargin.bottom;
|
||||
|
||||
// Figure out the amount of available size for the child (subtract
|
||||
// off the top margin we are going to apply to it)
|
||||
|
@ -1003,8 +1008,7 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
|
|||
}
|
||||
// Subtract off for left and right margin
|
||||
if (PR_FALSE == aState.unconstrainedWidth) {
|
||||
kidAvailSize.width -= kidSpacing->mMargin.left +
|
||||
kidSpacing->mMargin.right;
|
||||
kidAvailSize.width -= kidMargin.left + kidMargin.right;
|
||||
}
|
||||
|
||||
// Reflow the child into the available space
|
||||
|
@ -1030,7 +1034,7 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
|
|||
// Place the child after taking into account it's margin
|
||||
aState.y += topMargin;
|
||||
nsRect kidRect (0, 0, desiredSize.width, desiredSize.height);
|
||||
kidRect.x += aState.leftInset + kidSpacing->mMargin.left;
|
||||
kidRect.x += aState.leftInset + kidMargin.left;
|
||||
kidRect.y += aState.topInset + aState.y ;
|
||||
PlaceChild(aPresContext, aState, kidFrame, kidRect,
|
||||
aMaxElementSize, kidMaxElementSize);
|
||||
|
@ -1521,6 +1525,8 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
|
|||
|
||||
nsStyleSpacing* spacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
|
||||
// need to figure out the overall table width constraint
|
||||
// default case, get 100% of available space
|
||||
|
@ -1546,7 +1552,7 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
|
|||
// and padding
|
||||
if (NS_UNCONSTRAINEDSIZE!=maxWidth)
|
||||
{
|
||||
maxWidth -= spacing->mBorderPadding.left + spacing->mBorderPadding.right;
|
||||
maxWidth -= borderPadding.left + borderPadding.right;
|
||||
if (0>maxWidth) // nonsense style specification
|
||||
maxWidth = 0;
|
||||
}
|
||||
|
@ -1586,8 +1592,11 @@ void nsTableFrame::SetTableWidth(nsIPresContext* aPresContext)
|
|||
// Compute the insets (sum of border and padding)
|
||||
nsStyleSpacing* spacing =
|
||||
(nsStyleSpacing*)mStyleContext->GetData(kStyleSpacingSID);
|
||||
nscoord rightInset = spacing->mBorderPadding.right;
|
||||
nscoord leftInset = spacing->mBorderPadding.left;
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
|
||||
nscoord rightInset = borderPadding.right;
|
||||
nscoord leftInset = borderPadding.left;
|
||||
tableWidth += (leftInset + rightInset);
|
||||
nsRect tableSize = mRect;
|
||||
tableSize.width = tableWidth;
|
||||
|
@ -1616,8 +1625,10 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
|||
|
||||
nsStyleSpacing* spacing = (nsStyleSpacing*)
|
||||
mStyleContext->GetData(kStyleSpacingSID);
|
||||
tableHeight +=
|
||||
spacing->mBorderPadding.top + spacing->mBorderPadding.bottom;
|
||||
nsMargin borderPadding;
|
||||
spacing->CalcBorderPaddingFor(this, borderPadding);
|
||||
|
||||
tableHeight += borderPadding.top + borderPadding.bottom;
|
||||
|
||||
PRInt32 childCount = mChildCount;
|
||||
nsIFrame * kidFrame;
|
||||
|
|
|
@ -29,7 +29,6 @@ class CellData;
|
|||
class nsITableLayoutStrategy;
|
||||
struct InnerTableReflowState;
|
||||
struct nsStylePosition;
|
||||
struct nsStyleSpacing;
|
||||
|
||||
/** nsTableFrame maps the inner portion of a table (everything except captions.)
|
||||
* Used as a pseudo-frame within nsTableOuterFrame,
|
||||
|
@ -216,7 +215,7 @@ protected:
|
|||
|
||||
nscoord GetTopMarginFor(nsIPresContext* aCX,
|
||||
InnerTableReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing);
|
||||
const nsMargin& aKidMargin);
|
||||
|
||||
void PlaceChild(nsIPresContext* aPresContext,
|
||||
InnerTableReflowState& aState,
|
||||
|
|
|
@ -343,12 +343,12 @@ NS_METHOD nsTableOuterFrame::ResizeReflow(nsIPresContext* aPresContext,
|
|||
// Collapse child's top margin with previous bottom margin
|
||||
nscoord nsTableOuterFrame::GetTopMarginFor(nsIPresContext* aCX,
|
||||
OuterTableReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing)
|
||||
const nsMargin& aKidMargin)
|
||||
{
|
||||
nscoord margin;
|
||||
nscoord maxNegTopMargin = 0;
|
||||
nscoord maxPosTopMargin = 0;
|
||||
if ((margin = aKidSpacing->mMargin.top) < 0) {
|
||||
if ((margin = aKidMargin.top) < 0) {
|
||||
maxNegTopMargin = -margin;
|
||||
} else {
|
||||
maxPosTopMargin = margin;
|
||||
|
@ -463,8 +463,10 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
|
|||
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
|
||||
nsStyleSpacing* kidSpacing =
|
||||
(nsStyleSpacing*)kidSC->GetData(kStyleSpacingSID);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
|
||||
nscoord bottomMargin = kidSpacing->mMargin.bottom;
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kidFrame, kidMargin);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMargin);
|
||||
nscoord bottomMargin = kidMargin.bottom;
|
||||
|
||||
// Figure out the amount of available size for the child (subtract
|
||||
// off the top margin we are going to apply to it)
|
||||
|
@ -473,7 +475,7 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
|
|||
}
|
||||
// Subtract off for left and right margin
|
||||
if (PR_FALSE == aState.unconstrainedWidth) {
|
||||
aState.availSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
|
||||
aState.availSize.width -= kidMargin.left + kidMargin.right;
|
||||
}
|
||||
|
||||
// Only skip the reflow if this is not our first child and we are
|
||||
|
@ -503,7 +505,7 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
|
|||
// Place the child after taking into account it's margin
|
||||
aState.y += topMargin;
|
||||
nsRect kidRect (0, 0, kidSize.width, kidSize.height);
|
||||
kidRect.x += kidSpacing->mMargin.left;
|
||||
kidRect.x += kidMargin.left;
|
||||
kidRect.y += aState.y;
|
||||
PlaceChild(aState, kidFrame, kidRect, aMaxElementSize, kidMaxElementSize);
|
||||
if (bottomMargin < 0) {
|
||||
|
|
|
@ -25,7 +25,6 @@ class nsTableFrame;
|
|||
class nsVoidArray;
|
||||
class nsTableCaptionFrame;
|
||||
struct OuterTableReflowState;
|
||||
struct nsStyleSpacing;
|
||||
|
||||
/**
|
||||
* main frame for an nsTable content object,
|
||||
|
@ -157,7 +156,7 @@ protected:
|
|||
|
||||
nscoord GetTopMarginFor(nsIPresContext* aCX,
|
||||
OuterTableReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing);
|
||||
const nsMargin& aKidMargin);
|
||||
|
||||
void PlaceChild( OuterTableReflowState& aState,
|
||||
nsIFrame* aKidFrame,
|
||||
|
|
|
@ -170,12 +170,12 @@ PRInt32 nsTableRowFrame::GetTallestChild() const
|
|||
// Collapse child's top margin with previous bottom margin
|
||||
nscoord nsTableRowFrame::GetTopMarginFor( nsIPresContext* aCX,
|
||||
RowReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing)
|
||||
const nsMargin& aKidMargin)
|
||||
{
|
||||
nscoord margin;
|
||||
nscoord maxNegTopMargin = 0;
|
||||
nscoord maxPosTopMargin = 0;
|
||||
if ((margin = aKidSpacing->mMargin.top) < 0) {
|
||||
if ((margin = aKidMargin.top) < 0) {
|
||||
maxNegTopMargin = -margin;
|
||||
} else {
|
||||
maxPosTopMargin = margin;
|
||||
|
@ -281,8 +281,10 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
|||
kidFrame->GetStyleContext(aPresContext, kidSC);
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
|
||||
nscoord bottomMargin = kidSpacing->mMargin.bottom;
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(kidFrame, kidMargin);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMargin);
|
||||
nscoord bottomMargin = kidMargin.bottom;
|
||||
NS_RELEASE(kidSC);
|
||||
|
||||
// Figure out the amount of available size for the child (subtract
|
||||
|
@ -292,7 +294,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
|||
}
|
||||
// Subtract off for left and right margin
|
||||
if (PR_FALSE == aState.unconstrainedWidth) {
|
||||
kidAvailSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
|
||||
kidAvailSize.width -= kidMargin.left + kidMargin.right;
|
||||
}
|
||||
|
||||
if (NS_UNCONSTRAINEDSIZE == aState.availSize.width)
|
||||
|
@ -426,7 +428,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
|||
// Add back in the left and right margins, because one row does not
|
||||
// impact another row's width
|
||||
if (PR_FALSE == aState.unconstrainedWidth) {
|
||||
kidAvailSize.width += kidSpacing->mMargin.left + kidSpacing->mMargin.right;
|
||||
kidAvailSize.width += kidMargin.left + kidMargin.right;
|
||||
}
|
||||
|
||||
// Get the next child
|
||||
|
@ -805,8 +807,10 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
|
|||
aPresContext->ResolveStyleContextFor(cell, this);
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidStyleContext->GetData(kStyleSpacingSID);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
|
||||
nscoord bottomMargin = kidSpacing->mMargin.bottom;
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(this, kidMargin);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMargin);
|
||||
nscoord bottomMargin = kidMargin.bottom;
|
||||
|
||||
nsIFrame* kidFrame;
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "nsContainerFrame.h"
|
||||
|
||||
struct RowReflowState;
|
||||
struct nsStyleSpacing;
|
||||
|
||||
/**
|
||||
* nsTableRowFrame is the frame that maps table rows
|
||||
|
@ -118,7 +117,7 @@ protected:
|
|||
|
||||
nscoord GetTopMarginFor(nsIPresContext* aCX,
|
||||
RowReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing);
|
||||
const nsMargin& aKidMargin);
|
||||
|
||||
void PlaceChild( nsIPresContext* aPresContext,
|
||||
RowReflowState& aState,
|
||||
|
|
|
@ -164,12 +164,12 @@ void nsTableRowGroupFrame::PaintChildren(nsIPresContext& aPresContext,
|
|||
// Collapse child's top margin with previous bottom margin
|
||||
nscoord nsTableRowGroupFrame::GetTopMarginFor(nsIPresContext* aCX,
|
||||
RowGroupReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing)
|
||||
const nsMargin& aKidMargin)
|
||||
{
|
||||
nscoord margin;
|
||||
nscoord maxNegTopMargin = 0;
|
||||
nscoord maxPosTopMargin = 0;
|
||||
if ((margin = aKidSpacing->mMargin.top) < 0) {
|
||||
if ((margin = aKidMargin.top) < 0) {
|
||||
maxNegTopMargin = -margin;
|
||||
} else {
|
||||
maxPosTopMargin = margin;
|
||||
|
@ -282,8 +282,10 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
|
|||
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
|
||||
nscoord bottomMargin = kidSpacing->mMargin.bottom;
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(this, kidMargin);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMargin);
|
||||
nscoord bottomMargin = kidMargin.bottom;
|
||||
|
||||
// Figure out the amount of available size for the child (subtract
|
||||
// off the top margin we are going to apply to it)
|
||||
|
@ -292,7 +294,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
|
|||
}
|
||||
// Subtract off for left and right margin
|
||||
if (PR_FALSE == aState.unconstrainedWidth) {
|
||||
kidAvailSize.width -= kidSpacing->mMargin.left + kidSpacing->mMargin.right;
|
||||
kidAvailSize.width -= kidMargin.left + kidMargin.right;
|
||||
}
|
||||
|
||||
// Reflow the child into the available space
|
||||
|
@ -325,7 +327,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
|
|||
// Place the child after taking into account it's margin
|
||||
aState.y += topMargin;
|
||||
nsRect kidRect (0, 0, desiredSize.width, desiredSize.height);
|
||||
kidRect.x += kidSpacing->mMargin.left;
|
||||
kidRect.x += kidMargin.left;
|
||||
kidRect.y += aState.y;
|
||||
PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize,
|
||||
kidMaxElementSize);
|
||||
|
@ -394,7 +396,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
|
|||
// Add back in the left and right margins, because one row does not
|
||||
// impact another row's width
|
||||
if (PR_FALSE == aState.unconstrainedWidth) {
|
||||
kidAvailSize.width += kidSpacing->mMargin.left + kidSpacing->mMargin.right;
|
||||
kidAvailSize.width += kidMargin.left + kidMargin.right;
|
||||
}
|
||||
|
||||
// Get the next child
|
||||
|
@ -736,8 +738,10 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
|
|||
aPresContext->ResolveStyleContextFor(kid, this);
|
||||
nsStyleSpacing* kidSpacing = (nsStyleSpacing*)
|
||||
kidSC->GetData(kStyleSpacingSID);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidSpacing);
|
||||
nscoord bottomMargin = kidSpacing->mMargin.bottom;
|
||||
nsMargin kidMargin;
|
||||
kidSpacing->CalcMarginFor(this, kidMargin);
|
||||
nscoord topMargin = GetTopMarginFor(aPresContext, aState, kidMargin);
|
||||
nscoord bottomMargin = kidMargin.bottom;
|
||||
|
||||
nsIFrame* kidFrame;
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "nsIAtom.h"
|
||||
|
||||
struct RowGroupReflowState;
|
||||
struct nsStyleSpacing;
|
||||
|
||||
/**
|
||||
* nsTableRowGroupFrame is the frame that maps row groups
|
||||
|
@ -111,7 +110,7 @@ protected:
|
|||
|
||||
nscoord GetTopMarginFor(nsIPresContext* aCX,
|
||||
RowGroupReflowState& aState,
|
||||
nsStyleSpacing* aKidSpacing);
|
||||
const nsMargin& aKidMargin);
|
||||
|
||||
void PlaceChild( nsIPresContext* aPresContext,
|
||||
RowGroupReflowState& aState,
|
||||
|
|
Загрузка…
Ссылка в новой задаче