removing extra box sizing code that is not needed.

computed border and padding is always added for Standard and only for explicit w/h for NavQuirks.
r=dcone bug=18448
This commit is contained in:
rods%netscape.com 1999-11-18 15:15:07 +00:00
Родитель 665d39ad6c
Коммит 8c8f362920
5 изменённых файлов: 9 добавлений и 109 удалений

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

@ -570,42 +570,3 @@ nsFormControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
return NS_OK;
}
void
nsFormControlFrame::AddBoxSizingToCoord(PRUint8 aBoxStyle,
nscoord& aSize,
nscoord aBorder,
nscoord aPadding)
{
switch (aBoxStyle) {
case NS_STYLE_BOX_SIZING_CONTENT:
//aSize += aBorder + aPadding;
break;
case NS_STYLE_BOX_SIZING_PADDING:
aSize += aPadding;
break;
case NS_STYLE_BOX_SIZING_BORDER:
aSize += aBorder + aPadding;
break;
} //switch
}
void
nsFormControlFrame::AddBoxSizing(nsSize& aSize, PRBool aAddToWidth,
const nsMargin& aBorder,
const nsMargin& aPadding)
{
const nsStylePosition* position;
GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)position);
if (aAddToWidth) {
AddBoxSizingToCoord(position->mBoxSizing, aSize.width,
aBorder.left + aBorder.right,
aPadding.left + aPadding.right);
} else {
AddBoxSizingToCoord(position->mBoxSizing, aSize.height,
aBorder.top + aBorder.bottom,
aPadding.top + aPadding.bottom);
}
}

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

@ -210,12 +210,6 @@ public:
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsString& aValue);
NS_IMETHOD GetProperty(nsIAtom* aName, nsString& aValue);
// box sizing utility methods
static void AddBoxSizingToCoord(PRUint8 aBoxStyle,
nscoord& aSize,
nscoord aBorder,
nscoord aPadding);
protected:
virtual ~nsFormControlFrame();
@ -247,9 +241,6 @@ protected:
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
// box sizing utility methods
void AddBoxSizing(nsSize& aSize, PRBool aAddToWidth, const nsMargin& aBorder, const nsMargin& aPadding);
//
//-------------------------------------------------------------------------------------
// Utility methods for managing checkboxes and radiobuttons

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

@ -570,42 +570,3 @@ nsFormControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
return NS_OK;
}
void
nsFormControlFrame::AddBoxSizingToCoord(PRUint8 aBoxStyle,
nscoord& aSize,
nscoord aBorder,
nscoord aPadding)
{
switch (aBoxStyle) {
case NS_STYLE_BOX_SIZING_CONTENT:
//aSize += aBorder + aPadding;
break;
case NS_STYLE_BOX_SIZING_PADDING:
aSize += aPadding;
break;
case NS_STYLE_BOX_SIZING_BORDER:
aSize += aBorder + aPadding;
break;
} //switch
}
void
nsFormControlFrame::AddBoxSizing(nsSize& aSize, PRBool aAddToWidth,
const nsMargin& aBorder,
const nsMargin& aPadding)
{
const nsStylePosition* position;
GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)position);
if (aAddToWidth) {
AddBoxSizingToCoord(position->mBoxSizing, aSize.width,
aBorder.left + aBorder.right,
aPadding.left + aPadding.right);
} else {
AddBoxSizingToCoord(position->mBoxSizing, aSize.height,
aBorder.top + aBorder.bottom,
aPadding.top + aPadding.bottom);
}
}

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

@ -210,12 +210,6 @@ public:
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsString& aValue);
NS_IMETHOD GetProperty(nsIAtom* aName, nsString& aValue);
// box sizing utility methods
static void AddBoxSizingToCoord(PRUint8 aBoxStyle,
nscoord& aSize,
nscoord aBorder,
nscoord aPadding);
protected:
virtual ~nsFormControlFrame();
@ -247,9 +241,6 @@ protected:
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
// box sizing utility methods
void AddBoxSizing(nsSize& aSize, PRBool aAddToWidth, const nsMargin& aBorder, const nsMargin& aPadding);
//
//-------------------------------------------------------------------------------------
// Utility methods for managing checkboxes and radiobuttons

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

@ -1245,7 +1245,6 @@ nsGfxTextControlFrame::CalculateSizeNavQuirks (nsIPresContext* aPresContex
NS_ASSERTION(aCSSSize.width >= 0, "form control's computed width is < 0");
if (NS_INTRINSICSIZE != aCSSSize.width) {
aDesiredSize.width = aCSSSize.width;
AddBoxSizing(aDesiredSize, PR_TRUE, aBorder, aPadding);
aWidthExplicit = PR_TRUE;
}
}
@ -1256,7 +1255,6 @@ nsGfxTextControlFrame::CalculateSizeNavQuirks (nsIPresContext* aPresContex
NS_ASSERTION(aCSSSize.height > 0, "form control's computed height is <= 0");
if (NS_INTRINSICSIZE != aCSSSize.height) {
aDesiredSize.height = aCSSSize.height;
AddBoxSizing(aDesiredSize, PR_FALSE, aBorder, aPadding);
aHeightExplicit = PR_TRUE;
}
}
@ -1321,6 +1319,12 @@ nsGfxTextControlFrame::ReflowNavQuirks(nsIPresContext& aPresContext,
areaSpec, desiredSize, minSize, widthExplicit,
heightExplicit, ignore, aBorder, aPadding);
}
if (widthExplicit) {
desiredSize.width += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
}
if (heightExplicit) {
desiredSize.height += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
}
aDesiredSize.width = desiredSize.width;
aDesiredSize.height = desiredSize.height;
@ -1443,7 +1447,6 @@ nsGfxTextControlFrame::CalculateSizeStandard (nsIPresContext* aPresContext
col = (col <= 0) ? 1 : col; // XXX why a default of 1 char, why hide it
charWidth = nsFormControlHelper::GetTextSize(*aPresContext, aFrame, col, aDesiredSize, aRendContext);
aMinSize.width = aDesiredSize.width;
AddBoxSizing(aDesiredSize, PR_TRUE, aBorder, aPadding);
} else {
charWidth = nsFormControlHelper::GetTextSize(*aPresContext, aFrame, aSpec.mColDefaultSize, aDesiredSize, aRendContext);
aMinSize.width = aDesiredSize.width;
@ -1451,17 +1454,13 @@ nsGfxTextControlFrame::CalculateSizeStandard (nsIPresContext* aPresContext
NS_ASSERTION(aCSSSize.width >= 0, "form control's computed width is < 0");
if (NS_INTRINSICSIZE != aCSSSize.width) {
aDesiredSize.width = aCSSSize.width;
AddBoxSizing(aDesiredSize, PR_TRUE, aBorder, aPadding);
aWidthExplicit = PR_TRUE;
}
} else {
//AddBoxSizing(aDesiredSize, PR_TRUE, aBorder, aPadding);
aDesiredSize.width += aBorder.left + aBorder.right + aPadding.left + aPadding.right;
}
}
nscoord fontHeight = 0;
nscoord fontLeading = 0;
//nscoord fontLeading = 0;
// get leading
nsCOMPtr<nsIFontMetrics> fontMet;
nsFormControlHelper::GetFrameFontFM(*aPresContext, aFrame, getter_AddRefs(fontMet));
@ -1481,19 +1480,14 @@ nsGfxTextControlFrame::CalculateSizeStandard (nsIPresContext* aPresContext
? rowAttr.GetPixelValue() : rowAttr.GetIntValue());
numRows = (rowAttrInt > 0) ? rowAttrInt : 1;
aDesiredSize.height = aDesiredSize.height * numRows;
AddBoxSizing(aDesiredSize, PR_FALSE, aBorder, aPadding);
} else {
aDesiredSize.height = aDesiredSize.height * aSpec.mRowDefaultSize;
if (CSS_NOTSET != aCSSSize.height) { // css provides height
NS_ASSERTION(aCSSSize.height > 0, "form control's computed height is <= 0");
if (NS_INTRINSICSIZE != aCSSSize.height) {
aDesiredSize.height = aCSSSize.height;
AddBoxSizing(aDesiredSize, PR_FALSE, aBorder, aPadding);
aHeightExplicit = PR_TRUE;
}
} else {
//AddBoxSizing(aDesiredSize, PR_FALSE, aBorder, aPadding);
aDesiredSize.height += aBorder.top + aBorder.bottom + aPadding.top + aPadding.bottom;
}
}
@ -1582,6 +1576,8 @@ nsGfxTextControlFrame::ReflowStandard(nsIPresContext& aPresContext,
minSize.width += scrollbarWidth;
}
}
desiredSize.width += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
desiredSize.height += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
aDesiredSize.width = desiredSize.width;
aDesiredSize.height = desiredSize.height;