diff --git a/layout/generic/nsPlaceholderFrame.cpp b/layout/generic/nsPlaceholderFrame.cpp index 3a5ba276ccb5..363c793f91ad 100644 --- a/layout/generic/nsPlaceholderFrame.cpp +++ b/layout/generic/nsPlaceholderFrame.cpp @@ -25,6 +25,7 @@ #include "nsIView.h" #include "nsHTMLIIDs.h" #include "nsIPresContext.h" +#include "nsCSSLineLayout.h" nsresult nsPlaceholderFrame::NewFrame(nsIFrame** aInstancePtrResult, @@ -53,11 +54,34 @@ nsPlaceholderFrame::~nsPlaceholderFrame() } NS_IMETHODIMP -nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext, - nsReflowMetrics& aDesiredSize, - const nsReflowState& aReflowState, - nsReflowStatus& aStatus) +nsPlaceholderFrame::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) { + NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + if (aIID.Equals(kIInlineReflowIID)) { + nsIInlineReflow* tmp = this; + *aInstancePtrResult = (void*) tmp; + return NS_OK; + } + return nsFrame::QueryInterface(aIID, aInstancePtrResult); +} + +NS_IMETHODIMP +nsPlaceholderFrame::FindTextRuns(nsCSSLineLayout& aLineLayout, + nsIReflowCommand* aReflowCommand) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsPlaceholderFrame::InlineReflow(nsCSSLineLayout& aLineLayout, + nsReflowMetrics& aDesiredSize, + const nsReflowState& aReflowState) +{ + nsIPresContext& presContext = *aLineLayout.mPresContext; + // Get the floater container in which we're inserted nsIFrame* containingBlock; nsIFloaterContainer* container = nsnull; @@ -101,11 +125,11 @@ nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext, nsBodyFrame::NewFrame(&mAnchoredItem, mContent, this); // Use our style context for the pseudo-frame - mAnchoredItem->SetStyleContext(&aPresContext, mStyleContext); + mAnchoredItem->SetStyleContext(&presContext, mStyleContext); } else { // Create the anchored item - nsIContentDelegate* delegate = mContent->GetDelegate(&aPresContext); - nsresult rv = delegate->CreateFrame(&aPresContext, mContent, + nsIContentDelegate* delegate = mContent->GetDelegate(&presContext); + nsresult rv = delegate->CreateFrame(&presContext, mContent, mGeometricParent, mStyleContext, mAnchoredItem); NS_RELEASE(delegate); @@ -115,11 +139,11 @@ nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext, } // Notify our containing block that there's a new floater - container->AddFloater(&aPresContext, aReflowState, mAnchoredItem, this); + container->AddFloater(&presContext, aReflowState, mAnchoredItem, this); } if (nsIFrame::GetShowFrameBorders()) { - float p2t = aPresContext.GetPixelsToTwips(); + float p2t = presContext.GetPixelsToTwips(); aDesiredSize.width = nscoord(p2t * 5); aDesiredSize.height = aDesiredSize.width; } @@ -133,8 +157,7 @@ nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext, aDesiredSize.maxElementSize->width = aDesiredSize.width; aDesiredSize.maxElementSize->height = aDesiredSize.height; } - aStatus = NS_FRAME_COMPLETE; - return NS_OK; + return NS_FRAME_COMPLETE; } NS_IMETHODIMP diff --git a/layout/generic/nsPlaceholderFrame.h b/layout/generic/nsPlaceholderFrame.h index 9e2a4591742a..6c88b1868c3a 100644 --- a/layout/generic/nsPlaceholderFrame.h +++ b/layout/generic/nsPlaceholderFrame.h @@ -19,9 +19,10 @@ #define nsPlaceholderFrame_h___ #include "nsFrame.h" +#include "nsIInlineReflow.h" // Implementation of a frame that's used as a placeholder for an anchored item -class nsPlaceholderFrame : public nsFrame { +class nsPlaceholderFrame : public nsFrame, public nsIInlineReflow { public: /** * Create a new placeholder frame @@ -33,11 +34,15 @@ public: // Returns the associated anchored item nsIFrame* GetAnchoredItem() const {return mAnchoredItem;} + // nsISupports + NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); + // nsIFrame overrides - NS_IMETHOD Reflow(nsIPresContext& aPresContext, - nsReflowMetrics& aDesiredSize, - const nsReflowState& aReflowState, - nsReflowStatus& aStatus); + NS_IMETHOD FindTextRuns(nsCSSLineLayout& aLineLayout, + nsIReflowCommand* aReflowCommand); + NS_IMETHOD InlineReflow(nsCSSLineLayout& aLineLayout, + nsReflowMetrics& aDesiredSize, + const nsReflowState& aReflowState); NS_IMETHOD Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); diff --git a/layout/html/base/src/nsPlaceholderFrame.cpp b/layout/html/base/src/nsPlaceholderFrame.cpp index 3a5ba276ccb5..363c793f91ad 100644 --- a/layout/html/base/src/nsPlaceholderFrame.cpp +++ b/layout/html/base/src/nsPlaceholderFrame.cpp @@ -25,6 +25,7 @@ #include "nsIView.h" #include "nsHTMLIIDs.h" #include "nsIPresContext.h" +#include "nsCSSLineLayout.h" nsresult nsPlaceholderFrame::NewFrame(nsIFrame** aInstancePtrResult, @@ -53,11 +54,34 @@ nsPlaceholderFrame::~nsPlaceholderFrame() } NS_IMETHODIMP -nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext, - nsReflowMetrics& aDesiredSize, - const nsReflowState& aReflowState, - nsReflowStatus& aStatus) +nsPlaceholderFrame::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) { + NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + if (aIID.Equals(kIInlineReflowIID)) { + nsIInlineReflow* tmp = this; + *aInstancePtrResult = (void*) tmp; + return NS_OK; + } + return nsFrame::QueryInterface(aIID, aInstancePtrResult); +} + +NS_IMETHODIMP +nsPlaceholderFrame::FindTextRuns(nsCSSLineLayout& aLineLayout, + nsIReflowCommand* aReflowCommand) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsPlaceholderFrame::InlineReflow(nsCSSLineLayout& aLineLayout, + nsReflowMetrics& aDesiredSize, + const nsReflowState& aReflowState) +{ + nsIPresContext& presContext = *aLineLayout.mPresContext; + // Get the floater container in which we're inserted nsIFrame* containingBlock; nsIFloaterContainer* container = nsnull; @@ -101,11 +125,11 @@ nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext, nsBodyFrame::NewFrame(&mAnchoredItem, mContent, this); // Use our style context for the pseudo-frame - mAnchoredItem->SetStyleContext(&aPresContext, mStyleContext); + mAnchoredItem->SetStyleContext(&presContext, mStyleContext); } else { // Create the anchored item - nsIContentDelegate* delegate = mContent->GetDelegate(&aPresContext); - nsresult rv = delegate->CreateFrame(&aPresContext, mContent, + nsIContentDelegate* delegate = mContent->GetDelegate(&presContext); + nsresult rv = delegate->CreateFrame(&presContext, mContent, mGeometricParent, mStyleContext, mAnchoredItem); NS_RELEASE(delegate); @@ -115,11 +139,11 @@ nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext, } // Notify our containing block that there's a new floater - container->AddFloater(&aPresContext, aReflowState, mAnchoredItem, this); + container->AddFloater(&presContext, aReflowState, mAnchoredItem, this); } if (nsIFrame::GetShowFrameBorders()) { - float p2t = aPresContext.GetPixelsToTwips(); + float p2t = presContext.GetPixelsToTwips(); aDesiredSize.width = nscoord(p2t * 5); aDesiredSize.height = aDesiredSize.width; } @@ -133,8 +157,7 @@ nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext, aDesiredSize.maxElementSize->width = aDesiredSize.width; aDesiredSize.maxElementSize->height = aDesiredSize.height; } - aStatus = NS_FRAME_COMPLETE; - return NS_OK; + return NS_FRAME_COMPLETE; } NS_IMETHODIMP diff --git a/layout/html/base/src/nsPlaceholderFrame.h b/layout/html/base/src/nsPlaceholderFrame.h index 9e2a4591742a..6c88b1868c3a 100644 --- a/layout/html/base/src/nsPlaceholderFrame.h +++ b/layout/html/base/src/nsPlaceholderFrame.h @@ -19,9 +19,10 @@ #define nsPlaceholderFrame_h___ #include "nsFrame.h" +#include "nsIInlineReflow.h" // Implementation of a frame that's used as a placeholder for an anchored item -class nsPlaceholderFrame : public nsFrame { +class nsPlaceholderFrame : public nsFrame, public nsIInlineReflow { public: /** * Create a new placeholder frame @@ -33,11 +34,15 @@ public: // Returns the associated anchored item nsIFrame* GetAnchoredItem() const {return mAnchoredItem;} + // nsISupports + NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); + // nsIFrame overrides - NS_IMETHOD Reflow(nsIPresContext& aPresContext, - nsReflowMetrics& aDesiredSize, - const nsReflowState& aReflowState, - nsReflowStatus& aStatus); + NS_IMETHOD FindTextRuns(nsCSSLineLayout& aLineLayout, + nsIReflowCommand* aReflowCommand); + NS_IMETHOD InlineReflow(nsCSSLineLayout& aLineLayout, + nsReflowMetrics& aDesiredSize, + const nsReflowState& aReflowState); NS_IMETHOD Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect);