From 032c4f44223bec9cfbf7dc23a7460b4fb5b329d8 Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Mon, 27 Mar 2000 22:20:06 +0000 Subject: [PATCH] Added reflow of text frame for when the size is being set via style b=33402 --- layout/forms/nsFileControlFrame.cpp | 44 +++++++++++++++++++- layout/html/forms/src/nsFileControlFrame.cpp | 44 +++++++++++++++++++- 2 files changed, 86 insertions(+), 2 deletions(-) diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index 59c4e5f05f8..f80b5c356e0 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -288,7 +288,49 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext* aPresContext, } } - return nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); + // The Areaframe takes care of all our reflow + // except for when style is used to change its size. + nsresult rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); + if (NS_SUCCEEDED(rv)) { + nsIFrame * child; + FirstChild(aPresContext, nsnull, &child); + while (child == mTextFrame) { + child->GetNextSibling(&child); + } + if (child != nsnull) { + nsRect buttonRect; + nsRect txtRect; + mTextFrame->GetRect(txtRect); + child->GetRect(buttonRect); + + // check to see if we must reflow just the texField + // because style width or height was set. + if (txtRect.width + buttonRect.width != aDesiredSize.width || + txtRect.height != aDesiredSize.height) { + + nsSize txtAvailSize(aDesiredSize.width - buttonRect.width, aDesiredSize.height); + nsHTMLReflowMetrics txtKidSize(&txtAvailSize); + nsHTMLReflowState txtKidReflowState(aPresContext, aReflowState, mTextFrame, txtAvailSize); + txtKidReflowState.mComputedWidth = txtAvailSize.width; + txtKidReflowState.mComputedHeight = txtAvailSize.height; + mTextFrame->WillReflow(aPresContext); + nsReflowStatus status; + rv = mTextFrame->Reflow(aPresContext, txtKidSize, txtKidReflowState, status); + if (NS_FAILED(rv)) return rv; + rv = mTextFrame->DidReflow(aPresContext, aStatus); + if (NS_FAILED(rv)) return rv; + + // now adjust the frame positions + buttonRect.x = aDesiredSize.width - buttonRect.width + aReflowState.mComputedBorderPadding.left; + child->SetRect(aPresContext, buttonRect); + txtRect.y = aReflowState.mComputedBorderPadding.top; + txtRect.height = aDesiredSize.height; + txtRect.width = aDesiredSize.width - buttonRect.width; + mTextFrame->SetRect(aPresContext, txtRect); + } + } + } + return rv; } /* diff --git a/layout/html/forms/src/nsFileControlFrame.cpp b/layout/html/forms/src/nsFileControlFrame.cpp index 59c4e5f05f8..f80b5c356e0 100644 --- a/layout/html/forms/src/nsFileControlFrame.cpp +++ b/layout/html/forms/src/nsFileControlFrame.cpp @@ -288,7 +288,49 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext* aPresContext, } } - return nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); + // The Areaframe takes care of all our reflow + // except for when style is used to change its size. + nsresult rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); + if (NS_SUCCEEDED(rv)) { + nsIFrame * child; + FirstChild(aPresContext, nsnull, &child); + while (child == mTextFrame) { + child->GetNextSibling(&child); + } + if (child != nsnull) { + nsRect buttonRect; + nsRect txtRect; + mTextFrame->GetRect(txtRect); + child->GetRect(buttonRect); + + // check to see if we must reflow just the texField + // because style width or height was set. + if (txtRect.width + buttonRect.width != aDesiredSize.width || + txtRect.height != aDesiredSize.height) { + + nsSize txtAvailSize(aDesiredSize.width - buttonRect.width, aDesiredSize.height); + nsHTMLReflowMetrics txtKidSize(&txtAvailSize); + nsHTMLReflowState txtKidReflowState(aPresContext, aReflowState, mTextFrame, txtAvailSize); + txtKidReflowState.mComputedWidth = txtAvailSize.width; + txtKidReflowState.mComputedHeight = txtAvailSize.height; + mTextFrame->WillReflow(aPresContext); + nsReflowStatus status; + rv = mTextFrame->Reflow(aPresContext, txtKidSize, txtKidReflowState, status); + if (NS_FAILED(rv)) return rv; + rv = mTextFrame->DidReflow(aPresContext, aStatus); + if (NS_FAILED(rv)) return rv; + + // now adjust the frame positions + buttonRect.x = aDesiredSize.width - buttonRect.width + aReflowState.mComputedBorderPadding.left; + child->SetRect(aPresContext, buttonRect); + txtRect.y = aReflowState.mComputedBorderPadding.top; + txtRect.height = aDesiredSize.height; + txtRect.width = aDesiredSize.width - buttonRect.width; + mTextFrame->SetRect(aPresContext, txtRect); + } + } + } + return rv; } /*