Work around 3238 partially until we have a real solution

This commit is contained in:
kipp%netscape.com 1999-03-22 20:45:26 +00:00
parent bee4a28ce9
commit 524580850c
6 changed files with 84 additions and 72 deletions

View File

@ -107,6 +107,7 @@ nsBlockReflowContext::ReflowBlock(nsIFrame* aFrame,
if (!aIsAdjacentWithTop) {
reflowState.isTopOfPage = PR_FALSE; // make sure this is cleared
}
mIsTable = NS_STYLE_DISPLAY_TABLE == reflowState.mStyleDisplay->mDisplay;
// Compute x/y coordinate where reflow will begin. Use the rules
// from 10.3.3 to determine what to apply. At this point in the
@ -332,22 +333,22 @@ nsBlockReflowContext::PlaceBlock(PRBool aForceFit,
#endif
// See if the block will fit in the available space
PRBool fits;
PRBool fits = PR_TRUE;
nscoord x = mX;
nscoord y = mY;
if (0 == mMetrics.height) {
// Empty blocks do not have anything special done to them and they
// always fit.
nsRect r(mX, mY, 0, 0);
nsRect r(x, y, 0, 0);
mFrame->SetRect(r);
aInFlowBounds = r;
aCombinedRect = mMetrics.mCombinedArea;
aCombinedRect.x += x;
aCombinedRect.y += y;
mTopMargin = 0;
mBottomMargin = 0;
fits = PR_TRUE;
}
else {
nscoord x = mX;
nscoord y = mY;
// Apply top margin unless it's going to be carried out.
#ifndef SPECULATIVE_TOP_MARGIN
if (aApplyTopMargin) {
@ -358,8 +359,6 @@ nsBlockReflowContext::PlaceBlock(PRBool aForceFit,
// See if the frame fit. If its the first frame then it always
// fits.
if (aForceFit || (y + mMetrics.height <= mSpace.YMost())) {
fits = PR_TRUE;
// Get style unit associated with the left and right margins
nsStyleUnit leftUnit = mStyleSpacing->mMargin.GetLeftUnit();
if (eStyleUnit_Inherit == leftUnit) {
@ -393,38 +392,42 @@ nsBlockReflowContext::PlaceBlock(PRBool aForceFit,
}
}
else if (eStyleUnit_Auto != rightUnit) {
#if XXX_not_in_css2
// When neither margin is auto then text-align applies
const nsStyleText* styleText = mOuterReflowState.mStyleText;
switch (styleText->mTextAlign) {
case NS_STYLE_TEXT_ALIGN_DEFAULT:
case NS_STYLE_TEXT_ALIGN_JUSTIFY:
if (NS_STYLE_DIRECTION_RTL == mOuterReflowState.mDirection) {
// When given a default alignment, and a right-to-left
// direction, right align the frame.
PRBool mozCenter = PR_TRUE;/* XXX compatability-mode or ua.css hack */
PRUint8 direction = mOuterReflowState.mStyleDisplay->mDirection;
if (mozCenter && mIsTable) {
// When neither margin is auto then text-align applies
const nsStyleText* styleText;
mOuterReflowState.frame->GetStyleData(eStyleStruct_Text,
(const nsStyleStruct*&)styleText);
switch (styleText->mTextAlign) {
case NS_STYLE_TEXT_ALIGN_DEFAULT:
case NS_STYLE_TEXT_ALIGN_JUSTIFY:
if (NS_STYLE_DIRECTION_RTL == direction) {
// When given a default alignment, and a right-to-left
// direction, right align the frame.
x += remainder;
}
break;
case NS_STYLE_TEXT_ALIGN_RIGHT:
x += remainder;
}
break;
case NS_STYLE_TEXT_ALIGN_RIGHT:
x += remainder;
break;
case NS_STYLE_TEXT_ALIGN_CENTER:
x += remainder / 2;
break;
}
#else
// When neither margin is auto then the block is said to
// be over constrained, Depending on the direction, choose
// which margin to treat as auto.
if (NS_STYLE_DIRECTION_RTL ==
mOuterReflowState.mStyleDisplay->mDirection) {
// The left margin becomes auto
x += remainder;
break;
case NS_STYLE_TEXT_ALIGN_CENTER:
x += remainder / 2;
break;
}
}
else {
// The right margin becomes auto which is a no-op
// When neither margin is auto then the block is said to
// be over constrained, Depending on the direction, choose
// which margin to treat as auto.
if (NS_STYLE_DIRECTION_RTL == direction) {
// The left margin becomes auto
x += remainder;
}
else {
// The right margin becomes auto which is a no-op
}
}
#endif
}
}
}

View File

@ -142,6 +142,7 @@ protected:
nscoord mTopMargin;
nscoord mBottomMargin;
nsSize mMaxElementSize;
PRBool mIsTable;
};
#endif /* nsBlockReflowContext_h___ */

View File

@ -1071,11 +1071,13 @@ nsHTMLReflowState::CalculateLeftRightMargin(const nsHTMLReflowState* cbrs,
if (!isAutoLeftMargin && !isAutoRightMargin) {
// Neither margin is 'auto' so we're over constrained. Use the
// 'direction' property to tell which margin to ignore
/*XXX*/ if (NS_STYLE_DISPLAY_TABLE != mStyleDisplay->mDisplay) {
if (NS_STYLE_DIRECTION_LTR == mStyleDisplay->mDirection) {
isAutoRightMargin = PR_TRUE;
} else {
isAutoLeftMargin = PR_TRUE;
}
/*XXX*/ }
}
if (isAutoLeftMargin) {

View File

@ -107,6 +107,7 @@ nsBlockReflowContext::ReflowBlock(nsIFrame* aFrame,
if (!aIsAdjacentWithTop) {
reflowState.isTopOfPage = PR_FALSE; // make sure this is cleared
}
mIsTable = NS_STYLE_DISPLAY_TABLE == reflowState.mStyleDisplay->mDisplay;
// Compute x/y coordinate where reflow will begin. Use the rules
// from 10.3.3 to determine what to apply. At this point in the
@ -332,22 +333,22 @@ nsBlockReflowContext::PlaceBlock(PRBool aForceFit,
#endif
// See if the block will fit in the available space
PRBool fits;
PRBool fits = PR_TRUE;
nscoord x = mX;
nscoord y = mY;
if (0 == mMetrics.height) {
// Empty blocks do not have anything special done to them and they
// always fit.
nsRect r(mX, mY, 0, 0);
nsRect r(x, y, 0, 0);
mFrame->SetRect(r);
aInFlowBounds = r;
aCombinedRect = mMetrics.mCombinedArea;
aCombinedRect.x += x;
aCombinedRect.y += y;
mTopMargin = 0;
mBottomMargin = 0;
fits = PR_TRUE;
}
else {
nscoord x = mX;
nscoord y = mY;
// Apply top margin unless it's going to be carried out.
#ifndef SPECULATIVE_TOP_MARGIN
if (aApplyTopMargin) {
@ -358,8 +359,6 @@ nsBlockReflowContext::PlaceBlock(PRBool aForceFit,
// See if the frame fit. If its the first frame then it always
// fits.
if (aForceFit || (y + mMetrics.height <= mSpace.YMost())) {
fits = PR_TRUE;
// Get style unit associated with the left and right margins
nsStyleUnit leftUnit = mStyleSpacing->mMargin.GetLeftUnit();
if (eStyleUnit_Inherit == leftUnit) {
@ -393,38 +392,42 @@ nsBlockReflowContext::PlaceBlock(PRBool aForceFit,
}
}
else if (eStyleUnit_Auto != rightUnit) {
#if XXX_not_in_css2
// When neither margin is auto then text-align applies
const nsStyleText* styleText = mOuterReflowState.mStyleText;
switch (styleText->mTextAlign) {
case NS_STYLE_TEXT_ALIGN_DEFAULT:
case NS_STYLE_TEXT_ALIGN_JUSTIFY:
if (NS_STYLE_DIRECTION_RTL == mOuterReflowState.mDirection) {
// When given a default alignment, and a right-to-left
// direction, right align the frame.
PRBool mozCenter = PR_TRUE;/* XXX compatability-mode or ua.css hack */
PRUint8 direction = mOuterReflowState.mStyleDisplay->mDirection;
if (mozCenter && mIsTable) {
// When neither margin is auto then text-align applies
const nsStyleText* styleText;
mOuterReflowState.frame->GetStyleData(eStyleStruct_Text,
(const nsStyleStruct*&)styleText);
switch (styleText->mTextAlign) {
case NS_STYLE_TEXT_ALIGN_DEFAULT:
case NS_STYLE_TEXT_ALIGN_JUSTIFY:
if (NS_STYLE_DIRECTION_RTL == direction) {
// When given a default alignment, and a right-to-left
// direction, right align the frame.
x += remainder;
}
break;
case NS_STYLE_TEXT_ALIGN_RIGHT:
x += remainder;
}
break;
case NS_STYLE_TEXT_ALIGN_RIGHT:
x += remainder;
break;
case NS_STYLE_TEXT_ALIGN_CENTER:
x += remainder / 2;
break;
}
#else
// When neither margin is auto then the block is said to
// be over constrained, Depending on the direction, choose
// which margin to treat as auto.
if (NS_STYLE_DIRECTION_RTL ==
mOuterReflowState.mStyleDisplay->mDirection) {
// The left margin becomes auto
x += remainder;
break;
case NS_STYLE_TEXT_ALIGN_CENTER:
x += remainder / 2;
break;
}
}
else {
// The right margin becomes auto which is a no-op
// When neither margin is auto then the block is said to
// be over constrained, Depending on the direction, choose
// which margin to treat as auto.
if (NS_STYLE_DIRECTION_RTL == direction) {
// The left margin becomes auto
x += remainder;
}
else {
// The right margin becomes auto which is a no-op
}
}
#endif
}
}
}

View File

@ -142,6 +142,7 @@ protected:
nscoord mTopMargin;
nscoord mBottomMargin;
nsSize mMaxElementSize;
PRBool mIsTable;
};
#endif /* nsBlockReflowContext_h___ */

View File

@ -1071,11 +1071,13 @@ nsHTMLReflowState::CalculateLeftRightMargin(const nsHTMLReflowState* cbrs,
if (!isAutoLeftMargin && !isAutoRightMargin) {
// Neither margin is 'auto' so we're over constrained. Use the
// 'direction' property to tell which margin to ignore
/*XXX*/ if (NS_STYLE_DISPLAY_TABLE != mStyleDisplay->mDisplay) {
if (NS_STYLE_DIRECTION_LTR == mStyleDisplay->mDirection) {
isAutoRightMargin = PR_TRUE;
} else {
isAutoLeftMargin = PR_TRUE;
}
/*XXX*/ }
}
if (isAutoLeftMargin) {