From 1c8a506178254d9bcf21f4f276a1cf5e5ee1b5d8 Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Tue, 31 Aug 1999 13:03:38 +0000 Subject: [PATCH] Changed the way the button calculates it's size with respect to suggested size. I factored out the part where border and padding is added in so it can be overridden. git-svn-id: svn://10.0.0.236/trunk@45337 18797224-902f-48f8-a5cc-f745e15eee43 --- .../layout/forms/nsGfxButtonControlFrame.cpp | 25 +++++++++++++------ .../layout/forms/nsGfxButtonControlFrame.h | 3 +++ .../forms/src/nsGfxButtonControlFrame.cpp | 25 +++++++++++++------ .../html/forms/src/nsGfxButtonControlFrame.h | 3 +++ 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp index d8286416854..92be9978aad 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp @@ -158,6 +158,20 @@ nsGfxButtonControlFrame::GetFrameName(nsString& aResult) const +NS_IMETHODIMP +nsGfxButtonControlFrame::AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aSuggestedReflowState) +{ + if (kSuggestedNotSet == mSuggestedWidth) { + aDesiredSize.width += aSuggestedReflowState.mComputedBorderPadding.left + aSuggestedReflowState.mComputedBorderPadding.right; + } + + if (kSuggestedNotSet == mSuggestedHeight) { + aDesiredSize.height += aSuggestedReflowState.mComputedBorderPadding.top + aSuggestedReflowState.mComputedBorderPadding.bottom; + } + return NS_OK; +} + NS_IMETHODIMP nsGfxButtonControlFrame::Reflow(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, @@ -169,25 +183,22 @@ nsGfxButtonControlFrame::Reflow(nsIPresContext& aPresContext, } if ((kSuggestedNotSet != mSuggestedWidth) || - (kSuggestedNotSet != mSuggestedHeight)) - { + (kSuggestedNotSet != mSuggestedHeight)) { + nsHTMLReflowState suggestedReflowState(aReflowState); - + // Honor the suggested width and/or height. if (kSuggestedNotSet != mSuggestedWidth) { suggestedReflowState.mComputedWidth = mSuggestedWidth; - suggestedReflowState.mComputedWidth -= aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right; } if (kSuggestedNotSet != mSuggestedHeight) { suggestedReflowState.mComputedHeight = mSuggestedHeight; - suggestedReflowState.mComputedHeight -= aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom; } return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, suggestedReflowState, aStatus); - } else { - // Normal reflow. + } else { // Normal reflow. return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); } } diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.h b/mozilla/layout/forms/nsGfxButtonControlFrame.h index 658cec1612a..550f1e9b07c 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.h +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.h @@ -53,6 +53,9 @@ public: nsString* aValues, nsString* aNames); virtual void MouseClicked(nsIPresContext* aPresContext); +protected: + NS_IMETHOD AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aSuggestedReflowState); private: NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; } NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; } diff --git a/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp index d8286416854..92be9978aad 100644 --- a/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp @@ -158,6 +158,20 @@ nsGfxButtonControlFrame::GetFrameName(nsString& aResult) const +NS_IMETHODIMP +nsGfxButtonControlFrame::AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aSuggestedReflowState) +{ + if (kSuggestedNotSet == mSuggestedWidth) { + aDesiredSize.width += aSuggestedReflowState.mComputedBorderPadding.left + aSuggestedReflowState.mComputedBorderPadding.right; + } + + if (kSuggestedNotSet == mSuggestedHeight) { + aDesiredSize.height += aSuggestedReflowState.mComputedBorderPadding.top + aSuggestedReflowState.mComputedBorderPadding.bottom; + } + return NS_OK; +} + NS_IMETHODIMP nsGfxButtonControlFrame::Reflow(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, @@ -169,25 +183,22 @@ nsGfxButtonControlFrame::Reflow(nsIPresContext& aPresContext, } if ((kSuggestedNotSet != mSuggestedWidth) || - (kSuggestedNotSet != mSuggestedHeight)) - { + (kSuggestedNotSet != mSuggestedHeight)) { + nsHTMLReflowState suggestedReflowState(aReflowState); - + // Honor the suggested width and/or height. if (kSuggestedNotSet != mSuggestedWidth) { suggestedReflowState.mComputedWidth = mSuggestedWidth; - suggestedReflowState.mComputedWidth -= aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right; } if (kSuggestedNotSet != mSuggestedHeight) { suggestedReflowState.mComputedHeight = mSuggestedHeight; - suggestedReflowState.mComputedHeight -= aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom; } return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, suggestedReflowState, aStatus); - } else { - // Normal reflow. + } else { // Normal reflow. return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); } } diff --git a/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.h b/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.h index 658cec1612a..550f1e9b07c 100644 --- a/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.h +++ b/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.h @@ -53,6 +53,9 @@ public: nsString* aValues, nsString* aNames); virtual void MouseClicked(nsIPresContext* aPresContext); +protected: + NS_IMETHOD AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aSuggestedReflowState); private: NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; } NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }