Moved some files around
This commit is contained in:
@@ -21,20 +21,16 @@ LIBRARY_NAME=raptorlayout_s
|
|||||||
DEFINES=-D_IMPL_NS_LAYOUT -DWIN32_LEAN_AND_MEAN
|
DEFINES=-D_IMPL_NS_LAYOUT -DWIN32_LEAN_AND_MEAN
|
||||||
|
|
||||||
CPPSRCS = \
|
CPPSRCS = \
|
||||||
nsContainerFrame.cpp \
|
|
||||||
nsContentList.cpp \
|
nsContentList.cpp \
|
||||||
nsDocument.cpp \
|
nsDocument.cpp \
|
||||||
nsFrame.cpp \
|
|
||||||
nsFrameImageLoader.cpp \
|
nsFrameImageLoader.cpp \
|
||||||
nsGalleyContext.cpp \
|
nsGalleyContext.cpp \
|
||||||
nsPresContext.cpp \
|
nsPresContext.cpp \
|
||||||
nsPresShell.cpp \
|
|
||||||
nsPrintPreviewContext.cpp \
|
nsPrintPreviewContext.cpp \
|
||||||
nsSelection.cpp \
|
nsSelection.cpp \
|
||||||
nsSelectionPoint.cpp \
|
nsSelectionPoint.cpp \
|
||||||
nsSelectionRange.cpp \
|
nsSelectionRange.cpp \
|
||||||
nsSpaceManager.cpp \
|
nsSpaceManager.cpp \
|
||||||
nsSplittableFrame.cpp \
|
|
||||||
nsStyleContext.cpp \
|
nsStyleContext.cpp \
|
||||||
nsStyleCoord.cpp \
|
nsStyleCoord.cpp \
|
||||||
nsStyleSet.cpp \
|
nsStyleSet.cpp \
|
||||||
@@ -46,20 +42,16 @@ REQUIRES=xpcom raptor dom
|
|||||||
EXPORTS=nsSelectionRange.h nsSelectionPoint.h
|
EXPORTS=nsSelectionRange.h nsSelectionPoint.h
|
||||||
|
|
||||||
CPP_OBJS= \
|
CPP_OBJS= \
|
||||||
.\$(OBJDIR)\nsContainerFrame.obj \
|
|
||||||
.\$(OBJDIR)\nsContentList.obj \
|
.\$(OBJDIR)\nsContentList.obj \
|
||||||
.\$(OBJDIR)\nsDocument.obj \
|
.\$(OBJDIR)\nsDocument.obj \
|
||||||
.\$(OBJDIR)\nsFrame.obj \
|
|
||||||
.\$(OBJDIR)\nsFrameImageLoader.obj \
|
.\$(OBJDIR)\nsFrameImageLoader.obj \
|
||||||
.\$(OBJDIR)\nsGalleyContext.obj \
|
.\$(OBJDIR)\nsGalleyContext.obj \
|
||||||
.\$(OBJDIR)\nsPresContext.obj \
|
.\$(OBJDIR)\nsPresContext.obj \
|
||||||
.\$(OBJDIR)\nsPresShell.obj \
|
|
||||||
.\$(OBJDIR)\nsPrintPreviewContext.obj \
|
.\$(OBJDIR)\nsPrintPreviewContext.obj \
|
||||||
.\$(OBJDIR)\nsSelection.obj \
|
.\$(OBJDIR)\nsSelection.obj \
|
||||||
.\$(OBJDIR)\nsSelectionPoint.obj \
|
.\$(OBJDIR)\nsSelectionPoint.obj \
|
||||||
.\$(OBJDIR)\nsSelectionRange.obj \
|
.\$(OBJDIR)\nsSelectionRange.obj \
|
||||||
.\$(OBJDIR)\nsSpaceManager.obj \
|
.\$(OBJDIR)\nsSpaceManager.obj \
|
||||||
.\$(OBJDIR)\nsSplittableFrame.obj \
|
|
||||||
.\$(OBJDIR)\nsStyleContext.obj \
|
.\$(OBJDIR)\nsStyleContext.obj \
|
||||||
.\$(OBJDIR)\nsStyleCoord.obj \
|
.\$(OBJDIR)\nsStyleCoord.obj \
|
||||||
.\$(OBJDIR)\nsStyleSet.obj \
|
.\$(OBJDIR)\nsStyleSet.obj \
|
||||||
|
|||||||
@@ -1,700 +0,0 @@
|
|||||||
/* -*- 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 "nsContainerFrame.h"
|
|
||||||
#include "nsIContent.h"
|
|
||||||
#include "nsIPresContext.h"
|
|
||||||
#include "nsIRenderingContext.h"
|
|
||||||
#include "nsIRunaround.h"
|
|
||||||
#include "nsISpaceManager.h"
|
|
||||||
#include "nsIStyleContext.h"
|
|
||||||
#include "nsRect.h"
|
|
||||||
#include "nsPoint.h"
|
|
||||||
#include "nsGUIEvent.h"
|
|
||||||
#include "nsStyleConsts.h"
|
|
||||||
#include "nsIView.h"
|
|
||||||
#include "nsVoidArray.h"
|
|
||||||
#include "nsISizeOfHandler.h"
|
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
|
||||||
#undef NOISY
|
|
||||||
#else
|
|
||||||
#undef NOISY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
nsContainerFrame::nsContainerFrame(nsIContent* aContent, nsIFrame* aParent)
|
|
||||||
: nsSplittableFrame(aContent, aParent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
nsContainerFrame::~nsContainerFrame()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsContainerFrame::SizeOf(nsISizeOfHandler* aHandler) const
|
|
||||||
{
|
|
||||||
aHandler->Add(sizeof(*this));
|
|
||||||
nsContainerFrame::SizeOfWithoutThis(aHandler);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsContainerFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList)
|
|
||||||
{
|
|
||||||
NS_PRECONDITION(nsnull == mFirstChild, "already initialized");
|
|
||||||
|
|
||||||
mFirstChild = aChildList;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsContainerFrame::DeleteFrame(nsIPresContext& aPresContext)
|
|
||||||
{
|
|
||||||
// Delete our child frames before doing anything else. In particular
|
|
||||||
// we do all of this before our base class releases it's hold on the
|
|
||||||
// view.
|
|
||||||
for (nsIFrame* child = mFirstChild; child; ) {
|
|
||||||
mFirstChild = nsnull; // XXX hack until HandleEvent is not called until after destruction
|
|
||||||
nsIFrame* nextChild;
|
|
||||||
|
|
||||||
child->GetNextSibling(nextChild);
|
|
||||||
child->DeleteFrame(aPresContext);
|
|
||||||
child = nextChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsFrame::DeleteFrame(aPresContext);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nsContainerFrame::SizeOfWithoutThis(nsISizeOfHandler* aHandler) const
|
|
||||||
{
|
|
||||||
nsSplittableFrame::SizeOfWithoutThis(aHandler);
|
|
||||||
for (nsIFrame* child = mFirstChild; child; ) {
|
|
||||||
child->SizeOf(aHandler);
|
|
||||||
child->GetNextSibling(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nsContainerFrame::PrepareContinuingFrame(nsIPresContext& aPresContext,
|
|
||||||
nsIFrame* aParent,
|
|
||||||
nsIStyleContext* aStyleContext,
|
|
||||||
nsContainerFrame* aContFrame)
|
|
||||||
{
|
|
||||||
// Append the continuing frame to the flow
|
|
||||||
aContFrame->AppendToFlow(this);
|
|
||||||
aContFrame->SetStyleContext(&aPresContext, aStyleContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_METHOD
|
|
||||||
nsContainerFrame::DidReflow(nsIPresContext& aPresContext,
|
|
||||||
nsDidReflowStatus aStatus)
|
|
||||||
{
|
|
||||||
NS_FRAME_TRACE_MSG(NS_FRAME_TRACE_CALLS,
|
|
||||||
("enter nsContainerFrame::DidReflow: status=%d",
|
|
||||||
aStatus));
|
|
||||||
if (NS_FRAME_REFLOW_FINISHED == aStatus) {
|
|
||||||
nsIFrame* kid;
|
|
||||||
FirstChild(kid);
|
|
||||||
while (nsnull != kid) {
|
|
||||||
kid->DidReflow(aPresContext, aStatus);
|
|
||||||
kid->GetNextSibling(kid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_FRAME_TRACE_OUT("nsContainerFrame::DidReflow");
|
|
||||||
|
|
||||||
// Let nsFrame position and size our view (if we have one), and clear
|
|
||||||
// the NS_FRAME_IN_REFLOW bit
|
|
||||||
return nsFrame::DidReflow(aPresContext, aStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Child frame enumeration
|
|
||||||
|
|
||||||
NS_METHOD nsContainerFrame::FirstChild(nsIFrame*& aFirstChild) const
|
|
||||||
{
|
|
||||||
aFirstChild = mFirstChild;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Painting
|
|
||||||
|
|
||||||
NS_METHOD nsContainerFrame::Paint(nsIPresContext& aPresContext,
|
|
||||||
nsIRenderingContext& aRenderingContext,
|
|
||||||
const nsRect& aDirtyRect)
|
|
||||||
{
|
|
||||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// aDirtyRect is in our coordinate system
|
|
||||||
// child rect's are also in our coordinate system
|
|
||||||
void nsContainerFrame::PaintChildren(nsIPresContext& aPresContext,
|
|
||||||
nsIRenderingContext& aRenderingContext,
|
|
||||||
const nsRect& aDirtyRect)
|
|
||||||
{
|
|
||||||
// Set clip rect so that children don't leak out of us
|
|
||||||
const nsStyleDisplay* disp =
|
|
||||||
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
|
|
||||||
PRBool hidden = PR_FALSE;
|
|
||||||
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
|
|
||||||
aRenderingContext.PushState();
|
|
||||||
aRenderingContext.SetClipRect(nsRect(0, 0, mRect.width, mRect.height),
|
|
||||||
nsClipCombine_kIntersect);
|
|
||||||
hidden = PR_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX reminder: use the coordinates in the dirty rect to figure out
|
|
||||||
// which set of children are impacted and only do the intersection
|
|
||||||
// work for them. In addition, stop when we no longer overlap.
|
|
||||||
|
|
||||||
nsIFrame* kid = mFirstChild;
|
|
||||||
while (nsnull != kid) {
|
|
||||||
nsIView *pView;
|
|
||||||
|
|
||||||
kid->GetView(pView);
|
|
||||||
if (nsnull == pView) {
|
|
||||||
nsRect kidRect;
|
|
||||||
kid->GetRect(kidRect);
|
|
||||||
nsRect damageArea;
|
|
||||||
#ifdef NS_DEBUG
|
|
||||||
PRBool overlap = PR_FALSE;
|
|
||||||
if (nsIFrame::GetShowFrameBorders() &&
|
|
||||||
((kidRect.width == 0) || (kidRect.height == 0))) {
|
|
||||||
nscoord xmost = aDirtyRect.XMost();
|
|
||||||
nscoord ymost = aDirtyRect.YMost();
|
|
||||||
if ((aDirtyRect.x <= kidRect.x) && (kidRect.x < xmost) &&
|
|
||||||
(aDirtyRect.y <= kidRect.y) && (kidRect.y < ymost)) {
|
|
||||||
overlap = PR_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
overlap = damageArea.IntersectRect(aDirtyRect, kidRect);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
PRBool overlap = damageArea.IntersectRect(aDirtyRect, kidRect);
|
|
||||||
#endif
|
|
||||||
if (overlap) {
|
|
||||||
// Translate damage area into kid's coordinate system
|
|
||||||
nsRect kidDamageArea(damageArea.x - kidRect.x,
|
|
||||||
damageArea.y - kidRect.y,
|
|
||||||
damageArea.width, damageArea.height);
|
|
||||||
aRenderingContext.PushState();
|
|
||||||
aRenderingContext.Translate(kidRect.x, kidRect.y);
|
|
||||||
kid->Paint(aPresContext, aRenderingContext, kidDamageArea);
|
|
||||||
#ifdef NS_DEBUG
|
|
||||||
if (nsIFrame::GetShowFrameBorders() &&
|
|
||||||
(0 != kidRect.width) && (0 != kidRect.height)) {
|
|
||||||
nsIView* view;
|
|
||||||
GetView(view);
|
|
||||||
if (nsnull != view) {
|
|
||||||
aRenderingContext.SetColor(NS_RGB(0,0,255));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
aRenderingContext.SetColor(NS_RGB(255,0,0));
|
|
||||||
}
|
|
||||||
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
aRenderingContext.PopState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
kid->GetNextSibling(kid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hidden) {
|
|
||||||
aRenderingContext.PopState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Events
|
|
||||||
|
|
||||||
NS_METHOD nsContainerFrame::HandleEvent(nsIPresContext& aPresContext,
|
|
||||||
nsGUIEvent* aEvent,
|
|
||||||
nsEventStatus& aEventStatus)
|
|
||||||
{
|
|
||||||
aEventStatus = nsEventStatus_eIgnore;
|
|
||||||
|
|
||||||
nsIFrame* kid;
|
|
||||||
FirstChild(kid);
|
|
||||||
while (nsnull != kid) {
|
|
||||||
nsRect kidRect;
|
|
||||||
kid->GetRect(kidRect);
|
|
||||||
if (kidRect.Contains(aEvent->point)) {
|
|
||||||
aEvent->point.MoveBy(-kidRect.x, -kidRect.y);
|
|
||||||
kid->HandleEvent(aPresContext, aEvent, aEventStatus);
|
|
||||||
aEvent->point.MoveBy(kidRect.x, kidRect.y);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
kid->GetNextSibling(kid);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_METHOD nsContainerFrame::GetCursorAndContentAt(nsIPresContext& aPresContext,
|
|
||||||
const nsPoint& aPoint,
|
|
||||||
nsIFrame** aFrame,
|
|
||||||
nsIContent** aContent,
|
|
||||||
PRInt32& aCursor)
|
|
||||||
{
|
|
||||||
aCursor = NS_STYLE_CURSOR_INHERIT;
|
|
||||||
*aContent = mContent;
|
|
||||||
|
|
||||||
nsIFrame* kid;
|
|
||||||
FirstChild(kid);
|
|
||||||
nsPoint tmp;
|
|
||||||
while (nsnull != kid) {
|
|
||||||
nsRect kidRect;
|
|
||||||
kid->GetRect(kidRect);
|
|
||||||
if (kidRect.Contains(aPoint)) {
|
|
||||||
tmp.MoveTo(aPoint.x - kidRect.x, aPoint.y - kidRect.y);
|
|
||||||
kid->GetCursorAndContentAt(aPresContext, tmp, aFrame, aContent, aCursor);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
kid->GetNextSibling(kid);
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Helper member functions
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reflow a child frame and return the status of the reflow. If the
|
|
||||||
* child is complete and it has next-in-flows (it was a splittable child)
|
|
||||||
* then delete the next-in-flows.
|
|
||||||
*/
|
|
||||||
nsReflowStatus nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
|
|
||||||
nsIPresContext* aPresContext,
|
|
||||||
nsReflowMetrics& aDesiredSize,
|
|
||||||
const nsReflowState& aReflowState)
|
|
||||||
{
|
|
||||||
nsReflowStatus status;
|
|
||||||
|
|
||||||
NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state");
|
|
||||||
#ifdef NS_DEBUG
|
|
||||||
nsFrameState kidFrameState;
|
|
||||||
|
|
||||||
aKidFrame->GetFrameState(kidFrameState);
|
|
||||||
NS_ASSERTION(kidFrameState & NS_FRAME_IN_REFLOW, "kid frame is not in reflow");
|
|
||||||
#endif
|
|
||||||
aKidFrame->Reflow(*aPresContext, aDesiredSize, aReflowState, status);
|
|
||||||
|
|
||||||
if (NS_FRAME_IS_COMPLETE(status)) {
|
|
||||||
nsIFrame* kidNextInFlow;
|
|
||||||
|
|
||||||
aKidFrame->GetNextInFlow(kidNextInFlow);
|
|
||||||
if (nsnull != kidNextInFlow) {
|
|
||||||
// Remove all of the childs next-in-flows. Make sure that we ask
|
|
||||||
// the right parent to do the removal (it's possible that the
|
|
||||||
// parent is not this because we are executing pullup code)
|
|
||||||
nsIFrame* parent;
|
|
||||||
aKidFrame->GetGeometricParent(parent);
|
|
||||||
((nsContainerFrame*)parent)->DeleteChildsNextInFlow(*aPresContext, aKidFrame);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove and delete aChild's next-in-flow(s). Updates the sibling and flow
|
|
||||||
* pointers
|
|
||||||
*
|
|
||||||
* Updates the child count and content offsets of all containers that are
|
|
||||||
* affected
|
|
||||||
*
|
|
||||||
* @param aChild child this child's next-in-flow
|
|
||||||
* @return PR_TRUE if successful and PR_FALSE otherwise
|
|
||||||
*/
|
|
||||||
PRBool
|
|
||||||
nsContainerFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild)
|
|
||||||
{
|
|
||||||
NS_PRECONDITION(IsChild(aChild), "bad geometric parent");
|
|
||||||
|
|
||||||
nsIFrame* nextInFlow;
|
|
||||||
nsContainerFrame* parent;
|
|
||||||
|
|
||||||
aChild->GetNextInFlow(nextInFlow);
|
|
||||||
NS_PRECONDITION(nsnull != nextInFlow, "null next-in-flow");
|
|
||||||
nextInFlow->GetGeometricParent((nsIFrame*&)parent);
|
|
||||||
|
|
||||||
// If the next-in-flow has a next-in-flow then delete it, too (and
|
|
||||||
// delete it first).
|
|
||||||
nsIFrame* nextNextInFlow;
|
|
||||||
|
|
||||||
nextInFlow->GetNextInFlow(nextNextInFlow);
|
|
||||||
if (nsnull != nextNextInFlow) {
|
|
||||||
parent->DeleteChildsNextInFlow(aPresContext, nextInFlow);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
|
||||||
PRInt32 childCount;
|
|
||||||
nsIFrame* firstChild;
|
|
||||||
|
|
||||||
nextInFlow->FirstChild(firstChild);
|
|
||||||
childCount = LengthOf(firstChild);
|
|
||||||
|
|
||||||
if ((0 != childCount) || (nsnull != firstChild)) {
|
|
||||||
nsIFrame* top = nextInFlow;
|
|
||||||
for (;;) {
|
|
||||||
nsIFrame* parent;
|
|
||||||
top->GetGeometricParent(parent);
|
|
||||||
if (nsnull == parent) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
top = parent;
|
|
||||||
}
|
|
||||||
top->List();
|
|
||||||
}
|
|
||||||
NS_ASSERTION((0 == childCount) && (nsnull == firstChild),
|
|
||||||
"deleting !empty next-in-flow");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Disconnect the next-in-flow from the flow list
|
|
||||||
nextInFlow->BreakFromPrevFlow();
|
|
||||||
|
|
||||||
// Take the next-in-flow out of the parent's child list
|
|
||||||
if (parent->mFirstChild == nextInFlow) {
|
|
||||||
nextInFlow->GetNextSibling(parent->mFirstChild);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
nsIFrame* nextSibling;
|
|
||||||
|
|
||||||
// Because the next-in-flow is not the first child of the parent
|
|
||||||
// we know that it shares a parent with aChild. Therefore, we need
|
|
||||||
// to capture the next-in-flow's next sibling (in case the
|
|
||||||
// next-in-flow is the last next-in-flow for aChild AND the
|
|
||||||
// next-in-flow is not the last child in parent)
|
|
||||||
NS_ASSERTION(((nsContainerFrame*)parent)->IsChild(aChild), "screwy flow");
|
|
||||||
aChild->GetNextSibling(nextSibling);
|
|
||||||
NS_ASSERTION(nextSibling == nextInFlow, "unexpected sibling");
|
|
||||||
|
|
||||||
nextInFlow->GetNextSibling(nextSibling);
|
|
||||||
aChild->SetNextSibling(nextSibling);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the next-in-flow frame and adjust its parents child count
|
|
||||||
WillDeleteNextInFlowFrame(nextInFlow);
|
|
||||||
nextInFlow->DeleteFrame(aPresContext);
|
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
|
||||||
aChild->GetNextInFlow(nextInFlow);
|
|
||||||
NS_POSTCONDITION(nsnull == nextInFlow, "non null next-in-flow");
|
|
||||||
#endif
|
|
||||||
return PR_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nsContainerFrame::WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Push aFromChild and its next siblings to the next-in-flow. Change the
|
|
||||||
* geometric parent of each frame that's pushed. If there is no next-in-flow
|
|
||||||
* the frames are placed on the overflow list (and the geometric parent is
|
|
||||||
* left unchanged).
|
|
||||||
*
|
|
||||||
* Updates the next-in-flow's child count. Does <b>not</b> update the
|
|
||||||
* pusher's child count.
|
|
||||||
*
|
|
||||||
* @param aFromChild the first child frame to push. It is disconnected from
|
|
||||||
* aPrevSibling
|
|
||||||
* @param aPrevSibling aFromChild's previous sibling. Must not be null. It's
|
|
||||||
* an error to push a parent's first child frame
|
|
||||||
*/
|
|
||||||
void nsContainerFrame::PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling)
|
|
||||||
{
|
|
||||||
NS_PRECONDITION(nsnull != aFromChild, "null pointer");
|
|
||||||
NS_PRECONDITION(nsnull != aPrevSibling, "pushing first child");
|
|
||||||
#ifdef NS_DEBUG
|
|
||||||
nsIFrame* prevNextSibling;
|
|
||||||
|
|
||||||
aPrevSibling->GetNextSibling(prevNextSibling);
|
|
||||||
NS_PRECONDITION(prevNextSibling == aFromChild, "bad prev sibling");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Disconnect aFromChild from its previous sibling
|
|
||||||
aPrevSibling->SetNextSibling(nsnull);
|
|
||||||
|
|
||||||
// Do we have a next-in-flow?
|
|
||||||
nsContainerFrame* nextInFlow = (nsContainerFrame*)mNextInFlow;
|
|
||||||
if (nsnull != nextInFlow) {
|
|
||||||
PRInt32 numChildren = 0;
|
|
||||||
nsIFrame* lastChild = nsnull;
|
|
||||||
|
|
||||||
// Compute the number of children being pushed, and for each child change
|
|
||||||
// its geometric parent. Remember the last child
|
|
||||||
for (nsIFrame* f = aFromChild; nsnull != f; f->GetNextSibling(f)) {
|
|
||||||
numChildren++;
|
|
||||||
#ifdef NOISY
|
|
||||||
printf(" ");
|
|
||||||
((nsFrame*)f)->ListTag(stdout);
|
|
||||||
printf("\n");
|
|
||||||
#endif
|
|
||||||
lastChild = f;
|
|
||||||
f->SetGeometricParent(nextInFlow);
|
|
||||||
|
|
||||||
nsIFrame* contentParent;
|
|
||||||
|
|
||||||
f->GetContentParent(contentParent);
|
|
||||||
if (this == contentParent) {
|
|
||||||
f->SetContentParent(nextInFlow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NS_ASSERTION(numChildren > 0, "no children to push");
|
|
||||||
|
|
||||||
// Prepend the frames to our next-in-flow's child list
|
|
||||||
lastChild->SetNextSibling(nextInFlow->mFirstChild);
|
|
||||||
nextInFlow->mFirstChild = aFromChild;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Add the frames to our overflow list
|
|
||||||
NS_ASSERTION(nsnull == mOverflowList, "bad overflow list");
|
|
||||||
#ifdef NOISY
|
|
||||||
ListTag(stdout);
|
|
||||||
printf(": pushing kids to my overflow list\n");
|
|
||||||
#endif
|
|
||||||
mOverflowList = aFromChild;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Moves any frames on the overflwo lists (the prev-in-flow's overflow list and
|
|
||||||
* the receiver's overflow list) to the child list.
|
|
||||||
*
|
|
||||||
* Updates this frame's child count and content mapping.
|
|
||||||
*
|
|
||||||
* @return PR_TRUE if any frames were moved and PR_FALSE otherwise
|
|
||||||
*/
|
|
||||||
PRBool nsContainerFrame::MoveOverflowToChildList()
|
|
||||||
{
|
|
||||||
PRBool result = PR_FALSE;
|
|
||||||
|
|
||||||
// Check for an overflow list with our prev-in-flow
|
|
||||||
nsContainerFrame* prevInFlow = (nsContainerFrame*)mPrevInFlow;
|
|
||||||
if (nsnull != prevInFlow) {
|
|
||||||
if (nsnull != prevInFlow->mOverflowList) {
|
|
||||||
NS_ASSERTION(nsnull == mFirstChild, "bad overflow list");
|
|
||||||
AppendChildren(prevInFlow->mOverflowList);
|
|
||||||
prevInFlow->mOverflowList = nsnull;
|
|
||||||
result = PR_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// It's also possible that we have an overflow list for ourselves
|
|
||||||
if (nsnull != mOverflowList) {
|
|
||||||
NS_ASSERTION(nsnull != mFirstChild, "overflow list but no mapped children");
|
|
||||||
AppendChildren(mOverflowList, PR_FALSE);
|
|
||||||
mOverflowList = nsnull;
|
|
||||||
result = PR_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Append child list starting at aChild to this frame's child list. Used for
|
|
||||||
* processing of the overflow list.
|
|
||||||
*
|
|
||||||
* Updates this frame's child count and content mapping.
|
|
||||||
*
|
|
||||||
* @param aChild the beginning of the child list
|
|
||||||
* @param aSetParent if true each child's geometric (and content parent if
|
|
||||||
* they're the same) parent is set to this frame.
|
|
||||||
*/
|
|
||||||
void nsContainerFrame::AppendChildren(nsIFrame* aChild, PRBool aSetParent)
|
|
||||||
{
|
|
||||||
// Link the frames into our child frame list
|
|
||||||
if (nsnull == mFirstChild) {
|
|
||||||
// We have no children so aChild becomes the first child
|
|
||||||
mFirstChild = aChild;
|
|
||||||
} else {
|
|
||||||
nsIFrame* lastChild = LastFrame(mFirstChild);
|
|
||||||
lastChild->SetNextSibling(aChild);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update our child count and last content offset
|
|
||||||
nsIFrame* lastChild;
|
|
||||||
for (nsIFrame* f = aChild; nsnull != f; f->GetNextSibling(f)) {
|
|
||||||
lastChild = f;
|
|
||||||
|
|
||||||
// Reset the geometric parent if requested
|
|
||||||
if (aSetParent) {
|
|
||||||
nsIFrame* geometricParent;
|
|
||||||
nsIFrame* contentParent;
|
|
||||||
|
|
||||||
f->GetGeometricParent(geometricParent);
|
|
||||||
f->GetContentParent(contentParent);
|
|
||||||
if (contentParent == geometricParent) {
|
|
||||||
f->SetContentParent(this);
|
|
||||||
}
|
|
||||||
f->SetGeometricParent(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Debugging
|
|
||||||
|
|
||||||
NS_METHOD nsContainerFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const
|
|
||||||
{
|
|
||||||
// if a filter is present, only output this frame if the filter says we should
|
|
||||||
nsIAtom* tag;
|
|
||||||
nsAutoString tagString;
|
|
||||||
mContent->GetTag(tag);
|
|
||||||
if (tag != nsnull)
|
|
||||||
tag->ToString(tagString);
|
|
||||||
PRBool outputMe = (PRBool)((nsnull==aFilter) || (PR_TRUE==aFilter->OutputTag(&tagString)));
|
|
||||||
if (PR_TRUE==outputMe)
|
|
||||||
{
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nsnull != mPrevInFlow) {
|
|
||||||
fprintf(out, "prev-in-flow=%p ", mPrevInFlow);
|
|
||||||
}
|
|
||||||
if (nsnull != mNextInFlow) {
|
|
||||||
fprintf(out, "next-in-flow=%p ", mNextInFlow);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Output the rect
|
|
||||||
out << mRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Output the children
|
|
||||||
if (nsnull != mFirstChild) {
|
|
||||||
if (PR_TRUE==outputMe)
|
|
||||||
{
|
|
||||||
if (0 != mState) {
|
|
||||||
fprintf(out, " [state=%08x]", mState);
|
|
||||||
}
|
|
||||||
fputs("<\n", out);
|
|
||||||
}
|
|
||||||
for (nsIFrame* child = mFirstChild; child; child->GetNextSibling(child)) {
|
|
||||||
child->List(out, aIndent + 1, aFilter);
|
|
||||||
}
|
|
||||||
if (PR_TRUE==outputMe)
|
|
||||||
{
|
|
||||||
for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
||||||
fputs(">\n", out);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (PR_TRUE==outputMe)
|
|
||||||
{
|
|
||||||
if (0 != mState) {
|
|
||||||
fprintf(out, " [state=%08x]", mState);
|
|
||||||
}
|
|
||||||
fputs("<>\n", out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define VERIFY_ASSERT(_expr, _msg) \
|
|
||||||
if (!(_expr)) { \
|
|
||||||
DumpTree(); \
|
|
||||||
} \
|
|
||||||
NS_ASSERTION(_expr, _msg)
|
|
||||||
|
|
||||||
NS_METHOD nsContainerFrame::VerifyTree() const
|
|
||||||
{
|
|
||||||
#ifdef NS_DEBUG
|
|
||||||
NS_ASSERTION(0 == (mState & NS_FRAME_IN_REFLOW), "frame is in reflow");
|
|
||||||
VERIFY_ASSERT(nsnull == mOverflowList, "bad overflow list");
|
|
||||||
#endif
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
PRInt32 nsContainerFrame::LengthOf(nsIFrame* aFrame)
|
|
||||||
{
|
|
||||||
PRInt32 result = 0;
|
|
||||||
|
|
||||||
while (nsnull != aFrame) {
|
|
||||||
result++;
|
|
||||||
aFrame->GetNextSibling(aFrame);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIFrame* nsContainerFrame::LastFrame(nsIFrame* aFrame)
|
|
||||||
{
|
|
||||||
nsIFrame* lastChild = nsnull;
|
|
||||||
|
|
||||||
while (nsnull != aFrame) {
|
|
||||||
lastChild = aFrame;
|
|
||||||
aFrame->GetNextSibling(aFrame);
|
|
||||||
}
|
|
||||||
|
|
||||||
return lastChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIFrame* nsContainerFrame::FrameAt(nsIFrame* aFrame, PRInt32 aIndex)
|
|
||||||
{
|
|
||||||
while ((aIndex-- > 0) && (aFrame != nsnull)) {
|
|
||||||
aFrame->GetNextSibling(aFrame);
|
|
||||||
}
|
|
||||||
return aFrame;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
|
||||||
|
|
||||||
PRBool nsContainerFrame::IsChild(const nsIFrame* aChild) const
|
|
||||||
{
|
|
||||||
// Check the geometric parent
|
|
||||||
nsIFrame* parent;
|
|
||||||
|
|
||||||
aChild->GetGeometricParent(parent);
|
|
||||||
if (parent != (nsIFrame*)this) {
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return PR_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nsContainerFrame::DumpTree() const
|
|
||||||
{
|
|
||||||
nsIFrame* root = (nsIFrame*)this;
|
|
||||||
nsIFrame* parent = mGeometricParent;
|
|
||||||
|
|
||||||
while (nsnull != parent) {
|
|
||||||
root = parent;
|
|
||||||
parent->GetGeometricParent(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
root->List();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -27,6 +27,8 @@ CPPSRCS= \
|
|||||||
nsBRFrame.cpp \
|
nsBRFrame.cpp \
|
||||||
nsBlockFrame.cpp \
|
nsBlockFrame.cpp \
|
||||||
nsBodyFrame.cpp \
|
nsBodyFrame.cpp \
|
||||||
|
nsContainerFrame.cpp \
|
||||||
|
nsFrame.cpp \
|
||||||
nsFrameReflowState.cpp \
|
nsFrameReflowState.cpp \
|
||||||
nsGlobalVariables.cpp \
|
nsGlobalVariables.cpp \
|
||||||
nsHRFrame.cpp \
|
nsHRFrame.cpp \
|
||||||
@@ -44,8 +46,10 @@ CPPSRCS= \
|
|||||||
nsObjectFrame.cpp \
|
nsObjectFrame.cpp \
|
||||||
nsPageFrame.cpp \
|
nsPageFrame.cpp \
|
||||||
nsPlaceholderFrame.cpp \
|
nsPlaceholderFrame.cpp \
|
||||||
|
nsPresShell.cpp \
|
||||||
nsScrollFrame.cpp \
|
nsScrollFrame.cpp \
|
||||||
nsSpacerFrame.cpp \
|
nsSpacerFrame.cpp \
|
||||||
|
nsSplittableFrame.cpp \
|
||||||
nsTextFrame.cpp \
|
nsTextFrame.cpp \
|
||||||
nsWBRFrame.cpp \
|
nsWBRFrame.cpp \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
@@ -55,6 +59,8 @@ CPP_OBJS= \
|
|||||||
.\$(OBJDIR)\nsBRFrame.obj \
|
.\$(OBJDIR)\nsBRFrame.obj \
|
||||||
.\$(OBJDIR)\nsBlockFrame.obj \
|
.\$(OBJDIR)\nsBlockFrame.obj \
|
||||||
.\$(OBJDIR)\nsBodyFrame.obj \
|
.\$(OBJDIR)\nsBodyFrame.obj \
|
||||||
|
.\$(OBJDIR)\nsContainerFrame.obj \
|
||||||
|
.\$(OBJDIR)\nsFrame.obj \
|
||||||
.\$(OBJDIR)\nsFrameReflowState.obj \
|
.\$(OBJDIR)\nsFrameReflowState.obj \
|
||||||
.\$(OBJDIR)\nsGlobalVariables.obj \
|
.\$(OBJDIR)\nsGlobalVariables.obj \
|
||||||
.\$(OBJDIR)\nsHRFrame.obj \
|
.\$(OBJDIR)\nsHRFrame.obj \
|
||||||
@@ -72,8 +78,10 @@ CPP_OBJS= \
|
|||||||
.\$(OBJDIR)\nsObjectFrame.obj \
|
.\$(OBJDIR)\nsObjectFrame.obj \
|
||||||
.\$(OBJDIR)\nsPageFrame.obj \
|
.\$(OBJDIR)\nsPageFrame.obj \
|
||||||
.\$(OBJDIR)\nsPlaceholderFrame.obj \
|
.\$(OBJDIR)\nsPlaceholderFrame.obj \
|
||||||
|
.\$(OBJDIR)\nsPresShell.obj \
|
||||||
.\$(OBJDIR)\nsScrollFrame.obj \
|
.\$(OBJDIR)\nsScrollFrame.obj \
|
||||||
.\$(OBJDIR)\nsSpacerFrame.obj \
|
.\$(OBJDIR)\nsSpacerFrame.obj \
|
||||||
|
.\$(OBJDIR)\nsSplittableFrame.obj \
|
||||||
.\$(OBJDIR)\nsTextFrame.obj \
|
.\$(OBJDIR)\nsTextFrame.obj \
|
||||||
.\$(OBJDIR)\nsWBRFrame.obj \
|
.\$(OBJDIR)\nsWBRFrame.obj \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
@@ -85,6 +93,7 @@ LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
|
|||||||
-I..\..\style\src \
|
-I..\..\style\src \
|
||||||
-I..\..\content\src \
|
-I..\..\content\src \
|
||||||
-I..\..\..\base\src -I$(PUBLIC)\plugin -I$(PUBLIC)\java \
|
-I..\..\..\base\src -I$(PUBLIC)\plugin -I$(PUBLIC)\java \
|
||||||
|
-I$(PUBLIC)\pref \
|
||||||
-I$(PUBLIC)\oji
|
-I$(PUBLIC)\oji
|
||||||
|
|
||||||
LCFLAGS = \
|
LCFLAGS = \
|
||||||
|
|||||||
175
layout/html/base/src/nsContainerFrame.h
Normal file
175
layout/html/base/src/nsContainerFrame.h
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
/* -*- 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.
|
||||||
|
*/
|
||||||
|
#ifndef nsContainerFrame_h___
|
||||||
|
#define nsContainerFrame_h___
|
||||||
|
|
||||||
|
#include "nsSplittableFrame.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of a container frame.
|
||||||
|
*/
|
||||||
|
class nsContainerFrame : public nsSplittableFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const;
|
||||||
|
|
||||||
|
NS_IMETHOD Init(nsIPresContext& aPresContext, nsIFrame* aChildList);
|
||||||
|
|
||||||
|
NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext);
|
||||||
|
|
||||||
|
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
|
||||||
|
nsDidReflowStatus aStatus);
|
||||||
|
|
||||||
|
// Painting
|
||||||
|
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
||||||
|
nsIRenderingContext& aRenderingContext,
|
||||||
|
const nsRect& aDirtyRect);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pass through the event to the correct child frame.
|
||||||
|
* Return PR_TRUE if the event is consumed.
|
||||||
|
*/
|
||||||
|
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
|
||||||
|
nsGUIEvent* aEvent,
|
||||||
|
nsEventStatus& aEventStatus);
|
||||||
|
|
||||||
|
NS_IMETHOD GetCursorAndContentAt(nsIPresContext& aPresContext,
|
||||||
|
const nsPoint& aPoint,
|
||||||
|
nsIFrame** aFrame,
|
||||||
|
nsIContent** aContent,
|
||||||
|
PRInt32& aCursor);
|
||||||
|
|
||||||
|
// Child frame enumeration.
|
||||||
|
// ChildAt() retruns null if the index is not in the range 0 .. ChildCount() - 1.
|
||||||
|
// IndexOf() returns -1 if the frame is not in the child list.
|
||||||
|
NS_IMETHOD FirstChild(nsIFrame*& aFirstChild) const;
|
||||||
|
|
||||||
|
// Debugging
|
||||||
|
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const;
|
||||||
|
NS_IMETHOD VerifyTree() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the number of children in the sibling list, starting at aChild.
|
||||||
|
* Returns zero if aChild is nsnull.
|
||||||
|
*/
|
||||||
|
static PRInt32 LengthOf(nsIFrame* aChild);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the last frame in the sibling list.
|
||||||
|
* Returns nsnullif aChild is nsnull.
|
||||||
|
*/
|
||||||
|
static nsIFrame* LastFrame(nsIFrame* aChild);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the frame at the specified index relative to aFrame
|
||||||
|
*/
|
||||||
|
static nsIFrame* FrameAt(nsIFrame* aFrame, PRInt32 aIndex);
|
||||||
|
|
||||||
|
// XXX needs to be virtual so that nsBlockFrame can override it
|
||||||
|
virtual PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext,
|
||||||
|
nsIFrame* aChild);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Constructor. Takes as arguments the content object, the index in parent,
|
||||||
|
// and the Frame for the content parent
|
||||||
|
nsContainerFrame(nsIContent* aContent, nsIFrame* aParent);
|
||||||
|
|
||||||
|
virtual ~nsContainerFrame();
|
||||||
|
|
||||||
|
void SizeOfWithoutThis(nsISizeOfHandler* aHandler) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare a continuation frame of this frame for reflow. Appends
|
||||||
|
* it to the flow, sets its content offsets, mLastContentIsComplete,
|
||||||
|
* and style context. Subclasses should invoke this method after
|
||||||
|
* construction of a continuing frame.
|
||||||
|
*/
|
||||||
|
void PrepareContinuingFrame(nsIPresContext& aPresContext,
|
||||||
|
nsIFrame* aParent,
|
||||||
|
nsIStyleContext* aStyleContext,
|
||||||
|
nsContainerFrame* aContFrame);
|
||||||
|
|
||||||
|
|
||||||
|
virtual void PaintChildren(nsIPresContext& aPresContext,
|
||||||
|
nsIRenderingContext& aRenderingContext,
|
||||||
|
const nsRect& aDirtyRect);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reflow a child frame and return the status of the reflow. If the child
|
||||||
|
* is complete and it has next-in-flows, then delete the next-in-flows.
|
||||||
|
*/
|
||||||
|
nsReflowStatus ReflowChild(nsIFrame* aKidFrame,
|
||||||
|
nsIPresContext* aPresContext,
|
||||||
|
nsReflowMetrics& aDesiredSize,
|
||||||
|
const nsReflowState& aReflowState);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves any frames on both the prev-in-flow's overflow list and the receiver's
|
||||||
|
* overflow to the receiver's child list.
|
||||||
|
*
|
||||||
|
* Resets the overlist pointers to nsnull, and updates the receiver's child
|
||||||
|
* count and content mapping.
|
||||||
|
*
|
||||||
|
* @return PR_TRUE if any frames were moved and PR_FALSE otherwise
|
||||||
|
*/
|
||||||
|
PRBool MoveOverflowToChildList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Push aFromChild and its next siblings to the next-in-flow. Change the
|
||||||
|
* geometric parent of each frame that's pushed. If there is no next-in-flow
|
||||||
|
* the frames are placed on the overflow list (and the geometric parent is
|
||||||
|
* left unchanged).
|
||||||
|
*
|
||||||
|
* Updates the next-in-flow's child count. Does <b>not</b> update the
|
||||||
|
* pusher's child count.
|
||||||
|
*
|
||||||
|
* @param aFromChild the first child frame to push. It is disconnected from
|
||||||
|
* aPrevSibling
|
||||||
|
* @param aPrevSibling aFromChild's previous sibling. Must not be null. It's
|
||||||
|
* an error to push a parent's first child frame
|
||||||
|
*/
|
||||||
|
void PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append child list starting at aChild to this frame's child list. Used for
|
||||||
|
* processing of the overflow list.
|
||||||
|
*
|
||||||
|
* Updates this frame's child count and content mapping.
|
||||||
|
*
|
||||||
|
* @param aChild the beginning of the child list
|
||||||
|
* @param aSetParent if true each child's geometric (and content parent if
|
||||||
|
* they're the same) parent is set to this frame.
|
||||||
|
*/
|
||||||
|
void AppendChildren(nsIFrame* aChild, PRBool aSetParent = PR_TRUE);
|
||||||
|
|
||||||
|
virtual void WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow);
|
||||||
|
|
||||||
|
#ifdef NS_DEBUG
|
||||||
|
/**
|
||||||
|
* Returns PR_TRUE if aChild is a child of this frame.
|
||||||
|
*/
|
||||||
|
PRBool IsChild(const nsIFrame* aChild) const;
|
||||||
|
|
||||||
|
void DumpTree() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
nsIFrame* mFirstChild;
|
||||||
|
nsIFrame* mOverflowList;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* nsContainerFrame_h___ */
|
||||||
1880
layout/html/base/src/nsFrame.cpp
Normal file
1880
layout/html/base/src/nsFrame.cpp
Normal file
File diff suppressed because it is too large
Load Diff
294
layout/html/base/src/nsFrame.h
Normal file
294
layout/html/base/src/nsFrame.h
Normal file
@@ -0,0 +1,294 @@
|
|||||||
|
/* -*- 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.
|
||||||
|
*/
|
||||||
|
#ifndef nsFrame_h___
|
||||||
|
#define nsFrame_h___
|
||||||
|
|
||||||
|
#include "nsIFrame.h"
|
||||||
|
#include "nsRect.h"
|
||||||
|
#include "nsISelection.h"
|
||||||
|
#include "nsSelectionRange.h"
|
||||||
|
#include "nsSelectionPoint.h"
|
||||||
|
#include "prlog.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nsFrame logging constants. We redefine the nspr
|
||||||
|
* PRLogModuleInfo.level field to be a bitfield. Each bit controls a
|
||||||
|
* specific type of logging. Each logging operation has associated
|
||||||
|
* inline methods defined below.
|
||||||
|
*/
|
||||||
|
#define NS_FRAME_TRACE_CALLS 0x1
|
||||||
|
#define NS_FRAME_TRACE_PUSH_PULL 0x2
|
||||||
|
#define NS_FRAME_TRACE_CHILD_REFLOW 0x4
|
||||||
|
#define NS_FRAME_TRACE_NEW_FRAMES 0x8
|
||||||
|
|
||||||
|
#define NS_FRAME_LOG_TEST(_lm,_bit) (PRIntn((_lm)->level) & (_bit))
|
||||||
|
|
||||||
|
#ifdef NS_DEBUG
|
||||||
|
#define NS_FRAME_LOG(_bit,_args) \
|
||||||
|
PR_BEGIN_MACRO \
|
||||||
|
if (NS_FRAME_LOG_TEST(nsIFrame::GetLogModuleInfo(),_bit)) { \
|
||||||
|
PR_LogPrint _args; \
|
||||||
|
} \
|
||||||
|
PR_END_MACRO
|
||||||
|
#else
|
||||||
|
#define NS_FRAME_LOG(_bit,_args)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// XXX Need to rework this so that logging is free when it's off
|
||||||
|
#ifdef NS_DEBUG
|
||||||
|
#define NS_FRAME_TRACE_IN(_method) Trace(_method, PR_TRUE)
|
||||||
|
|
||||||
|
#define NS_FRAME_TRACE_OUT(_method) Trace(_method, PR_FALSE)
|
||||||
|
|
||||||
|
// XXX remove me
|
||||||
|
#define NS_FRAME_TRACE_MSG(_bit,_args) \
|
||||||
|
PR_BEGIN_MACRO \
|
||||||
|
if (NS_FRAME_LOG_TEST(nsIFrame::GetLogModuleInfo(),_bit)) { \
|
||||||
|
TraceMsg _args; \
|
||||||
|
} \
|
||||||
|
PR_END_MACRO
|
||||||
|
|
||||||
|
#define NS_FRAME_TRACE(_bit,_args) \
|
||||||
|
PR_BEGIN_MACRO \
|
||||||
|
if (NS_FRAME_LOG_TEST(nsIFrame::GetLogModuleInfo(),_bit)) { \
|
||||||
|
TraceMsg _args; \
|
||||||
|
} \
|
||||||
|
PR_END_MACRO
|
||||||
|
|
||||||
|
#define NS_FRAME_TRACE_REFLOW_IN(_method) Trace(_method, PR_TRUE)
|
||||||
|
|
||||||
|
#define NS_FRAME_TRACE_REFLOW_OUT(_method, _status) \
|
||||||
|
Trace(_method, PR_FALSE, _status)
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define NS_FRAME_TRACE(_bits,_args)
|
||||||
|
#define NS_FRAME_TRACE_IN(_method)
|
||||||
|
#define NS_FRAME_TRACE_OUT(_method)
|
||||||
|
#define NS_FRAME_TRACE_MSG(_bits,_args)
|
||||||
|
#define NS_FRAME_TRACE_REFLOW_IN(_method)
|
||||||
|
#define NS_FRAME_TRACE_REFLOW_OUT(_method, _status)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Implementation of a simple frame with no children and that isn't splittable
|
||||||
|
class nsFrame : public nsIFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Create a new "empty" frame that maps a given piece of content into a
|
||||||
|
* 0,0 area.
|
||||||
|
*/
|
||||||
|
static nsresult NewFrame(nsIFrame** aInstancePtrResult,
|
||||||
|
nsIContent* aContent,
|
||||||
|
nsIFrame* aParent);
|
||||||
|
|
||||||
|
// Overloaded new operator. Initializes the memory to 0
|
||||||
|
void* operator new(size_t size);
|
||||||
|
|
||||||
|
// nsISupports
|
||||||
|
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||||
|
|
||||||
|
// nsIFrame
|
||||||
|
NS_IMETHOD Init(nsIPresContext& aPresContext, nsIFrame* aChildList);
|
||||||
|
NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext);
|
||||||
|
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const;
|
||||||
|
NS_IMETHOD GetContent(nsIContent*& aContent) const;
|
||||||
|
NS_IMETHOD GetContentIndex(PRInt32& aIndexInParent) const;
|
||||||
|
NS_IMETHOD GetStyleContext(nsIPresContext* aContext,
|
||||||
|
nsIStyleContext*& aStyleContext);
|
||||||
|
NS_IMETHOD SetStyleContext(nsIPresContext* aPresContext,
|
||||||
|
nsIStyleContext* aContext);
|
||||||
|
NS_IMETHOD GetStyleData(nsStyleStructID aSID,
|
||||||
|
const nsStyleStruct*& aStyleStruct) const;
|
||||||
|
NS_IMETHOD GetContentParent(nsIFrame*& aParent) const;
|
||||||
|
NS_IMETHOD SetContentParent(const nsIFrame* aParent);
|
||||||
|
NS_IMETHOD GetGeometricParent(nsIFrame*& aParent) const;
|
||||||
|
NS_IMETHOD SetGeometricParent(const nsIFrame* aParent);
|
||||||
|
NS_IMETHOD GetRect(nsRect& aRect) const;
|
||||||
|
NS_IMETHOD GetOrigin(nsPoint& aPoint) const;
|
||||||
|
NS_IMETHOD GetSize(nsSize& aSize) const;
|
||||||
|
NS_IMETHOD SetRect(const nsRect& aRect);
|
||||||
|
NS_IMETHOD MoveTo(nscoord aX, nscoord aY);
|
||||||
|
NS_IMETHOD SizeTo(nscoord aWidth, nscoord aHeight);
|
||||||
|
NS_IMETHOD FirstChild(nsIFrame*& aFirstChild) const;
|
||||||
|
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
||||||
|
nsIRenderingContext& aRenderingContext,
|
||||||
|
const nsRect& aDirtyRect);
|
||||||
|
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
|
||||||
|
nsGUIEvent* aEvent,
|
||||||
|
nsEventStatus& aEventStatus);
|
||||||
|
NS_IMETHOD GetCursorAndContentAt(nsIPresContext& aPresContext,
|
||||||
|
const nsPoint& aPoint,
|
||||||
|
nsIFrame** aFrame,
|
||||||
|
nsIContent** aContent,
|
||||||
|
PRInt32& aCursor);
|
||||||
|
NS_IMETHOD GetFrameState(nsFrameState& aResult);
|
||||||
|
NS_IMETHOD SetFrameState(nsFrameState aNewState);
|
||||||
|
NS_IMETHOD WillReflow(nsIPresContext& aPresContext);
|
||||||
|
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
|
||||||
|
nsDidReflowStatus aStatus);
|
||||||
|
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
|
||||||
|
nsReflowMetrics& aDesiredSize,
|
||||||
|
const nsReflowState& aReflowState,
|
||||||
|
nsReflowStatus& aStatus);
|
||||||
|
|
||||||
|
NS_IMETHOD ContentChanged(nsIPresContext* aPresContext,
|
||||||
|
nsIContent* aChild,
|
||||||
|
nsISupports* aSubContent);
|
||||||
|
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||||
|
nsIContent* aChild,
|
||||||
|
nsIAtom* aAttribute,
|
||||||
|
PRInt32 aHint);
|
||||||
|
NS_IMETHOD GetReflowMetrics(nsIPresContext& aPresContext,
|
||||||
|
nsReflowMetrics& aMetrics);
|
||||||
|
NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const;
|
||||||
|
NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext,
|
||||||
|
nsIFrame* aParent,
|
||||||
|
nsIStyleContext* aStyleContext,
|
||||||
|
nsIFrame*& aContinuingFrame);
|
||||||
|
NS_IMETHOD GetPrevInFlow(nsIFrame*& aPrevInFlow) const;
|
||||||
|
NS_IMETHOD SetPrevInFlow(nsIFrame*);
|
||||||
|
NS_IMETHOD GetNextInFlow(nsIFrame*& aNextInFlow) const;
|
||||||
|
NS_IMETHOD SetNextInFlow(nsIFrame*);
|
||||||
|
NS_IMETHOD AppendToFlow(nsIFrame* aAfterFrame);
|
||||||
|
NS_IMETHOD PrependToFlow(nsIFrame* aAfterFrame);
|
||||||
|
NS_IMETHOD RemoveFromFlow();
|
||||||
|
NS_IMETHOD BreakFromPrevFlow();
|
||||||
|
NS_IMETHOD BreakFromNextFlow();
|
||||||
|
NS_IMETHOD GetView(nsIView*& aView) const;
|
||||||
|
NS_IMETHOD SetView(nsIView* aView);
|
||||||
|
NS_IMETHOD GetParentWithView(nsIFrame*& aParent) const;
|
||||||
|
NS_IMETHOD GetOffsetFromView(nsPoint& aOffset, nsIView*& aView) const;
|
||||||
|
NS_IMETHOD GetWindow(nsIWidget*&) const;
|
||||||
|
NS_IMETHOD IsPercentageBase(PRBool& aBase) const;
|
||||||
|
NS_IMETHOD GetAutoMarginSize(PRUint8 aSide, nscoord& aSize) const;
|
||||||
|
NS_IMETHOD GetNextSibling(nsIFrame*& aNextSibling) const;
|
||||||
|
NS_IMETHOD SetNextSibling(nsIFrame* aNextSibling);
|
||||||
|
NS_IMETHOD IsTransparent(PRBool& aTransparent) const;
|
||||||
|
NS_IMETHOD Scrolled(nsIView *aView);
|
||||||
|
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const;
|
||||||
|
NS_IMETHOD ListTag(FILE* out = stdout) const;
|
||||||
|
NS_IMETHOD VerifyTree() const;
|
||||||
|
|
||||||
|
// Selection Methods
|
||||||
|
NS_IMETHOD HandlePress(nsIPresContext& aPresContext,
|
||||||
|
nsGUIEvent * aEvent,
|
||||||
|
nsEventStatus& aEventStatus);
|
||||||
|
|
||||||
|
NS_IMETHOD HandleDrag(nsIPresContext& aPresContext,
|
||||||
|
nsGUIEvent * aEvent,
|
||||||
|
nsEventStatus& aEventStatus);
|
||||||
|
|
||||||
|
NS_IMETHOD HandleRelease(nsIPresContext& aPresContext,
|
||||||
|
nsGUIEvent * aEvent,
|
||||||
|
nsEventStatus& aEventStatus);
|
||||||
|
|
||||||
|
virtual PRInt32 GetPosition(nsIPresContext& aPresContext,
|
||||||
|
nsGUIEvent* aEvent,
|
||||||
|
nsIFrame * aNewFrame,
|
||||||
|
PRUint32& aAcutalContentOffset);
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// Additional methods
|
||||||
|
|
||||||
|
// Invalidate part of the frame by asking the view manager to repaint.
|
||||||
|
// aDamageRect is in the frame's local coordinate space
|
||||||
|
void Invalidate(const nsRect& aDamageRect,
|
||||||
|
PRBool aImmediate = PR_FALSE) const;
|
||||||
|
|
||||||
|
#ifdef NS_DEBUG
|
||||||
|
/**
|
||||||
|
* Tracing method that writes a method enter/exit routine to the
|
||||||
|
* nspr log using the nsIFrame log module. The tracing is only
|
||||||
|
* done when the NS_FRAME_TRACE_CALLS bit is set in the log module's
|
||||||
|
* level field.
|
||||||
|
*/
|
||||||
|
void Trace(const char* aMethod, PRBool aEnter);
|
||||||
|
void Trace(const char* aMethod, PRBool aEnter, nsReflowStatus aStatus);
|
||||||
|
void TraceMsg(const char* fmt, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void NewContentIsBefore(nsIPresContext& aPresContext,
|
||||||
|
nsGUIEvent * aEvent,
|
||||||
|
nsIContent * aNewContent,
|
||||||
|
nsIContent * aCurrentContent,
|
||||||
|
nsIFrame * aNewFrame);
|
||||||
|
|
||||||
|
virtual void NewContentIsAfter(nsIPresContext& aPresContext,
|
||||||
|
nsGUIEvent * aEvent,
|
||||||
|
nsIContent * aNewContent,
|
||||||
|
nsIContent * aCurrentContent,
|
||||||
|
nsIFrame * aNewFrame);
|
||||||
|
|
||||||
|
virtual void AdjustPointsInNewContent(nsIPresContext& aPresContext,
|
||||||
|
nsGUIEvent * aEvent,
|
||||||
|
nsIFrame * aNewFrame);
|
||||||
|
|
||||||
|
virtual void AdjustPointsInSameContent(nsIPresContext& aPresContext,
|
||||||
|
nsGUIEvent * aEvent);
|
||||||
|
|
||||||
|
PRBool DisplaySelection(nsIPresContext& aPresContext, PRBool isOkToTurnOn = PR_FALSE);
|
||||||
|
|
||||||
|
// Style post processing hook
|
||||||
|
NS_IMETHOD DidSetStyleContext(nsIPresContext* aPresContext);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Constructor. Takes as arguments the content object, the index in parent,
|
||||||
|
// and the Frame for the content parent
|
||||||
|
nsFrame(nsIContent* aContent, nsIFrame* aParent);
|
||||||
|
|
||||||
|
virtual ~nsFrame();
|
||||||
|
|
||||||
|
void SizeOfWithoutThis(nsISizeOfHandler* aHandler) const;
|
||||||
|
|
||||||
|
nsRect mRect;
|
||||||
|
nsIContent* mContent;
|
||||||
|
nsIStyleContext* mStyleContext;
|
||||||
|
nsIFrame* mContentParent;
|
||||||
|
nsIFrame* mGeometricParent;
|
||||||
|
nsIFrame* mNextSibling; // singly linked list of frames
|
||||||
|
nsFrameState mState;
|
||||||
|
|
||||||
|
///////////////////////////////////
|
||||||
|
// Important Selection Variables
|
||||||
|
///////////////////////////////////
|
||||||
|
static nsIFrame * mCurrentFrame;
|
||||||
|
static PRBool mDoingSelection;
|
||||||
|
static PRBool mDidDrag;
|
||||||
|
static PRInt32 mStartPos;
|
||||||
|
|
||||||
|
// Selection data is valid only from the Mouse Press to the Mouse Release
|
||||||
|
static nsSelectionRange * mSelectionRange;
|
||||||
|
static nsISelection * mSelection;
|
||||||
|
|
||||||
|
static nsSelectionPoint * mStartSelectionPoint;
|
||||||
|
static nsSelectionPoint * mEndSelectionPoint;
|
||||||
|
///////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
nsIView* mView; // must use accessor member functions
|
||||||
|
|
||||||
|
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||||
|
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* nsFrame_h___ */
|
||||||
1140
layout/html/base/src/nsPresShell.cpp
Normal file
1140
layout/html/base/src/nsPresShell.cpp
Normal file
File diff suppressed because it is too large
Load Diff
182
layout/html/base/src/nsSplittableFrame.cpp
Normal file
182
layout/html/base/src/nsSplittableFrame.cpp
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
/* -*- 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"
|
||||||
|
#include "nsISizeOfHandler.h"
|
||||||
|
|
||||||
|
nsSplittableFrame::nsSplittableFrame(nsIContent* aContent,
|
||||||
|
nsIFrame* aParent)
|
||||||
|
: nsFrame(aContent, aParent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
nsSplittableFrame::~nsSplittableFrame()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flow member functions
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsSplittableFrame::IsSplittable(nsSplittableType& aIsSplittable) const
|
||||||
|
{
|
||||||
|
aIsSplittable = NS_FRAME_SPLITTABLE;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_METHOD nsSplittableFrame::GetPrevInFlow(nsIFrame*& aPrevInFlow) const
|
||||||
|
{
|
||||||
|
aPrevInFlow = mPrevInFlow;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_METHOD nsSplittableFrame::SetPrevInFlow(nsIFrame* aFrame)
|
||||||
|
{
|
||||||
|
mPrevInFlow = aFrame;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_METHOD nsSplittableFrame::GetNextInFlow(nsIFrame*& aNextInFlow) const
|
||||||
|
{
|
||||||
|
aNextInFlow = mNextInFlow;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_METHOD nsSplittableFrame::SetNextInFlow(nsIFrame* aFrame)
|
||||||
|
{
|
||||||
|
mNextInFlow = aFrame;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
NS_PRECONDITION(aAfterFrame != nsnull, "null pointer");
|
||||||
|
|
||||||
|
mPrevInFlow = aAfterFrame;
|
||||||
|
aAfterFrame->GetNextInFlow(mNextInFlow);
|
||||||
|
mPrevInFlow->SetNextInFlow(this);
|
||||||
|
if (mNextInFlow) {
|
||||||
|
mNextInFlow->SetPrevInFlow(this);
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepend this frame to flow before aBeforeFrame
|
||||||
|
NS_METHOD nsSplittableFrame::PrependToFlow(nsIFrame* aBeforeFrame)
|
||||||
|
{
|
||||||
|
NS_PRECONDITION(aBeforeFrame != nsnull, "null pointer");
|
||||||
|
|
||||||
|
aBeforeFrame->GetPrevInFlow(mPrevInFlow);
|
||||||
|
mNextInFlow = aBeforeFrame;
|
||||||
|
mNextInFlow->SetPrevInFlow(this);
|
||||||
|
if (mPrevInFlow) {
|
||||||
|
mPrevInFlow->SetNextInFlow(this);
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove this frame from the flow. Connects prev in flow and next in flow
|
||||||
|
NS_METHOD nsSplittableFrame::RemoveFromFlow()
|
||||||
|
{
|
||||||
|
if (mPrevInFlow) {
|
||||||
|
mPrevInFlow->SetNextInFlow(mNextInFlow);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mNextInFlow) {
|
||||||
|
mNextInFlow->SetPrevInFlow(mPrevInFlow);
|
||||||
|
}
|
||||||
|
|
||||||
|
mPrevInFlow = mNextInFlow = nsnull;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detach from previous frame in flow
|
||||||
|
NS_METHOD nsSplittableFrame::BreakFromPrevFlow()
|
||||||
|
{
|
||||||
|
if (mPrevInFlow) {
|
||||||
|
mPrevInFlow->SetNextInFlow(nsnull);
|
||||||
|
mPrevInFlow = nsnull;
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detach from next frame in flow
|
||||||
|
NS_METHOD nsSplittableFrame::BreakFromNextFlow()
|
||||||
|
{
|
||||||
|
if (mNextInFlow) {
|
||||||
|
mNextInFlow->SetPrevInFlow(nsnull);
|
||||||
|
mNextInFlow = nsnull;
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsIFrame * nsSplittableFrame::GetPrevInFlow()
|
||||||
|
{
|
||||||
|
return mPrevInFlow;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsIFrame * nsSplittableFrame::GetNextInFlow()
|
||||||
|
{
|
||||||
|
return mNextInFlow;
|
||||||
|
}
|
||||||
71
layout/html/base/src/nsSplittableFrame.h
Normal file
71
layout/html/base/src/nsSplittableFrame.h
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/* -*- 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.
|
||||||
|
*/
|
||||||
|
#ifndef nsSplittableFrame_h___
|
||||||
|
#define nsSplittableFrame_h___
|
||||||
|
|
||||||
|
#include "nsFrame.h"
|
||||||
|
|
||||||
|
// Derived class that allows splitting
|
||||||
|
class nsSplittableFrame : public nsFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const;
|
||||||
|
// CreateContinuingFrame() does the default behavior of using the
|
||||||
|
// content delegate to create a new frame
|
||||||
|
NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const;
|
||||||
|
|
||||||
|
// Flow member functions.
|
||||||
|
NS_IMETHOD GetPrevInFlow(nsIFrame*& aPrevInFlow) const;
|
||||||
|
NS_IMETHOD SetPrevInFlow(nsIFrame*);
|
||||||
|
NS_IMETHOD GetNextInFlow(nsIFrame*& aNextInFlow) const;
|
||||||
|
NS_IMETHOD SetNextInFlow(nsIFrame*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the first frame in our current flow.
|
||||||
|
*/
|
||||||
|
nsIFrame* GetFirstInFlow() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the last frame in our current flow.
|
||||||
|
*/
|
||||||
|
nsIFrame* GetLastInFlow() const;
|
||||||
|
|
||||||
|
NS_IMETHOD AppendToFlow(nsIFrame* aAfterFrame);
|
||||||
|
NS_IMETHOD PrependToFlow(nsIFrame* aAfterFrame);
|
||||||
|
NS_IMETHOD RemoveFromFlow();
|
||||||
|
NS_IMETHOD BreakFromPrevFlow();
|
||||||
|
NS_IMETHOD BreakFromNextFlow();
|
||||||
|
|
||||||
|
nsIFrame* GetPrevInFlow();
|
||||||
|
nsIFrame* GetNextInFlow();
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Constructor. Takes as arguments the content object, the index in parent,
|
||||||
|
// and the Frame for the content parent
|
||||||
|
nsSplittableFrame(nsIContent* aContent, nsIFrame* aParent);
|
||||||
|
|
||||||
|
virtual ~nsSplittableFrame();
|
||||||
|
|
||||||
|
void SizeOfWithoutThis(nsISizeOfHandler* aHandler) const;
|
||||||
|
|
||||||
|
nsIFrame* mPrevInFlow;
|
||||||
|
nsIFrame* mNextInFlow;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* nsSplittableFrame_h___ */
|
||||||
Reference in New Issue
Block a user