diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index 87b1e24b85f..403a0bba390 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -2711,9 +2711,7 @@ PlaceFrameView(nsIPresContext* aPresContext, nsIFrame* aFrame) { if (aFrame->HasView()) - nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aFrame, - aFrame->GetView(), - aFrame->GetOverflowAreaProperty(aPresContext)); + nsContainerFrame::PositionFrameView(aPresContext, aFrame); nsContainerFrame::PositionChildViews(aPresContext, aFrame); } @@ -4292,18 +4290,6 @@ nsBlockFrame::PostPlaceLine(nsBlockReflowState& aState, nsLineBox* aLine, nscoord aMaxElementWidth) { - // If it's inline elements, then make sure the views are correctly - // positioned and sized - if (aLine->IsInline()) { - nsIFrame* frame = aLine->mFirstChild; - for (PRInt32 i = 0; (i < aLine->GetChildCount() && frame); i++) { - ::PlaceFrameView(aState.mPresContext, frame); - frame = frame->GetNextSibling(); - NS_ASSERTION(frame || (i+1) == aLine->GetChildCount(), - "Child count bigger than the number of linked frames!!!"); - } - } - // Update max-element-width if (aState.GetFlag(BRS_COMPUTEMAXELEMENTWIDTH)) { aState.UpdateMaxElementWidth(aMaxElementWidth); diff --git a/mozilla/layout/generic/nsContainerFrame.cpp b/mozilla/layout/generic/nsContainerFrame.cpp index d94272e050e..84f5339a324 100644 --- a/mozilla/layout/generic/nsContainerFrame.cpp +++ b/mozilla/layout/generic/nsContainerFrame.cpp @@ -710,6 +710,9 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext, // If the frame has child frames that stick outside the content // area, then size the view large enough to include those child // frames + NS_ASSERTION(!(aFrame->GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) || + aCombinedArea, + "resizing view for frame with overflow to the wrong size"); if ((aFrame->GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) && aCombinedArea) { vm->ResizeView(aView, *aCombinedArea, PR_TRUE); } else { diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index 356e9811f24..8a7abb7bb6b 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/nsLineLayout.cpp @@ -97,7 +97,7 @@ static nscoord AccumulateImageSizes(nsIPresContext& aPresContext, nsIFrame& aFra nsCOMPtr type; aFrame.GetFrameType(getter_AddRefs(type)); if(type.get() == nsLayoutAtoms::imageFrame) { - sizes += NS_STATIC_CAST(nscoord, aFrame.GetSize().width); + sizes += aFrame.GetSize().width; } else { // see if there are children to process nsIFrame* child = nsnull; @@ -1219,19 +1219,8 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, pfd->mMaxElementWidth = metrics.mMaxElementWidth; } - // Size the frame and size its view (if it has one) + // Size the frame, but |RelativePositionFrames| will size the view. aFrame->SetSize(nsSize(metrics.width, metrics.height)); - if (aFrame->HasView()) { - nsIView* view = aFrame->GetView(); - nsIViewManager *vm = view->GetViewManager(); - -#if 0 // XXX This is the correct code. We'll turn it on later to mitigate risk. - vm->ResizeView(view, pfd->mCombinedArea); -#else // imitate the old, wrong code - nsRect r(0, 0, metrics.width, metrics.height); - vm->ResizeView(view, r); -#endif - } // Tell the frame that we're done reflowing it aFrame->DidReflow(mPresContext, &reflowState, NS_FRAME_REFLOW_FINISHED); @@ -1859,6 +1848,7 @@ nsLineLayout::VerticalAlignLine(nsLineBox* aLineBox, if (!strictMode && inUnconstrainedTable ) { nscoord imgSizes = AccumulateImageSizes(*mPresContext, *pfd->mFrame); + // XXXldb We should NOT be using mCombinedArea here! PRBool curFrameAccumulates = (imgSizes > 0) || (pfd->mMaxElementWidth == pfd->mCombinedArea.width && pfd->GetFlag(PFD_ISNONWHITESPACETEXTFRAME)); @@ -3146,9 +3136,7 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsRect& aCombinedArea) maxY = mTopEdge + mFinalLineHeight; } - pfd = psd->mFirstFrame; - PRBool updatedCombinedArea = PR_FALSE; - while (nsnull != pfd) { + for (pfd = psd->mFirstFrame; pfd; pfd = pfd->mNext) { nscoord x = pfd->mBounds.x; nscoord y = pfd->mBounds.y; @@ -3175,54 +3163,28 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsRect& aCombinedArea) RelativePositionFrames(pfd->mSpan, spanCombinedArea); } - // see bug 21415: we used to prevent empty inlines from impacting the - // size of the combined area, however that is wrong so now we allow - // empty inlines to contribute to the line's combined area. - // - the following comment is being preserved in case there are issues - // with floaters, as is alluded to. -#if 0 - // Only if the frame has some area do we let it affect the - // combined area. Otherwise empty frames placed next to a floating - // element will cause the floaters margin to be relevant, which we - // don't want to happen. - if (r->width && r->height) { -#endif - nscoord xl = x + r->x; - nscoord xr = x + r->XMost(); - if (xl < minX) { - minX = xl; - } - if (xr > maxX) { - maxX = xr; - } - nscoord yt = y + r->y; - nscoord yb = y + r->YMost(); - if (yt < minY) { - minY = yt; - } - if (yb > maxY) { - maxY = yb; - } - updatedCombinedArea = PR_TRUE; -#if 0 + nscoord xl = x + r->x; + if (xl < minX) { + minX = xl; + } + nscoord xr = x + r->XMost(); + if (xr > maxX) { + maxX = xr; + } + nscoord yt = y + r->y; + if (yt < minY) { + minY = yt; + } + nscoord yb = y + r->YMost(); + if (yb > maxY) { + maxY = yb; } -#endif - pfd = pfd->mNext; } - // Compute aggregated combined area - if (updatedCombinedArea) { - aCombinedArea.x = minX; - aCombinedArea.y = minY; - aCombinedArea.width = maxX - minX; - aCombinedArea.height = maxY - minY; - } - else { - aCombinedArea.x = 0; - aCombinedArea.y = minY; - aCombinedArea.width = 0; - aCombinedArea.height = 0; - } + aCombinedArea.x = minX; + aCombinedArea.y = minY; + aCombinedArea.width = maxX - minX; + aCombinedArea.height = maxY - minY; // If we just computed a spans combined area, we need to update its // NS_FRAME_OUTSIDE_CHILDREN bit.. @@ -3235,6 +3197,11 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsRect& aCombinedArea) } else { frame->RemoveStateBits(NS_FRAME_OUTSIDE_CHILDREN); } + + if (frame->HasView()) + nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, frame, + frame->GetView(), + &aCombinedArea); } } diff --git a/mozilla/layout/generic/nsLineLayout.h b/mozilla/layout/generic/nsLineLayout.h index 6beb5446493..1384fd8ff19 100644 --- a/mozilla/layout/generic/nsLineLayout.h +++ b/mozilla/layout/generic/nsLineLayout.h @@ -118,6 +118,11 @@ public: PRBool aAllowJustify, PRBool aShrinkWrapWidth); + /** + * Handle all the relative positioning in the line, compute the + * combined area (== overflow area) for the line, and handle view + * sizing/positioning and the setting of NS_FRAME_OUTSIDE_CHILDREN. + */ void RelativePositionFrames(nsRect& aCombinedArea); //---------------------------------------- diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index 87b1e24b85f..403a0bba390 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -2711,9 +2711,7 @@ PlaceFrameView(nsIPresContext* aPresContext, nsIFrame* aFrame) { if (aFrame->HasView()) - nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aFrame, - aFrame->GetView(), - aFrame->GetOverflowAreaProperty(aPresContext)); + nsContainerFrame::PositionFrameView(aPresContext, aFrame); nsContainerFrame::PositionChildViews(aPresContext, aFrame); } @@ -4292,18 +4290,6 @@ nsBlockFrame::PostPlaceLine(nsBlockReflowState& aState, nsLineBox* aLine, nscoord aMaxElementWidth) { - // If it's inline elements, then make sure the views are correctly - // positioned and sized - if (aLine->IsInline()) { - nsIFrame* frame = aLine->mFirstChild; - for (PRInt32 i = 0; (i < aLine->GetChildCount() && frame); i++) { - ::PlaceFrameView(aState.mPresContext, frame); - frame = frame->GetNextSibling(); - NS_ASSERTION(frame || (i+1) == aLine->GetChildCount(), - "Child count bigger than the number of linked frames!!!"); - } - } - // Update max-element-width if (aState.GetFlag(BRS_COMPUTEMAXELEMENTWIDTH)) { aState.UpdateMaxElementWidth(aMaxElementWidth); diff --git a/mozilla/layout/html/base/src/nsContainerFrame.cpp b/mozilla/layout/html/base/src/nsContainerFrame.cpp index d94272e050e..84f5339a324 100644 --- a/mozilla/layout/html/base/src/nsContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsContainerFrame.cpp @@ -710,6 +710,9 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext, // If the frame has child frames that stick outside the content // area, then size the view large enough to include those child // frames + NS_ASSERTION(!(aFrame->GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) || + aCombinedArea, + "resizing view for frame with overflow to the wrong size"); if ((aFrame->GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) && aCombinedArea) { vm->ResizeView(aView, *aCombinedArea, PR_TRUE); } else { diff --git a/mozilla/layout/html/base/src/nsLineLayout.cpp b/mozilla/layout/html/base/src/nsLineLayout.cpp index 356e9811f24..8a7abb7bb6b 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.cpp +++ b/mozilla/layout/html/base/src/nsLineLayout.cpp @@ -97,7 +97,7 @@ static nscoord AccumulateImageSizes(nsIPresContext& aPresContext, nsIFrame& aFra nsCOMPtr type; aFrame.GetFrameType(getter_AddRefs(type)); if(type.get() == nsLayoutAtoms::imageFrame) { - sizes += NS_STATIC_CAST(nscoord, aFrame.GetSize().width); + sizes += aFrame.GetSize().width; } else { // see if there are children to process nsIFrame* child = nsnull; @@ -1219,19 +1219,8 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, pfd->mMaxElementWidth = metrics.mMaxElementWidth; } - // Size the frame and size its view (if it has one) + // Size the frame, but |RelativePositionFrames| will size the view. aFrame->SetSize(nsSize(metrics.width, metrics.height)); - if (aFrame->HasView()) { - nsIView* view = aFrame->GetView(); - nsIViewManager *vm = view->GetViewManager(); - -#if 0 // XXX This is the correct code. We'll turn it on later to mitigate risk. - vm->ResizeView(view, pfd->mCombinedArea); -#else // imitate the old, wrong code - nsRect r(0, 0, metrics.width, metrics.height); - vm->ResizeView(view, r); -#endif - } // Tell the frame that we're done reflowing it aFrame->DidReflow(mPresContext, &reflowState, NS_FRAME_REFLOW_FINISHED); @@ -1859,6 +1848,7 @@ nsLineLayout::VerticalAlignLine(nsLineBox* aLineBox, if (!strictMode && inUnconstrainedTable ) { nscoord imgSizes = AccumulateImageSizes(*mPresContext, *pfd->mFrame); + // XXXldb We should NOT be using mCombinedArea here! PRBool curFrameAccumulates = (imgSizes > 0) || (pfd->mMaxElementWidth == pfd->mCombinedArea.width && pfd->GetFlag(PFD_ISNONWHITESPACETEXTFRAME)); @@ -3146,9 +3136,7 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsRect& aCombinedArea) maxY = mTopEdge + mFinalLineHeight; } - pfd = psd->mFirstFrame; - PRBool updatedCombinedArea = PR_FALSE; - while (nsnull != pfd) { + for (pfd = psd->mFirstFrame; pfd; pfd = pfd->mNext) { nscoord x = pfd->mBounds.x; nscoord y = pfd->mBounds.y; @@ -3175,54 +3163,28 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsRect& aCombinedArea) RelativePositionFrames(pfd->mSpan, spanCombinedArea); } - // see bug 21415: we used to prevent empty inlines from impacting the - // size of the combined area, however that is wrong so now we allow - // empty inlines to contribute to the line's combined area. - // - the following comment is being preserved in case there are issues - // with floaters, as is alluded to. -#if 0 - // Only if the frame has some area do we let it affect the - // combined area. Otherwise empty frames placed next to a floating - // element will cause the floaters margin to be relevant, which we - // don't want to happen. - if (r->width && r->height) { -#endif - nscoord xl = x + r->x; - nscoord xr = x + r->XMost(); - if (xl < minX) { - minX = xl; - } - if (xr > maxX) { - maxX = xr; - } - nscoord yt = y + r->y; - nscoord yb = y + r->YMost(); - if (yt < minY) { - minY = yt; - } - if (yb > maxY) { - maxY = yb; - } - updatedCombinedArea = PR_TRUE; -#if 0 + nscoord xl = x + r->x; + if (xl < minX) { + minX = xl; + } + nscoord xr = x + r->XMost(); + if (xr > maxX) { + maxX = xr; + } + nscoord yt = y + r->y; + if (yt < minY) { + minY = yt; + } + nscoord yb = y + r->YMost(); + if (yb > maxY) { + maxY = yb; } -#endif - pfd = pfd->mNext; } - // Compute aggregated combined area - if (updatedCombinedArea) { - aCombinedArea.x = minX; - aCombinedArea.y = minY; - aCombinedArea.width = maxX - minX; - aCombinedArea.height = maxY - minY; - } - else { - aCombinedArea.x = 0; - aCombinedArea.y = minY; - aCombinedArea.width = 0; - aCombinedArea.height = 0; - } + aCombinedArea.x = minX; + aCombinedArea.y = minY; + aCombinedArea.width = maxX - minX; + aCombinedArea.height = maxY - minY; // If we just computed a spans combined area, we need to update its // NS_FRAME_OUTSIDE_CHILDREN bit.. @@ -3235,6 +3197,11 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsRect& aCombinedArea) } else { frame->RemoveStateBits(NS_FRAME_OUTSIDE_CHILDREN); } + + if (frame->HasView()) + nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, frame, + frame->GetView(), + &aCombinedArea); } } diff --git a/mozilla/layout/html/base/src/nsLineLayout.h b/mozilla/layout/html/base/src/nsLineLayout.h index 6beb5446493..1384fd8ff19 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.h +++ b/mozilla/layout/html/base/src/nsLineLayout.h @@ -118,6 +118,11 @@ public: PRBool aAllowJustify, PRBool aShrinkWrapWidth); + /** + * Handle all the relative positioning in the line, compute the + * combined area (== overflow area) for the line, and handle view + * sizing/positioning and the setting of NS_FRAME_OUTSIDE_CHILDREN. + */ void RelativePositionFrames(nsRect& aCombinedArea); //----------------------------------------