/src/mozilla-central/layout/generic/nsFrameSetFrame.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | /* rendering object for HTML <frameset> elements */ |
8 | | |
9 | | #ifndef nsHTMLFrameset_h___ |
10 | | #define nsHTMLFrameset_h___ |
11 | | |
12 | | #include "mozilla/Attributes.h" |
13 | | #include "mozilla/UniquePtr.h" |
14 | | #include "nsContainerFrame.h" |
15 | | #include "nsColor.h" |
16 | | |
17 | | class nsIContent; |
18 | | class nsPresContext; |
19 | | struct nsRect; |
20 | | struct nsSize; |
21 | | class nsAtom; |
22 | | class nsHTMLFramesetBorderFrame; |
23 | | class nsHTMLFramesetFrame; |
24 | | |
25 | 0 | #define NO_COLOR 0xFFFFFFFA |
26 | | |
27 | | // defined at HTMLFrameSetElement.h |
28 | | struct nsFramesetSpec; |
29 | | |
30 | | struct nsBorderColor |
31 | | { |
32 | | nscolor mLeft; |
33 | | nscolor mRight; |
34 | | nscolor mTop; |
35 | | nscolor mBottom; |
36 | | |
37 | 0 | nsBorderColor() { Set(NO_COLOR); } |
38 | 0 | ~nsBorderColor() {} |
39 | 0 | void Set(nscolor aColor) { mLeft = mRight = mTop = mBottom = aColor; } |
40 | | }; |
41 | | |
42 | | enum nsFrameborder { |
43 | | eFrameborder_Yes = 0, |
44 | | eFrameborder_No, |
45 | | eFrameborder_Notset |
46 | | }; |
47 | | |
48 | | struct nsFramesetDrag { |
49 | | nsHTMLFramesetFrame* mSource; // frameset whose border was dragged to cause the resize |
50 | | int32_t mIndex; // index of left col or top row of effected area |
51 | | int32_t mChange; // pos for left to right or top to bottom, neg otherwise |
52 | | bool mVertical; // vertical if true, otherwise horizontal |
53 | | |
54 | | nsFramesetDrag(); |
55 | | void Reset(bool aVertical, |
56 | | int32_t aIndex, |
57 | | int32_t aChange, |
58 | | nsHTMLFramesetFrame* aSource); |
59 | | void UnSet(); |
60 | | }; |
61 | | |
62 | | /******************************************************************************* |
63 | | * nsHTMLFramesetFrame |
64 | | ******************************************************************************/ |
65 | | class nsHTMLFramesetFrame final : public nsContainerFrame |
66 | | { |
67 | | public: |
68 | | NS_DECL_QUERYFRAME |
69 | | NS_DECL_FRAMEARENA_HELPERS(nsHTMLFramesetFrame) |
70 | | |
71 | | explicit nsHTMLFramesetFrame(ComputedStyle* aStyle); |
72 | | |
73 | | virtual ~nsHTMLFramesetFrame(); |
74 | | |
75 | | virtual void Init(nsIContent* aContent, |
76 | | nsContainerFrame* aParent, |
77 | | nsIFrame* aPrevInFlow) override; |
78 | | |
79 | | virtual void SetInitialChildList(ChildListID aListID, |
80 | | nsFrameList& aChildList) override; |
81 | | |
82 | | static bool gDragInProgress; |
83 | | |
84 | | void GetSizeOfChild(nsIFrame* aChild, mozilla::WritingMode aWM, |
85 | | mozilla::LogicalSize& aSize); |
86 | | |
87 | | void GetSizeOfChildAt(int32_t aIndexInParent, |
88 | | mozilla::WritingMode aWM, |
89 | | mozilla::LogicalSize& aSize, |
90 | | nsIntPoint& aCellIndex); |
91 | | |
92 | | virtual nsresult HandleEvent(nsPresContext* aPresContext, |
93 | | mozilla::WidgetGUIEvent* aEvent, |
94 | | nsEventStatus* aEventStatus) override; |
95 | | |
96 | | virtual nsresult GetCursor(const nsPoint& aPoint, |
97 | | nsIFrame::Cursor& aCursor) override; |
98 | | |
99 | | virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
100 | | const nsDisplayListSet& aLists) override; |
101 | | |
102 | | virtual void Reflow(nsPresContext* aPresContext, |
103 | | ReflowOutput& aDesiredSize, |
104 | | const ReflowInput& aReflowInput, |
105 | | nsReflowStatus& aStatus) override; |
106 | | |
107 | | #ifdef DEBUG_FRAME_DUMP |
108 | | virtual nsresult GetFrameName(nsAString& aResult) const override; |
109 | | #endif |
110 | | |
111 | | void StartMouseDrag(nsPresContext* aPresContext, |
112 | | nsHTMLFramesetBorderFrame* aBorder, |
113 | | mozilla::WidgetGUIEvent* aEvent); |
114 | | |
115 | | void MouseDrag(nsPresContext* aPresContext, |
116 | | mozilla::WidgetGUIEvent* aEvent); |
117 | | |
118 | | void EndMouseDrag(nsPresContext* aPresContext); |
119 | | |
120 | 0 | nsFrameborder GetParentFrameborder() { return mParentFrameborder; } |
121 | | |
122 | 0 | void SetParentFrameborder(nsFrameborder aValue) { mParentFrameborder = aValue; } |
123 | | |
124 | 0 | nsFramesetDrag& GetDrag() { return mDrag; } |
125 | | |
126 | | void RecalculateBorderResize(); |
127 | | |
128 | | protected: |
129 | | void Scale(nscoord aDesired, |
130 | | int32_t aNumIndicies, |
131 | | int32_t* aIndicies, |
132 | | int32_t aNumItems, |
133 | | int32_t* aItems); |
134 | | |
135 | | void CalculateRowCol(nsPresContext* aPresContext, |
136 | | nscoord aSize, |
137 | | int32_t aNumSpecs, |
138 | | const nsFramesetSpec* aSpecs, |
139 | | nscoord* aValues); |
140 | | |
141 | | void GenerateRowCol(nsPresContext* aPresContext, |
142 | | nscoord aSize, |
143 | | int32_t aNumSpecs, |
144 | | const nsFramesetSpec* aSpecs, |
145 | | nscoord* aValues, |
146 | | nsString& aNewAttr); |
147 | | |
148 | | virtual void GetDesiredSize(nsPresContext* aPresContext, |
149 | | const ReflowInput& aReflowInput, |
150 | | ReflowOutput& aDesiredSize); |
151 | | |
152 | | int32_t GetBorderWidth(nsPresContext* aPresContext, |
153 | | bool aTakeForcingIntoAccount); |
154 | | |
155 | 0 | int32_t GetParentBorderWidth() { return mParentBorderWidth; } |
156 | | |
157 | 0 | void SetParentBorderWidth(int32_t aWidth) { mParentBorderWidth = aWidth; } |
158 | | |
159 | 0 | nscolor GetParentBorderColor() { return mParentBorderColor; } |
160 | | |
161 | 0 | void SetParentBorderColor(nscolor aColor) { mParentBorderColor = aColor; } |
162 | | |
163 | | nsFrameborder GetFrameBorder(); |
164 | | |
165 | | nsFrameborder GetFrameBorder(nsIContent* aContent); |
166 | | |
167 | | nscolor GetBorderColor(); |
168 | | |
169 | | nscolor GetBorderColor(nsIContent* aFrameContent); |
170 | | |
171 | | bool GetNoResize(nsIFrame* aChildFrame); |
172 | | |
173 | | void ReflowPlaceChild(nsIFrame* aChild, |
174 | | nsPresContext* aPresContext, |
175 | | const ReflowInput& aReflowInput, |
176 | | nsPoint& aOffset, |
177 | | nsSize& aSize, |
178 | | nsIntPoint* aCellIndex = 0); |
179 | | |
180 | | bool CanResize(bool aVertical, bool aLeft); |
181 | | |
182 | | bool CanChildResize(bool aVertical, bool aLeft, int32_t aChildX); |
183 | | |
184 | | void SetBorderResize(nsHTMLFramesetBorderFrame* aBorderFrame); |
185 | | |
186 | | template<typename T, class D = mozilla::DefaultDelete<T>> |
187 | | using UniquePtr = mozilla::UniquePtr<T, D>; |
188 | | |
189 | | nsFramesetDrag mDrag; |
190 | | nsBorderColor mEdgeColors; |
191 | | nsHTMLFramesetBorderFrame* mDragger; |
192 | | nsHTMLFramesetFrame* mTopLevelFrameset; |
193 | | UniquePtr<nsHTMLFramesetBorderFrame*[]> mVerBorders; // vertical borders |
194 | | UniquePtr<nsHTMLFramesetBorderFrame*[]> mHorBorders; // horizontal borders |
195 | | UniquePtr<nsFrameborder[]> mChildFrameborder; // the frameborder attr of children |
196 | | UniquePtr<nsBorderColor[]> mChildBorderColors; |
197 | | UniquePtr<nscoord[]> mRowSizes; // currently computed row sizes |
198 | | UniquePtr<nscoord[]> mColSizes; // currently computed col sizes |
199 | | mozilla::LayoutDeviceIntPoint mFirstDragPoint; |
200 | | int32_t mNumRows; |
201 | | int32_t mNumCols; |
202 | | int32_t mNonBorderChildCount; |
203 | | int32_t mNonBlankChildCount; |
204 | | int32_t mEdgeVisibility; |
205 | | nsFrameborder mParentFrameborder; |
206 | | nscolor mParentBorderColor; |
207 | | int32_t mParentBorderWidth; |
208 | | int32_t mPrevNeighborOrigSize; // used during resize |
209 | | int32_t mNextNeighborOrigSize; |
210 | | int32_t mMinDrag; |
211 | | int32_t mChildCount; |
212 | | }; |
213 | | |
214 | | #endif |