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 NS_IFRAMESETFRAME_IID \
63 { 0xf47deac0, 0x4200, 0x11d2, \
64 { 0x80, 0x3c, 0x0, 0x60, 0x8, 0x15, 0xa7, 0x91 } }
66 #define NO_COLOR 0xFFFFFFFA
75 nsBorderColor() { Set(NO_COLOR
); }
77 void Set(nscolor aColor
) { mLeft
= mRight
= mTop
= mBottom
= aColor
; }
86 struct nsFramesetDrag
{
87 PRBool mVertical
; // vertical if true, otherwise horizontal
88 PRInt32 mIndex
; // index of left col or top row of effected area
89 PRInt32 mChange
; // pos for left to right or top to bottom, neg otherwise
90 nsHTMLFramesetFrame
* mSource
; // frameset whose border was dragged to cause the resize
94 nsFramesetDrag(PRBool aVertical
,
97 nsHTMLFramesetFrame
* aSource
);
98 void Reset(PRBool aVertical
,
101 nsHTMLFramesetFrame
* aSource
);
105 /*******************************************************************************
106 * nsHTMLFramesetFrame
107 ******************************************************************************/
108 class nsHTMLFramesetFrame
: public nsHTMLContainerFrame
111 // Woohoo, concrete class with an IID!
112 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFRAMESETFRAME_IID
)
114 nsHTMLFramesetFrame(nsStyleContext
* aContext
);
116 virtual ~nsHTMLFramesetFrame();
118 NS_IMETHOD
QueryInterface(const nsIID
& aIID
, void** aInstancePtr
);
120 NS_IMETHOD
Init(nsIContent
* aContent
,
122 nsIFrame
* aPrevInFlow
);
124 static PRBool gDragInProgress
;
126 void GetSizeOfChild(nsIFrame
* aChild
, nsSize
& aSize
);
128 void GetSizeOfChildAt(PRInt32 aIndexInParent
,
130 nsPoint
& aCellIndex
);
132 static nsHTMLFramesetFrame
* GetFramesetParent(nsIFrame
* aChild
);
134 NS_IMETHOD
HandleEvent(nsPresContext
* aPresContext
,
136 nsEventStatus
* aEventStatus
);
138 NS_IMETHOD
GetCursor(const nsPoint
& aPoint
,
139 nsIFrame::Cursor
& aCursor
);
141 NS_IMETHOD
BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
142 const nsRect
& aDirtyRect
,
143 const nsDisplayListSet
& aLists
);
145 NS_IMETHOD
Reflow(nsPresContext
* aPresContext
,
146 nsHTMLReflowMetrics
& aDesiredSize
,
147 const nsHTMLReflowState
& aReflowState
,
148 nsReflowStatus
& aStatus
);
150 virtual nsIAtom
* GetType() const;
152 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const;
155 virtual PRBool
IsLeaf() const;
157 NS_IMETHOD
VerifyTree() const;
159 void StartMouseDrag(nsPresContext
* aPresContext
,
160 nsHTMLFramesetBorderFrame
* aBorder
,
163 void MouseDrag(nsPresContext
* aPresContext
,
166 void EndMouseDrag(nsPresContext
* aPresContext
);
168 nsFrameborder
GetParentFrameborder() { return mParentFrameborder
; }
170 void SetParentFrameborder(nsFrameborder aValue
) { mParentFrameborder
= aValue
; }
172 nsFramesetDrag
& GetDrag() { return mDrag
; }
174 void RecalculateBorderResize();
177 void Scale(nscoord aDesired
,
178 PRInt32 aNumIndicies
,
183 void CalculateRowCol(nsPresContext
* aPresContext
,
186 const nsFramesetSpec
* aSpecs
,
189 void GenerateRowCol(nsPresContext
* aPresContext
,
192 const nsFramesetSpec
* aSpecs
,
196 virtual void GetDesiredSize(nsPresContext
* aPresContext
,
197 const nsHTMLReflowState
& aReflowState
,
198 nsHTMLReflowMetrics
& aDesiredSize
);
200 PRInt32
GetBorderWidth(nsPresContext
* aPresContext
,
201 PRBool aTakeForcingIntoAccount
);
203 PRInt32
GetParentBorderWidth() { return mParentBorderWidth
; }
205 void SetParentBorderWidth(PRInt32 aWidth
) { mParentBorderWidth
= aWidth
; }
207 nscolor
GetParentBorderColor() { return mParentBorderColor
; }
209 void SetParentBorderColor(nscolor aColor
) { mParentBorderColor
= aColor
; }
211 nsFrameborder
GetFrameBorder();
213 nsFrameborder
GetFrameBorder(nsIContent
* aContent
);
215 nscolor
GetBorderColor();
217 nscolor
GetBorderColor(nsIContent
* aFrameContent
);
219 PRBool
GetNoResize(nsIFrame
* aChildFrame
);
221 virtual PRIntn
GetSkipSides() const;
223 void ReflowPlaceChild(nsIFrame
* aChild
,
224 nsPresContext
* aPresContext
,
225 const nsHTMLReflowState
& aReflowState
,
228 nsPoint
* aCellIndex
= 0);
230 PRBool
CanResize(PRBool aVertical
,
233 PRBool
CanChildResize(PRBool aVertical
,
238 void SetBorderResize(PRInt32
* aChildTypes
,
239 nsHTMLFramesetBorderFrame
* aBorderFrame
);
241 PRBool
ChildIsFrameset(nsIFrame
* aChild
);
243 static int FrameResizePrefCallback(const char* aPref
, void* aClosure
);
246 nscoord
* mRowSizes
; // currently computed row sizes
248 nscoord
* mColSizes
; // currently computed col sizes
249 PRInt32 mNonBorderChildCount
;
250 PRInt32 mNonBlankChildCount
;
251 PRInt32 mEdgeVisibility
;
252 nsBorderColor mEdgeColors
;
253 nsFrameborder mParentFrameborder
;
254 nscolor mParentBorderColor
;
255 PRInt32 mParentBorderWidth
;
257 nsHTMLFramesetBorderFrame
* mDragger
;
258 nsFramesetDrag mDrag
;
259 nsPoint mFirstDragPoint
;
260 PRInt32 mPrevNeighborOrigSize
; // used during resize
261 PRInt32 mNextNeighborOrigSize
;
264 nsHTMLFramesetFrame
* mTopLevelFrameset
;
265 nsHTMLFramesetBorderFrame
** mVerBorders
; // vertical borders
266 nsHTMLFramesetBorderFrame
** mHorBorders
; // horizontal borders
268 PRInt32
* mChildTypes
; // frameset/frame distinction of children
269 nsFrameborder
* mChildFrameborder
; // the frameborder attr of children
270 nsBorderColor
* mChildBorderColors
;
272 PRBool mForceFrameResizability
;
275 NS_DEFINE_STATIC_IID_ACCESSOR(nsHTMLFramesetFrame
, NS_IFRAMESETFRAME_IID
)