From 6158f7cec4ed0a035b52308345bc077c03816b2a Mon Sep 17 00:00:00 2001 From: troy Date: Mon, 1 Jun 1998 23:31:30 +0000 Subject: [PATCH] Changed nsLeafFrane's GetdesiredSize() to not pass in the max size since it's now part of nsReflowState --- layout/generic/nsLeafFrame.cpp | 3 +-- layout/generic/nsLeafFrame.h | 5 ++--- layout/html/base/src/nsHRPart.cpp | 14 ++++++-------- layout/html/base/src/nsHTMLBullet.cpp | 6 ++---- layout/html/base/src/nsHTMLImage.cpp | 6 +----- layout/html/base/src/nsHTMLImage.h | 1 - layout/html/base/src/nsLeafFrame.cpp | 3 +-- layout/html/base/src/nsLeafFrame.h | 5 ++--- layout/html/forms/src/nsInputButton.cpp | 8 ++------ layout/html/forms/src/nsInputCheckbox.cpp | 6 ++++-- layout/html/forms/src/nsInputFrame.cpp | 10 +++------- layout/html/forms/src/nsInputFrame.h | 2 -- layout/html/forms/src/nsInputRadio.cpp | 6 ++++-- layout/html/forms/src/nsSelect.cpp | 2 -- 14 files changed, 28 insertions(+), 49 deletions(-) diff --git a/layout/generic/nsLeafFrame.cpp b/layout/generic/nsLeafFrame.cpp index 6cd450dac81..7e31f64b784 100644 --- a/layout/generic/nsLeafFrame.cpp +++ b/layout/generic/nsLeafFrame.cpp @@ -58,8 +58,7 @@ NS_METHOD nsLeafFrame::Reflow(nsIPresContext* aPresContext, // XXX add in code to check for width/height being set via css // and if set use them instead of calling GetDesiredSize. - GetDesiredSize(aPresContext, aReflowState, - aReflowState.maxSize, aDesiredSize); + GetDesiredSize(aPresContext, aReflowState, aDesiredSize); AddBordersAndPadding(aPresContext, aDesiredSize); if (nsnull != aDesiredSize.maxElementSize) { aDesiredSize.maxElementSize->width = aDesiredSize.width; diff --git a/layout/generic/nsLeafFrame.h b/layout/generic/nsLeafFrame.h index abf43a7767d..4d70f4f6ef5 100644 --- a/layout/generic/nsLeafFrame.h +++ b/layout/generic/nsLeafFrame.h @@ -46,14 +46,13 @@ protected: virtual ~nsLeafFrame(); /** - * Return the desired size of the frame. Note that this method - * doesn't need to deal with padding or borders (the caller will + * Return the desired size of the frame's content area. Note that this + * method doesn't need to deal with padding or borders (the caller will * deal with it). In addition, the ascent will be set to the height * and the descent will be set to zero. */ virtual void GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredSize) = 0; /** diff --git a/layout/html/base/src/nsHRPart.cpp b/layout/html/base/src/nsHRPart.cpp index 989c492a533..6a96043e792 100644 --- a/layout/html/base/src/nsHRPart.cpp +++ b/layout/html/base/src/nsHRPart.cpp @@ -81,7 +81,6 @@ protected: virtual void GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredSize); }; @@ -227,7 +226,6 @@ HRuleFrame::Paint(nsIPresContext& aPresContext, void HRuleFrame::GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredSize) { nsStylePosition* position = (nsStylePosition*) @@ -237,18 +235,18 @@ HRuleFrame::GetDesiredSize(nsIPresContext* aPresContext, } else if (position->mWidth.GetUnit() == eStyleUnit_Percent) { float pct = position->mWidth.GetPercentValue(); - aDesiredSize.width = nscoord(pct * aMaxSize.width); + aDesiredSize.width = nscoord(pct * aReflowState.maxSize.width); } else { - if (aMaxSize.width == NS_UNCONSTRAINEDSIZE) { + if (aReflowState.maxSize.width == NS_UNCONSTRAINEDSIZE) { aDesiredSize.width = 1; } else { - aDesiredSize.width = aMaxSize.width; + aDesiredSize.width = aReflowState.maxSize.width; } } - if (aMaxSize.width != NS_UNCONSTRAINEDSIZE) { - if (aDesiredSize.width < aMaxSize.width) { - aDesiredSize.width = aMaxSize.width; + if (aReflowState.maxSize.width != NS_UNCONSTRAINEDSIZE) { + if (aDesiredSize.width < aReflowState.maxSize.width) { + aDesiredSize.width = aReflowState.maxSize.width; } } diff --git a/layout/html/base/src/nsHTMLBullet.cpp b/layout/html/base/src/nsHTMLBullet.cpp index 39750f55106..8e2dfec0079 100644 --- a/layout/html/base/src/nsHTMLBullet.cpp +++ b/layout/html/base/src/nsHTMLBullet.cpp @@ -68,7 +68,6 @@ public: protected: virtual void GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredSize); /** @@ -260,7 +259,7 @@ BulletFrame::Reflow(nsIPresContext* aCX, const nsReflowState& aReflowState, nsReflowStatus& aStatus) { - GetDesiredSize(aCX, aReflowState, aReflowState.maxSize, aDesiredSize); + GetDesiredSize(aCX, aReflowState, aDesiredSize); if (nsnull != aDesiredSize.maxElementSize) { aDesiredSize.maxElementSize->width = aDesiredSize.width; aDesiredSize.maxElementSize->height = aDesiredSize.height; @@ -494,7 +493,6 @@ BulletFrame::GetListItemText(nsIPresContext* aCX, void BulletFrame::GetDesiredSize(nsIPresContext* aCX, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredSize) { nsStyleList* myList = @@ -505,7 +503,7 @@ BulletFrame::GetDesiredSize(nsIPresContext* aCX, nsIFontMetrics* fm = aCX->GetMetricsFor(myFont->mFont); if (myList->mListStyleImage.Length() > 0) { mImageLoader.SetURL(myList->mListStyleImage); - mImageLoader.GetDesiredSize(aCX, aReflowState, aMaxSize, aDesiredSize); + mImageLoader.GetDesiredSize(aCX, aReflowState, aDesiredSize); aDesiredSize.ascent = aDesiredSize.height; aDesiredSize.descent = 0; } diff --git a/layout/html/base/src/nsHTMLImage.cpp b/layout/html/base/src/nsHTMLImage.cpp index 04bf5c4a231..0aef0d0a11a 100644 --- a/layout/html/base/src/nsHTMLImage.cpp +++ b/layout/html/base/src/nsHTMLImage.cpp @@ -69,7 +69,6 @@ protected: virtual void GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredSize); nsIImageMap* GetImageMap(); @@ -229,7 +228,6 @@ nsHTMLImageLoader::LoadImage(nsIPresContext* aPresContext, void nsHTMLImageLoader::GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredSize) { nsSize styleSize; @@ -363,7 +361,6 @@ ImageFrame::DeleteFrame() void ImageFrame::GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredSize) { // Setup url before starting the image load @@ -371,8 +368,7 @@ ImageFrame::GetDesiredSize(nsIPresContext* aPresContext, if (eContentAttr_HasValue == mContent->GetAttribute("SRC", src)) { mImageLoader.SetURL(src); } - mImageLoader.GetDesiredSize(aPresContext, aReflowState, - aMaxSize, aDesiredSize); + mImageLoader.GetDesiredSize(aPresContext, aReflowState, aDesiredSize); } NS_METHOD diff --git a/layout/html/base/src/nsHTMLImage.h b/layout/html/base/src/nsHTMLImage.h index a251875cb35..3d7fc42c301 100644 --- a/layout/html/base/src/nsHTMLImage.h +++ b/layout/html/base/src/nsHTMLImage.h @@ -53,7 +53,6 @@ public: void GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredSize); protected: diff --git a/layout/html/base/src/nsLeafFrame.cpp b/layout/html/base/src/nsLeafFrame.cpp index 6cd450dac81..7e31f64b784 100644 --- a/layout/html/base/src/nsLeafFrame.cpp +++ b/layout/html/base/src/nsLeafFrame.cpp @@ -58,8 +58,7 @@ NS_METHOD nsLeafFrame::Reflow(nsIPresContext* aPresContext, // XXX add in code to check for width/height being set via css // and if set use them instead of calling GetDesiredSize. - GetDesiredSize(aPresContext, aReflowState, - aReflowState.maxSize, aDesiredSize); + GetDesiredSize(aPresContext, aReflowState, aDesiredSize); AddBordersAndPadding(aPresContext, aDesiredSize); if (nsnull != aDesiredSize.maxElementSize) { aDesiredSize.maxElementSize->width = aDesiredSize.width; diff --git a/layout/html/base/src/nsLeafFrame.h b/layout/html/base/src/nsLeafFrame.h index abf43a7767d..4d70f4f6ef5 100644 --- a/layout/html/base/src/nsLeafFrame.h +++ b/layout/html/base/src/nsLeafFrame.h @@ -46,14 +46,13 @@ protected: virtual ~nsLeafFrame(); /** - * Return the desired size of the frame. Note that this method - * doesn't need to deal with padding or borders (the caller will + * Return the desired size of the frame's content area. Note that this + * method doesn't need to deal with padding or borders (the caller will * deal with it). In addition, the ascent will be set to the height * and the descent will be set to zero. */ virtual void GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredSize) = 0; /** diff --git a/layout/html/forms/src/nsInputButton.cpp b/layout/html/forms/src/nsInputButton.cpp index 7e1574614e9..3bec9399de4 100644 --- a/layout/html/forms/src/nsInputButton.cpp +++ b/layout/html/forms/src/nsInputButton.cpp @@ -128,7 +128,6 @@ protected: virtual void GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredLayoutSize, nsSize& aDesiredWidgetSize); @@ -419,8 +418,7 @@ nsInputButtonFrame::Reflow(nsIPresContext* aPresContext, if ((kButtonTag_Input == GetButtonTagType()) && (kButton_Image == GetButtonType())) { nsSize ignore; - GetDesiredSize(aPresContext, aReflowState, aReflowState.maxSize, - aDesiredSize, ignore); + GetDesiredSize(aPresContext, aReflowState, aDesiredSize, ignore); AddBordersAndPadding(aPresContext, aDesiredSize); if (nsnull != aDesiredSize.maxElementSize) { aDesiredSize.maxElementSize->width = aDesiredSize.width; @@ -438,7 +436,6 @@ nsInputButtonFrame::Reflow(nsIPresContext* aPresContext, void nsInputButtonFrame::GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredLayoutSize, nsSize& aDesiredWidgetSize) { @@ -456,8 +453,7 @@ nsInputButtonFrame::GetDesiredSize(nsIPresContext* aPresContext, if (eContentAttr_HasValue == mContent->GetAttribute("SRC", src)) { mImageLoader.SetURL(src); } - mImageLoader.GetDesiredSize(aPresContext, aReflowState, aMaxSize, - aDesiredLayoutSize); + mImageLoader.GetDesiredSize(aPresContext, aReflowState, aDesiredLayoutSize); } else { // there is a widget nsSize styleSize; diff --git a/layout/html/forms/src/nsInputCheckbox.cpp b/layout/html/forms/src/nsInputCheckbox.cpp index 9ca28b13bba..62efbb0c5d0 100644 --- a/layout/html/forms/src/nsInputCheckbox.cpp +++ b/layout/html/forms/src/nsInputCheckbox.cpp @@ -49,7 +49,7 @@ protected: virtual ~nsInputCheckboxFrame(); PRBool mCacheState; virtual void GetDesiredSize(nsIPresContext* aPresContext, - const nsSize& aMaxSize, + const nsReflowState& aReflowState, nsReflowMetrics& aDesiredLayoutSize, nsSize& aDesiredWidgetSize); }; @@ -93,7 +93,7 @@ PRInt32 nsInputCheckboxFrame::GetPadding() const void nsInputCheckboxFrame::GetDesiredSize(nsIPresContext* aPresContext, - const nsSize& aMaxSize, + const nsReflowState& aReflowState, nsReflowMetrics& aDesiredLayoutSize, nsSize& aDesiredWidgetSize) { @@ -109,6 +109,8 @@ nsInputCheckboxFrame::GetDesiredSize(nsIPresContext* aPresContext, float p2t = aPresContext->GetPixelsToTwips(); aDesiredWidgetSize.width = (int)(12 * p2t); aDesiredWidgetSize.height = (int)(12 * p2t); + // XXX Why is padding being added? GetDesiredSize() as defined by nsLeafFrame + // should return the size of the content area only... PRInt32 padding = GetPadding(); aDesiredLayoutSize.width = aDesiredWidgetSize.width + (2 * padding); aDesiredLayoutSize.height = aDesiredWidgetSize.height; diff --git a/layout/html/forms/src/nsInputFrame.cpp b/layout/html/forms/src/nsInputFrame.cpp index 51648062560..077311c6fba 100644 --- a/layout/html/forms/src/nsInputFrame.cpp +++ b/layout/html/forms/src/nsInputFrame.cpp @@ -190,7 +190,6 @@ nsInputFrame::IsHidden() void nsInputFrame::GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredLayoutSize, nsSize& aDesiredWidgetSize) { @@ -210,11 +209,10 @@ nsInputFrame::GetDesiredSize(nsIPresContext* aPresContext, void nsInputFrame::GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredSize) { nsSize ignore; - GetDesiredSize(aPresContext, aReflowState, aMaxSize, aDesiredSize, ignore); + GetDesiredSize(aPresContext, aReflowState, aDesiredSize, ignore); } NS_METHOD @@ -244,8 +242,7 @@ nsInputFrame::Reflow(nsIPresContext* aPresContext, nsIPresShell *presShell = aPresContext->GetShell(); // need to release nsIViewManager *viewMan = presShell->GetViewManager(); // need to release - GetDesiredSize(aPresContext, aReflowState, aReflowState.maxSize, - aDesiredSize, mWidgetSize); + GetDesiredSize(aPresContext, aReflowState, aDesiredSize, mWidgetSize); //nsRect boundBox(0, 0, mWidgetSize.width, mWidgetSize.height); nsRect boundBox(0, 0, aDesiredSize.width, aDesiredSize.height); @@ -292,8 +289,7 @@ nsInputFrame::Reflow(nsIPresContext* aPresContext, NS_IF_RELEASE(presShell); } else { - GetDesiredSize(aPresContext, aReflowState, aReflowState.maxSize, - aDesiredSize, mWidgetSize); + GetDesiredSize(aPresContext, aReflowState, aDesiredSize, mWidgetSize); // If we are being reflowed and have a view, hide the view until // we are told to paint (which is when our location will have diff --git a/layout/html/forms/src/nsInputFrame.h b/layout/html/forms/src/nsInputFrame.h index 31ed7cdbaf4..3b5beaf3414 100644 --- a/layout/html/forms/src/nsInputFrame.h +++ b/layout/html/forms/src/nsInputFrame.h @@ -190,12 +190,10 @@ protected: */ virtual void GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredSize); virtual void GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredLayoutSize, nsSize& aDesiredWidgetSize); diff --git a/layout/html/forms/src/nsInputRadio.cpp b/layout/html/forms/src/nsInputRadio.cpp index 2033d62b819..217e524e3cc 100644 --- a/layout/html/forms/src/nsInputRadio.cpp +++ b/layout/html/forms/src/nsInputRadio.cpp @@ -52,7 +52,7 @@ protected: virtual ~nsInputRadioFrame(); virtual void GetDesiredSize(nsIPresContext* aPresContext, - const nsSize& aMaxSize, + const nsReflowState& aReflowState, nsReflowMetrics& aDesiredLayoutSize, nsSize& aDesiredWidgetSize); }; @@ -96,7 +96,7 @@ nsInputRadioFrame::GetCID() void nsInputRadioFrame::GetDesiredSize(nsIPresContext* aPresContext, - const nsSize& aMaxSize, + const nsReflowState& aReflowState, nsReflowMetrics& aDesiredLayoutSize, nsSize& aDesiredWidgetSize) { @@ -104,6 +104,8 @@ nsInputRadioFrame::GetDesiredSize(nsIPresContext* aPresContext, aDesiredWidgetSize.width = (int)(12 * p2t); aDesiredWidgetSize.height = (int)(12 * p2t); PRInt32 padding = GetPadding(); + // XXX Why is padding being added? GetDesiredSize() as defined by nsLeafFrame + // should return the size of the content area only... aDesiredLayoutSize.width = aDesiredWidgetSize.width + (2 * padding); aDesiredLayoutSize.height = aDesiredWidgetSize.height; aDesiredLayoutSize.ascent = aDesiredLayoutSize.height; diff --git a/layout/html/forms/src/nsSelect.cpp b/layout/html/forms/src/nsSelect.cpp index 143320f87f7..0bf456e9e01 100644 --- a/layout/html/forms/src/nsSelect.cpp +++ b/layout/html/forms/src/nsSelect.cpp @@ -62,7 +62,6 @@ protected: virtual void GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredLayoutSize, nsSize& aDesiredWidgetSize); PRBool mIsComboBox; @@ -178,7 +177,6 @@ nsSelectFrame::GetCID() void nsSelectFrame::GetDesiredSize(nsIPresContext* aPresContext, const nsReflowState& aReflowState, - const nsSize& aMaxSize, nsReflowMetrics& aDesiredLayoutSize, nsSize& aDesiredWidgetSize) {