better sizing of form controls, especially percentage based sizes and max element sizes

git-svn-id: svn://10.0.0.236/trunk@21570 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
karnaze%netscape.com
1999-02-23 03:48:01 +00:00
parent bbf9e64a65
commit 3955f8e7f3
25 changed files with 817 additions and 471 deletions

View File

@@ -226,6 +226,7 @@ nsTextControlFrame::EnterPressed(nsIPresContext& aPresContext)
}
}
#define DEFAULT_PIXEL_WIDTH 20
void
nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
@@ -239,7 +240,8 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
nsSize styleSize;
GetStyleSize(*aPresContext, aReflowState, styleSize);
nsSize size;
nsSize desiredSize;
nsSize minSize;
PRBool widthExplicit, heightExplicit;
PRInt32 ignore;
@@ -248,22 +250,20 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
if ((NS_FORM_INPUT_TEXT == type) || (NS_FORM_INPUT_PASSWORD == type)) {
PRInt32 width;
if (NS_CONTENT_ATTR_HAS_VALUE != GetSizeFromContent(&width)) {
width = 20;
width = DEFAULT_PIXEL_WIDTH;
}
//if (eCompatibility_NavQuirks == mode) {
// width += 1;
//}
nsInputDimensionSpec textSpec(nsnull, PR_FALSE, nsnull,
nsnull, width, PR_FALSE, nsnull, 1);
nsFormControlHelper::CalculateSize(aPresContext, this, styleSize, textSpec, size,
widthExplicit, heightExplicit, ignore,
aReflowState.rendContext);
nsFormControlHelper::CalculateSize(aPresContext, aReflowState.rendContext, this, styleSize,
textSpec, desiredSize, minSize, widthExplicit, heightExplicit, ignore);
} else {
nsInputDimensionSpec areaSpec(nsHTMLAtoms::cols, PR_FALSE, nsnull, nsnull, 20,
nsInputDimensionSpec areaSpec(nsHTMLAtoms::cols, PR_FALSE, nsnull, nsnull, DEFAULT_PIXEL_WIDTH,
PR_FALSE, nsHTMLAtoms::rows, 1);
nsFormControlHelper::CalculateSize(aPresContext, this, styleSize, areaSpec, size,
widthExplicit, heightExplicit, ignore,
aReflowState.rendContext);
nsFormControlHelper::CalculateSize(aPresContext, aReflowState.rendContext, this, styleSize,
areaSpec, desiredSize, minSize, widthExplicit, heightExplicit, ignore);
}
if (NS_FORM_TEXTAREA == type) {
@@ -287,20 +287,28 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
}
if (!heightExplicit) {
size.height += scrollbarHeight;
desiredSize.height += scrollbarHeight;
minSize.height += scrollbarHeight;
}
if (!widthExplicit) {
size.width += scrollbarWidth;
desiredSize.width += scrollbarWidth;
minSize.width += scrollbarWidth;
}
}
aDesiredLayoutSize.width = size.width;
aDesiredLayoutSize.height = size.height;
aDesiredLayoutSize.width = desiredSize.width;
aDesiredLayoutSize.height = desiredSize.height;
aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;
aDesiredLayoutSize.descent = 0;
if (aDesiredLayoutSize.maxElementSize) {
aDesiredLayoutSize.maxElementSize->width = minSize.width;
aDesiredLayoutSize.maxElementSize->height = minSize.width;
}
aDesiredWidgetSize.width = aDesiredLayoutSize.width;
aDesiredWidgetSize.height = aDesiredLayoutSize.height;
}
nsWidgetInitData*