|
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/. */ |
|
5 |
|
6 /* rendering object for HTML <frameset> elements */ |
|
7 |
|
8 #ifndef nsHTMLFrameset_h___ |
|
9 #define nsHTMLFrameset_h___ |
|
10 |
|
11 #include "mozilla/Attributes.h" |
|
12 #include "nsContainerFrame.h" |
|
13 #include "nsColor.h" |
|
14 |
|
15 class nsIContent; |
|
16 class nsPresContext; |
|
17 struct nsRect; |
|
18 struct nsHTMLReflowState; |
|
19 struct nsSize; |
|
20 class nsIAtom; |
|
21 class nsHTMLFramesetBorderFrame; |
|
22 class nsHTMLFramesetFrame; |
|
23 |
|
24 #define NO_COLOR 0xFFFFFFFA |
|
25 |
|
26 // defined at HTMLFrameSetElement.h |
|
27 struct nsFramesetSpec; |
|
28 |
|
29 struct nsBorderColor |
|
30 { |
|
31 nscolor mLeft; |
|
32 nscolor mRight; |
|
33 nscolor mTop; |
|
34 nscolor mBottom; |
|
35 |
|
36 nsBorderColor() { Set(NO_COLOR); } |
|
37 ~nsBorderColor() {} |
|
38 void Set(nscolor aColor) { mLeft = mRight = mTop = mBottom = aColor; } |
|
39 }; |
|
40 |
|
41 enum nsFrameborder { |
|
42 eFrameborder_Yes = 0, |
|
43 eFrameborder_No, |
|
44 eFrameborder_Notset |
|
45 }; |
|
46 |
|
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 |
|
52 |
|
53 nsFramesetDrag(); |
|
54 void Reset(bool aVertical, |
|
55 int32_t aIndex, |
|
56 int32_t aChange, |
|
57 nsHTMLFramesetFrame* aSource); |
|
58 void UnSet(); |
|
59 }; |
|
60 |
|
61 /******************************************************************************* |
|
62 * nsHTMLFramesetFrame |
|
63 ******************************************************************************/ |
|
64 class nsHTMLFramesetFrame : public nsContainerFrame |
|
65 { |
|
66 public: |
|
67 NS_DECL_QUERYFRAME_TARGET(nsHTMLFramesetFrame) |
|
68 NS_DECL_QUERYFRAME |
|
69 NS_DECL_FRAMEARENA_HELPERS |
|
70 |
|
71 nsHTMLFramesetFrame(nsStyleContext* aContext); |
|
72 |
|
73 virtual ~nsHTMLFramesetFrame(); |
|
74 |
|
75 virtual void Init(nsIContent* aContent, |
|
76 nsIFrame* aParent, |
|
77 nsIFrame* aPrevInFlow) MOZ_OVERRIDE; |
|
78 |
|
79 virtual nsresult SetInitialChildList(ChildListID aListID, |
|
80 nsFrameList& aChildList) MOZ_OVERRIDE; |
|
81 |
|
82 static bool gDragInProgress; |
|
83 |
|
84 void GetSizeOfChild(nsIFrame* aChild, nsSize& aSize); |
|
85 |
|
86 void GetSizeOfChildAt(int32_t aIndexInParent, |
|
87 nsSize& aSize, |
|
88 nsIntPoint& aCellIndex); |
|
89 |
|
90 virtual nsresult HandleEvent(nsPresContext* aPresContext, |
|
91 mozilla::WidgetGUIEvent* aEvent, |
|
92 nsEventStatus* aEventStatus) MOZ_OVERRIDE; |
|
93 |
|
94 virtual nsresult GetCursor(const nsPoint& aPoint, |
|
95 nsIFrame::Cursor& aCursor) MOZ_OVERRIDE; |
|
96 |
|
97 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
|
98 const nsRect& aDirtyRect, |
|
99 const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
|
100 |
|
101 virtual nsresult Reflow(nsPresContext* aPresContext, |
|
102 nsHTMLReflowMetrics& aDesiredSize, |
|
103 const nsHTMLReflowState& aReflowState, |
|
104 nsReflowStatus& aStatus) MOZ_OVERRIDE; |
|
105 |
|
106 virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
|
107 #ifdef DEBUG_FRAME_DUMP |
|
108 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; |
|
109 #endif |
|
110 |
|
111 virtual bool IsLeaf() const MOZ_OVERRIDE; |
|
112 |
|
113 void StartMouseDrag(nsPresContext* aPresContext, |
|
114 nsHTMLFramesetBorderFrame* aBorder, |
|
115 mozilla::WidgetGUIEvent* aEvent); |
|
116 |
|
117 void MouseDrag(nsPresContext* aPresContext, |
|
118 mozilla::WidgetGUIEvent* aEvent); |
|
119 |
|
120 void EndMouseDrag(nsPresContext* aPresContext); |
|
121 |
|
122 nsFrameborder GetParentFrameborder() { return mParentFrameborder; } |
|
123 |
|
124 void SetParentFrameborder(nsFrameborder aValue) { mParentFrameborder = aValue; } |
|
125 |
|
126 nsFramesetDrag& GetDrag() { return mDrag; } |
|
127 |
|
128 void RecalculateBorderResize(); |
|
129 |
|
130 protected: |
|
131 void Scale(nscoord aDesired, |
|
132 int32_t aNumIndicies, |
|
133 int32_t* aIndicies, |
|
134 int32_t aNumItems, |
|
135 int32_t* aItems); |
|
136 |
|
137 void CalculateRowCol(nsPresContext* aPresContext, |
|
138 nscoord aSize, |
|
139 int32_t aNumSpecs, |
|
140 const nsFramesetSpec* aSpecs, |
|
141 nscoord* aValues); |
|
142 |
|
143 void GenerateRowCol(nsPresContext* aPresContext, |
|
144 nscoord aSize, |
|
145 int32_t aNumSpecs, |
|
146 const nsFramesetSpec* aSpecs, |
|
147 nscoord* aValues, |
|
148 nsString& aNewAttr); |
|
149 |
|
150 virtual void GetDesiredSize(nsPresContext* aPresContext, |
|
151 const nsHTMLReflowState& aReflowState, |
|
152 nsHTMLReflowMetrics& aDesiredSize); |
|
153 |
|
154 int32_t GetBorderWidth(nsPresContext* aPresContext, |
|
155 bool aTakeForcingIntoAccount); |
|
156 |
|
157 int32_t GetParentBorderWidth() { return mParentBorderWidth; } |
|
158 |
|
159 void SetParentBorderWidth(int32_t aWidth) { mParentBorderWidth = aWidth; } |
|
160 |
|
161 nscolor GetParentBorderColor() { return mParentBorderColor; } |
|
162 |
|
163 void SetParentBorderColor(nscolor aColor) { mParentBorderColor = aColor; } |
|
164 |
|
165 nsFrameborder GetFrameBorder(); |
|
166 |
|
167 nsFrameborder GetFrameBorder(nsIContent* aContent); |
|
168 |
|
169 nscolor GetBorderColor(); |
|
170 |
|
171 nscolor GetBorderColor(nsIContent* aFrameContent); |
|
172 |
|
173 bool GetNoResize(nsIFrame* aChildFrame); |
|
174 |
|
175 void ReflowPlaceChild(nsIFrame* aChild, |
|
176 nsPresContext* aPresContext, |
|
177 const nsHTMLReflowState& aReflowState, |
|
178 nsPoint& aOffset, |
|
179 nsSize& aSize, |
|
180 nsIntPoint* aCellIndex = 0); |
|
181 |
|
182 bool CanResize(bool aVertical, bool aLeft); |
|
183 |
|
184 bool CanChildResize(bool aVertical, bool aLeft, int32_t aChildX); |
|
185 |
|
186 void SetBorderResize(nsHTMLFramesetBorderFrame* aBorderFrame); |
|
187 |
|
188 static void FrameResizePrefCallback(const char* aPref, void* aClosure); |
|
189 |
|
190 nsFramesetDrag mDrag; |
|
191 nsBorderColor mEdgeColors; |
|
192 nsHTMLFramesetBorderFrame* mDragger; |
|
193 nsHTMLFramesetFrame* mTopLevelFrameset; |
|
194 nsHTMLFramesetBorderFrame** mVerBorders; // vertical borders |
|
195 nsHTMLFramesetBorderFrame** mHorBorders; // horizontal borders |
|
196 nsFrameborder* mChildFrameborder; // the frameborder attr of children |
|
197 nsBorderColor* mChildBorderColors; |
|
198 nscoord* mRowSizes; // currently computed row sizes |
|
199 nscoord* mColSizes; // currently computed col sizes |
|
200 nsIntPoint mFirstDragPoint; |
|
201 int32_t mNumRows; |
|
202 int32_t mNumCols; |
|
203 int32_t mNonBorderChildCount; |
|
204 int32_t mNonBlankChildCount; |
|
205 int32_t mEdgeVisibility; |
|
206 nsFrameborder mParentFrameborder; |
|
207 nscolor mParentBorderColor; |
|
208 int32_t mParentBorderWidth; |
|
209 int32_t mPrevNeighborOrigSize; // used during resize |
|
210 int32_t mNextNeighborOrigSize; |
|
211 int32_t mMinDrag; |
|
212 int32_t mChildCount; |
|
213 bool mForceFrameResizability; |
|
214 }; |
|
215 |
|
216 #endif |