1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /* rendering object for HTML <frameset> elements */
8 #ifndef nsHTMLFrameset_h___
9 #define nsHTMLFrameset_h___
11 #include "mozilla/Attributes.h"
12 #include "nsContainerFrame.h"
18 struct nsHTMLReflowState
;
21 class nsHTMLFramesetBorderFrame
;
22 class nsHTMLFramesetFrame
;
24 #define NO_COLOR 0xFFFFFFFA
26 // defined at HTMLFrameSetElement.h
27 struct nsFramesetSpec
;
36 nsBorderColor() { Set(NO_COLOR
); }
38 void Set(nscolor aColor
) { mLeft
= mRight
= mTop
= mBottom
= aColor
; }
47 struct nsFramesetDrag
{
48 nsHTMLFramesetFrame
* mSource
; // frameset whose border was dragged to cause the resize
49 int32_t mIndex
; // index of left col or top row of effected area
50 int32_t mChange
; // pos for left to right or top to bottom, neg otherwise
51 bool mVertical
; // vertical if true, otherwise horizontal
54 void Reset(bool aVertical
,
57 nsHTMLFramesetFrame
* aSource
);
61 /*******************************************************************************
63 ******************************************************************************/
64 class nsHTMLFramesetFrame
: public nsContainerFrame
67 NS_DECL_QUERYFRAME_TARGET(nsHTMLFramesetFrame
)
69 NS_DECL_FRAMEARENA_HELPERS
71 explicit nsHTMLFramesetFrame(nsStyleContext
* aContext
);
73 virtual ~nsHTMLFramesetFrame();
75 virtual void Init(nsIContent
* aContent
,
76 nsContainerFrame
* aParent
,
77 nsIFrame
* aPrevInFlow
) MOZ_OVERRIDE
;
79 virtual void SetInitialChildList(ChildListID aListID
,
80 nsFrameList
& aChildList
) MOZ_OVERRIDE
;
82 static bool gDragInProgress
;
84 void GetSizeOfChild(nsIFrame
* aChild
, mozilla::WritingMode aWM
,
85 mozilla::LogicalSize
& aSize
);
87 void GetSizeOfChildAt(int32_t aIndexInParent
,
88 mozilla::WritingMode aWM
,
89 mozilla::LogicalSize
& aSize
,
90 nsIntPoint
& aCellIndex
);
92 virtual nsresult
HandleEvent(nsPresContext
* aPresContext
,
93 mozilla::WidgetGUIEvent
* aEvent
,
94 nsEventStatus
* aEventStatus
) MOZ_OVERRIDE
;
96 virtual nsresult
GetCursor(const nsPoint
& aPoint
,
97 nsIFrame::Cursor
& aCursor
) MOZ_OVERRIDE
;
99 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
100 const nsRect
& aDirtyRect
,
101 const nsDisplayListSet
& aLists
) MOZ_OVERRIDE
;
103 virtual void Reflow(nsPresContext
* aPresContext
,
104 nsHTMLReflowMetrics
& aDesiredSize
,
105 const nsHTMLReflowState
& aReflowState
,
106 nsReflowStatus
& aStatus
) MOZ_OVERRIDE
;
108 virtual nsIAtom
* GetType() const MOZ_OVERRIDE
;
109 #ifdef DEBUG_FRAME_DUMP
110 virtual nsresult
GetFrameName(nsAString
& aResult
) const MOZ_OVERRIDE
;
113 virtual bool IsLeaf() const MOZ_OVERRIDE
;
115 void StartMouseDrag(nsPresContext
* aPresContext
,
116 nsHTMLFramesetBorderFrame
* aBorder
,
117 mozilla::WidgetGUIEvent
* aEvent
);
119 void MouseDrag(nsPresContext
* aPresContext
,
120 mozilla::WidgetGUIEvent
* aEvent
);
122 void EndMouseDrag(nsPresContext
* aPresContext
);
124 nsFrameborder
GetParentFrameborder() { return mParentFrameborder
; }
126 void SetParentFrameborder(nsFrameborder aValue
) { mParentFrameborder
= aValue
; }
128 nsFramesetDrag
& GetDrag() { return mDrag
; }
130 void RecalculateBorderResize();
133 void Scale(nscoord aDesired
,
134 int32_t aNumIndicies
,
139 void CalculateRowCol(nsPresContext
* aPresContext
,
142 const nsFramesetSpec
* aSpecs
,
145 void GenerateRowCol(nsPresContext
* aPresContext
,
148 const nsFramesetSpec
* aSpecs
,
152 virtual void GetDesiredSize(nsPresContext
* aPresContext
,
153 const nsHTMLReflowState
& aReflowState
,
154 nsHTMLReflowMetrics
& aDesiredSize
);
156 int32_t GetBorderWidth(nsPresContext
* aPresContext
,
157 bool aTakeForcingIntoAccount
);
159 int32_t GetParentBorderWidth() { return mParentBorderWidth
; }
161 void SetParentBorderWidth(int32_t aWidth
) { mParentBorderWidth
= aWidth
; }
163 nscolor
GetParentBorderColor() { return mParentBorderColor
; }
165 void SetParentBorderColor(nscolor aColor
) { mParentBorderColor
= aColor
; }
167 nsFrameborder
GetFrameBorder();
169 nsFrameborder
GetFrameBorder(nsIContent
* aContent
);
171 nscolor
GetBorderColor();
173 nscolor
GetBorderColor(nsIContent
* aFrameContent
);
175 bool GetNoResize(nsIFrame
* aChildFrame
);
177 void ReflowPlaceChild(nsIFrame
* aChild
,
178 nsPresContext
* aPresContext
,
179 const nsHTMLReflowState
& aReflowState
,
182 nsIntPoint
* aCellIndex
= 0);
184 bool CanResize(bool aVertical
, bool aLeft
);
186 bool CanChildResize(bool aVertical
, bool aLeft
, int32_t aChildX
);
188 void SetBorderResize(nsHTMLFramesetBorderFrame
* aBorderFrame
);
190 static void FrameResizePrefCallback(const char* aPref
, void* aClosure
);
192 nsFramesetDrag mDrag
;
193 nsBorderColor mEdgeColors
;
194 nsHTMLFramesetBorderFrame
* mDragger
;
195 nsHTMLFramesetFrame
* mTopLevelFrameset
;
196 nsHTMLFramesetBorderFrame
** mVerBorders
; // vertical borders
197 nsHTMLFramesetBorderFrame
** mHorBorders
; // horizontal borders
198 nsFrameborder
* mChildFrameborder
; // the frameborder attr of children
199 nsBorderColor
* mChildBorderColors
;
200 nscoord
* mRowSizes
; // currently computed row sizes
201 nscoord
* mColSizes
; // currently computed col sizes
202 nsIntPoint mFirstDragPoint
;
205 int32_t mNonBorderChildCount
;
206 int32_t mNonBlankChildCount
;
207 int32_t mEdgeVisibility
;
208 nsFrameborder mParentFrameborder
;
209 nscolor mParentBorderColor
;
210 int32_t mParentBorderWidth
;
211 int32_t mPrevNeighborOrigSize
; // used during resize
212 int32_t mNextNeighborOrigSize
;
215 bool mForceFrameResizability
;