зеркало из https://github.com/mozilla/pjs.git
Work around more bugs in the style context code and use old margin calculations; factored get-containing-block-width better
This commit is contained in:
Родитель
a67079f75c
Коммит
1b29a31cc1
|
@ -57,32 +57,40 @@ nsHTMLReflowState::GetPageBoxReflowState(const nsReflowState* aParentRS)
|
|||
}
|
||||
|
||||
nscoord
|
||||
nsHTMLReflowState::GetContainingBlockContentWidth() const
|
||||
nsHTMLReflowState::GetContainingBlockContentWidth(const nsReflowState* aParentRS)
|
||||
{
|
||||
nscoord width = 0;
|
||||
const nsHTMLReflowState* rs =
|
||||
GetContainingBlockReflowState(parentReflowState);
|
||||
GetContainingBlockReflowState(aParentRS);
|
||||
if (nsnull != rs) {
|
||||
if (rs->HaveFixedContentWidth()) {
|
||||
width = rs->minWidth;
|
||||
}
|
||||
else if (NS_UNCONSTRAINEDSIZE != rs->maxSize.width) {
|
||||
width = rs->maxSize.width;
|
||||
if (nsnull != rs->frame) {
|
||||
// Subtract out the border and padding values because the
|
||||
// percentage is to be computed relative to the content
|
||||
// width, not the outer width.
|
||||
const nsStyleSpacing* spacing;
|
||||
nsresult rv;
|
||||
rv = rs->frame->GetStyleData(eStyleStruct_Spacing,
|
||||
(const nsStyleStruct*&) spacing);
|
||||
if (NS_SUCCEEDED(rv) && (nsnull != spacing)) {
|
||||
nsMargin borderPadding;
|
||||
rs->ComputeBorderPaddingFor(rs->frame,
|
||||
(nsHTMLReflowState*) rs->parentReflowState,
|
||||
borderPadding);
|
||||
width -= borderPadding.left + borderPadding.right;
|
||||
}
|
||||
return ((nsHTMLReflowState*)aParentRS)->GetContentWidth();/* XXX cast */
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
nscoord
|
||||
nsHTMLReflowState::GetContentWidth() const
|
||||
{
|
||||
nscoord width = 0;
|
||||
if (HaveFixedContentWidth()) {
|
||||
width = minWidth;
|
||||
}
|
||||
else if (NS_UNCONSTRAINEDSIZE != maxSize.width) {
|
||||
width = maxSize.width;
|
||||
if (nsnull != frame) {
|
||||
// Subtract out the border and padding values because the
|
||||
// percentage is to be computed relative to the content
|
||||
// width, not the outer width.
|
||||
const nsStyleSpacing* spacing;
|
||||
nsresult rv;
|
||||
rv = frame->GetStyleData(eStyleStruct_Spacing,
|
||||
(const nsStyleStruct*&) spacing);
|
||||
if (NS_SUCCEEDED(rv) && (nsnull != spacing)) {
|
||||
nsMargin borderPadding;
|
||||
ComputeBorderPaddingFor(frame,
|
||||
parentReflowState,
|
||||
borderPadding);
|
||||
width -= borderPadding.left + borderPadding.right;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +326,7 @@ nsHTMLReflowState::ComputeHorizontalValue(const nsHTMLReflowState& aRS,
|
|||
{
|
||||
aResult = 0;
|
||||
if (eStyleUnit_Percent == aUnit) {
|
||||
nscoord width = aRS.GetContainingBlockContentWidth();
|
||||
nscoord width = aRS.GetContentWidth();
|
||||
float pct = aCoord.GetPercentValue();
|
||||
aResult = NSToCoordFloor(width * pct);
|
||||
}
|
||||
|
@ -333,7 +341,7 @@ nsHTMLReflowState::ComputeVerticalValue(const nsHTMLReflowState& aRS,
|
|||
aResult = 0;
|
||||
if (eStyleUnit_Percent == aUnit) {
|
||||
// XXX temporary!
|
||||
nscoord width = aRS.GetContainingBlockContentWidth();
|
||||
nscoord width = aRS.GetContentWidth();
|
||||
float pct = aCoord.GetPercentValue();
|
||||
aResult = NSToCoordFloor(width * pct);
|
||||
}
|
||||
|
@ -350,7 +358,16 @@ nsHTMLReflowState::ComputeMarginFor(nsIFrame* aFrame,
|
|||
(const nsStyleStruct*&) spacing);
|
||||
if (NS_SUCCEEDED(rv) && (nsnull != spacing)) {
|
||||
// If style style can provide us the margin directly, then use it.
|
||||
if (!spacing->GetMargin(aResult) && (nsnull != aParentRS)) {
|
||||
#if 0
|
||||
if (!spacing->GetMargin(aResult) && (nsnull != aParentRS))
|
||||
#else
|
||||
spacing->CalcMarginFor(aFrame, aResult);
|
||||
if ((eStyleUnit_Percent == spacing->mMargin.GetTopUnit()) ||
|
||||
(eStyleUnit_Percent == spacing->mMargin.GetRightUnit()) ||
|
||||
(eStyleUnit_Percent == spacing->mMargin.GetBottomUnit()) ||
|
||||
(eStyleUnit_Percent == spacing->mMargin.GetLeftUnit()))
|
||||
#endif
|
||||
{
|
||||
// We have to compute the value (because it's uncomputable by
|
||||
// the style code).
|
||||
const nsHTMLReflowState* rs = GetContainingBlockReflowState(aParentRS);
|
||||
|
|
|
@ -224,7 +224,11 @@ struct nsHTMLReflowState : nsReflowState {
|
|||
return eHTMLFrameConstraint_FixedContent == heightConstraint;
|
||||
}
|
||||
|
||||
nscoord GetContainingBlockContentWidth() const;
|
||||
/**
|
||||
* Return the width of the content area based on this reflow state's
|
||||
* state.
|
||||
*/
|
||||
nscoord GetContentWidth() const;
|
||||
|
||||
/**
|
||||
* Get the containing block reflow state, starting from a frames
|
||||
|
@ -234,6 +238,14 @@ struct nsHTMLReflowState : nsReflowState {
|
|||
static const nsHTMLReflowState*
|
||||
GetContainingBlockReflowState(const nsReflowState* aParentRS);
|
||||
|
||||
/**
|
||||
* First find the containing block's reflow state using
|
||||
* GetContainingBlockReflowState, then ask the containing block for
|
||||
* it's content width using GetContentWidth
|
||||
*/
|
||||
static nscoord
|
||||
GetContainingBlockContentWidth(const nsReflowState* aParentRS);
|
||||
|
||||
/**
|
||||
* Get the page box reflow state, starting from a frames
|
||||
* <B>parent</B> reflow state (the parent reflow state may or may not end
|
||||
|
|
Загрузка…
Ссылка в новой задаче