Line data Source code
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 "mozilla/UniquePtr.h"
13 : #include "nsContainerFrame.h"
14 : #include "nsColor.h"
15 :
16 : class nsIContent;
17 : class nsPresContext;
18 : struct nsRect;
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 0 : nsBorderColor() { Set(NO_COLOR); }
37 0 : ~nsBorderColor() {}
38 0 : 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
68 0 : NS_DECL_FRAMEARENA_HELPERS(nsHTMLFramesetFrame)
69 :
70 : explicit nsHTMLFramesetFrame(nsStyleContext* aContext);
71 :
72 : virtual ~nsHTMLFramesetFrame();
73 :
74 : virtual void Init(nsIContent* aContent,
75 : nsContainerFrame* aParent,
76 : nsIFrame* aPrevInFlow) override;
77 :
78 : virtual void SetInitialChildList(ChildListID aListID,
79 : nsFrameList& aChildList) override;
80 :
81 : static bool gDragInProgress;
82 :
83 : void GetSizeOfChild(nsIFrame* aChild, mozilla::WritingMode aWM,
84 : mozilla::LogicalSize& aSize);
85 :
86 : void GetSizeOfChildAt(int32_t aIndexInParent,
87 : mozilla::WritingMode aWM,
88 : mozilla::LogicalSize& aSize,
89 : nsIntPoint& aCellIndex);
90 :
91 : virtual nsresult HandleEvent(nsPresContext* aPresContext,
92 : mozilla::WidgetGUIEvent* aEvent,
93 : nsEventStatus* aEventStatus) override;
94 :
95 : virtual nsresult GetCursor(const nsPoint& aPoint,
96 : nsIFrame::Cursor& aCursor) override;
97 :
98 : virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
99 : const nsRect& aDirtyRect,
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 : nsFrameborder GetParentFrameborder() { return mParentFrameborder; }
121 :
122 0 : void SetParentFrameborder(nsFrameborder aValue) { mParentFrameborder = aValue; }
123 :
124 : 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 : int32_t GetParentBorderWidth() { return mParentBorderWidth; }
156 :
157 0 : void SetParentBorderWidth(int32_t aWidth) { mParentBorderWidth = aWidth; }
158 :
159 : 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
|