diff --git a/mozilla/layout/generic/nsContainerFrame.cpp b/mozilla/layout/generic/nsContainerFrame.cpp index 6201f6c05c5..2901ddc3cd4 100644 --- a/mozilla/layout/generic/nsContainerFrame.cpp +++ b/mozilla/layout/generic/nsContainerFrame.cpp @@ -285,30 +285,36 @@ NS_METHOD nsContainerFrame::GetCursorAndContentAt(nsIPresContext& aPresContext, // Helper member functions /** - * Reflow a child frame and return the status of the reflow. If the - * child is complete and it has next-in-flows (it was a splittable child) - * then delete the next-in-flows. + * Queries the child frame for the nsIHTMLReflow interface and if it's + * supported invokes the WillReflow() and Reflow() member functions. If + * the reflow succeeds and the child frame is complete, deletes any + * next-in-flows using DeleteChildsNextInFlow() */ -nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, - nsIPresContext* aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState) +nsresult +nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, + nsIPresContext& aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus) { - nsReflowStatus status; - NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state"); -#ifdef NS_DEBUG - nsFrameState kidFrameState; - aKidFrame->GetFrameState(kidFrameState); - NS_ASSERTION(kidFrameState & NS_FRAME_IN_REFLOW, "kid frame is not in reflow"); -#endif + // Query for the nsIHTMLReflow interface nsIHTMLReflow* htmlReflow; - if (NS_OK == aKidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->Reflow(*aPresContext, aDesiredSize, aReflowState, status); + nsresult result; + + result = aKidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow); + if (NS_FAILED(result)) { + return result; } - if (NS_FRAME_IS_COMPLETE(status)) { + // Send the WillReflow notification, and reflow the child frame + htmlReflow->WillReflow(aPresContext); + result = htmlReflow->Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); + + // If the reflow was successful and the child frame is complete, delete any + // next-in-flows + if (NS_SUCCEEDED(result) && NS_FRAME_IS_COMPLETE(aStatus)) { nsIFrame* kidNextInFlow; aKidFrame->GetNextInFlow(kidNextInFlow); @@ -318,10 +324,11 @@ nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, // parent is not this because we are executing pullup code) nsIFrame* parent; aKidFrame->GetGeometricParent(parent); - ((nsContainerFrame*)parent)->DeleteChildsNextInFlow(*aPresContext, aKidFrame); + ((nsContainerFrame*)parent)->DeleteChildsNextInFlow(aPresContext, aKidFrame); } } - return status; + + return result; } /** @@ -401,7 +408,7 @@ nsContainerFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild->SetNextSibling(nextSibling); } - // Delete the next-in-flow frame and adjust its parents child count + // Delete the next-in-flow frame WillDeleteNextInFlowFrame(nextInFlow); nextInFlow->DeleteFrame(aPresContext); diff --git a/mozilla/layout/generic/nsContainerFrame.h b/mozilla/layout/generic/nsContainerFrame.h index 73d9057c267..6d7df7e9ca4 100644 --- a/mozilla/layout/generic/nsContainerFrame.h +++ b/mozilla/layout/generic/nsContainerFrame.h @@ -110,13 +110,16 @@ protected: const nsRect& aDirtyRect); /** - * Reflow a child frame and return the status of the reflow. If the child - * is complete and it has next-in-flows, then delete the next-in-flows. + * Queries the child frame for the nsIHTMLReflow interface and if it's + * supported invokes the WillReflow() and Reflow() member functions. If + * the reflow succeeds and the child frame is complete, deletes any + * next-in-flows using DeleteChildsNextInFlow() */ - nsReflowStatus ReflowChild(nsIFrame* aKidFrame, - nsIPresContext* aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState); + nsresult ReflowChild(nsIFrame* aKidFrame, + nsIPresContext& aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus); /** * Moves any frames on both the prev-in-flow's overflow list and the receiver's diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 499acbae8a2..9fa1c8b3f59 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -328,8 +328,7 @@ nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext, nsIHTMLReflow* htmlReflow; if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, kidMetrics, kidReflowState); + ReflowChild(mFirstChild, aPresContext, kidMetrics, kidReflowState, aStatus); NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); // Place and size the child diff --git a/mozilla/layout/generic/nsFrameSetFrame.cpp b/mozilla/layout/generic/nsFrameSetFrame.cpp index 38d9e021965..a65d1f51f32 100644 --- a/mozilla/layout/generic/nsFrameSetFrame.cpp +++ b/mozilla/layout/generic/nsFrameSetFrame.cpp @@ -674,18 +674,17 @@ nsHTMLFramesetFrame::ReflowPlaceChild(nsIFrame* aChild, nsIHTMLReflow* htmlReflow; if (NS_OK == aChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - nsHTMLReflowMetrics metrics(nsnull); metrics.width = aSize.width; metrics.height= aSize.height; nsReflowStatus status; if (needFramesetReflow) { + htmlReflow->WillReflow(aPresContext); status = ((nsHTMLFramesetFrame*)aChild)->Reflow(aPresContext, childDrag, metrics, reflowState, status); } else { - status = ReflowChild(aChild, &aPresContext, metrics, reflowState); + ReflowChild(aChild, aPresContext, metrics, reflowState, status); } NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "bad status"); diff --git a/mozilla/layout/generic/nsHTMLFrame.cpp b/mozilla/layout/generic/nsHTMLFrame.cpp index c50188f5774..f40589bde2b 100644 --- a/mozilla/layout/generic/nsHTMLFrame.cpp +++ b/mozilla/layout/generic/nsHTMLFrame.cpp @@ -151,12 +151,14 @@ RootFrame::Reflow(nsIPresContext& aPresContext, nsIHTMLReflow* htmlReflow; if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, desiredSize, kidReflowState); + ReflowChild(mFirstChild, aPresContext, desiredSize, kidReflowState, aStatus); // Place and size the child nsRect rect(0, 0, desiredSize.width, desiredSize.height); mFirstChild->SetRect(rect); + + // XXX We should resolve the details of who/when DidReflow() notifications + // are sent... htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED); } } @@ -363,18 +365,14 @@ RootContentFrame::Reflow(nsIPresContext& aPresContext, nsSize maxSize(availWidth, NS_UNCONSTRAINEDSIZE); nsHTMLReflowState kidReflowState(next, aReflowState, maxSize); - nsIHTMLReflow* htmlReflow; // Dispatch the reflow command to our child frame. Allow it to be as high // as it wants - if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, aDesiredSize, kidReflowState); + ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); - // Place and size the child - nsRect rect(left, top, aDesiredSize.width, aDesiredSize.height); - mFirstChild->SetRect(rect); - } + // Place and size the child + nsRect rect(left, top, aDesiredSize.width, aDesiredSize.height); + mFirstChild->SetRect(rect); // Compute our desired size aDesiredSize.width += left + right + sbarWidth; @@ -415,46 +413,41 @@ RootContentFrame::Reflow(nsIPresContext& aPresContext, // Reflow the page nsHTMLReflowState kidReflowState(kidFrame, aReflowState, pageSize, reflowReason); - nsIHTMLReflow* htmlReflow; nsReflowStatus status; // Place and size the page. If the page is narrower than our // max width then center it horizontally - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - status = ReflowChild(kidFrame, &aPresContext, kidSize, - kidReflowState); - kidFrame->SetRect(nsRect(x, y, kidSize.width, kidSize.height)); - y += kidSize.height; + ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, status); + kidFrame->SetRect(nsRect(x, y, kidSize.width, kidSize.height)); + y += kidSize.height; - // Leave a slight gap between the pages - y += PAGE_SPACING_TWIPS; + // Leave a slight gap between the pages + y += PAGE_SPACING_TWIPS; - // Is the page complete? - nsIFrame* kidNextInFlow; + // Is the page complete? + nsIFrame* kidNextInFlow; - kidFrame->GetNextInFlow(kidNextInFlow); - if (NS_FRAME_IS_COMPLETE(status)) { - NS_ASSERTION(nsnull == kidNextInFlow, "bad child flow list"); - } else if (nsnull == kidNextInFlow) { - // The page isn't complete and it doesn't have a next-in-flow so - // create a continuing page - nsIStyleContext* kidSC; - kidFrame->GetStyleContext(&aPresContext, kidSC); - nsIFrame* continuingPage; - nsresult rv = kidFrame->CreateContinuingFrame(aPresContext, this, - kidSC, continuingPage); - NS_RELEASE(kidSC); - reflowReason = eReflowReason_Initial; + kidFrame->GetNextInFlow(kidNextInFlow); + if (NS_FRAME_IS_COMPLETE(status)) { + NS_ASSERTION(nsnull == kidNextInFlow, "bad child flow list"); + } else if (nsnull == kidNextInFlow) { + // The page isn't complete and it doesn't have a next-in-flow so + // create a continuing page + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(&aPresContext, kidSC); + nsIFrame* continuingPage; + nsresult rv = kidFrame->CreateContinuingFrame(aPresContext, this, + kidSC, continuingPage); + NS_RELEASE(kidSC); + reflowReason = eReflowReason_Initial; - // Add it to our child list + // Add it to our child list #ifdef NS_DEBUG - nsIFrame* kidNextSibling; - kidFrame->GetNextSibling(kidNextSibling); - NS_ASSERTION(nsnull == kidNextSibling, "unexpected sibling"); + nsIFrame* kidNextSibling; + kidFrame->GetNextSibling(kidNextSibling); + NS_ASSERTION(nsnull == kidNextSibling, "unexpected sibling"); #endif - kidFrame->SetNextSibling(continuingPage); - } + kidFrame->SetNextSibling(continuingPage); } // Get the next page @@ -475,25 +468,21 @@ RootContentFrame::Reflow(nsIPresContext& aPresContext, nsSize maxSize(availWidth, NS_UNCONSTRAINEDSIZE); nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, maxSize, reflowReason); - nsIHTMLReflow* htmlReflow; - if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - // Get the child's desired size. Our child's desired height is our - // desired size - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, aDesiredSize, kidReflowState); - NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); + // Get the child's desired size. Our child's desired height is our + // desired size + ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); + NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); - // Place and size the child - nsRect rect(left, top, aDesiredSize.width, aDesiredSize.height); - mFirstChild->SetRect(rect); + // Place and size the child + nsRect rect(left, top, aDesiredSize.width, aDesiredSize.height); + mFirstChild->SetRect(rect); - // Compute our desired size - aDesiredSize.width += left + right + sbarWidth; - aDesiredSize.height += top + bottom; - if (aDesiredSize.height < aReflowState.maxSize.height) { - aDesiredSize.height = aReflowState.maxSize.height; - } + // Compute our desired size + aDesiredSize.width += left + right + sbarWidth; + aDesiredSize.height += top + bottom; + if (aDesiredSize.height < aReflowState.maxSize.height) { + aDesiredSize.height = aReflowState.maxSize.height; } // Do the necessary repainting diff --git a/mozilla/layout/generic/nsPageFrame.cpp b/mozilla/layout/generic/nsPageFrame.cpp index db51e22e6be..87230a8b332 100644 --- a/mozilla/layout/generic/nsPageFrame.cpp +++ b/mozilla/layout/generic/nsPageFrame.cpp @@ -92,7 +92,7 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE); nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, maxSize); - aStatus = ReflowChild(mFirstChild, &aPresContext, aDesiredSize, kidReflowState); + ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); // Place and size the child. Make sure the child is at least as // tall as our max size (the containing window) @@ -131,8 +131,7 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { // Get the child's desired size - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, aDesiredSize, kidReflowState); + ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); // Make sure the child is at least as tall as our max size (the containing window) if (aDesiredSize.height < aReflowState.maxSize.height) { @@ -142,6 +141,7 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, // Place and size the child nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height); mFirstChild->SetRect(rect); + // XXX Should we be sending the DidReflow? htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED); // Is the frame complete? diff --git a/mozilla/layout/html/base/src/nsContainerFrame.cpp b/mozilla/layout/html/base/src/nsContainerFrame.cpp index 6201f6c05c5..2901ddc3cd4 100644 --- a/mozilla/layout/html/base/src/nsContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsContainerFrame.cpp @@ -285,30 +285,36 @@ NS_METHOD nsContainerFrame::GetCursorAndContentAt(nsIPresContext& aPresContext, // Helper member functions /** - * Reflow a child frame and return the status of the reflow. If the - * child is complete and it has next-in-flows (it was a splittable child) - * then delete the next-in-flows. + * Queries the child frame for the nsIHTMLReflow interface and if it's + * supported invokes the WillReflow() and Reflow() member functions. If + * the reflow succeeds and the child frame is complete, deletes any + * next-in-flows using DeleteChildsNextInFlow() */ -nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, - nsIPresContext* aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState) +nsresult +nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, + nsIPresContext& aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus) { - nsReflowStatus status; - NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state"); -#ifdef NS_DEBUG - nsFrameState kidFrameState; - aKidFrame->GetFrameState(kidFrameState); - NS_ASSERTION(kidFrameState & NS_FRAME_IN_REFLOW, "kid frame is not in reflow"); -#endif + // Query for the nsIHTMLReflow interface nsIHTMLReflow* htmlReflow; - if (NS_OK == aKidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->Reflow(*aPresContext, aDesiredSize, aReflowState, status); + nsresult result; + + result = aKidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow); + if (NS_FAILED(result)) { + return result; } - if (NS_FRAME_IS_COMPLETE(status)) { + // Send the WillReflow notification, and reflow the child frame + htmlReflow->WillReflow(aPresContext); + result = htmlReflow->Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); + + // If the reflow was successful and the child frame is complete, delete any + // next-in-flows + if (NS_SUCCEEDED(result) && NS_FRAME_IS_COMPLETE(aStatus)) { nsIFrame* kidNextInFlow; aKidFrame->GetNextInFlow(kidNextInFlow); @@ -318,10 +324,11 @@ nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, // parent is not this because we are executing pullup code) nsIFrame* parent; aKidFrame->GetGeometricParent(parent); - ((nsContainerFrame*)parent)->DeleteChildsNextInFlow(*aPresContext, aKidFrame); + ((nsContainerFrame*)parent)->DeleteChildsNextInFlow(aPresContext, aKidFrame); } } - return status; + + return result; } /** @@ -401,7 +408,7 @@ nsContainerFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild->SetNextSibling(nextSibling); } - // Delete the next-in-flow frame and adjust its parents child count + // Delete the next-in-flow frame WillDeleteNextInFlowFrame(nextInFlow); nextInFlow->DeleteFrame(aPresContext); diff --git a/mozilla/layout/html/base/src/nsContainerFrame.h b/mozilla/layout/html/base/src/nsContainerFrame.h index 73d9057c267..6d7df7e9ca4 100644 --- a/mozilla/layout/html/base/src/nsContainerFrame.h +++ b/mozilla/layout/html/base/src/nsContainerFrame.h @@ -110,13 +110,16 @@ protected: const nsRect& aDirtyRect); /** - * Reflow a child frame and return the status of the reflow. If the child - * is complete and it has next-in-flows, then delete the next-in-flows. + * Queries the child frame for the nsIHTMLReflow interface and if it's + * supported invokes the WillReflow() and Reflow() member functions. If + * the reflow succeeds and the child frame is complete, deletes any + * next-in-flows using DeleteChildsNextInFlow() */ - nsReflowStatus ReflowChild(nsIFrame* aKidFrame, - nsIPresContext* aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState); + nsresult ReflowChild(nsIFrame* aKidFrame, + nsIPresContext& aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus); /** * Moves any frames on both the prev-in-flow's overflow list and the receiver's diff --git a/mozilla/layout/html/base/src/nsHTMLFrame.cpp b/mozilla/layout/html/base/src/nsHTMLFrame.cpp index c50188f5774..f40589bde2b 100644 --- a/mozilla/layout/html/base/src/nsHTMLFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLFrame.cpp @@ -151,12 +151,14 @@ RootFrame::Reflow(nsIPresContext& aPresContext, nsIHTMLReflow* htmlReflow; if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, desiredSize, kidReflowState); + ReflowChild(mFirstChild, aPresContext, desiredSize, kidReflowState, aStatus); // Place and size the child nsRect rect(0, 0, desiredSize.width, desiredSize.height); mFirstChild->SetRect(rect); + + // XXX We should resolve the details of who/when DidReflow() notifications + // are sent... htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED); } } @@ -363,18 +365,14 @@ RootContentFrame::Reflow(nsIPresContext& aPresContext, nsSize maxSize(availWidth, NS_UNCONSTRAINEDSIZE); nsHTMLReflowState kidReflowState(next, aReflowState, maxSize); - nsIHTMLReflow* htmlReflow; // Dispatch the reflow command to our child frame. Allow it to be as high // as it wants - if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, aDesiredSize, kidReflowState); + ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); - // Place and size the child - nsRect rect(left, top, aDesiredSize.width, aDesiredSize.height); - mFirstChild->SetRect(rect); - } + // Place and size the child + nsRect rect(left, top, aDesiredSize.width, aDesiredSize.height); + mFirstChild->SetRect(rect); // Compute our desired size aDesiredSize.width += left + right + sbarWidth; @@ -415,46 +413,41 @@ RootContentFrame::Reflow(nsIPresContext& aPresContext, // Reflow the page nsHTMLReflowState kidReflowState(kidFrame, aReflowState, pageSize, reflowReason); - nsIHTMLReflow* htmlReflow; nsReflowStatus status; // Place and size the page. If the page is narrower than our // max width then center it horizontally - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - status = ReflowChild(kidFrame, &aPresContext, kidSize, - kidReflowState); - kidFrame->SetRect(nsRect(x, y, kidSize.width, kidSize.height)); - y += kidSize.height; + ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, status); + kidFrame->SetRect(nsRect(x, y, kidSize.width, kidSize.height)); + y += kidSize.height; - // Leave a slight gap between the pages - y += PAGE_SPACING_TWIPS; + // Leave a slight gap between the pages + y += PAGE_SPACING_TWIPS; - // Is the page complete? - nsIFrame* kidNextInFlow; + // Is the page complete? + nsIFrame* kidNextInFlow; - kidFrame->GetNextInFlow(kidNextInFlow); - if (NS_FRAME_IS_COMPLETE(status)) { - NS_ASSERTION(nsnull == kidNextInFlow, "bad child flow list"); - } else if (nsnull == kidNextInFlow) { - // The page isn't complete and it doesn't have a next-in-flow so - // create a continuing page - nsIStyleContext* kidSC; - kidFrame->GetStyleContext(&aPresContext, kidSC); - nsIFrame* continuingPage; - nsresult rv = kidFrame->CreateContinuingFrame(aPresContext, this, - kidSC, continuingPage); - NS_RELEASE(kidSC); - reflowReason = eReflowReason_Initial; + kidFrame->GetNextInFlow(kidNextInFlow); + if (NS_FRAME_IS_COMPLETE(status)) { + NS_ASSERTION(nsnull == kidNextInFlow, "bad child flow list"); + } else if (nsnull == kidNextInFlow) { + // The page isn't complete and it doesn't have a next-in-flow so + // create a continuing page + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(&aPresContext, kidSC); + nsIFrame* continuingPage; + nsresult rv = kidFrame->CreateContinuingFrame(aPresContext, this, + kidSC, continuingPage); + NS_RELEASE(kidSC); + reflowReason = eReflowReason_Initial; - // Add it to our child list + // Add it to our child list #ifdef NS_DEBUG - nsIFrame* kidNextSibling; - kidFrame->GetNextSibling(kidNextSibling); - NS_ASSERTION(nsnull == kidNextSibling, "unexpected sibling"); + nsIFrame* kidNextSibling; + kidFrame->GetNextSibling(kidNextSibling); + NS_ASSERTION(nsnull == kidNextSibling, "unexpected sibling"); #endif - kidFrame->SetNextSibling(continuingPage); - } + kidFrame->SetNextSibling(continuingPage); } // Get the next page @@ -475,25 +468,21 @@ RootContentFrame::Reflow(nsIPresContext& aPresContext, nsSize maxSize(availWidth, NS_UNCONSTRAINEDSIZE); nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, maxSize, reflowReason); - nsIHTMLReflow* htmlReflow; - if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - // Get the child's desired size. Our child's desired height is our - // desired size - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, aDesiredSize, kidReflowState); - NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); + // Get the child's desired size. Our child's desired height is our + // desired size + ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); + NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); - // Place and size the child - nsRect rect(left, top, aDesiredSize.width, aDesiredSize.height); - mFirstChild->SetRect(rect); + // Place and size the child + nsRect rect(left, top, aDesiredSize.width, aDesiredSize.height); + mFirstChild->SetRect(rect); - // Compute our desired size - aDesiredSize.width += left + right + sbarWidth; - aDesiredSize.height += top + bottom; - if (aDesiredSize.height < aReflowState.maxSize.height) { - aDesiredSize.height = aReflowState.maxSize.height; - } + // Compute our desired size + aDesiredSize.width += left + right + sbarWidth; + aDesiredSize.height += top + bottom; + if (aDesiredSize.height < aReflowState.maxSize.height) { + aDesiredSize.height = aReflowState.maxSize.height; } // Do the necessary repainting diff --git a/mozilla/layout/html/base/src/nsPageFrame.cpp b/mozilla/layout/html/base/src/nsPageFrame.cpp index db51e22e6be..87230a8b332 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageFrame.cpp @@ -92,7 +92,7 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE); nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, maxSize); - aStatus = ReflowChild(mFirstChild, &aPresContext, aDesiredSize, kidReflowState); + ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); // Place and size the child. Make sure the child is at least as // tall as our max size (the containing window) @@ -131,8 +131,7 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { // Get the child's desired size - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, aDesiredSize, kidReflowState); + ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); // Make sure the child is at least as tall as our max size (the containing window) if (aDesiredSize.height < aReflowState.maxSize.height) { @@ -142,6 +141,7 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, // Place and size the child nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height); mFirstChild->SetRect(rect); + // XXX Should we be sending the DidReflow? htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED); // Is the frame complete? diff --git a/mozilla/layout/html/base/src/nsScrollFrame.cpp b/mozilla/layout/html/base/src/nsScrollFrame.cpp index 1dcce90b274..f0be22227ea 100644 --- a/mozilla/layout/html/base/src/nsScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsScrollFrame.cpp @@ -127,8 +127,7 @@ nsScrollBodyFrame::Reflow(nsIPresContext& aPresContext, if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { // Dispatch the reflow command to our child frame. Allow it to be as high // as it wants - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, aDesiredSize, kidReflowState); + ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); // Place and size the child. Make sure the child is at least as // tall as our max size (the containing window) @@ -138,6 +137,7 @@ nsScrollBodyFrame::Reflow(nsIPresContext& aPresContext, nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height); mFirstChild->SetRect(rect); + // XXX Why are we sending a DidReflow() notification here? htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED); } @@ -175,7 +175,7 @@ nsScrollBodyFrame::Reflow(nsIPresContext& aPresContext, if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { htmlReflow->WillReflow(aPresContext); - status = ReflowChild(kidFrame, &aPresContext, kidSize, kidReflowState); + ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, status); kidFrame->SetRect(nsRect(x, y, kidSize.width, kidSize.height)); htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED); @@ -230,7 +230,7 @@ nsScrollBodyFrame::Reflow(nsIPresContext& aPresContext, // Get the child's desired size. Our child's desired height is our // desired size htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, aDesiredSize, kidReflowState); + ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); #if 0 @@ -393,8 +393,7 @@ nsScrollInnerFrame::Reflow(nsIPresContext& aPresContext, if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, kidMetrics, - kidReflowState); + ReflowChild(mFirstChild, aPresContext, kidMetrics, kidReflowState, aStatus); NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); // Place and size the child @@ -507,8 +506,7 @@ nsScrollOuterFrame::Reflow(nsIPresContext& aPresContext, if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, aDesiredSize, - kidReflowState); + ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); // Place and size the child diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 499acbae8a2..9fa1c8b3f59 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -328,8 +328,7 @@ nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext, nsIHTMLReflow* htmlReflow; if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, kidMetrics, kidReflowState); + ReflowChild(mFirstChild, aPresContext, kidMetrics, kidReflowState, aStatus); NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); // Place and size the child diff --git a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp index 38d9e021965..a65d1f51f32 100644 --- a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp @@ -674,18 +674,17 @@ nsHTMLFramesetFrame::ReflowPlaceChild(nsIFrame* aChild, nsIHTMLReflow* htmlReflow; if (NS_OK == aChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - nsHTMLReflowMetrics metrics(nsnull); metrics.width = aSize.width; metrics.height= aSize.height; nsReflowStatus status; if (needFramesetReflow) { + htmlReflow->WillReflow(aPresContext); status = ((nsHTMLFramesetFrame*)aChild)->Reflow(aPresContext, childDrag, metrics, reflowState, status); } else { - status = ReflowChild(aChild, &aPresContext, metrics, reflowState); + ReflowChild(aChild, aPresContext, metrics, reflowState, status); } NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "bad status"); diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp index c97e8137584..fd521a48cc4 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp @@ -326,19 +326,15 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext, kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0; SetPriorAvailWidth(aReflowState.maxSize.width); nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, availSize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, kidSize, kidReflowState); + ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState, aStatus); #ifdef NS_DEBUG - if (kidSize.width > availSize.width) - { - printf("WARNING: cell content returned desired width %d given avail width %d\n", - kidSize.width, availSize.width); - } -#endif + if (kidSize.width > availSize.width) + { + printf("WARNING: cell content returned desired width %d given avail width %d\n", + kidSize.width, availSize.width); } +#endif if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT) { if (nsnull!=pMaxElementSize) diff --git a/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp b/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp index 18c908d6e6c..cacde3a24b8 100644 --- a/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp @@ -208,15 +208,11 @@ NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext& aPresContext, nsHTMLReflowMetrics kidSize(nsnull); // XXX Use a valid reason... nsHTMLReflowState kidReflowState(kidFrame, aReflowState, nsSize(0,0), eReflowReason_Initial); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - nsReflowStatus status = ReflowChild(kidFrame,&aPresContext, kidSize, - kidReflowState); - // note that DidReflow is called as the result of some ancestor firing off a DidReflow above me - kidFrame->SetRect(nsRect(0,0,0,0)); - } + nsReflowStatus status; + ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, status); + // note that DidReflow is called as the result of some ancestor firing off a DidReflow above me + kidFrame->SetRect(nsRect(0,0,0,0)); } aDesiredSize.width=0; diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index f0d92b937d4..f39c7a37441 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -1535,17 +1535,13 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext& aPresContext, nsHTMLReflowMetrics desiredSize(nsnull); // XXX Correctly compute the available space... nsHTMLReflowState kidReflowState(kidFrame, aReflowState, aReflowState.maxSize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(kidFrame, &aPresContext, desiredSize, kidReflowState); + ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus); - // Resize the row group frame - nsRect kidRect; - kidFrame->GetRect(kidRect); - kidFrame->SizeTo(desiredSize.width, desiredSize.height); - } + // Resize the row group frame + nsRect kidRect; + kidFrame->GetRect(kidRect); + kidFrame->SizeTo(desiredSize.width, desiredSize.height); #if 1 // XXX For the time being just fall through and treat it like a @@ -1681,38 +1677,33 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext, } nsSize maxKidElementSize(0,0); nsHTMLReflowState kidReflowState(kidFrame, aReflowState, availSize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - PRInt32 yCoord = y; - if (NS_UNCONSTRAINEDSIZE!=yCoord) - yCoord+= topInset; - htmlReflow->WillReflow(*aPresContext); - result = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); + PRInt32 yCoord = y; + if (NS_UNCONSTRAINEDSIZE!=yCoord) + yCoord+= topInset; + ReflowChild(kidFrame, *aPresContext, kidSize, kidReflowState, result); - // Place the child since some of its content fit in us. - if (PR_TRUE==gsDebugNT) { - printf ("%p: reflow of row group returned desired=%d,%d, max-element=%d,%d\n", - this, kidSize.width, kidSize.height, kidMaxSize.width, kidMaxSize.height); - } - kidFrame->SetRect(nsRect(leftInset, yCoord, - kidSize.width, kidSize.height)); - if (NS_UNCONSTRAINEDSIZE==kidSize.height) - y = NS_UNCONSTRAINEDSIZE; - else - y += kidSize.height; - if (kidMaxSize.width > maxSize.width) { - maxSize.width = kidMaxSize.width; - } - if (kidMaxSize.height > maxSize.height) { - maxSize.height = kidMaxSize.height; - } + // Place the child since some of its content fit in us. + if (PR_TRUE==gsDebugNT) { + printf ("%p: reflow of row group returned desired=%d,%d, max-element=%d,%d\n", + this, kidSize.width, kidSize.height, kidMaxSize.width, kidMaxSize.height); + } + kidFrame->SetRect(nsRect(leftInset, yCoord, kidSize.width, kidSize.height)); + if (NS_UNCONSTRAINEDSIZE==kidSize.height) + y = NS_UNCONSTRAINEDSIZE; + else + y += kidSize.height; + if (kidMaxSize.width > maxSize.width) { + maxSize.width = kidMaxSize.width; + } + if (kidMaxSize.height > maxSize.height) { + maxSize.height = kidMaxSize.height; + } - if (NS_FRAME_IS_NOT_COMPLETE(result)) { - // If the child didn't finish layout then it means that it used - // up all of our available space (or needs us to split). - break; - } + if (NS_FRAME_IS_NOT_COMPLETE(result)) { + // If the child didn't finish layout then it means that it used + // up all of our available space (or needs us to split). + break; } } } @@ -1998,42 +1989,38 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext, // Reflow the child into the available space nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, reason); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(*aPresContext); - nscoord x = aState.leftInset + kidMargin.left; - nscoord y = aState.topInset + aState.y + topMargin; - status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); - // Did the child fit? - if ((kidFrame != mFirstChild) && (desiredSize.height > kidAvailSize.height)) - { - // The child is too wide to fit in the available space, and it's - // not our first child - PushChildren(kidFrame, prevKidFrame); - result = PR_FALSE; - break; - } + nscoord x = aState.leftInset + kidMargin.left; + nscoord y = aState.topInset + aState.y + topMargin; + ReflowChild(kidFrame, *aPresContext, desiredSize, kidReflowState, status); + // Did the child fit? + if ((kidFrame != mFirstChild) && (desiredSize.height > kidAvailSize.height)) + { + // The child is too wide to fit in the available space, and it's + // not our first child + PushChildren(kidFrame, prevKidFrame); + result = PR_FALSE; + break; + } - // Place the child after taking into account it's margin - aState.y += topMargin; - nsRect kidRect (x, y, desiredSize.width, desiredSize.height); - if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay || - NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == childDisplay->mDisplay || - NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay ) - { - // we don't want to adjust the maxElementSize if this is an initial reflow - // it was set by the TableLayoutStrategy and shouldn't be changed. - nsSize *requestedMaxElementSize = nsnull; - if (eReflowReason_Initial != aState.reflowState.reason) - requestedMaxElementSize = aMaxElementSize; - PlaceChild(aPresContext, aState, kidFrame, kidRect, - requestedMaxElementSize, kidMaxElementSize); - if (bottomMargin < 0) { - aState.prevMaxNegBottomMargin = -bottomMargin; - } else { - aState.prevMaxPosBottomMargin = bottomMargin; - } + // Place the child after taking into account it's margin + aState.y += topMargin; + nsRect kidRect (x, y, desiredSize.width, desiredSize.height); + if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay || + NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == childDisplay->mDisplay || + NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay ) + { + // we don't want to adjust the maxElementSize if this is an initial reflow + // it was set by the TableLayoutStrategy and shouldn't be changed. + nsSize *requestedMaxElementSize = nsnull; + if (eReflowReason_Initial != aState.reflowState.reason) + requestedMaxElementSize = aMaxElementSize; + PlaceChild(aPresContext, aState, kidFrame, kidRect, + requestedMaxElementSize, kidMaxElementSize); + if (bottomMargin < 0) { + aState.prevMaxNegBottomMargin = -bottomMargin; + } else { + aState.prevMaxPosBottomMargin = bottomMargin; } } childCount++; @@ -2143,38 +2130,34 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext, } nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize, eReflowReason_Resize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(*aPresContext); - status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); + ReflowChild(kidFrame, *aPresContext, kidSize, kidReflowState, status); - // Did the child fit? - if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) { - // The child is too wide to fit in the available space, and it's - // not our first child - result = PR_FALSE; - break; - } + // Did the child fit? + if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) { + // The child is too wide to fit in the available space, and it's + // not our first child + result = PR_FALSE; + break; + } - // Advance y by the topMargin between children. Zero out the - // topMargin in case this frame is continued because - // continuations do not have a top margin. Update the prev - // bottom margin state in the body reflow state so that we can - // apply the bottom margin when we hit the next child (or - // finish). - //aState.y += topMargin; - nsRect kidRect (0, 0, kidSize.width, kidSize.height); - //kidRect.x += kidMol->margin.left; - kidRect.y += aState.y; - const nsStyleDisplay *childDisplay; - kidFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay)); - if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay || - NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == childDisplay->mDisplay || - NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay ) - { - PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize); - } + // Advance y by the topMargin between children. Zero out the + // topMargin in case this frame is continued because + // continuations do not have a top margin. Update the prev + // bottom margin state in the body reflow state so that we can + // apply the bottom margin when we hit the next child (or + // finish). + //aState.y += topMargin; + nsRect kidRect (0, 0, kidSize.width, kidSize.height); + //kidRect.x += kidMol->margin.left; + kidRect.y += aState.y; + const nsStyleDisplay *childDisplay; + kidFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay)); + if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay || + NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == childDisplay->mDisplay || + NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay ) + { + PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize); } // Remove the frame from its current parent diff --git a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp index eb4d74f0d94..e4bcf7ffb02 100644 --- a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp @@ -464,19 +464,14 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext, nsHTMLReflowState innerReflowState(mInnerTableFrame, aReflowState, nsSize(tableWidth, aReflowState.maxSize.height)); nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == mInnerTableFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mInnerTableFrame, &aPresContext, innerSize, - innerReflowState); + ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus); - // Table's max element size is the MAX of the caption's max element size - // and the inner table's max element size... - if (nsnull != aDesiredSize.maxElementSize) { - if (mMinCaptionWidth > aDesiredSize.maxElementSize->width) { - aDesiredSize.maxElementSize->width = mMinCaptionWidth; - } + // Table's max element size is the MAX of the caption's max element size + // and the inner table's max element size... + if (nsnull != aDesiredSize.maxElementSize) { + if (mMinCaptionWidth > aDesiredSize.maxElementSize->width) { + aDesiredSize.maxElementSize->width = mMinCaptionWidth; } } state.innerTableMaxSize.width = innerSize.width; diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.cpp b/mozilla/layout/html/table/src/nsTableRowFrame.cpp index 62125dcea0a..081d566fd09 100644 --- a/mozilla/layout/html/table/src/nsTableRowFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowFrame.cpp @@ -477,37 +477,32 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext, nsSize kidAvailSize(availWidth, NS_UNCONSTRAINEDSIZE); // Reflow the child - nsIHTMLReflow* htmlReflow; - - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, - eReflowReason_Resize); - if (gsDebug) printf ("%p RR: avail=%d\n", this, availWidth); - nsReflowStatus status = ReflowChild(kidFrame, &aPresContext, desiredSize, - kidReflowState); - if (gsDebug) printf ("%p RR: desired=%d\n", this, desiredSize.width); + nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, + eReflowReason_Resize); + if (gsDebug) printf ("%p RR: avail=%d\n", this, availWidth); + nsReflowStatus status; + ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, status); + if (gsDebug) printf ("%p RR: desired=%d\n", this, desiredSize.width); #ifdef NS_DEBUG - if (desiredSize.width > availWidth) - { - printf("WARNING: cell returned desired width %d given avail width %d\n", - desiredSize.width, availWidth); - } + if (desiredSize.width > availWidth) + { + printf("WARNING: cell returned desired width %d given avail width %d\n", + desiredSize.width, availWidth); + } #endif - NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected reflow status"); + NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected reflow status"); - if (gsDebug) - { - if (nsnull!=pKidMaxElementSize) - printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n", - NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete", - desiredSize.width, desiredSize.height, - pKidMaxElementSize->width, pKidMaxElementSize->height); - else - printf("reflow of cell returned result = %s with desired=%d,%d, min = nsnull\n", - NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete", - desiredSize.width, desiredSize.height); - } + if (gsDebug) + { + if (nsnull!=pKidMaxElementSize) + printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n", + NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete", + desiredSize.width, desiredSize.height, + pKidMaxElementSize->width, pKidMaxElementSize->height); + else + printf("reflow of cell returned result = %s with desired=%d,%d, min = nsnull\n", + NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete", + desiredSize.width, desiredSize.height); } } else @@ -652,40 +647,37 @@ nsTableRowFrame::InitialReflow(nsIPresContext& aPresContext, nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, eReflowReason_Initial); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - if (gsDebug) printf ("%p InitR: avail=%d\n", this, kidAvailSize.width); - nsresult status = ReflowChild(kidFrame, &aPresContext, kidSize, kidReflowState); - if (gsDebug) - printf ("TR %p for cell %p Initial Reflow: desired=%d, MES=%d\n", - this, kidFrame, kidSize.width, kidMaxElementSize.width); - //XXX: this is a hack, shouldn't it be the case that a min size is - // never larger than a desired size? - if (kidMaxElementSize.width>kidSize.width) - kidSize.width = kidMaxElementSize.width; - if (kidMaxElementSize.height>kidSize.height) - kidSize.height = kidMaxElementSize.height; - ((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(kidSize); - ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize); - NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected child reflow status"); + if (gsDebug) printf ("%p InitR: avail=%d\n", this, kidAvailSize.width); + nsresult status; + ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, status); + if (gsDebug) + printf ("TR %p for cell %p Initial Reflow: desired=%d, MES=%d\n", + this, kidFrame, kidSize.width, kidMaxElementSize.width); + //XXX: this is a hack, shouldn't it be the case that a min size is + // never larger than a desired size? + if (kidMaxElementSize.width>kidSize.width) + kidSize.width = kidMaxElementSize.width; + if (kidMaxElementSize.height>kidSize.height) + kidSize.height = kidMaxElementSize.height; + ((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(kidSize); + ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize); + NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected child reflow status"); - if (gsDebug) - { - printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n", - NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete", - kidSize.width, kidSize.height, - kidMaxElementSize.width, kidMaxElementSize.height); - } - - // Place the child - x += margin.left; - nsRect kidRect(x, topMargin, kidSize.width, kidSize.height); - PlaceChild(aPresContext, aState, kidFrame, kidRect, aDesiredSize.maxElementSize, - &kidMaxElementSize); - x += kidSize.width + margin.right; + if (gsDebug) + { + printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n", + NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete", + kidSize.width, kidSize.height, + kidMaxElementSize.width, kidMaxElementSize.height); } + + // Place the child + x += margin.left; + nsRect kidRect(x, topMargin, kidSize.width, kidSize.height); + PlaceChild(aPresContext, aState, kidFrame, kidRect, aDesiredSize.maxElementSize, + &kidMaxElementSize); + x += kidSize.width + margin.right; } } @@ -850,83 +842,78 @@ nsresult nsTableRowFrame::IncrementalReflow(nsIPresContext& aPresContext, nsSize kidMaxElementSize; nsHTMLReflowMetrics desiredSize(&kidMaxElementSize); nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); + // XXX Unfortunately we need to reflow the child several times. + // The first time is for the incremental reflow command. We can't pass in + // a max width of NS_UNCONSTRAINEDSIZE, because the max width must match + // the width of the previous reflow... + ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, status); - // XXX Unfortunately we need to reflow the child several times. - // The first time is for the incremental reflow command. We can't pass in - // a max width of NS_UNCONSTRAINEDSIZE, because the max width must match - // the width of the previous reflow... - status = ReflowChild(kidFrame, &aPresContext, desiredSize, kidReflowState); + // Now do the regular pass 1 reflow and gather the max width and max element + // size. + // XXX It would be nice if we could skip this step and the next step if the + // column width isn't dependent on the max cell width... + kidReflowState.reason = eReflowReason_Resize; + kidReflowState.reflowCommand = nsnull; + kidReflowState.maxSize.width = NS_UNCONSTRAINEDSIZE; + ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, status); + if (gsDebug) + printf ("TR %p for cell %p Incremental Reflow: desired=%d, MES=%d\n", + this, kidFrame, desiredSize.width, kidMaxElementSize.width); + // Update the cell layout data. + //XXX: this is a hack, shouldn't it be the case that a min size is + // never larger than a desired size? + if (kidMaxElementSize.width>desiredSize.width) + desiredSize.width = kidMaxElementSize.width; + if (kidMaxElementSize.height>desiredSize.height) + desiredSize.height = kidMaxElementSize.height; + ((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(desiredSize); + ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize); + + // Now reflow the cell again this time constraining the width + // XXX Ignore for now the possibility that the column width has changed... + kidReflowState.maxSize.width = availWidth; + ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, status); + + // Place the child after taking into account it's margin and attributes + // XXX We need to ask the table (or the table layout strategy) if the column + // widths have changed. If so, we just bail and return a status indicating + // what happened and let the table reflow all the table cells... + nscoord specifiedHeight = 0; + nscoord cellHeight = desiredSize.height; + nsIStyleContextPtr kidSC; + kidFrame->GetStyleContext(&aPresContext, kidSC.AssignRef()); + const nsStylePosition* kidPosition = (const nsStylePosition*) + kidSC->GetStyleData(eStyleStruct_Position); + switch (kidPosition->mHeight.GetUnit()) { + case eStyleUnit_Coord: + specifiedHeight = kidPosition->mHeight.GetCoordValue(); + break; - // Now do the regular pass 1 reflow and gather the max width and max element - // size. - // XXX It would be nice if we could skip this step and the next step if the - // column width isn't dependent on the max cell width... - kidReflowState.reason = eReflowReason_Resize; - kidReflowState.reflowCommand = nsnull; - kidReflowState.maxSize.width = NS_UNCONSTRAINEDSIZE; - status = ReflowChild(kidFrame, &aPresContext, desiredSize, kidReflowState); - if (gsDebug) - printf ("TR %p for cell %p Incremental Reflow: desired=%d, MES=%d\n", - this, kidFrame, desiredSize.width, kidMaxElementSize.width); - // Update the cell layout data. - //XXX: this is a hack, shouldn't it be the case that a min size is - // never larger than a desired size? - if (kidMaxElementSize.width>desiredSize.width) - desiredSize.width = kidMaxElementSize.width; - if (kidMaxElementSize.height>desiredSize.height) - desiredSize.height = kidMaxElementSize.height; - ((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(desiredSize); - ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize); - - // Now reflow the cell again this time constraining the width - // XXX Ignore for now the possibility that the column width has changed... - kidReflowState.maxSize.width = availWidth; - status = ReflowChild(kidFrame, &aPresContext, desiredSize, kidReflowState); - - // Place the child after taking into account it's margin and attributes - // XXX We need to ask the table (or the table layout strategy) if the column - // widths have changed. If so, we just bail and return a status indicating - // what happened and let the table reflow all the table cells... - nscoord specifiedHeight = 0; - nscoord cellHeight = desiredSize.height; - nsIStyleContextPtr kidSC; - kidFrame->GetStyleContext(&aPresContext, kidSC.AssignRef()); - const nsStylePosition* kidPosition = (const nsStylePosition*) - kidSC->GetStyleData(eStyleStruct_Position); - switch (kidPosition->mHeight.GetUnit()) { - case eStyleUnit_Coord: - specifiedHeight = kidPosition->mHeight.GetCoordValue(); - break; - - case eStyleUnit_Inherit: - // XXX for now, do nothing - default: - case eStyleUnit_Auto: - break; - } - if (specifiedHeight>cellHeight) - cellHeight = specifiedHeight; - - nscoord cellWidth = desiredSize.width; - // begin special Nav4 compatibility code - if (0==cellWidth) - { - cellWidth = aState.tableFrame->GetColumnWidth(cellColIndex); - } - // end special Nav4 compatibility code - - // Now place the child - nsRect kidRect (aState.x, kidMargin.top, cellWidth, cellHeight); - - PlaceChild(aPresContext, aState, kidFrame, kidRect, aDesiredSize.maxElementSize, - &kidMaxElementSize); - - SetMaxChildHeight(aState.maxCellHeight, maxCellTopMargin, maxCellBottomMargin); + case eStyleUnit_Inherit: + // XXX for now, do nothing + default: + case eStyleUnit_Auto: + break; } + if (specifiedHeight>cellHeight) + cellHeight = specifiedHeight; + + nscoord cellWidth = desiredSize.width; + // begin special Nav4 compatibility code + if (0==cellWidth) + { + cellWidth = aState.tableFrame->GetColumnWidth(cellColIndex); + } + // end special Nav4 compatibility code + + // Now place the child + nsRect kidRect (aState.x, kidMargin.top, cellWidth, cellHeight); + + PlaceChild(aPresContext, aState, kidFrame, kidRect, aDesiredSize.maxElementSize, + &kidMaxElementSize); + + SetMaxChildHeight(aState.maxCellHeight, maxCellTopMargin, maxCellBottomMargin); // Return our desired size. Note that our desired width is just whatever width // we were given by the row group frame diff --git a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp index 333efe61681..052624386e6 100644 --- a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp @@ -301,40 +301,36 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon // Reflow the child into the available space nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(*aPresContext); - if (gsDebug) printf("%p RG reflowing child %d (frame=%p) with avail width = %d\n", - this, debugCounter, kidFrame, kidAvailSize.width); - status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); - if (gsDebug) printf("%p RG child %d (frame=%p) returned desired width = %d\n", - this, debugCounter, kidFrame, desiredSize.width); + if (gsDebug) printf("%p RG reflowing child %d (frame=%p) with avail width = %d\n", + this, debugCounter, kidFrame, kidAvailSize.width); + ReflowChild(kidFrame, *aPresContext, desiredSize, kidReflowState, status); + if (gsDebug) printf("%p RG child %d (frame=%p) returned desired width = %d\n", + this, debugCounter, kidFrame, desiredSize.width); - // Did the child fit? - if ((kidFrame != mFirstChild) && - ((kidAvailSize.height <= 0) || - (desiredSize.height > kidAvailSize.height))) - { - // The child's height is too big to fit at all in our remaining space, - // and it's not our first child. - // - // Note that if the width is too big that's okay and we allow the - // child to extend horizontally outside of the reflow area - PushChildren(kidFrame, prevKidFrame); - result = PR_FALSE; - break; - } + // Did the child fit? + if ((kidFrame != mFirstChild) && + ((kidAvailSize.height <= 0) || + (desiredSize.height > kidAvailSize.height))) + { + // The child's height is too big to fit at all in our remaining space, + // and it's not our first child. + // + // Note that if the width is too big that's okay and we allow the + // child to extend horizontally outside of the reflow area + PushChildren(kidFrame, prevKidFrame); + result = PR_FALSE; + break; + } - // Place the child after taking into account it's margin - nsRect kidRect (kidMargin.left, aState.y, desiredSize.width, desiredSize.height); - PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, - kidMaxElementSize); - if (bottomMargin < 0) { - aState.prevMaxNegBottomMargin = -bottomMargin; - } else { - aState.prevMaxPosBottomMargin = bottomMargin; - } + // Place the child after taking into account it's margin + nsRect kidRect (kidMargin.left, aState.y, desiredSize.width, desiredSize.height); + PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, + kidMaxElementSize); + if (bottomMargin < 0) { + aState.prevMaxNegBottomMargin = -bottomMargin; + } else { + aState.prevMaxPosBottomMargin = bottomMargin; } // Remember where we just were in case we end up pushing children @@ -453,28 +449,24 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext, } nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize, eReflowReason_Resize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(*aPresContext); - status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); + ReflowChild(kidFrame, *aPresContext, kidSize, kidReflowState, status); - // Did the child fit? - if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) { - // The child is too wide to fit in the available space, and it's - // not our first child - result = PR_FALSE; - break; - } - - // Place the child - //aState.y += topMargin; - nsRect kidRect (0, 0, kidSize.width, kidSize.height); - //kidRect.x += kidMol->margin.left; - kidRect.y += aState.y; - PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize); + // Did the child fit? + if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) { + // The child is too wide to fit in the available space, and it's + // not our first child + result = PR_FALSE; + break; } + // Place the child + //aState.y += topMargin; + nsRect kidRect (0, 0, kidSize.width, kidSize.height); + //kidRect.x += kidMol->margin.left; + kidRect.y += aState.y; + PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize); + // Remove the frame from its current parent kidFrame->GetNextSibling(nextInFlow->mFirstChild); @@ -780,21 +772,17 @@ nsTableRowGroupFrame::Reflow(nsIPresContext& aPresContext, // XXX Correctly compute the available space... nsHTMLReflowState kidReflowState(kidFrame, aReflowState, aReflowState.maxSize); nsHTMLReflowMetrics desiredSize(nsnull); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(kidFrame, &aPresContext, desiredSize, kidReflowState); + ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus); - // Resize the row frame - nsRect kidRect; - kidFrame->GetRect(kidRect); - kidFrame->SizeTo(desiredSize.width, desiredSize.height); + // Resize the row frame + nsRect kidRect; + kidFrame->GetRect(kidRect); + kidFrame->SizeTo(desiredSize.width, desiredSize.height); - // Adjust the frames that follow... - AdjustSiblingsAfterReflow(&aPresContext, state, kidFrame, desiredSize.height - - oldKidRect.height); - } + // Adjust the frames that follow... + AdjustSiblingsAfterReflow(&aPresContext, state, kidFrame, desiredSize.height - + oldKidRect.height); // Return of desired size aDesiredSize.width = aReflowState.maxSize.width; diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index c97e8137584..fd521a48cc4 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -326,19 +326,15 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext, kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0; SetPriorAvailWidth(aReflowState.maxSize.width); nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, availSize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, kidSize, kidReflowState); + ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState, aStatus); #ifdef NS_DEBUG - if (kidSize.width > availSize.width) - { - printf("WARNING: cell content returned desired width %d given avail width %d\n", - kidSize.width, availSize.width); - } -#endif + if (kidSize.width > availSize.width) + { + printf("WARNING: cell content returned desired width %d given avail width %d\n", + kidSize.width, availSize.width); } +#endif if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT) { if (nsnull!=pMaxElementSize) diff --git a/mozilla/layout/tables/nsTableColGroupFrame.cpp b/mozilla/layout/tables/nsTableColGroupFrame.cpp index 18c908d6e6c..cacde3a24b8 100644 --- a/mozilla/layout/tables/nsTableColGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableColGroupFrame.cpp @@ -208,15 +208,11 @@ NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext& aPresContext, nsHTMLReflowMetrics kidSize(nsnull); // XXX Use a valid reason... nsHTMLReflowState kidReflowState(kidFrame, aReflowState, nsSize(0,0), eReflowReason_Initial); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - nsReflowStatus status = ReflowChild(kidFrame,&aPresContext, kidSize, - kidReflowState); - // note that DidReflow is called as the result of some ancestor firing off a DidReflow above me - kidFrame->SetRect(nsRect(0,0,0,0)); - } + nsReflowStatus status; + ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, status); + // note that DidReflow is called as the result of some ancestor firing off a DidReflow above me + kidFrame->SetRect(nsRect(0,0,0,0)); } aDesiredSize.width=0; diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index f0d92b937d4..f39c7a37441 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -1535,17 +1535,13 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext& aPresContext, nsHTMLReflowMetrics desiredSize(nsnull); // XXX Correctly compute the available space... nsHTMLReflowState kidReflowState(kidFrame, aReflowState, aReflowState.maxSize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(kidFrame, &aPresContext, desiredSize, kidReflowState); + ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus); - // Resize the row group frame - nsRect kidRect; - kidFrame->GetRect(kidRect); - kidFrame->SizeTo(desiredSize.width, desiredSize.height); - } + // Resize the row group frame + nsRect kidRect; + kidFrame->GetRect(kidRect); + kidFrame->SizeTo(desiredSize.width, desiredSize.height); #if 1 // XXX For the time being just fall through and treat it like a @@ -1681,38 +1677,33 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext, } nsSize maxKidElementSize(0,0); nsHTMLReflowState kidReflowState(kidFrame, aReflowState, availSize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - PRInt32 yCoord = y; - if (NS_UNCONSTRAINEDSIZE!=yCoord) - yCoord+= topInset; - htmlReflow->WillReflow(*aPresContext); - result = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); + PRInt32 yCoord = y; + if (NS_UNCONSTRAINEDSIZE!=yCoord) + yCoord+= topInset; + ReflowChild(kidFrame, *aPresContext, kidSize, kidReflowState, result); - // Place the child since some of its content fit in us. - if (PR_TRUE==gsDebugNT) { - printf ("%p: reflow of row group returned desired=%d,%d, max-element=%d,%d\n", - this, kidSize.width, kidSize.height, kidMaxSize.width, kidMaxSize.height); - } - kidFrame->SetRect(nsRect(leftInset, yCoord, - kidSize.width, kidSize.height)); - if (NS_UNCONSTRAINEDSIZE==kidSize.height) - y = NS_UNCONSTRAINEDSIZE; - else - y += kidSize.height; - if (kidMaxSize.width > maxSize.width) { - maxSize.width = kidMaxSize.width; - } - if (kidMaxSize.height > maxSize.height) { - maxSize.height = kidMaxSize.height; - } + // Place the child since some of its content fit in us. + if (PR_TRUE==gsDebugNT) { + printf ("%p: reflow of row group returned desired=%d,%d, max-element=%d,%d\n", + this, kidSize.width, kidSize.height, kidMaxSize.width, kidMaxSize.height); + } + kidFrame->SetRect(nsRect(leftInset, yCoord, kidSize.width, kidSize.height)); + if (NS_UNCONSTRAINEDSIZE==kidSize.height) + y = NS_UNCONSTRAINEDSIZE; + else + y += kidSize.height; + if (kidMaxSize.width > maxSize.width) { + maxSize.width = kidMaxSize.width; + } + if (kidMaxSize.height > maxSize.height) { + maxSize.height = kidMaxSize.height; + } - if (NS_FRAME_IS_NOT_COMPLETE(result)) { - // If the child didn't finish layout then it means that it used - // up all of our available space (or needs us to split). - break; - } + if (NS_FRAME_IS_NOT_COMPLETE(result)) { + // If the child didn't finish layout then it means that it used + // up all of our available space (or needs us to split). + break; } } } @@ -1998,42 +1989,38 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext, // Reflow the child into the available space nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, reason); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(*aPresContext); - nscoord x = aState.leftInset + kidMargin.left; - nscoord y = aState.topInset + aState.y + topMargin; - status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); - // Did the child fit? - if ((kidFrame != mFirstChild) && (desiredSize.height > kidAvailSize.height)) - { - // The child is too wide to fit in the available space, and it's - // not our first child - PushChildren(kidFrame, prevKidFrame); - result = PR_FALSE; - break; - } + nscoord x = aState.leftInset + kidMargin.left; + nscoord y = aState.topInset + aState.y + topMargin; + ReflowChild(kidFrame, *aPresContext, desiredSize, kidReflowState, status); + // Did the child fit? + if ((kidFrame != mFirstChild) && (desiredSize.height > kidAvailSize.height)) + { + // The child is too wide to fit in the available space, and it's + // not our first child + PushChildren(kidFrame, prevKidFrame); + result = PR_FALSE; + break; + } - // Place the child after taking into account it's margin - aState.y += topMargin; - nsRect kidRect (x, y, desiredSize.width, desiredSize.height); - if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay || - NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == childDisplay->mDisplay || - NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay ) - { - // we don't want to adjust the maxElementSize if this is an initial reflow - // it was set by the TableLayoutStrategy and shouldn't be changed. - nsSize *requestedMaxElementSize = nsnull; - if (eReflowReason_Initial != aState.reflowState.reason) - requestedMaxElementSize = aMaxElementSize; - PlaceChild(aPresContext, aState, kidFrame, kidRect, - requestedMaxElementSize, kidMaxElementSize); - if (bottomMargin < 0) { - aState.prevMaxNegBottomMargin = -bottomMargin; - } else { - aState.prevMaxPosBottomMargin = bottomMargin; - } + // Place the child after taking into account it's margin + aState.y += topMargin; + nsRect kidRect (x, y, desiredSize.width, desiredSize.height); + if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay || + NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == childDisplay->mDisplay || + NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay ) + { + // we don't want to adjust the maxElementSize if this is an initial reflow + // it was set by the TableLayoutStrategy and shouldn't be changed. + nsSize *requestedMaxElementSize = nsnull; + if (eReflowReason_Initial != aState.reflowState.reason) + requestedMaxElementSize = aMaxElementSize; + PlaceChild(aPresContext, aState, kidFrame, kidRect, + requestedMaxElementSize, kidMaxElementSize); + if (bottomMargin < 0) { + aState.prevMaxNegBottomMargin = -bottomMargin; + } else { + aState.prevMaxPosBottomMargin = bottomMargin; } } childCount++; @@ -2143,38 +2130,34 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext, } nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize, eReflowReason_Resize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(*aPresContext); - status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); + ReflowChild(kidFrame, *aPresContext, kidSize, kidReflowState, status); - // Did the child fit? - if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) { - // The child is too wide to fit in the available space, and it's - // not our first child - result = PR_FALSE; - break; - } + // Did the child fit? + if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) { + // The child is too wide to fit in the available space, and it's + // not our first child + result = PR_FALSE; + break; + } - // Advance y by the topMargin between children. Zero out the - // topMargin in case this frame is continued because - // continuations do not have a top margin. Update the prev - // bottom margin state in the body reflow state so that we can - // apply the bottom margin when we hit the next child (or - // finish). - //aState.y += topMargin; - nsRect kidRect (0, 0, kidSize.width, kidSize.height); - //kidRect.x += kidMol->margin.left; - kidRect.y += aState.y; - const nsStyleDisplay *childDisplay; - kidFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay)); - if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay || - NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == childDisplay->mDisplay || - NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay ) - { - PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize); - } + // Advance y by the topMargin between children. Zero out the + // topMargin in case this frame is continued because + // continuations do not have a top margin. Update the prev + // bottom margin state in the body reflow state so that we can + // apply the bottom margin when we hit the next child (or + // finish). + //aState.y += topMargin; + nsRect kidRect (0, 0, kidSize.width, kidSize.height); + //kidRect.x += kidMol->margin.left; + kidRect.y += aState.y; + const nsStyleDisplay *childDisplay; + kidFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay)); + if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay || + NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == childDisplay->mDisplay || + NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay ) + { + PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize); } // Remove the frame from its current parent diff --git a/mozilla/layout/tables/nsTableOuterFrame.cpp b/mozilla/layout/tables/nsTableOuterFrame.cpp index eb4d74f0d94..e4bcf7ffb02 100644 --- a/mozilla/layout/tables/nsTableOuterFrame.cpp +++ b/mozilla/layout/tables/nsTableOuterFrame.cpp @@ -464,19 +464,14 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext, nsHTMLReflowState innerReflowState(mInnerTableFrame, aReflowState, nsSize(tableWidth, aReflowState.maxSize.height)); nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == mInnerTableFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(mInnerTableFrame, &aPresContext, innerSize, - innerReflowState); + ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus); - // Table's max element size is the MAX of the caption's max element size - // and the inner table's max element size... - if (nsnull != aDesiredSize.maxElementSize) { - if (mMinCaptionWidth > aDesiredSize.maxElementSize->width) { - aDesiredSize.maxElementSize->width = mMinCaptionWidth; - } + // Table's max element size is the MAX of the caption's max element size + // and the inner table's max element size... + if (nsnull != aDesiredSize.maxElementSize) { + if (mMinCaptionWidth > aDesiredSize.maxElementSize->width) { + aDesiredSize.maxElementSize->width = mMinCaptionWidth; } } state.innerTableMaxSize.width = innerSize.width; diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index 62125dcea0a..081d566fd09 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -477,37 +477,32 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext, nsSize kidAvailSize(availWidth, NS_UNCONSTRAINEDSIZE); // Reflow the child - nsIHTMLReflow* htmlReflow; - - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, - eReflowReason_Resize); - if (gsDebug) printf ("%p RR: avail=%d\n", this, availWidth); - nsReflowStatus status = ReflowChild(kidFrame, &aPresContext, desiredSize, - kidReflowState); - if (gsDebug) printf ("%p RR: desired=%d\n", this, desiredSize.width); + nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, + eReflowReason_Resize); + if (gsDebug) printf ("%p RR: avail=%d\n", this, availWidth); + nsReflowStatus status; + ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, status); + if (gsDebug) printf ("%p RR: desired=%d\n", this, desiredSize.width); #ifdef NS_DEBUG - if (desiredSize.width > availWidth) - { - printf("WARNING: cell returned desired width %d given avail width %d\n", - desiredSize.width, availWidth); - } + if (desiredSize.width > availWidth) + { + printf("WARNING: cell returned desired width %d given avail width %d\n", + desiredSize.width, availWidth); + } #endif - NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected reflow status"); + NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected reflow status"); - if (gsDebug) - { - if (nsnull!=pKidMaxElementSize) - printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n", - NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete", - desiredSize.width, desiredSize.height, - pKidMaxElementSize->width, pKidMaxElementSize->height); - else - printf("reflow of cell returned result = %s with desired=%d,%d, min = nsnull\n", - NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete", - desiredSize.width, desiredSize.height); - } + if (gsDebug) + { + if (nsnull!=pKidMaxElementSize) + printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n", + NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete", + desiredSize.width, desiredSize.height, + pKidMaxElementSize->width, pKidMaxElementSize->height); + else + printf("reflow of cell returned result = %s with desired=%d,%d, min = nsnull\n", + NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete", + desiredSize.width, desiredSize.height); } } else @@ -652,40 +647,37 @@ nsTableRowFrame::InitialReflow(nsIPresContext& aPresContext, nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, eReflowReason_Initial); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - if (gsDebug) printf ("%p InitR: avail=%d\n", this, kidAvailSize.width); - nsresult status = ReflowChild(kidFrame, &aPresContext, kidSize, kidReflowState); - if (gsDebug) - printf ("TR %p for cell %p Initial Reflow: desired=%d, MES=%d\n", - this, kidFrame, kidSize.width, kidMaxElementSize.width); - //XXX: this is a hack, shouldn't it be the case that a min size is - // never larger than a desired size? - if (kidMaxElementSize.width>kidSize.width) - kidSize.width = kidMaxElementSize.width; - if (kidMaxElementSize.height>kidSize.height) - kidSize.height = kidMaxElementSize.height; - ((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(kidSize); - ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize); - NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected child reflow status"); + if (gsDebug) printf ("%p InitR: avail=%d\n", this, kidAvailSize.width); + nsresult status; + ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, status); + if (gsDebug) + printf ("TR %p for cell %p Initial Reflow: desired=%d, MES=%d\n", + this, kidFrame, kidSize.width, kidMaxElementSize.width); + //XXX: this is a hack, shouldn't it be the case that a min size is + // never larger than a desired size? + if (kidMaxElementSize.width>kidSize.width) + kidSize.width = kidMaxElementSize.width; + if (kidMaxElementSize.height>kidSize.height) + kidSize.height = kidMaxElementSize.height; + ((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(kidSize); + ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize); + NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected child reflow status"); - if (gsDebug) - { - printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n", - NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete", - kidSize.width, kidSize.height, - kidMaxElementSize.width, kidMaxElementSize.height); - } - - // Place the child - x += margin.left; - nsRect kidRect(x, topMargin, kidSize.width, kidSize.height); - PlaceChild(aPresContext, aState, kidFrame, kidRect, aDesiredSize.maxElementSize, - &kidMaxElementSize); - x += kidSize.width + margin.right; + if (gsDebug) + { + printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n", + NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete", + kidSize.width, kidSize.height, + kidMaxElementSize.width, kidMaxElementSize.height); } + + // Place the child + x += margin.left; + nsRect kidRect(x, topMargin, kidSize.width, kidSize.height); + PlaceChild(aPresContext, aState, kidFrame, kidRect, aDesiredSize.maxElementSize, + &kidMaxElementSize); + x += kidSize.width + margin.right; } } @@ -850,83 +842,78 @@ nsresult nsTableRowFrame::IncrementalReflow(nsIPresContext& aPresContext, nsSize kidMaxElementSize; nsHTMLReflowMetrics desiredSize(&kidMaxElementSize); nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); + // XXX Unfortunately we need to reflow the child several times. + // The first time is for the incremental reflow command. We can't pass in + // a max width of NS_UNCONSTRAINEDSIZE, because the max width must match + // the width of the previous reflow... + ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, status); - // XXX Unfortunately we need to reflow the child several times. - // The first time is for the incremental reflow command. We can't pass in - // a max width of NS_UNCONSTRAINEDSIZE, because the max width must match - // the width of the previous reflow... - status = ReflowChild(kidFrame, &aPresContext, desiredSize, kidReflowState); + // Now do the regular pass 1 reflow and gather the max width and max element + // size. + // XXX It would be nice if we could skip this step and the next step if the + // column width isn't dependent on the max cell width... + kidReflowState.reason = eReflowReason_Resize; + kidReflowState.reflowCommand = nsnull; + kidReflowState.maxSize.width = NS_UNCONSTRAINEDSIZE; + ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, status); + if (gsDebug) + printf ("TR %p for cell %p Incremental Reflow: desired=%d, MES=%d\n", + this, kidFrame, desiredSize.width, kidMaxElementSize.width); + // Update the cell layout data. + //XXX: this is a hack, shouldn't it be the case that a min size is + // never larger than a desired size? + if (kidMaxElementSize.width>desiredSize.width) + desiredSize.width = kidMaxElementSize.width; + if (kidMaxElementSize.height>desiredSize.height) + desiredSize.height = kidMaxElementSize.height; + ((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(desiredSize); + ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize); + + // Now reflow the cell again this time constraining the width + // XXX Ignore for now the possibility that the column width has changed... + kidReflowState.maxSize.width = availWidth; + ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, status); + + // Place the child after taking into account it's margin and attributes + // XXX We need to ask the table (or the table layout strategy) if the column + // widths have changed. If so, we just bail and return a status indicating + // what happened and let the table reflow all the table cells... + nscoord specifiedHeight = 0; + nscoord cellHeight = desiredSize.height; + nsIStyleContextPtr kidSC; + kidFrame->GetStyleContext(&aPresContext, kidSC.AssignRef()); + const nsStylePosition* kidPosition = (const nsStylePosition*) + kidSC->GetStyleData(eStyleStruct_Position); + switch (kidPosition->mHeight.GetUnit()) { + case eStyleUnit_Coord: + specifiedHeight = kidPosition->mHeight.GetCoordValue(); + break; - // Now do the regular pass 1 reflow and gather the max width and max element - // size. - // XXX It would be nice if we could skip this step and the next step if the - // column width isn't dependent on the max cell width... - kidReflowState.reason = eReflowReason_Resize; - kidReflowState.reflowCommand = nsnull; - kidReflowState.maxSize.width = NS_UNCONSTRAINEDSIZE; - status = ReflowChild(kidFrame, &aPresContext, desiredSize, kidReflowState); - if (gsDebug) - printf ("TR %p for cell %p Incremental Reflow: desired=%d, MES=%d\n", - this, kidFrame, desiredSize.width, kidMaxElementSize.width); - // Update the cell layout data. - //XXX: this is a hack, shouldn't it be the case that a min size is - // never larger than a desired size? - if (kidMaxElementSize.width>desiredSize.width) - desiredSize.width = kidMaxElementSize.width; - if (kidMaxElementSize.height>desiredSize.height) - desiredSize.height = kidMaxElementSize.height; - ((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(desiredSize); - ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize); - - // Now reflow the cell again this time constraining the width - // XXX Ignore for now the possibility that the column width has changed... - kidReflowState.maxSize.width = availWidth; - status = ReflowChild(kidFrame, &aPresContext, desiredSize, kidReflowState); - - // Place the child after taking into account it's margin and attributes - // XXX We need to ask the table (or the table layout strategy) if the column - // widths have changed. If so, we just bail and return a status indicating - // what happened and let the table reflow all the table cells... - nscoord specifiedHeight = 0; - nscoord cellHeight = desiredSize.height; - nsIStyleContextPtr kidSC; - kidFrame->GetStyleContext(&aPresContext, kidSC.AssignRef()); - const nsStylePosition* kidPosition = (const nsStylePosition*) - kidSC->GetStyleData(eStyleStruct_Position); - switch (kidPosition->mHeight.GetUnit()) { - case eStyleUnit_Coord: - specifiedHeight = kidPosition->mHeight.GetCoordValue(); - break; - - case eStyleUnit_Inherit: - // XXX for now, do nothing - default: - case eStyleUnit_Auto: - break; - } - if (specifiedHeight>cellHeight) - cellHeight = specifiedHeight; - - nscoord cellWidth = desiredSize.width; - // begin special Nav4 compatibility code - if (0==cellWidth) - { - cellWidth = aState.tableFrame->GetColumnWidth(cellColIndex); - } - // end special Nav4 compatibility code - - // Now place the child - nsRect kidRect (aState.x, kidMargin.top, cellWidth, cellHeight); - - PlaceChild(aPresContext, aState, kidFrame, kidRect, aDesiredSize.maxElementSize, - &kidMaxElementSize); - - SetMaxChildHeight(aState.maxCellHeight, maxCellTopMargin, maxCellBottomMargin); + case eStyleUnit_Inherit: + // XXX for now, do nothing + default: + case eStyleUnit_Auto: + break; } + if (specifiedHeight>cellHeight) + cellHeight = specifiedHeight; + + nscoord cellWidth = desiredSize.width; + // begin special Nav4 compatibility code + if (0==cellWidth) + { + cellWidth = aState.tableFrame->GetColumnWidth(cellColIndex); + } + // end special Nav4 compatibility code + + // Now place the child + nsRect kidRect (aState.x, kidMargin.top, cellWidth, cellHeight); + + PlaceChild(aPresContext, aState, kidFrame, kidRect, aDesiredSize.maxElementSize, + &kidMaxElementSize); + + SetMaxChildHeight(aState.maxCellHeight, maxCellTopMargin, maxCellBottomMargin); // Return our desired size. Note that our desired width is just whatever width // we were given by the row group frame diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.cpp b/mozilla/layout/tables/nsTableRowGroupFrame.cpp index 333efe61681..052624386e6 100644 --- a/mozilla/layout/tables/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableRowGroupFrame.cpp @@ -301,40 +301,36 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon // Reflow the child into the available space nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(*aPresContext); - if (gsDebug) printf("%p RG reflowing child %d (frame=%p) with avail width = %d\n", - this, debugCounter, kidFrame, kidAvailSize.width); - status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState); - if (gsDebug) printf("%p RG child %d (frame=%p) returned desired width = %d\n", - this, debugCounter, kidFrame, desiredSize.width); + if (gsDebug) printf("%p RG reflowing child %d (frame=%p) with avail width = %d\n", + this, debugCounter, kidFrame, kidAvailSize.width); + ReflowChild(kidFrame, *aPresContext, desiredSize, kidReflowState, status); + if (gsDebug) printf("%p RG child %d (frame=%p) returned desired width = %d\n", + this, debugCounter, kidFrame, desiredSize.width); - // Did the child fit? - if ((kidFrame != mFirstChild) && - ((kidAvailSize.height <= 0) || - (desiredSize.height > kidAvailSize.height))) - { - // The child's height is too big to fit at all in our remaining space, - // and it's not our first child. - // - // Note that if the width is too big that's okay and we allow the - // child to extend horizontally outside of the reflow area - PushChildren(kidFrame, prevKidFrame); - result = PR_FALSE; - break; - } + // Did the child fit? + if ((kidFrame != mFirstChild) && + ((kidAvailSize.height <= 0) || + (desiredSize.height > kidAvailSize.height))) + { + // The child's height is too big to fit at all in our remaining space, + // and it's not our first child. + // + // Note that if the width is too big that's okay and we allow the + // child to extend horizontally outside of the reflow area + PushChildren(kidFrame, prevKidFrame); + result = PR_FALSE; + break; + } - // Place the child after taking into account it's margin - nsRect kidRect (kidMargin.left, aState.y, desiredSize.width, desiredSize.height); - PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, - kidMaxElementSize); - if (bottomMargin < 0) { - aState.prevMaxNegBottomMargin = -bottomMargin; - } else { - aState.prevMaxPosBottomMargin = bottomMargin; - } + // Place the child after taking into account it's margin + nsRect kidRect (kidMargin.left, aState.y, desiredSize.width, desiredSize.height); + PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, + kidMaxElementSize); + if (bottomMargin < 0) { + aState.prevMaxNegBottomMargin = -bottomMargin; + } else { + aState.prevMaxPosBottomMargin = bottomMargin; } // Remember where we just were in case we end up pushing children @@ -453,28 +449,24 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext, } nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize, eReflowReason_Resize); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(*aPresContext); - status = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); + ReflowChild(kidFrame, *aPresContext, kidSize, kidReflowState, status); - // Did the child fit? - if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) { - // The child is too wide to fit in the available space, and it's - // not our first child - result = PR_FALSE; - break; - } - - // Place the child - //aState.y += topMargin; - nsRect kidRect (0, 0, kidSize.width, kidSize.height); - //kidRect.x += kidMol->margin.left; - kidRect.y += aState.y; - PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize); + // Did the child fit? + if ((kidSize.height > aState.availSize.height) && (nsnull != mFirstChild)) { + // The child is too wide to fit in the available space, and it's + // not our first child + result = PR_FALSE; + break; } + // Place the child + //aState.y += topMargin; + nsRect kidRect (0, 0, kidSize.width, kidSize.height); + //kidRect.x += kidMol->margin.left; + kidRect.y += aState.y; + PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize); + // Remove the frame from its current parent kidFrame->GetNextSibling(nextInFlow->mFirstChild); @@ -780,21 +772,17 @@ nsTableRowGroupFrame::Reflow(nsIPresContext& aPresContext, // XXX Correctly compute the available space... nsHTMLReflowState kidReflowState(kidFrame, aReflowState, aReflowState.maxSize); nsHTMLReflowMetrics desiredSize(nsnull); - nsIHTMLReflow* htmlReflow; - if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(aPresContext); - aStatus = ReflowChild(kidFrame, &aPresContext, desiredSize, kidReflowState); + ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus); - // Resize the row frame - nsRect kidRect; - kidFrame->GetRect(kidRect); - kidFrame->SizeTo(desiredSize.width, desiredSize.height); + // Resize the row frame + nsRect kidRect; + kidFrame->GetRect(kidRect); + kidFrame->SizeTo(desiredSize.width, desiredSize.height); - // Adjust the frames that follow... - AdjustSiblingsAfterReflow(&aPresContext, state, kidFrame, desiredSize.height - - oldKidRect.height); - } + // Adjust the frames that follow... + AdjustSiblingsAfterReflow(&aPresContext, state, kidFrame, desiredSize.height - + oldKidRect.height); // Return of desired size aDesiredSize.width = aReflowState.maxSize.width;