1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 /* rendering object for HTML <frameset> elements */
40 #ifndef nsHTMLFrameset_h___
41 #define nsHTMLFrameset_h___
43 #include "nsGkAtoms.h"
44 #include "nsHTMLContainerFrame.h"
46 #include "nsIObserver.h"
47 #include "nsWeakPtr.h"
48 #include "nsIFrameSetElement.h"
53 class nsIRenderingContext
;
55 struct nsHTMLReflowState
;
58 class nsHTMLFramesetBorderFrame
;
60 class nsHTMLFramesetFrame
;
62 #define NO_COLOR 0xFFFFFFFA
71 nsBorderColor() { Set(NO_COLOR
); }
73 void Set(nscolor aColor
) { mLeft
= mRight
= mTop
= mBottom
= aColor
; }
82 struct nsFramesetDrag
{
83 nsHTMLFramesetFrame
* mSource
; // frameset whose border was dragged to cause the resize
84 PRInt32 mIndex
; // index of left col or top row of effected area
85 PRInt32 mChange
; // pos for left to right or top to bottom, neg otherwise
86 PRPackedBool mVertical
; // vertical if true, otherwise horizontal
90 void Reset(PRBool aVertical
,
93 nsHTMLFramesetFrame
* aSource
);
97 /*******************************************************************************
99 ******************************************************************************/
100 class nsHTMLFramesetFrame
: public nsHTMLContainerFrame
103 NS_DECL_QUERYFRAME_TARGET(nsHTMLFramesetFrame
)
105 NS_DECL_FRAMEARENA_HELPERS
107 nsHTMLFramesetFrame(nsStyleContext
* aContext
);
109 virtual ~nsHTMLFramesetFrame();
111 NS_IMETHOD
Init(nsIContent
* aContent
,
113 nsIFrame
* aPrevInFlow
);
115 NS_IMETHOD
SetInitialChildList(nsIAtom
* aListName
,
116 nsFrameList
& aChildList
);
118 static PRBool gDragInProgress
;
120 void GetSizeOfChild(nsIFrame
* aChild
, nsSize
& aSize
);
122 void GetSizeOfChildAt(PRInt32 aIndexInParent
,
124 nsIntPoint
& aCellIndex
);
126 static nsHTMLFramesetFrame
* GetFramesetParent(nsIFrame
* aChild
);
128 NS_IMETHOD
HandleEvent(nsPresContext
* aPresContext
,
130 nsEventStatus
* aEventStatus
);
132 NS_IMETHOD
GetCursor(const nsPoint
& aPoint
,
133 nsIFrame::Cursor
& aCursor
);
135 NS_IMETHOD
BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
136 const nsRect
& aDirtyRect
,
137 const nsDisplayListSet
& aLists
);
139 NS_IMETHOD
Reflow(nsPresContext
* aPresContext
,
140 nsHTMLReflowMetrics
& aDesiredSize
,
141 const nsHTMLReflowState
& aReflowState
,
142 nsReflowStatus
& aStatus
);
144 virtual nsIAtom
* GetType() const;
146 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const;
149 virtual PRBool
IsLeaf() const;
151 void StartMouseDrag(nsPresContext
* aPresContext
,
152 nsHTMLFramesetBorderFrame
* aBorder
,
155 void MouseDrag(nsPresContext
* aPresContext
,
158 void EndMouseDrag(nsPresContext
* aPresContext
);
160 nsFrameborder
GetParentFrameborder() { return mParentFrameborder
; }
162 void SetParentFrameborder(nsFrameborder aValue
) { mParentFrameborder
= aValue
; }
164 nsFramesetDrag
& GetDrag() { return mDrag
; }
166 void RecalculateBorderResize();
169 void Scale(nscoord aDesired
,
170 PRInt32 aNumIndicies
,
175 void CalculateRowCol(nsPresContext
* aPresContext
,
178 const nsFramesetSpec
* aSpecs
,
181 void GenerateRowCol(nsPresContext
* aPresContext
,
184 const nsFramesetSpec
* aSpecs
,
188 virtual void GetDesiredSize(nsPresContext
* aPresContext
,
189 const nsHTMLReflowState
& aReflowState
,
190 nsHTMLReflowMetrics
& aDesiredSize
);
192 PRInt32
GetBorderWidth(nsPresContext
* aPresContext
,
193 PRBool aTakeForcingIntoAccount
);
195 PRInt32
GetParentBorderWidth() { return mParentBorderWidth
; }
197 void SetParentBorderWidth(PRInt32 aWidth
) { mParentBorderWidth
= aWidth
; }
199 nscolor
GetParentBorderColor() { return mParentBorderColor
; }
201 void SetParentBorderColor(nscolor aColor
) { mParentBorderColor
= aColor
; }
203 nsFrameborder
GetFrameBorder();
205 nsFrameborder
GetFrameBorder(nsIContent
* aContent
);
207 nscolor
GetBorderColor();
209 nscolor
GetBorderColor(nsIContent
* aFrameContent
);
211 PRBool
GetNoResize(nsIFrame
* aChildFrame
);
213 virtual PRIntn
GetSkipSides() const;
215 void ReflowPlaceChild(nsIFrame
* aChild
,
216 nsPresContext
* aPresContext
,
217 const nsHTMLReflowState
& aReflowState
,
220 nsIntPoint
* aCellIndex
= 0);
222 PRBool
CanResize(PRBool aVertical
,
225 PRBool
CanChildResize(PRBool aVertical
,
230 void SetBorderResize(PRInt32
* aChildTypes
,
231 nsHTMLFramesetBorderFrame
* aBorderFrame
);
233 PRBool
ChildIsFrameset(nsIFrame
* aChild
);
235 static int FrameResizePrefCallback(const char* aPref
, void* aClosure
);
237 nsFramesetDrag mDrag
;
238 nsBorderColor mEdgeColors
;
239 nsHTMLFramesetBorderFrame
* mDragger
;
240 nsHTMLFramesetFrame
* mTopLevelFrameset
;
241 nsHTMLFramesetBorderFrame
** mVerBorders
; // vertical borders
242 nsHTMLFramesetBorderFrame
** mHorBorders
; // horizontal borders
243 PRInt32
* mChildTypes
; // frameset/frame distinction of children
244 nsFrameborder
* mChildFrameborder
; // the frameborder attr of children
245 nsBorderColor
* mChildBorderColors
;
246 nscoord
* mRowSizes
; // currently computed row sizes
247 nscoord
* mColSizes
; // currently computed col sizes
248 nsIntPoint mFirstDragPoint
;
251 PRInt32 mNonBorderChildCount
;
252 PRInt32 mNonBlankChildCount
;
253 PRInt32 mEdgeVisibility
;
254 nsFrameborder mParentFrameborder
;
255 nscolor mParentBorderColor
;
256 PRInt32 mParentBorderWidth
;
257 PRInt32 mPrevNeighborOrigSize
; // used during resize
258 PRInt32 mNextNeighborOrigSize
;
261 PRBool mForceFrameResizability
;