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
|
|
|
*/
|
|
|
|
#ifndef nsContainerFrame_h___
|
|
|
|
#define nsContainerFrame_h___
|
|
|
|
|
|
|
|
#include "nsSplittableFrame.h"
|
1999-01-16 01:53:39 +03:00
|
|
|
#include "nsFrameList.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
// Option flags for ReflowChild() and FinishReflowChild()
|
|
|
|
// member functions
|
|
|
|
#define NS_FRAME_NO_MOVE_VIEW 0x0001
|
|
|
|
#define NS_FRAME_NO_MOVE_FRAME (0x0002 | NS_FRAME_NO_MOVE_VIEW)
|
|
|
|
#define NS_FRAME_NO_SIZE_VIEW 0x0004
|
|
|
|
#define NS_FRAME_NO_MOVE_CHILD_VIEWS 0x0008
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/**
|
1998-09-24 08:57:30 +04:00
|
|
|
* Implementation of a container frame.
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
|
|
|
class nsContainerFrame : public nsSplittableFrame
|
|
|
|
{
|
|
|
|
public:
|
1999-01-16 01:53:39 +03:00
|
|
|
// nsIFrame overrides
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
|
1998-11-10 09:05:32 +03:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList);
|
1999-02-10 05:25:01 +03:00
|
|
|
NS_IMETHOD FirstChild(nsIAtom* aListName, nsIFrame** aFirstChild) const;
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Destroy(nsIPresContext* aPresContext);
|
|
|
|
NS_IMETHOD Paint(nsIPresContext* aPresContext,
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1999-10-26 08:44:41 +04:00
|
|
|
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsIFrame** aFrame);
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD ReplaceFrame(nsIPresContext* aPresContext,
|
1999-07-22 08:32:31 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame,
|
|
|
|
nsIFrame* aNewFrame);
|
1999-09-01 05:02:16 +04:00
|
|
|
#ifdef DEBUG
|
1999-11-02 01:12:45 +03:00
|
|
|
NS_IMETHOD List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const;
|
1999-08-31 07:09:40 +04:00
|
|
|
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-01-16 01:53:39 +03:00
|
|
|
// nsContainerFrame methods
|
1999-11-24 09:03:41 +03:00
|
|
|
virtual void DeleteChildsNextInFlow(nsIPresContext* aPresContext,
|
1999-01-16 01:53:39 +03:00
|
|
|
nsIFrame* aChild);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-01-16 01:53:39 +03:00
|
|
|
static PRInt32 LengthOf(nsIFrame* aFrameList) {
|
|
|
|
nsFrameList tmp(aFrameList);
|
|
|
|
return tmp.GetLength();
|
|
|
|
}
|
1998-09-19 07:24:26 +04:00
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
// Positions the frame's view based on the frame's origin
|
|
|
|
static void PositionFrameView(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
nsIView* aView);
|
|
|
|
|
|
|
|
// Sets several view attributes:
|
|
|
|
// - if requested sizes the frame's view based on the current size and origin.
|
|
|
|
// Takes into account the combined area and (if overflow is visible) whether
|
|
|
|
// the frame has children that extend outside
|
|
|
|
// - opacity
|
|
|
|
// - visibility
|
|
|
|
// - content transparency
|
|
|
|
// - clip
|
|
|
|
//
|
|
|
|
// Flags:
|
|
|
|
// NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
|
|
|
|
// don't want to automatically sync the frame and view
|
1999-11-30 07:48:34 +03:00
|
|
|
// NS_FRAME_NO_SIZE_VIEW - don't size the view
|
1999-11-19 18:33:29 +03:00
|
|
|
static void SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIView* aView,
|
1999-11-30 07:48:34 +03:00
|
|
|
const nsRect* aCombinedArea,
|
1999-11-19 18:33:29 +03:00
|
|
|
PRUint32 aFlags = 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invokes the WillReflow() function, positions the frame and its view (if
|
|
|
|
* requested), and then calls Reflow(). If the reflow succeeds and the child
|
|
|
|
* frame is complete, deletes any next-in-flows using DeleteChildsNextInFlow()
|
|
|
|
*
|
|
|
|
* Flags:
|
|
|
|
* NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
|
|
|
|
* don't want to automatically sync the frame and view
|
|
|
|
* NS_FRAME_NO_MOVE_VIEW - don't move the frame. aX and aY are ignored in this
|
|
|
|
* case. Also implies NS_FRAME_NO_MOVE_VIEW
|
|
|
|
*/
|
|
|
|
nsresult ReflowChild(nsIFrame* aKidFrame,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsIPresContext* aPresContext,
|
1999-11-19 18:33:29 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
|
|
|
PRUint32 aFlags,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The second half of frame reflow. Does the following:
|
|
|
|
* - sets the frame's bounds
|
|
|
|
* - sizes and positions (if requested) the frame's view. If the frame's final
|
|
|
|
* position differs from the current position and the frame itself does not
|
|
|
|
* have a view, then any child frames with views are positioned so they stay
|
|
|
|
* in sync
|
|
|
|
* - sets the view's visibility, opacity, content transparency, and clip
|
|
|
|
* - invoked the DidReflow() function
|
|
|
|
*
|
|
|
|
* Flags:
|
|
|
|
* NS_FRAME_NO_MOVE_FRAME - don't move the frame. aX and aY are ignored in this
|
|
|
|
* case. Also implies NS_FRAME_NO_MOVE_VIEW
|
|
|
|
* NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
|
|
|
|
* don't want to automatically sync the frame and view
|
|
|
|
* NS_FRAME_NO_SIZE_VIEW - don't size the frame's view
|
|
|
|
* NS_FRAME_NO_MOVE_CHILD_VIEWS - don't move child views. This is for the case
|
|
|
|
* where the frame's new position differs from its current position and the
|
|
|
|
* frame itself doesn't have a view, so moving the frame would cause any child
|
|
|
|
* views to be out of sync
|
|
|
|
*/
|
|
|
|
static nsresult FinishReflowChild(nsIFrame* aKidFrame,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsIPresContext* aPresContext,
|
1999-11-19 18:33:29 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
|
|
|
PRUint32 aFlags);
|
|
|
|
|
|
|
|
static void PositionChildViews(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame);
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
protected:
|
1999-01-16 01:53:39 +03:00
|
|
|
nsContainerFrame();
|
|
|
|
~nsContainerFrame();
|
1998-06-06 01:06:24 +04:00
|
|
|
|
1999-10-26 08:44:41 +04:00
|
|
|
nsresult GetFrameForPointUsing(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
1998-11-19 21:09:03 +03:00
|
|
|
nsIAtom* aList,
|
|
|
|
nsIFrame** aFrame);
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
virtual void PaintChildren(nsIPresContext* aPresContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
virtual void PaintChild(nsIPresContext* aPresContext,
|
1998-10-31 01:11:06 +03:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
1998-12-18 18:54:23 +03:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1998-10-31 01:11:06 +03:00
|
|
|
|
1999-10-21 09:11:43 +04:00
|
|
|
/**
|
|
|
|
* Get the frames on the overflow list
|
|
|
|
*/
|
|
|
|
nsIFrame* GetOverflowFrames(nsIPresContext* aPresContext,
|
|
|
|
PRBool aRemoveProperty);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the overflow list
|
|
|
|
*/
|
|
|
|
nsresult SetOverflowFrames(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aOverflowFrames);
|
|
|
|
|
1999-01-16 01:53:39 +03:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
1999-10-21 09:11:43 +04:00
|
|
|
PRBool MoveOverflowToChildList(nsIPresContext* aPresContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-01-16 01:53:39 +03:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
1999-10-21 09:11:43 +04:00
|
|
|
void PushChildren(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFromChild,
|
|
|
|
nsIFrame* aPrevSibling);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-01-16 01:53:39 +03:00
|
|
|
nsFrameList mFrames;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsContainerFrame_h___ */
|