From 89ba99747aa7729f81a491cd02094dcdfdf8f083 Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Wed, 3 Nov 1999 00:03:32 +0000 Subject: [PATCH] Combos now size correctly when the size is specified via style r=kmcclusk, b=16317 git-svn-id: svn://10.0.0.236/trunk@52620 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/forms/nsComboboxControlFrame.cpp | 16 +++++++++++++++- .../html/forms/src/nsComboboxControlFrame.cpp | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index d67b2eff432..ff4a910ec7a 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -652,7 +652,7 @@ nsComboboxControlFrame::Reflow(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { -#ifdef DEBUG_rodsXXX +#ifdef DEBUG_rods printf("nsComboboxControlFrame::Reflow %d Reason: ", myCounter++); switch (aReflowState.reason) { case eReflowReason_Initial:printf("eReflowReason_Initial\n");break; @@ -687,6 +687,12 @@ nsComboboxControlFrame::Reflow(nsIPresContext& aPresContext, nsFormFrame::AddFormControlFrame(aPresContext, *this); } + const nsStyleSpacing* spacing; + GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); + nsMargin borderPadding; + borderPadding.SizeTo(0, 0, 0, 0); + spacing->CalcBorderPaddingFor(this, borderPadding); + // Get the current sizes of the combo box child frames displayFrame->GetRect(displayRect); buttonFrame->GetRect(buttonRect); @@ -704,6 +710,10 @@ nsComboboxControlFrame::Reflow(nsIPresContext& aPresContext, nsRect oldDisplayRect = displayRect; nsRect oldButtonRect = buttonRect; rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); + // nsAreaFrame::Reflow adds in the border and padding so we need to remove it + if (NS_UNCONSTRAINEDSIZE != firstPassState.mComputedWidth) { + aDesiredSize.width -= borderPadding.left + borderPadding.right; + } displayFrame->GetRect(displayRect); buttonFrame->GetRect(buttonRect); if ((oldDisplayRect == displayRect) && (oldButtonRect == buttonRect)) { @@ -783,12 +793,16 @@ nsComboboxControlFrame::Reflow(nsIPresContext& aPresContext, // Since the button's width is the same as its height // we subtract size.height (the width) nscoord displayWidth = firstPassState.mComputedWidth - size.height; + // nsAreaFrame::Reflow adds in the border and padding so we need to remove it + displayWidth -= borderPadding.left + borderPadding.right; // Set the displayFrame to match the displayWidth computed above SetChildFrameSize(displayFrame, displayWidth, size.height); // Reflow again with the width of the display frame set. nsAreaFrame::Reflow(aPresContext, aDesiredSize, firstPassState, aStatus); + // nsAreaFrame::Reflow adds in the border and padding so we need to remove it + aDesiredSize.width -= borderPadding.left + borderPadding.right; // Reflow the dropdown list to match the width of the display + button ReflowComboChildFrame(dropdownFrame, aPresContext, dropdownDesiredSize, firstPassState, aStatus, aDesiredSize.width, NS_UNCONSTRAINEDSIZE); diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index d67b2eff432..ff4a910ec7a 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -652,7 +652,7 @@ nsComboboxControlFrame::Reflow(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { -#ifdef DEBUG_rodsXXX +#ifdef DEBUG_rods printf("nsComboboxControlFrame::Reflow %d Reason: ", myCounter++); switch (aReflowState.reason) { case eReflowReason_Initial:printf("eReflowReason_Initial\n");break; @@ -687,6 +687,12 @@ nsComboboxControlFrame::Reflow(nsIPresContext& aPresContext, nsFormFrame::AddFormControlFrame(aPresContext, *this); } + const nsStyleSpacing* spacing; + GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); + nsMargin borderPadding; + borderPadding.SizeTo(0, 0, 0, 0); + spacing->CalcBorderPaddingFor(this, borderPadding); + // Get the current sizes of the combo box child frames displayFrame->GetRect(displayRect); buttonFrame->GetRect(buttonRect); @@ -704,6 +710,10 @@ nsComboboxControlFrame::Reflow(nsIPresContext& aPresContext, nsRect oldDisplayRect = displayRect; nsRect oldButtonRect = buttonRect; rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); + // nsAreaFrame::Reflow adds in the border and padding so we need to remove it + if (NS_UNCONSTRAINEDSIZE != firstPassState.mComputedWidth) { + aDesiredSize.width -= borderPadding.left + borderPadding.right; + } displayFrame->GetRect(displayRect); buttonFrame->GetRect(buttonRect); if ((oldDisplayRect == displayRect) && (oldButtonRect == buttonRect)) { @@ -783,12 +793,16 @@ nsComboboxControlFrame::Reflow(nsIPresContext& aPresContext, // Since the button's width is the same as its height // we subtract size.height (the width) nscoord displayWidth = firstPassState.mComputedWidth - size.height; + // nsAreaFrame::Reflow adds in the border and padding so we need to remove it + displayWidth -= borderPadding.left + borderPadding.right; // Set the displayFrame to match the displayWidth computed above SetChildFrameSize(displayFrame, displayWidth, size.height); // Reflow again with the width of the display frame set. nsAreaFrame::Reflow(aPresContext, aDesiredSize, firstPassState, aStatus); + // nsAreaFrame::Reflow adds in the border and padding so we need to remove it + aDesiredSize.width -= borderPadding.left + borderPadding.right; // Reflow the dropdown list to match the width of the display + button ReflowComboChildFrame(dropdownFrame, aPresContext, dropdownDesiredSize, firstPassState, aStatus, aDesiredSize.width, NS_UNCONSTRAINEDSIZE);