зеркало из https://github.com/mozilla/pjs.git
Made absolute frame a container too to work around the pseudo-frame problem
This commit is contained in:
Родитель
aa8a5b019f
Коммит
da75c0ffea
|
@ -49,15 +49,21 @@ nsAbsoluteFrame::NewFrame(nsIFrame** aInstancePtrResult,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAbsoluteFrame::nsAbsoluteFrame(nsIContent* aContent, nsIFrame* aParent)
|
nsAbsoluteFrame::nsAbsoluteFrame(nsIContent* aContent, nsIFrame* aParent)
|
||||||
: nsFrame(aContent, aParent)
|
: nsContainerFrame(aContent, aParent)
|
||||||
{
|
{
|
||||||
mFrame = nsnull;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAbsoluteFrame::~nsAbsoluteFrame()
|
nsAbsoluteFrame::~nsAbsoluteFrame()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsAbsoluteFrame::IsSplittable(nsSplittableType& aIsSplittable) const
|
||||||
|
{
|
||||||
|
aIsSplittable = NS_FRAME_NOT_SPLITTABLE;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsIView* nsAbsoluteFrame::CreateView(nsIView* aContainingView,
|
nsIView* nsAbsoluteFrame::CreateView(nsIView* aContainingView,
|
||||||
const nsRect& aRect,
|
const nsRect& aRect,
|
||||||
nsStylePosition* aPosition,
|
nsStylePosition* aPosition,
|
||||||
|
@ -275,13 +281,13 @@ NS_METHOD nsAbsoluteFrame::Reflow(nsIPresContext* aPresContext,
|
||||||
nsReflowStatus& aStatus)
|
nsReflowStatus& aStatus)
|
||||||
{
|
{
|
||||||
// Have we created the absolutely positioned item yet?
|
// Have we created the absolutely positioned item yet?
|
||||||
if (nsnull == mFrame) {
|
if (nsnull == mFirstChild) {
|
||||||
// If the content object is a container then wrap it in a body pseudo-frame
|
// If the content object is a container then wrap it in a body pseudo-frame
|
||||||
if (mContent->CanContainChildren()) {
|
if (mContent->CanContainChildren()) {
|
||||||
nsBodyFrame::NewFrame(&mFrame, mContent, this);
|
nsBodyFrame::NewFrame(&mFirstChild, mContent, this);
|
||||||
|
|
||||||
// Use our style context for the pseudo-frame
|
// Use our style context for the pseudo-frame
|
||||||
mFrame->SetStyleContext(aPresContext, mStyleContext);
|
mFirstChild->SetStyleContext(aPresContext, mStyleContext);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Create the absolutely positioned item as a pseudo-frame child. We'll
|
// Create the absolutely positioned item as a pseudo-frame child. We'll
|
||||||
|
@ -289,7 +295,7 @@ NS_METHOD nsAbsoluteFrame::Reflow(nsIPresContext* aPresContext,
|
||||||
nsIContentDelegate* delegate = mContent->GetDelegate(aPresContext);
|
nsIContentDelegate* delegate = mContent->GetDelegate(aPresContext);
|
||||||
|
|
||||||
nsresult rv = delegate->CreateFrame(aPresContext, mContent, this,
|
nsresult rv = delegate->CreateFrame(aPresContext, mContent, this,
|
||||||
mStyleContext, mFrame);
|
mStyleContext, mFirstChild);
|
||||||
NS_RELEASE(delegate);
|
NS_RELEASE(delegate);
|
||||||
if (NS_OK != rv) {
|
if (NS_OK != rv) {
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -312,7 +318,7 @@ NS_METHOD nsAbsoluteFrame::Reflow(nsIPresContext* aPresContext,
|
||||||
nsIView* view = CreateView(containingView, rect, position, display);
|
nsIView* view = CreateView(containingView, rect, position, display);
|
||||||
NS_RELEASE(containingView);
|
NS_RELEASE(containingView);
|
||||||
|
|
||||||
mFrame->SetView(view);
|
mFirstChild->SetView(view);
|
||||||
NS_RELEASE(view);
|
NS_RELEASE(view);
|
||||||
|
|
||||||
// Resize reflow the absolutely positioned element
|
// Resize reflow the absolutely positioned element
|
||||||
|
@ -325,9 +331,9 @@ NS_METHOD nsAbsoluteFrame::Reflow(nsIPresContext* aPresContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsReflowMetrics desiredSize(nsnull);
|
nsReflowMetrics desiredSize(nsnull);
|
||||||
nsReflowState reflowState(mFrame, aReflowState, availSize, eReflowReason_Initial);
|
nsReflowState reflowState(mFirstChild, aReflowState, availSize, eReflowReason_Initial);
|
||||||
mFrame->WillReflow(*aPresContext);
|
mFirstChild->WillReflow(*aPresContext);
|
||||||
mFrame->Reflow(aPresContext, desiredSize, reflowState, aStatus);
|
mFirstChild->Reflow(aPresContext, desiredSize, reflowState, aStatus);
|
||||||
|
|
||||||
// Figure out what size to actually use. If the position style is 'auto' or
|
// Figure out what size to actually use. If the position style is 'auto' or
|
||||||
// the container should be enlarged to contain overflowing frames then use
|
// the container should be enlarged to contain overflowing frames then use
|
||||||
|
@ -340,63 +346,14 @@ NS_METHOD nsAbsoluteFrame::Reflow(nsIPresContext* aPresContext,
|
||||||
if (eStyleUnit_Auto == position->mHeight.GetUnit()) {
|
if (eStyleUnit_Auto == position->mHeight.GetUnit()) {
|
||||||
rect.height = desiredSize.height;
|
rect.height = desiredSize.height;
|
||||||
}
|
}
|
||||||
mFrame->SizeTo(rect.width, rect.height);
|
mFirstChild->SetRect(rect);
|
||||||
mFrame->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
|
mFirstChild->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return our desired size as (0, 0)
|
// Return our desired size as (0, 0)
|
||||||
return nsFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
return nsFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_METHOD
|
|
||||||
nsAbsoluteFrame::ChildCount(PRInt32& aChildCount) const
|
|
||||||
{
|
|
||||||
aChildCount = 1;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_METHOD
|
|
||||||
nsAbsoluteFrame::ChildAt(PRInt32 aIndex, nsIFrame*& aFrame) const
|
|
||||||
{
|
|
||||||
aFrame = (0 == aIndex) ? mFrame : nsnull;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_METHOD
|
|
||||||
nsAbsoluteFrame::IndexOf(const nsIFrame* aChild, PRInt32& aIndex) const
|
|
||||||
{
|
|
||||||
aIndex = (aChild == mFrame) ? 0 : -1;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_METHOD
|
|
||||||
nsAbsoluteFrame::FirstChild(nsIFrame*& aFirstChild) const
|
|
||||||
{
|
|
||||||
aFirstChild = mFrame;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_METHOD
|
|
||||||
nsAbsoluteFrame::NextChild(const nsIFrame* aChild, nsIFrame*& aNextChild) const
|
|
||||||
{
|
|
||||||
aNextChild = nsnull;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_METHOD
|
|
||||||
nsAbsoluteFrame::PrevChild(const nsIFrame* aChild, nsIFrame*& aPrevChild) const
|
|
||||||
{
|
|
||||||
aPrevChild = nsnull;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_METHOD
|
|
||||||
nsAbsoluteFrame::LastChild(nsIFrame*& aLastChild) const
|
|
||||||
{
|
|
||||||
aLastChild = mFrame;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_METHOD nsAbsoluteFrame::ListTag(FILE* out) const
|
NS_METHOD nsAbsoluteFrame::ListTag(FILE* out) const
|
||||||
{
|
{
|
||||||
fputs("*absolute", out);
|
fputs("*absolute", out);
|
||||||
|
@ -405,31 +362,3 @@ NS_METHOD nsAbsoluteFrame::ListTag(FILE* out) const
|
||||||
fprintf(out, "(%d)@%p", contentIndex, this);
|
fprintf(out, "(%d)@%p", contentIndex, this);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_METHOD nsAbsoluteFrame::List(FILE* out, PRInt32 aIndent) const
|
|
||||||
{
|
|
||||||
// Indent
|
|
||||||
for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
||||||
|
|
||||||
// Output the tag
|
|
||||||
ListTag(out);
|
|
||||||
nsIView* view;
|
|
||||||
GetView(view);
|
|
||||||
if (nsnull != view) {
|
|
||||||
fprintf(out, " [view=%p]", view);
|
|
||||||
NS_RELEASE(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Output the rect
|
|
||||||
out << mRect;
|
|
||||||
|
|
||||||
// List the absolutely positioned frame
|
|
||||||
if (0 != mState) {
|
|
||||||
fprintf(out, " [state=%08x]", mState);
|
|
||||||
}
|
|
||||||
fputs("<\n", out);
|
|
||||||
mFrame->List(out, aIndent + 1);
|
|
||||||
fputs(">\n", out);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
|
@ -18,14 +18,13 @@
|
||||||
#ifndef nsAbsoluteFrame_h___
|
#ifndef nsAbsoluteFrame_h___
|
||||||
#define nsAbsoluteFrame_h___
|
#define nsAbsoluteFrame_h___
|
||||||
|
|
||||||
#include "nsFrame.h"
|
#include "nsContainerFrame.h"
|
||||||
struct nsStylePosition;
|
struct nsStylePosition;
|
||||||
struct nsStyleDisplay;
|
struct nsStyleDisplay;
|
||||||
|
|
||||||
// Implementation of a frame that's used as a placeholder for an absolutely
|
// Implementation of a frame that's used as a placeholder for an absolutely
|
||||||
// positioned frame
|
// positioned frame
|
||||||
class nsAbsoluteFrame : public nsFrame
|
class nsAbsoluteFrame : public nsContainerFrame {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Create a new absolutely positioned frame
|
* Create a new absolutely positioned frame
|
||||||
|
@ -35,23 +34,14 @@ public:
|
||||||
nsIFrame* aParent);
|
nsIFrame* aParent);
|
||||||
|
|
||||||
// nsIFrame overrides
|
// nsIFrame overrides
|
||||||
NS_IMETHOD ChildCount(PRInt32& aChildCount) const;
|
NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const;
|
||||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIFrame*& aFrame) const;
|
|
||||||
NS_IMETHOD IndexOf(const nsIFrame* aChild, PRInt32& aIndex) const;
|
|
||||||
NS_IMETHOD FirstChild(nsIFrame*& aFirstChild) const;
|
|
||||||
NS_IMETHOD NextChild(const nsIFrame* aChild, nsIFrame*& aNextChild) const;
|
|
||||||
NS_IMETHOD PrevChild(const nsIFrame* aChild, nsIFrame*& aPrevChild) const;
|
|
||||||
NS_IMETHOD LastChild(nsIFrame*& aLastChild) const;
|
|
||||||
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
||||||
nsReflowMetrics& aDesiredSize,
|
nsReflowMetrics& aDesiredSize,
|
||||||
const nsReflowState& aReflowState,
|
const nsReflowState& aReflowState,
|
||||||
nsReflowStatus& aStatus);
|
nsReflowStatus& aStatus);
|
||||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
|
||||||
NS_IMETHOD ListTag(FILE* out = stdout) const;
|
NS_IMETHOD ListTag(FILE* out = stdout) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsIFrame* mFrame; // the actual absolutely positioned frame
|
|
||||||
|
|
||||||
// Constructor. Takes as arguments the content object, the index in parent,
|
// Constructor. Takes as arguments the content object, the index in parent,
|
||||||
// and the Frame for the content parent
|
// and the Frame for the content parent
|
||||||
nsAbsoluteFrame(nsIContent* aContent, nsIFrame* aParent);
|
nsAbsoluteFrame(nsIContent* aContent, nsIFrame* aParent);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче