diff --git a/layout/forms/nsFormControlFrame.cpp b/layout/forms/nsFormControlFrame.cpp index 4fb190421e9..07b391a42a5 100644 --- a/layout/forms/nsFormControlFrame.cpp +++ b/layout/forms/nsFormControlFrame.cpp @@ -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); - } - -} diff --git a/layout/forms/nsFormControlFrame.h b/layout/forms/nsFormControlFrame.h index dbb4af5dad9..dffc402be74 100644 --- a/layout/forms/nsFormControlFrame.h +++ b/layout/forms/nsFormControlFrame.h @@ -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 diff --git a/layout/html/forms/src/nsFormControlFrame.cpp b/layout/html/forms/src/nsFormControlFrame.cpp index 4fb190421e9..07b391a42a5 100644 --- a/layout/html/forms/src/nsFormControlFrame.cpp +++ b/layout/html/forms/src/nsFormControlFrame.cpp @@ -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); - } - -} diff --git a/layout/html/forms/src/nsFormControlFrame.h b/layout/html/forms/src/nsFormControlFrame.h index dbb4af5dad9..dffc402be74 100644 --- a/layout/html/forms/src/nsFormControlFrame.h +++ b/layout/html/forms/src/nsFormControlFrame.h @@ -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 diff --git a/layout/html/forms/src/nsGfxTextControlFrame.cpp b/layout/html/forms/src/nsGfxTextControlFrame.cpp index 95715b92b6e..1fef6e4578a 100644 --- a/layout/html/forms/src/nsGfxTextControlFrame.cpp +++ b/layout/html/forms/src/nsGfxTextControlFrame.cpp @@ -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 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;