gecko-dev/layout/generic/nsSplittableFrame.cpp

197 строки
4.8 KiB
C++
Исходник Обычный вид История

1998-04-14 00:24:54 +04:00
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsSplittableFrame.h"
#include "nsIContent.h"
#include "nsIPresContext.h"
#include "nsIStyleContext.h"
1998-06-06 01:06:24 +04:00
#include "nsISizeOfHandler.h"
1998-04-14 00:24:54 +04:00
nsSplittableFrame::nsSplittableFrame(nsIContent* aContent,
nsIFrame* aParent)
: nsFrame(aContent, aParent)
1998-04-14 00:24:54 +04:00
{
}
nsSplittableFrame::~nsSplittableFrame()
{
1998-06-06 01:06:24 +04:00
}
NS_IMETHODIMP
nsSplittableFrame::SizeOf(nsISizeOfHandler* aHandler) const
{
aHandler->Add(sizeof(*this));
nsSplittableFrame::SizeOfWithoutThis(aHandler);
return NS_OK;
}
void
nsSplittableFrame::SizeOfWithoutThis(nsISizeOfHandler* aHandler) const
{
nsFrame::SizeOfWithoutThis(aHandler);
if (!aHandler->HaveSeen(mPrevInFlow)) {
mPrevInFlow->SizeOf(aHandler);
}
if (!aHandler->HaveSeen(mNextInFlow)) {
mNextInFlow->SizeOf(aHandler);
}
1998-04-14 00:24:54 +04:00
}
// Flow member functions
1998-06-06 01:06:24 +04:00
NS_IMETHODIMP
nsSplittableFrame::IsSplittable(nsSplittableType& aIsSplittable) const
1998-04-14 00:24:54 +04:00
{
aIsSplittable = NS_FRAME_SPLITTABLE;
return NS_OK;
1998-04-14 00:24:54 +04:00
}
NS_METHOD nsSplittableFrame::GetPrevInFlow(nsIFrame*& aPrevInFlow) const
1998-04-14 00:24:54 +04:00
{
aPrevInFlow = mPrevInFlow;
return NS_OK;
1998-04-14 00:24:54 +04:00
}
NS_METHOD nsSplittableFrame::SetPrevInFlow(nsIFrame* aFrame)
1998-04-14 00:24:54 +04:00
{
mPrevInFlow = aFrame;
return NS_OK;
1998-04-14 00:24:54 +04:00
}
NS_METHOD nsSplittableFrame::GetNextInFlow(nsIFrame*& aNextInFlow) const
1998-04-14 00:24:54 +04:00
{
aNextInFlow = mNextInFlow;
return NS_OK;
1998-04-14 00:24:54 +04:00
}
NS_METHOD nsSplittableFrame::SetNextInFlow(nsIFrame* aFrame)
1998-04-14 00:24:54 +04:00
{
mNextInFlow = aFrame;
return NS_OK;
1998-04-14 00:24:54 +04:00
}
nsIFrame* nsSplittableFrame::GetFirstInFlow() const
{
nsSplittableFrame* firstInFlow;
nsSplittableFrame* prevInFlow = (nsSplittableFrame*)this;
while (nsnull!=prevInFlow) {
firstInFlow = prevInFlow;
prevInFlow = (nsSplittableFrame*)firstInFlow->mPrevInFlow;
}
NS_POSTCONDITION(nsnull!=firstInFlow, "illegal state in flow chain.");
return firstInFlow;
}
nsIFrame* nsSplittableFrame::GetLastInFlow() const
{
nsSplittableFrame* lastInFlow;
nsSplittableFrame* nextInFlow = (nsSplittableFrame*)this;
while (nsnull!=nextInFlow) {
lastInFlow = nextInFlow;
nextInFlow = (nsSplittableFrame*)lastInFlow->mNextInFlow;
}
NS_POSTCONDITION(nsnull!=lastInFlow, "illegal state in flow chain.");
return lastInFlow;
}
// Append this frame to flow after aAfterFrame
NS_METHOD nsSplittableFrame::AppendToFlow(nsIFrame* aAfterFrame)
1998-04-14 00:24:54 +04:00
{
NS_PRECONDITION(aAfterFrame != nsnull, "null pointer");
mPrevInFlow = aAfterFrame;
aAfterFrame->GetNextInFlow(mNextInFlow);
1998-04-14 00:24:54 +04:00
mPrevInFlow->SetNextInFlow(this);
if (mNextInFlow) {
mNextInFlow->SetPrevInFlow(this);
}
return NS_OK;
1998-04-14 00:24:54 +04:00
}
// Prepend this frame to flow before aBeforeFrame
NS_METHOD nsSplittableFrame::PrependToFlow(nsIFrame* aBeforeFrame)
1998-04-14 00:24:54 +04:00
{
NS_PRECONDITION(aBeforeFrame != nsnull, "null pointer");
aBeforeFrame->GetPrevInFlow(mPrevInFlow);
1998-04-14 00:24:54 +04:00
mNextInFlow = aBeforeFrame;
mNextInFlow->SetPrevInFlow(this);
if (mPrevInFlow) {
mPrevInFlow->SetNextInFlow(this);
}
return NS_OK;
1998-04-14 00:24:54 +04:00
}
// Remove this frame from the flow. Connects prev in flow and next in flow
NS_METHOD nsSplittableFrame::RemoveFromFlow()
1998-04-14 00:24:54 +04:00
{
if (mPrevInFlow) {
mPrevInFlow->SetNextInFlow(mNextInFlow);
}
if (mNextInFlow) {
mNextInFlow->SetPrevInFlow(mPrevInFlow);
}
mPrevInFlow = mNextInFlow = nsnull;
return NS_OK;
1998-04-14 00:24:54 +04:00
}
// Detach from previous frame in flow
NS_METHOD nsSplittableFrame::BreakFromPrevFlow()
1998-04-14 00:24:54 +04:00
{
if (mPrevInFlow) {
mPrevInFlow->SetNextInFlow(nsnull);
mPrevInFlow = nsnull;
}
return NS_OK;
1998-04-14 00:24:54 +04:00
}
// Detach from next frame in flow
NS_METHOD nsSplittableFrame::BreakFromNextFlow()
1998-04-14 00:24:54 +04:00
{
if (mNextInFlow) {
mNextInFlow->SetPrevInFlow(nsnull);
mNextInFlow = nsnull;
}
return NS_OK;
1998-04-14 00:24:54 +04:00
}
nsIFrame * nsSplittableFrame::GetPrevInFlow()
{
return mPrevInFlow;
}
nsIFrame * nsSplittableFrame::GetNextInFlow()
{
return mNextInFlow;
}
void
nsSplittableFrame::DumpBaseRegressionData(FILE* out, PRInt32 aIndent)
{
nsFrame::DumpBaseRegressionData(out, aIndent);
if (nsnull != mNextInFlow) {
IndentBy(out, aIndent);
fprintf(out, "<next-in-flow addr=\"%p\"/>\n", mNextInFlow);
}
if (nsnull != mPrevInFlow) {
IndentBy(out, aIndent);
fprintf(out, "<prev-in-flow addr=\"%p\"/>\n", mPrevInFlow);
}
}