From 07fdb05f24ea98219ce22176efaf388ca66d2274 Mon Sep 17 00:00:00 2001 From: "evaughan%netscape.com" Date: Fri, 23 Jul 1999 23:30:17 +0000 Subject: [PATCH] Fixed some box problems. --- layout/xul/base/src/nsBoxFrame.cpp | 75 +++++++++++--------- layout/xul/base/src/nsBoxFrame.h | 2 +- layout/xul/base/src/nsProgressMeterFrame.cpp | 11 +++ layout/xul/base/src/nsTitledButtonFrame.cpp | 16 +++-- 4 files changed, 67 insertions(+), 37 deletions(-) diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index f68da1df62d..dbd2572a353 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -161,7 +161,7 @@ nsBoxFrame::GetRedefinedMinPrefMax(nsIFrame* aFrame, nsBoxInfo& aSize) * */ nsresult -nsBoxFrame::GetChildBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame* aFrame, nsBoxInfo& aSize) +nsBoxFrame::GetChildBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame* aFrame, nsCalculatedBoxInfo& aSize) { aSize.clear(); @@ -186,44 +186,46 @@ nsBoxFrame::GetChildBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowStat // redefine anything depending on css GetRedefinedMinPrefMax(aFrame, aSize); - // subtract out the childs margin and border - const nsStyleSpacing* spacing; - nsresult rv = aFrame->GetStyleData(eStyleStruct_Spacing, - (const nsStyleStruct*&) spacing); + // if we are still intrinsically sized the flow to get the size otherwise + // we are done. + if (aSize.prefSize.width == NS_INTRINSICSIZE && aSize.prefSize.width == NS_INTRINSICSIZE) + { + // subtract out the childs margin and border + const nsStyleSpacing* spacing; + nsresult rv = aFrame->GetStyleData(eStyleStruct_Spacing, + (const nsStyleStruct*&) spacing); - nsMargin margin; - spacing->GetMargin(margin); - nsMargin border; - spacing->GetBorderPadding(border); - nsMargin total = margin + border; + nsMargin margin; + spacing->GetMargin(margin); + nsMargin border; + spacing->GetBorderPadding(border); + nsMargin total = margin + border; - // add in childs margin and border - if (aSize.prefSize.height != NS_INTRINSICSIZE) - aSize.prefSize.height += (total.left + total.right); + // add in childs margin and border + if (aSize.prefSize.height != NS_INTRINSICSIZE) + aSize.prefSize.height += (total.left + total.right); - if (aSize.prefSize.height != NS_INTRINSICSIZE) - aSize.prefSize.height += (total.top + total.bottom); + if (aSize.prefSize.height != NS_INTRINSICSIZE) + aSize.prefSize.height += (total.top + total.bottom); - // flow child at preferred size - nsHTMLReflowMetrics desiredSize(nsnull); + // flow child at preferred size + nsHTMLReflowMetrics desiredSize(nsnull); - nsCalculatedBoxInfo info(aSize); + aSize.calculatedSize = aSize.prefSize; - info.calculatedSize = aSize.prefSize; + nsReflowStatus status; + PRBool redraw; + nsString reason("To get pref size"); + FlowChildAt(aFrame, aPresContext, desiredSize, aReflowState, status, aSize, redraw, reason); - nsReflowStatus status; - PRBool redraw; - nsString reason("To get pref size"); - FlowChildAt(aFrame, aPresContext, desiredSize, aReflowState, status, info, redraw, reason); - - // remove margin and border - desiredSize.height -= (total.top + total.bottom); - desiredSize.width -= (total.left + total.right); - - // get the size returned and the it as the preferredsize. - aSize.prefSize.width = desiredSize.width; - aSize.prefSize.height = desiredSize.height; + // remove margin and border + desiredSize.height -= (total.top + total.bottom); + desiredSize.width -= (total.left + total.right); + // get the size returned and the it as the preferredsize. + aSize.prefSize.width = desiredSize.width; + aSize.prefSize.height = desiredSize.height; + } return NS_OK; } @@ -280,7 +282,16 @@ nsBoxFrame::Reflow(nsIPresContext& aPresContext, // cached values for the children in the reflow list nsIFrame* incrementalChild = nsnull; if ( aReflowState.reason == eReflowReason_Incremental ) { - Dirty(aReflowState,incrementalChild); + nsIFrame* targetFrame; + // See if it's targeted at us + aReflowState.reflowCommand->GetTarget(targetFrame); + if (this == targetFrame) { + // if it has redraw us + Invalidate(nsRect(0,0,mRect.width,mRect.height), PR_FALSE); + } else { + // otherwise dirty our children + Dirty(aReflowState,incrementalChild); + } } #if 0 ListTag(stdout); diff --git a/layout/xul/base/src/nsBoxFrame.h b/layout/xul/base/src/nsBoxFrame.h index 236b32f6439..3485a8bbd35 100644 --- a/layout/xul/base/src/nsBoxFrame.h +++ b/layout/xul/base/src/nsBoxFrame.h @@ -114,7 +114,7 @@ protected: nsBoxFrame(PRUint32 aFlags = 0); virtual void GetRedefinedMinPrefMax(nsIFrame* aFrame, nsBoxInfo& aSize); - virtual nsresult GetChildBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame* aFrame, nsBoxInfo& aSize); + virtual nsresult GetChildBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame* aFrame, nsCalculatedBoxInfo& aSize); virtual nsresult FlowChildren(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, diff --git a/layout/xul/base/src/nsProgressMeterFrame.cpp b/layout/xul/base/src/nsProgressMeterFrame.cpp index 519e42dc649..3fc3eb512ee 100644 --- a/layout/xul/base/src/nsProgressMeterFrame.cpp +++ b/layout/xul/base/src/nsProgressMeterFrame.cpp @@ -607,6 +607,17 @@ nsProgressMeterFrame :: Reflow ( nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { + + if (eReflowReason_Incremental == aReflowState.reason) { + nsIFrame* targetFrame; + + // See if it's targeted at us + aReflowState.reflowCommand->GetTarget(targetFrame); + if (this == targetFrame) { + Invalidate(nsRect(0,0,mRect.width,mRect.height), PR_FALSE); + } + } + if (mUndetermined) gStripeAnimator->AddFrame(this); else diff --git a/layout/xul/base/src/nsTitledButtonFrame.cpp b/layout/xul/base/src/nsTitledButtonFrame.cpp index 48ecde8e9cb..f699a6dfa6a 100644 --- a/layout/xul/base/src/nsTitledButtonFrame.cpp +++ b/layout/xul/base/src/nsTitledButtonFrame.cpp @@ -702,12 +702,20 @@ nsTitledButtonFrame::Reflow(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { + // redraw us on a reflow + + if (eReflowReason_Incremental == aReflowState.reason) { + nsIFrame* targetFrame; + + // See if it's targeted at us + aReflowState.reflowCommand->GetTarget(targetFrame); + if (this == targetFrame) { + Invalidate(nsRect(0,0,mRect.width,mRect.height), PR_FALSE); + } + } + mNeedsLayout = PR_TRUE; nsresult result = nsLeafFrame::Reflow(aPresContext, aMetrics, aReflowState, aStatus); - - // redraw us on a reflow - Invalidate(nsRect(0,0,mRect.width, mRect.height), PR_FALSE); - return result; }