1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-14 00:24:54 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
|
|
|
#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
|
|
|
|
1999-02-25 06:27:57 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsSplittableFrame::Init(nsIPresContext* aPresContext,
|
1999-02-25 06:27:57 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = nsFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
|
|
|
|
|
|
|
if (aPrevInFlow) {
|
|
|
|
// Hook the frame into the flow
|
1999-10-22 18:53:52 +04:00
|
|
|
mPrevInFlow = aPrevInFlow;
|
|
|
|
aPrevInFlow->SetNextInFlow(this);
|
1999-02-25 06:27:57 +03:00
|
|
|
|
|
|
|
// Make sure the general flags bits are the same
|
|
|
|
nsFrameState state;
|
|
|
|
aPrevInFlow->GetFrameState(&state);
|
1999-02-25 08:41:05 +03:00
|
|
|
if ((state & NS_FRAME_SYNC_FRAME_AND_VIEW) == 0) {
|
|
|
|
mState &= ~NS_FRAME_SYNC_FRAME_AND_VIEW;
|
1999-02-25 06:27:57 +03:00
|
|
|
}
|
|
|
|
if (state & NS_FRAME_REPLACED_ELEMENT) {
|
|
|
|
mState |= NS_FRAME_REPLACED_ELEMENT;
|
|
|
|
}
|
1999-04-26 08:02:04 +04:00
|
|
|
if (state & NS_FRAME_SELECTED_CONTENT) {
|
|
|
|
mState |= NS_FRAME_SELECTED_CONTENT;
|
|
|
|
}
|
1999-02-25 06:27:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-06-06 01:06:24 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSplittableFrame::IsSplittable(nsSplittableType& aIsSplittable) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-05-22 08:54:11 +04:00
|
|
|
aIsSplittable = NS_FRAME_SPLITTABLE;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-24 07:48:08 +03:00
|
|
|
NS_METHOD nsSplittableFrame::GetPrevInFlow(nsIFrame** aPrevInFlow) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-24 07:48:08 +03:00
|
|
|
*aPrevInFlow = mPrevInFlow;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsSplittableFrame::SetPrevInFlow(nsIFrame* aFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
mPrevInFlow = aFrame;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-24 07:48:08 +03:00
|
|
|
NS_METHOD nsSplittableFrame::GetNextInFlow(nsIFrame** aNextInFlow) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-24 07:48:08 +03:00
|
|
|
*aNextInFlow = mNextInFlow;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsSplittableFrame::SetNextInFlow(nsIFrame* aFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
mNextInFlow = aFrame;
|
1998-04-17 05:41:24 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-10-22 18:53:52 +04:00
|
|
|
// Remove this frame from the flow. Connects prev in flow and next in flow
|
|
|
|
void
|
|
|
|
nsSplittableFrame::RemoveFromFlow(nsIFrame* aFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-10-22 18:53:52 +04:00
|
|
|
nsIFrame* prevInFlow;
|
|
|
|
nsIFrame* nextInFlow;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-10-22 18:53:52 +04:00
|
|
|
aFrame->GetPrevInFlow(&prevInFlow);
|
|
|
|
aFrame->GetNextInFlow(&nextInFlow);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-10-22 18:53:52 +04:00
|
|
|
if (prevInFlow) {
|
|
|
|
prevInFlow->SetNextInFlow(nextInFlow);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-10-22 18:53:52 +04:00
|
|
|
if (nextInFlow) {
|
|
|
|
nextInFlow->SetPrevInFlow(prevInFlow);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-10-22 18:53:52 +04:00
|
|
|
aFrame->SetPrevInFlow(nsnull);
|
|
|
|
aFrame->SetNextInFlow(nsnull);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Detach from previous frame in flow
|
1999-10-22 18:53:52 +04:00
|
|
|
void
|
|
|
|
nsSplittableFrame::BreakFromPrevFlow(nsIFrame* aFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-10-22 18:53:52 +04:00
|
|
|
nsIFrame* prevInFlow;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-10-22 18:53:52 +04:00
|
|
|
aFrame->GetPrevInFlow(&prevInFlow);
|
|
|
|
if (prevInFlow) {
|
|
|
|
prevInFlow->SetNextInFlow(nsnull);
|
|
|
|
aFrame->SetPrevInFlow(nsnull);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-05-08 19:07:41 +04:00
|
|
|
nsIFrame * nsSplittableFrame::GetPrevInFlow()
|
|
|
|
{
|
|
|
|
return mPrevInFlow;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame * nsSplittableFrame::GetNextInFlow()
|
|
|
|
{
|
|
|
|
return mNextInFlow;
|
|
|
|
}
|
1998-11-19 21:51:53 +03:00
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 21:51:53 +03:00
|
|
|
void
|
2000-12-07 18:31:40 +03:00
|
|
|
nsSplittableFrame::DumpBaseRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent, PRBool aIncludeStyleData)
|
1998-11-19 21:51:53 +03:00
|
|
|
{
|
2000-12-07 18:31:40 +03:00
|
|
|
nsFrame::DumpBaseRegressionData(aPresContext, out, aIndent, aIncludeStyleData);
|
1998-11-19 21:51:53 +03:00
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
IndentBy(out, aIndent);
|
1999-02-12 20:45:58 +03:00
|
|
|
fprintf(out, "<next-in-flow va=\"%ld\"/>\n", PRUptrdiff(mNextInFlow));
|
1998-11-19 21:51:53 +03:00
|
|
|
}
|
|
|
|
if (nsnull != mPrevInFlow) {
|
|
|
|
IndentBy(out, aIndent);
|
1999-02-12 20:45:58 +03:00
|
|
|
fprintf(out, "<prev-in-flow va=\"%ld\"/>\n", PRUptrdiff(mPrevInFlow));
|
1998-11-19 21:51:53 +03:00
|
|
|
}
|
1999-08-31 07:09:40 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSplittableFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
|
|
|
|
{
|
1999-09-01 05:02:16 +04:00
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
*aResult = sizeof(*this);
|
|
|
|
return NS_OK;
|
1998-11-19 21:51:53 +03:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|