mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
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:
parent
3989b4018f
commit
8313932cd7
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user