Added ComputePadding() member function

This commit is contained in:
troy%netscape.com 1999-03-06 00:36:59 +00:00
Родитель 8ca03df6c8
Коммит 4810c912a1
3 изменённых файлов: 87 добавлений и 3 удалений

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

@ -740,7 +740,7 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
(computedMargin.right < 200000), "oy");
#endif
ComputeBorderFor(frame, mComputedBorderPadding);
ComputePaddingFor(frame, parentReflowState, mComputedPadding);
ComputePadding(containingBlockWidth);
mComputedBorderPadding += mComputedPadding;
nsStyleUnit widthUnit = mStylePosition->mWidth.GetUnit();
@ -1265,6 +1265,46 @@ nsHTMLReflowState::ComputeMargin(nscoord aContainingBlockWidth)
}
}
void
nsHTMLReflowState::ComputePadding(nscoord aContainingBlockWidth)
{
// If style can provide us the padding directly, then use it.
#if 0
if (!mStyleSpacing->GetPadding(mComputedPadding))
#else
mStyleSpacing->CalcPaddingFor(frame, mComputedPadding);
if ((eStyleUnit_Percent == mStyleSpacing->mPadding.GetTopUnit()) ||
(eStyleUnit_Percent == mStyleSpacing->mPadding.GetRightUnit()) ||
(eStyleUnit_Percent == mStyleSpacing->mPadding.GetBottomUnit()) ||
(eStyleUnit_Percent == mStyleSpacing->mPadding.GetLeftUnit()))
#endif
{
// We have to compute the value (because it's uncomputable by
// the style code).
nsStyleCoord left, right, top, bottom;
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetLeftUnit(),
mStyleSpacing->mPadding.GetLeft(left),
mComputedPadding.left);
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetRightUnit(),
mStyleSpacing->mPadding.GetRight(right),
mComputedPadding.right);
// According to the CSS2 spec, padding percentages are
// calculated with respect to the *width* of the containing
// block, even for padding-top and padding-bottom.
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetTopUnit(),
mStyleSpacing->mPadding.GetTop(top),
mComputedPadding.top);
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetBottomUnit(),
mStyleSpacing->mPadding.GetBottom(bottom),
mComputedPadding.bottom);
}
}
void
nsHTMLReflowState::ComputePaddingFor(nsIFrame* aFrame,
const nsReflowState* aParentRS,

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

@ -740,7 +740,7 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
(computedMargin.right < 200000), "oy");
#endif
ComputeBorderFor(frame, mComputedBorderPadding);
ComputePaddingFor(frame, parentReflowState, mComputedPadding);
ComputePadding(containingBlockWidth);
mComputedBorderPadding += mComputedPadding;
nsStyleUnit widthUnit = mStylePosition->mWidth.GetUnit();
@ -1265,6 +1265,46 @@ nsHTMLReflowState::ComputeMargin(nscoord aContainingBlockWidth)
}
}
void
nsHTMLReflowState::ComputePadding(nscoord aContainingBlockWidth)
{
// If style can provide us the padding directly, then use it.
#if 0
if (!mStyleSpacing->GetPadding(mComputedPadding))
#else
mStyleSpacing->CalcPaddingFor(frame, mComputedPadding);
if ((eStyleUnit_Percent == mStyleSpacing->mPadding.GetTopUnit()) ||
(eStyleUnit_Percent == mStyleSpacing->mPadding.GetRightUnit()) ||
(eStyleUnit_Percent == mStyleSpacing->mPadding.GetBottomUnit()) ||
(eStyleUnit_Percent == mStyleSpacing->mPadding.GetLeftUnit()))
#endif
{
// We have to compute the value (because it's uncomputable by
// the style code).
nsStyleCoord left, right, top, bottom;
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetLeftUnit(),
mStyleSpacing->mPadding.GetLeft(left),
mComputedPadding.left);
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetRightUnit(),
mStyleSpacing->mPadding.GetRight(right),
mComputedPadding.right);
// According to the CSS2 spec, padding percentages are
// calculated with respect to the *width* of the containing
// block, even for padding-top and padding-bottom.
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetTopUnit(),
mStyleSpacing->mPadding.GetTop(top),
mComputedPadding.top);
ComputeHorizontalValue(aContainingBlockWidth,
mStyleSpacing->mPadding.GetBottomUnit(),
mStyleSpacing->mPadding.GetBottom(bottom),
mComputedPadding.bottom);
}
}
void
nsHTMLReflowState::ComputePaddingFor(nsIFrame* aFrame,
const nsReflowState* aParentRS,

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

@ -345,9 +345,13 @@ protected:
const nsStylePosition* aPosition,
const nsStyleDisplay* aDisplay);
// Computes margins from the specified margin style information, and
// Computes margin values from the specified margin style information, and
// fills in the mComputedMargin member
void ComputeMargin(nscoord aContainingBlockWidth);
// Computes padding values from the specified padding style information, and
// fills in the mComputedPadding member
void ComputePadding(nscoord aContainingBlockWidth);
};
//----------------------------------------------------------------------