preliminary work for bug 4534

This commit is contained in:
karnaze%netscape.com 1999-04-06 04:47:18 +00:00
parent 7bec300981
commit 49da190d0f
2 changed files with 62 additions and 46 deletions

View File

@ -190,24 +190,24 @@ nsFieldSetFrame::Paint(nsIPresContext& aPresContext,
const nsStyleSpacing* spacing = const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing); (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
//XXX nsRect backgroundRect(0, 0, mRect.width, mRect.height); // XXX nsRect backgroundRect(0, 0, mRect.width, mRect.height);
// XXX our parent doesn't account for top and bottom margins yet, if we are inline // XXX our parent doesn't account for top and bottom margins yet, if we are inline
if (mInline) { //if (mInline) {
nsMargin margin; // nsMargin margin;
spacing->CalcMarginFor(this, margin); // spacing->CalcMarginFor(this, margin);
nsRect rect(0, mTopBorderOffset, mRect.width, mRect.height - margin.top - // nsRect rect(0, mTopBorderOffset, mRect.width, mRect.height - margin.top -
margin.bottom - mTopBorderOffset); // margin.bottom - mTopBorderOffset);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, // nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0); // aDirtyRect, rect, *color, *spacing, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, // nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, skipSides, &mTopBorderGap); // aDirtyRect, rect, *spacing, mStyleContext, skipSides, &mTopBorderGap);
} else { //} else {
nsRect rect(0, mTopBorderOffset, mRect.width, mRect.height - mTopBorderOffset); nsRect rect(0, mTopBorderOffset, mRect.width, mRect.height - mTopBorderOffset);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0); aDirtyRect, rect, *color, *spacing, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, skipSides, &mTopBorderGap); aDirtyRect, rect, *spacing, mStyleContext, skipSides, &mTopBorderGap);
} //}
} }
} }
@ -270,7 +270,9 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
nsReflowStatus& aStatus) nsReflowStatus& aStatus)
{ {
// XXX remove the following when the reflow state is fixed // XXX remove the following when the reflow state is fixed
#ifndef bug4534_not_fixed
FieldSetHack((nsHTMLReflowState&)aReflowState, "fieldset", PR_TRUE); FieldSetHack((nsHTMLReflowState&)aReflowState, "fieldset", PR_TRUE);
#endif
// availSize could have unconstrained values, don't perform any addition on them // availSize could have unconstrained values, don't perform any addition on them
nsSize availSize(aReflowState.computedWidth, aReflowState.computedHeight); nsSize availSize(aReflowState.computedWidth, aReflowState.computedHeight);
@ -281,8 +283,8 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
const nsStyleSpacing* spacing = const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing); (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
nsMargin margin; //nsMargin margin;
spacing->CalcMarginFor(this, margin); //spacing->CalcMarginFor(this, margin);
nsMargin border; nsMargin border;
nsMargin padding; nsMargin padding;
@ -290,7 +292,7 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
spacing->CalcPaddingFor(this, padding); spacing->CalcPaddingFor(this, padding);
nsMargin borderPadding = border + padding; nsMargin borderPadding = border + padding;
nsMargin legendMargin; nsMargin legendMargin(0,0,0,0);
if (mLegendFrame) { if (mLegendFrame) {
nsIStyleContext* legendSC = nsnull; nsIStyleContext* legendSC = nsnull;
mLegendFrame->GetStyleContext(&legendSC); mLegendFrame->GetStyleContext(&legendSC);
@ -304,7 +306,7 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
// reduce available space by border, padding, etc. if we're in a constrained situation // reduce available space by border, padding, etc. if we're in a constrained situation
nscoord horTaken = borderPadding.left + borderPadding.right + legendMargin.left + legendMargin.right; nscoord horTaken = borderPadding.left + borderPadding.right + legendMargin.left + legendMargin.right;
nscoord verTaken = padding.top + borderPadding.bottom + legendMargin.top + legendMargin.bottom; nscoord verTaken = borderPadding.top + borderPadding.bottom + legendMargin.top + legendMargin.bottom;
if (NS_INTRINSICSIZE != availSize.width) { if (NS_INTRINSICSIZE != availSize.width) {
availSize.width -= horTaken; availSize.width -= horTaken;
@ -324,7 +326,9 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowState legendReflowState(aPresContext, aReflowState, nsHTMLReflowState legendReflowState(aPresContext, aReflowState,
mLegendFrame, availSize); mLegendFrame, availSize);
// XXX remove when reflow state is fixed // XXX remove when reflow state is fixed
#ifndef bug4534_not_fixed
FieldSetHack((nsHTMLReflowState&)legendReflowState, "fieldset's legend", PR_FALSE); FieldSetHack((nsHTMLReflowState&)legendReflowState, "fieldset's legend", PR_FALSE);
#endif
ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, aStatus); ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, aStatus);
legendSize.width = aDesiredSize.width; legendSize.width = aDesiredSize.width;
@ -354,7 +358,9 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowState contentReflowState(aPresContext, aReflowState, nsHTMLReflowState contentReflowState(aPresContext, aReflowState,
mContentFrame, availSize); mContentFrame, availSize);
// XXX remove when reflow state is fixed // XXX remove when reflow state is fixed
#ifndef bug4534_not_fixed
FieldSetHack(contentReflowState, "fieldset's area", PR_FALSE); FieldSetHack(contentReflowState, "fieldset's area", PR_FALSE);
#endif
nscoord contentTopOffset = (legendSize.height > border.top) nscoord contentTopOffset = (legendSize.height > border.top)
? legendSize.height + padding.top ? legendSize.height + padding.top
@ -381,7 +387,9 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowState legendReflowState(aPresContext, aReflowState, nsHTMLReflowState legendReflowState(aPresContext, aReflowState,
mLegendFrame, availSize); mLegendFrame, availSize);
// XXX remove when reflow state is fixed // XXX remove when reflow state is fixed
#ifndef bug4534_not_fixed
FieldSetHack(legendReflowState, "fieldset's legend frame", PR_FALSE); FieldSetHack(legendReflowState, "fieldset's legend frame", PR_FALSE);
#endif
ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, aStatus); ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, aStatus);
legendSize.width = aDesiredSize.width; legendSize.width = aDesiredSize.width;
@ -396,10 +404,10 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
aDesiredSize.width = (legendWidth > contentWidth) ? legendWidth : contentWidth; aDesiredSize.width = (legendWidth > contentWidth) ? legendWidth : contentWidth;
// if we are constrained and the child is smaller, use the constrained values // if we are constrained and the child is smaller, use the constrained values
//if ((NS_INTRINSICSIZE != aReflowState.computedWidth) && if ((NS_INTRINSICSIZE != aReflowState.computedWidth) &&
// (aReflowState.computedWidth > aDesiredSize.width)) { (aReflowState.computedWidth > aDesiredSize.width)) {
// aDesiredSize.width = aReflowState.computedWidth; aDesiredSize.width = aReflowState.computedWidth;
//} }
if ((NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) && if ((NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) &&
( (legendWidth + (2 * desiredLegendOffset)) > aDesiredSize.width) ) { ( (legendWidth + (2 * desiredLegendOffset)) > aDesiredSize.width) ) {
@ -464,9 +472,9 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
aDesiredSize.height = contentTopOffset + legendSize.height + contentSize.height + borderPadding.bottom; aDesiredSize.height = contentTopOffset + legendSize.height + contentSize.height + borderPadding.bottom;
// if we are constrained and the child is smaller, use the constrained values // if we are constrained and the child is smaller, use the constrained values
//if ((NS_AUTOHEIGHT != aReflowState.computedHeight) && (aReflowState.computedHeight > aDesiredSize.height)) { if ((NS_AUTOHEIGHT != aReflowState.computedHeight) && (aReflowState.computedHeight > aDesiredSize.height)) {
// aDesiredSize.height = aReflowState.computedHeight; aDesiredSize.height = aReflowState.computedHeight;
//} }
aDesiredSize.ascent = aDesiredSize.height; aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0; aDesiredSize.descent = 0;
if (nsnull != aDesiredSize.maxElementSize) { if (nsnull != aDesiredSize.maxElementSize) {

View File

@ -190,24 +190,24 @@ nsFieldSetFrame::Paint(nsIPresContext& aPresContext,
const nsStyleSpacing* spacing = const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing); (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
//XXX nsRect backgroundRect(0, 0, mRect.width, mRect.height); // XXX nsRect backgroundRect(0, 0, mRect.width, mRect.height);
// XXX our parent doesn't account for top and bottom margins yet, if we are inline // XXX our parent doesn't account for top and bottom margins yet, if we are inline
if (mInline) { //if (mInline) {
nsMargin margin; // nsMargin margin;
spacing->CalcMarginFor(this, margin); // spacing->CalcMarginFor(this, margin);
nsRect rect(0, mTopBorderOffset, mRect.width, mRect.height - margin.top - // nsRect rect(0, mTopBorderOffset, mRect.width, mRect.height - margin.top -
margin.bottom - mTopBorderOffset); // margin.bottom - mTopBorderOffset);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, // nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0); // aDirtyRect, rect, *color, *spacing, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, // nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, skipSides, &mTopBorderGap); // aDirtyRect, rect, *spacing, mStyleContext, skipSides, &mTopBorderGap);
} else { //} else {
nsRect rect(0, mTopBorderOffset, mRect.width, mRect.height - mTopBorderOffset); nsRect rect(0, mTopBorderOffset, mRect.width, mRect.height - mTopBorderOffset);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0); aDirtyRect, rect, *color, *spacing, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, skipSides, &mTopBorderGap); aDirtyRect, rect, *spacing, mStyleContext, skipSides, &mTopBorderGap);
} //}
} }
} }
@ -270,7 +270,9 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
nsReflowStatus& aStatus) nsReflowStatus& aStatus)
{ {
// XXX remove the following when the reflow state is fixed // XXX remove the following when the reflow state is fixed
#ifndef bug4534_not_fixed
FieldSetHack((nsHTMLReflowState&)aReflowState, "fieldset", PR_TRUE); FieldSetHack((nsHTMLReflowState&)aReflowState, "fieldset", PR_TRUE);
#endif
// availSize could have unconstrained values, don't perform any addition on them // availSize could have unconstrained values, don't perform any addition on them
nsSize availSize(aReflowState.computedWidth, aReflowState.computedHeight); nsSize availSize(aReflowState.computedWidth, aReflowState.computedHeight);
@ -281,8 +283,8 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
const nsStyleSpacing* spacing = const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing); (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
nsMargin margin; //nsMargin margin;
spacing->CalcMarginFor(this, margin); //spacing->CalcMarginFor(this, margin);
nsMargin border; nsMargin border;
nsMargin padding; nsMargin padding;
@ -290,7 +292,7 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
spacing->CalcPaddingFor(this, padding); spacing->CalcPaddingFor(this, padding);
nsMargin borderPadding = border + padding; nsMargin borderPadding = border + padding;
nsMargin legendMargin; nsMargin legendMargin(0,0,0,0);
if (mLegendFrame) { if (mLegendFrame) {
nsIStyleContext* legendSC = nsnull; nsIStyleContext* legendSC = nsnull;
mLegendFrame->GetStyleContext(&legendSC); mLegendFrame->GetStyleContext(&legendSC);
@ -304,7 +306,7 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
// reduce available space by border, padding, etc. if we're in a constrained situation // reduce available space by border, padding, etc. if we're in a constrained situation
nscoord horTaken = borderPadding.left + borderPadding.right + legendMargin.left + legendMargin.right; nscoord horTaken = borderPadding.left + borderPadding.right + legendMargin.left + legendMargin.right;
nscoord verTaken = padding.top + borderPadding.bottom + legendMargin.top + legendMargin.bottom; nscoord verTaken = borderPadding.top + borderPadding.bottom + legendMargin.top + legendMargin.bottom;
if (NS_INTRINSICSIZE != availSize.width) { if (NS_INTRINSICSIZE != availSize.width) {
availSize.width -= horTaken; availSize.width -= horTaken;
@ -324,7 +326,9 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowState legendReflowState(aPresContext, aReflowState, nsHTMLReflowState legendReflowState(aPresContext, aReflowState,
mLegendFrame, availSize); mLegendFrame, availSize);
// XXX remove when reflow state is fixed // XXX remove when reflow state is fixed
#ifndef bug4534_not_fixed
FieldSetHack((nsHTMLReflowState&)legendReflowState, "fieldset's legend", PR_FALSE); FieldSetHack((nsHTMLReflowState&)legendReflowState, "fieldset's legend", PR_FALSE);
#endif
ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, aStatus); ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, aStatus);
legendSize.width = aDesiredSize.width; legendSize.width = aDesiredSize.width;
@ -354,7 +358,9 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowState contentReflowState(aPresContext, aReflowState, nsHTMLReflowState contentReflowState(aPresContext, aReflowState,
mContentFrame, availSize); mContentFrame, availSize);
// XXX remove when reflow state is fixed // XXX remove when reflow state is fixed
#ifndef bug4534_not_fixed
FieldSetHack(contentReflowState, "fieldset's area", PR_FALSE); FieldSetHack(contentReflowState, "fieldset's area", PR_FALSE);
#endif
nscoord contentTopOffset = (legendSize.height > border.top) nscoord contentTopOffset = (legendSize.height > border.top)
? legendSize.height + padding.top ? legendSize.height + padding.top
@ -381,7 +387,9 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowState legendReflowState(aPresContext, aReflowState, nsHTMLReflowState legendReflowState(aPresContext, aReflowState,
mLegendFrame, availSize); mLegendFrame, availSize);
// XXX remove when reflow state is fixed // XXX remove when reflow state is fixed
#ifndef bug4534_not_fixed
FieldSetHack(legendReflowState, "fieldset's legend frame", PR_FALSE); FieldSetHack(legendReflowState, "fieldset's legend frame", PR_FALSE);
#endif
ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, aStatus); ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, aStatus);
legendSize.width = aDesiredSize.width; legendSize.width = aDesiredSize.width;
@ -396,10 +404,10 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
aDesiredSize.width = (legendWidth > contentWidth) ? legendWidth : contentWidth; aDesiredSize.width = (legendWidth > contentWidth) ? legendWidth : contentWidth;
// if we are constrained and the child is smaller, use the constrained values // if we are constrained and the child is smaller, use the constrained values
//if ((NS_INTRINSICSIZE != aReflowState.computedWidth) && if ((NS_INTRINSICSIZE != aReflowState.computedWidth) &&
// (aReflowState.computedWidth > aDesiredSize.width)) { (aReflowState.computedWidth > aDesiredSize.width)) {
// aDesiredSize.width = aReflowState.computedWidth; aDesiredSize.width = aReflowState.computedWidth;
//} }
if ((NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) && if ((NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) &&
( (legendWidth + (2 * desiredLegendOffset)) > aDesiredSize.width) ) { ( (legendWidth + (2 * desiredLegendOffset)) > aDesiredSize.width) ) {
@ -464,9 +472,9 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
aDesiredSize.height = contentTopOffset + legendSize.height + contentSize.height + borderPadding.bottom; aDesiredSize.height = contentTopOffset + legendSize.height + contentSize.height + borderPadding.bottom;
// if we are constrained and the child is smaller, use the constrained values // if we are constrained and the child is smaller, use the constrained values
//if ((NS_AUTOHEIGHT != aReflowState.computedHeight) && (aReflowState.computedHeight > aDesiredSize.height)) { if ((NS_AUTOHEIGHT != aReflowState.computedHeight) && (aReflowState.computedHeight > aDesiredSize.height)) {
// aDesiredSize.height = aReflowState.computedHeight; aDesiredSize.height = aReflowState.computedHeight;
//} }
aDesiredSize.ascent = aDesiredSize.height; aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0; aDesiredSize.descent = 0;
if (nsnull != aDesiredSize.maxElementSize) { if (nsnull != aDesiredSize.maxElementSize) {