Made placeholders implement nsIInlineReflow so that their existance wouldn't screw up whitespace compression
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include "nsIView.h"
|
#include "nsIView.h"
|
||||||
#include "nsHTMLIIDs.h"
|
#include "nsHTMLIIDs.h"
|
||||||
#include "nsIPresContext.h"
|
#include "nsIPresContext.h"
|
||||||
|
#include "nsCSSLineLayout.h"
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsPlaceholderFrame::NewFrame(nsIFrame** aInstancePtrResult,
|
nsPlaceholderFrame::NewFrame(nsIFrame** aInstancePtrResult,
|
||||||
@@ -53,11 +54,34 @@ nsPlaceholderFrame::~nsPlaceholderFrame()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext,
|
nsPlaceholderFrame::QueryInterface(REFNSIID aIID, void** aInstancePtrResult)
|
||||||
nsReflowMetrics& aDesiredSize,
|
|
||||||
const nsReflowState& aReflowState,
|
|
||||||
nsReflowStatus& aStatus)
|
|
||||||
{
|
{
|
||||||
|
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
|
// Get the floater container in which we're inserted
|
||||||
nsIFrame* containingBlock;
|
nsIFrame* containingBlock;
|
||||||
nsIFloaterContainer* container = nsnull;
|
nsIFloaterContainer* container = nsnull;
|
||||||
@@ -101,11 +125,11 @@ nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext,
|
|||||||
nsBodyFrame::NewFrame(&mAnchoredItem, mContent, this);
|
nsBodyFrame::NewFrame(&mAnchoredItem, mContent, this);
|
||||||
|
|
||||||
// Use our style context for the pseudo-frame
|
// Use our style context for the pseudo-frame
|
||||||
mAnchoredItem->SetStyleContext(&aPresContext, mStyleContext);
|
mAnchoredItem->SetStyleContext(&presContext, mStyleContext);
|
||||||
} else {
|
} else {
|
||||||
// Create the anchored item
|
// Create the anchored item
|
||||||
nsIContentDelegate* delegate = mContent->GetDelegate(&aPresContext);
|
nsIContentDelegate* delegate = mContent->GetDelegate(&presContext);
|
||||||
nsresult rv = delegate->CreateFrame(&aPresContext, mContent,
|
nsresult rv = delegate->CreateFrame(&presContext, mContent,
|
||||||
mGeometricParent, mStyleContext,
|
mGeometricParent, mStyleContext,
|
||||||
mAnchoredItem);
|
mAnchoredItem);
|
||||||
NS_RELEASE(delegate);
|
NS_RELEASE(delegate);
|
||||||
@@ -115,11 +139,11 @@ nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Notify our containing block that there's a new floater
|
// 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()) {
|
if (nsIFrame::GetShowFrameBorders()) {
|
||||||
float p2t = aPresContext.GetPixelsToTwips();
|
float p2t = presContext.GetPixelsToTwips();
|
||||||
aDesiredSize.width = nscoord(p2t * 5);
|
aDesiredSize.width = nscoord(p2t * 5);
|
||||||
aDesiredSize.height = aDesiredSize.width;
|
aDesiredSize.height = aDesiredSize.width;
|
||||||
}
|
}
|
||||||
@@ -133,8 +157,7 @@ nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext,
|
|||||||
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
||||||
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
||||||
}
|
}
|
||||||
aStatus = NS_FRAME_COMPLETE;
|
return NS_FRAME_COMPLETE;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|||||||
@@ -19,9 +19,10 @@
|
|||||||
#define nsPlaceholderFrame_h___
|
#define nsPlaceholderFrame_h___
|
||||||
|
|
||||||
#include "nsFrame.h"
|
#include "nsFrame.h"
|
||||||
|
#include "nsIInlineReflow.h"
|
||||||
|
|
||||||
// Implementation of a frame that's used as a placeholder for an anchored item
|
// 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:
|
public:
|
||||||
/**
|
/**
|
||||||
* Create a new placeholder frame
|
* Create a new placeholder frame
|
||||||
@@ -33,11 +34,15 @@ public:
|
|||||||
// Returns the associated anchored item
|
// Returns the associated anchored item
|
||||||
nsIFrame* GetAnchoredItem() const {return mAnchoredItem;}
|
nsIFrame* GetAnchoredItem() const {return mAnchoredItem;}
|
||||||
|
|
||||||
|
// nsISupports
|
||||||
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||||
|
|
||||||
// nsIFrame overrides
|
// nsIFrame overrides
|
||||||
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
|
NS_IMETHOD FindTextRuns(nsCSSLineLayout& aLineLayout,
|
||||||
|
nsIReflowCommand* aReflowCommand);
|
||||||
|
NS_IMETHOD InlineReflow(nsCSSLineLayout& aLineLayout,
|
||||||
nsReflowMetrics& aDesiredSize,
|
nsReflowMetrics& aDesiredSize,
|
||||||
const nsReflowState& aReflowState,
|
const nsReflowState& aReflowState);
|
||||||
nsReflowStatus& aStatus);
|
|
||||||
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
||||||
nsIRenderingContext& aRenderingContext,
|
nsIRenderingContext& aRenderingContext,
|
||||||
const nsRect& aDirtyRect);
|
const nsRect& aDirtyRect);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "nsIView.h"
|
#include "nsIView.h"
|
||||||
#include "nsHTMLIIDs.h"
|
#include "nsHTMLIIDs.h"
|
||||||
#include "nsIPresContext.h"
|
#include "nsIPresContext.h"
|
||||||
|
#include "nsCSSLineLayout.h"
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsPlaceholderFrame::NewFrame(nsIFrame** aInstancePtrResult,
|
nsPlaceholderFrame::NewFrame(nsIFrame** aInstancePtrResult,
|
||||||
@@ -53,11 +54,34 @@ nsPlaceholderFrame::~nsPlaceholderFrame()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext,
|
nsPlaceholderFrame::QueryInterface(REFNSIID aIID, void** aInstancePtrResult)
|
||||||
nsReflowMetrics& aDesiredSize,
|
|
||||||
const nsReflowState& aReflowState,
|
|
||||||
nsReflowStatus& aStatus)
|
|
||||||
{
|
{
|
||||||
|
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
|
// Get the floater container in which we're inserted
|
||||||
nsIFrame* containingBlock;
|
nsIFrame* containingBlock;
|
||||||
nsIFloaterContainer* container = nsnull;
|
nsIFloaterContainer* container = nsnull;
|
||||||
@@ -101,11 +125,11 @@ nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext,
|
|||||||
nsBodyFrame::NewFrame(&mAnchoredItem, mContent, this);
|
nsBodyFrame::NewFrame(&mAnchoredItem, mContent, this);
|
||||||
|
|
||||||
// Use our style context for the pseudo-frame
|
// Use our style context for the pseudo-frame
|
||||||
mAnchoredItem->SetStyleContext(&aPresContext, mStyleContext);
|
mAnchoredItem->SetStyleContext(&presContext, mStyleContext);
|
||||||
} else {
|
} else {
|
||||||
// Create the anchored item
|
// Create the anchored item
|
||||||
nsIContentDelegate* delegate = mContent->GetDelegate(&aPresContext);
|
nsIContentDelegate* delegate = mContent->GetDelegate(&presContext);
|
||||||
nsresult rv = delegate->CreateFrame(&aPresContext, mContent,
|
nsresult rv = delegate->CreateFrame(&presContext, mContent,
|
||||||
mGeometricParent, mStyleContext,
|
mGeometricParent, mStyleContext,
|
||||||
mAnchoredItem);
|
mAnchoredItem);
|
||||||
NS_RELEASE(delegate);
|
NS_RELEASE(delegate);
|
||||||
@@ -115,11 +139,11 @@ nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Notify our containing block that there's a new floater
|
// 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()) {
|
if (nsIFrame::GetShowFrameBorders()) {
|
||||||
float p2t = aPresContext.GetPixelsToTwips();
|
float p2t = presContext.GetPixelsToTwips();
|
||||||
aDesiredSize.width = nscoord(p2t * 5);
|
aDesiredSize.width = nscoord(p2t * 5);
|
||||||
aDesiredSize.height = aDesiredSize.width;
|
aDesiredSize.height = aDesiredSize.width;
|
||||||
}
|
}
|
||||||
@@ -133,8 +157,7 @@ nsPlaceholderFrame::Reflow(nsIPresContext& aPresContext,
|
|||||||
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
||||||
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
||||||
}
|
}
|
||||||
aStatus = NS_FRAME_COMPLETE;
|
return NS_FRAME_COMPLETE;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|||||||
@@ -19,9 +19,10 @@
|
|||||||
#define nsPlaceholderFrame_h___
|
#define nsPlaceholderFrame_h___
|
||||||
|
|
||||||
#include "nsFrame.h"
|
#include "nsFrame.h"
|
||||||
|
#include "nsIInlineReflow.h"
|
||||||
|
|
||||||
// Implementation of a frame that's used as a placeholder for an anchored item
|
// 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:
|
public:
|
||||||
/**
|
/**
|
||||||
* Create a new placeholder frame
|
* Create a new placeholder frame
|
||||||
@@ -33,11 +34,15 @@ public:
|
|||||||
// Returns the associated anchored item
|
// Returns the associated anchored item
|
||||||
nsIFrame* GetAnchoredItem() const {return mAnchoredItem;}
|
nsIFrame* GetAnchoredItem() const {return mAnchoredItem;}
|
||||||
|
|
||||||
|
// nsISupports
|
||||||
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||||
|
|
||||||
// nsIFrame overrides
|
// nsIFrame overrides
|
||||||
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
|
NS_IMETHOD FindTextRuns(nsCSSLineLayout& aLineLayout,
|
||||||
|
nsIReflowCommand* aReflowCommand);
|
||||||
|
NS_IMETHOD InlineReflow(nsCSSLineLayout& aLineLayout,
|
||||||
nsReflowMetrics& aDesiredSize,
|
nsReflowMetrics& aDesiredSize,
|
||||||
const nsReflowState& aReflowState,
|
const nsReflowState& aReflowState);
|
||||||
nsReflowStatus& aStatus);
|
|
||||||
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
||||||
nsIRenderingContext& aRenderingContext,
|
nsIRenderingContext& aRenderingContext,
|
||||||
const nsRect& aDirtyRect);
|
const nsRect& aDirtyRect);
|
||||||
|
|||||||
Reference in New Issue
Block a user