temporarily adding box sizing utility methods to help forms calculate their size

appropriately for box sizing.
r=kmcllsuk, bug 18448
This commit is contained in:
rods%netscape.com 1999-11-15 15:16:28 +00:00
parent 3989b4018f
commit 8313932cd7
4 changed files with 98 additions and 0 deletions

View File

@ -569,3 +569,43 @@ nsFormControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
mSuggestedHeight = 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);
}
}

View File

@ -210,6 +210,12 @@ 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();
@ -241,6 +247,9 @@ 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

View File

@ -569,3 +569,43 @@ nsFormControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
mSuggestedHeight = 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);
}
}

View File

@ -210,6 +210,12 @@ 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();
@ -241,6 +247,9 @@ 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