Made placeholders implement nsIInlineReflow so that their existance wouldn't screw up whitespace compression

This commit is contained in:
kipp%netscape.com 1998-07-29 04:05:49 +00:00
parent 06d95d348f
commit 360dc68e35
4 changed files with 88 additions and 32 deletions

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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);