From 82cfd09e260da0403c104fc3a0658ddd75c1b04e Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Tue, 12 Dec 2006 15:18:40 +0000 Subject: [PATCH] Fix percentage padding on nodes with overflow other than visible. Bug 332557, r+sr=dbaron. git-svn-id: svn://10.0.0.236/trunk@216874 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsGfxScrollFrame.cpp | 15 ++++++++++----- mozilla/layout/generic/nsHTMLReflowState.cpp | 11 ++++++----- mozilla/layout/generic/nsHTMLReflowState.h | 11 ++++++----- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index fcebe766579..0b7899bddb9 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -437,20 +437,25 @@ nsHTMLScrollFrame::ReflowScrolledFrame(const ScrollReflowState& aState, availWidth = PR_MAX(0, availWidth - vScrollbarPrefSize.width); } // pixel align the content - nscoord twp = GetPresContext()->IntScaledPixelsToTwips(1); + nsPresContext* presContext = GetPresContext(); + nscoord twp = presContext->IntScaledPixelsToTwips(1); availWidth -= availWidth % twp; if (!aFirstPass) mInner.mScrolledFrame->AddStateBits(NS_FRAME_IS_DIRTY); - nsHTMLReflowState kidReflowState(GetPresContext(), aState.mReflowState, + // Pass PR_FALSE for aInit so we can pass in the correct padding + nsHTMLReflowState kidReflowState(presContext, aState.mReflowState, mInner.mScrolledFrame, - nsSize(availWidth, NS_UNCONSTRAINEDSIZE)); + nsSize(availWidth, NS_UNCONSTRAINEDSIZE), + -1, -1, PR_FALSE); + kidReflowState.Init(presContext, -1, -1, nsnull, + &aState.mReflowState.mComputedPadding); kidReflowState.mFlags.mAssumingHScrollbar = aAssumeHScroll; kidReflowState.mFlags.mAssumingVScrollbar = aAssumeVScroll; nsReflowStatus status; - nsresult rv = ReflowChild(mInner.mScrolledFrame, GetPresContext(), *aMetrics, + nsresult rv = ReflowChild(mInner.mScrolledFrame, presContext, *aMetrics, kidReflowState, 0, 0, NS_FRAME_NO_MOVE_FRAME | NS_FRAME_NO_MOVE_VIEW, status); // Don't resize or position the view because we're going to resize @@ -458,7 +463,7 @@ nsHTMLScrollFrame::ReflowScrolledFrame(const ScrollReflowState& aState, // resize here would size it to the natural height of the frame, // which will usually be different from the scrollport height; // invalidating the difference will cause unnecessary repainting. - FinishReflowChild(mInner.mScrolledFrame, GetPresContext(), + FinishReflowChild(mInner.mScrolledFrame, presContext, &kidReflowState, *aMetrics, 0, 0, NS_FRAME_NO_MOVE_FRAME | NS_FRAME_NO_MOVE_VIEW | NS_FRAME_NO_SIZE_VIEW); diff --git a/mozilla/layout/generic/nsHTMLReflowState.cpp b/mozilla/layout/generic/nsHTMLReflowState.cpp index acdbce18506..38c831fdd27 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.cpp +++ b/mozilla/layout/generic/nsHTMLReflowState.cpp @@ -211,8 +211,8 @@ void nsHTMLReflowState::Init(nsPresContext* aPresContext, nscoord aContainingBlockWidth, nscoord aContainingBlockHeight, - nsMargin* aBorder, - nsMargin* aPadding) + const nsMargin* aBorder, + const nsMargin* aPadding) { NS_ASSERTION(availableWidth != NS_UNCONSTRAINEDSIZE, "shouldn't use unconstrained widths anymore"); @@ -1454,8 +1454,8 @@ void nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext, nscoord aContainingBlockWidth, nscoord aContainingBlockHeight, - nsMargin* aBorder, - nsMargin* aPadding) + const nsMargin* aBorder, + const nsMargin* aPadding) { // If this is the root frame, then set the computed width and // height equal to the available space @@ -1664,7 +1664,8 @@ nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext, void nsCSSOffsetState::InitOffsets(nscoord aContainingBlockWidth, - nsMargin *aBorder, nsMargin *aPadding) + const nsMargin *aBorder, + const nsMargin *aPadding) { // Compute margins from the specified margin style information. These // become the default computed values, and may be adjusted below diff --git a/mozilla/layout/generic/nsHTMLReflowState.h b/mozilla/layout/generic/nsHTMLReflowState.h index 317f358b6ca..1d673a230d1 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.h +++ b/mozilla/layout/generic/nsHTMLReflowState.h @@ -169,7 +169,8 @@ public: } void InitOffsets(nscoord aContainingBlockWidth, - nsMargin *aBorder = nsnull, nsMargin *aPadding = nsnull); + const nsMargin *aBorder = nsnull, + const nsMargin *aPadding = nsnull); private: // Computes margin values from the specified margin style information, and @@ -354,8 +355,8 @@ struct nsHTMLReflowState : public nsCSSOffsetState { void Init(nsPresContext* aPresContext, nscoord aContainingBlockWidth = -1, nscoord aContainingBlockHeight = -1, - nsMargin* aBorder = nsnull, - nsMargin* aPadding = nsnull); + const nsMargin* aBorder = nsnull, + const nsMargin* aPadding = nsnull); /** * Find the content width of the containing block of aReflowState */ @@ -416,8 +417,8 @@ protected: void InitConstraints(nsPresContext* aPresContext, nscoord aContainingBlockWidth, nscoord aContainingBlockHeight, - nsMargin* aBorder, - nsMargin* aPadding); + const nsMargin* aBorder, + const nsMargin* aPadding); void CalculateHypotheticalBox(nsPresContext* aPresContext, nsIFrame* aPlaceholderFrame,