/src/mozilla-central/layout/tables/nsTableColGroupFrame.h
Line | Count | Source (jump to first uncovered line) |
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 | | #ifndef nsTableColGroupFrame_h__ |
6 | | #define nsTableColGroupFrame_h__ |
7 | | |
8 | | #include "mozilla/Attributes.h" |
9 | | #include "nscore.h" |
10 | | #include "nsContainerFrame.h" |
11 | | #include "nsTableFrame.h" |
12 | | #include "mozilla/WritingModes.h" |
13 | | |
14 | | class nsTableColFrame; |
15 | | |
16 | | /** |
17 | | * nsTableColGroupFrame |
18 | | * data structure to maintain information about a single table cell's frame |
19 | | */ |
20 | | class nsTableColGroupFrame final : public nsContainerFrame |
21 | | { |
22 | | public: |
23 | | NS_DECL_FRAMEARENA_HELPERS(nsTableColGroupFrame) |
24 | | |
25 | | /** instantiate a new instance of nsTableRowFrame. |
26 | | * @param aPresShell the pres shell for this frame |
27 | | * |
28 | | * @return the frame that was created |
29 | | */ |
30 | | friend nsTableColGroupFrame* NS_NewTableColGroupFrame(nsIPresShell* aPresShell, |
31 | | ComputedStyle* aStyle); |
32 | | |
33 | | // nsIFrame overrides |
34 | | virtual void Init(nsIContent* aContent, |
35 | | nsContainerFrame* aParent, |
36 | | nsIFrame* aPrevInFlow) override |
37 | 0 | { |
38 | 0 | nsContainerFrame::Init(aContent, aParent, aPrevInFlow); |
39 | 0 | if (!aPrevInFlow) { |
40 | 0 | mWritingMode = GetTableFrame()->GetWritingMode(); |
41 | 0 | } |
42 | 0 | } |
43 | | |
44 | | nsTableFrame* GetTableFrame() const |
45 | 0 | { |
46 | 0 | nsIFrame* parent = GetParent(); |
47 | 0 | MOZ_ASSERT(parent && parent->IsTableFrame()); |
48 | 0 | MOZ_ASSERT(!parent->GetPrevInFlow(), |
49 | 0 | "Col group should always be in a first-in-flow table frame"); |
50 | 0 | return static_cast<nsTableFrame*>(parent); |
51 | 0 | } |
52 | | |
53 | | virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
54 | | const nsDisplayListSet& aLists) override; |
55 | | |
56 | | /** A colgroup can be caused by three things: |
57 | | * 1) An element with table-column-group display |
58 | | * 2) An element with a table-column display without a |
59 | | * table-column-group parent |
60 | | * 3) Cells that are not in a column (and hence get an anonymous |
61 | | * column and colgroup). |
62 | | * |
63 | | * In practice, we don't need to differentiate between cases (1) and (2), |
64 | | * because they both correspond to table-column-group boxes in the spec and |
65 | | * hence have observably identical behavior. Case three is flagged as a |
66 | | * synthetic colgroup, because it may need to have different behavior in some |
67 | | * cases. |
68 | | */ |
69 | | bool IsSynthetic() const; |
70 | | void SetIsSynthetic(); |
71 | | |
72 | | /** Real in this context are colgroups that come from an element |
73 | | * with table-column-group display or wrap around columns that |
74 | | * come from an element with table-column display. Colgroups |
75 | | * that are the result of wrapping cells in an anonymous |
76 | | * column and colgroup are not considered real here. |
77 | | * @param aTableFrame - the table parent of the colgroups |
78 | | * @return the last real colgroup |
79 | | */ |
80 | | static nsTableColGroupFrame* GetLastRealColGroup(nsTableFrame* aTableFrame); |
81 | | |
82 | | /** @see nsIFrame::DidSetComputedStyle */ |
83 | | virtual void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override; |
84 | | |
85 | | virtual void SetInitialChildList(ChildListID aListID, |
86 | | nsFrameList& aChildList) override; |
87 | | virtual void AppendFrames(ChildListID aListID, |
88 | | nsFrameList& aFrameList) override; |
89 | | virtual void InsertFrames(ChildListID aListID, |
90 | | nsIFrame* aPrevFrame, |
91 | | nsFrameList& aFrameList) override; |
92 | | virtual void RemoveFrame(ChildListID aListID, |
93 | | nsIFrame* aOldFrame) override; |
94 | | |
95 | | /** remove the column aChild from the column group, if requested renumber |
96 | | * the subsequent columns in this column group and all following column |
97 | | * groups. see also ResetColIndices for this |
98 | | * @param aChild - the column frame that needs to be removed |
99 | | * @param aResetSubsequentColIndices - if true the columns that follow |
100 | | * after aChild will be reenumerated |
101 | | */ |
102 | | void RemoveChild(nsTableColFrame& aChild, |
103 | | bool aResetSubsequentColIndices); |
104 | | |
105 | | /** reflow of a column group is a trivial matter of reflowing |
106 | | * the col group's children (columns), and setting this frame |
107 | | * to 0-size. Since tables are row-centric, column group frames |
108 | | * don't play directly in the rendering game. They do however |
109 | | * maintain important state that effects table and cell layout. |
110 | | */ |
111 | | virtual void Reflow(nsPresContext* aPresContext, |
112 | | ReflowOutput& aDesiredSize, |
113 | | const ReflowInput& aReflowInput, |
114 | | nsReflowStatus& aStatus) override; |
115 | | |
116 | | /** Add column frames to the table storages: colframe cache and cellmap |
117 | | * this doesn't change the mFrames of the colgroup frame. |
118 | | * @param aFirstColIndex - the index at which aFirstFrame should be inserted |
119 | | * into the colframe cache. |
120 | | * @param aResetSubsequentColIndices - the indices of the col frames |
121 | | * after the insertion might need |
122 | | * an update |
123 | | * @param aCols - an iterator that can be used to iterate over the col |
124 | | * frames to be added. Once this is done, the frames on the |
125 | | * sbling chain of its .get() at that point will still need |
126 | | * their col indices updated. |
127 | | * @result - if there is no table frame or the table frame is not |
128 | | * the first in flow it will return an error |
129 | | */ |
130 | | nsresult AddColsToTable(int32_t aFirstColIndex, |
131 | | bool aResetSubsequentColIndices, |
132 | | const nsFrameList::Slice& aCols); |
133 | | |
134 | | #ifdef DEBUG_FRAME_DUMP |
135 | | virtual nsresult GetFrameName(nsAString& aResult) const override; |
136 | | void Dump(int32_t aIndent); |
137 | | #endif |
138 | | |
139 | | /** returns the number of columns represented by this group. |
140 | | * if there are col children, count them (taking into account the span of each) |
141 | | * else, check my own span attribute. |
142 | | */ |
143 | | virtual int32_t GetColCount() const; |
144 | | |
145 | | /** first column on the child list */ |
146 | | nsTableColFrame * GetFirstColumn(); |
147 | | /** next sibling to aChildFrame that is a column frame, first column frame |
148 | | * in the column group if aChildFrame is null |
149 | | */ |
150 | | nsTableColFrame * GetNextColumn(nsIFrame *aChildFrame); |
151 | | |
152 | | /** @return - the position of the first column in this colgroup in the table |
153 | | * colframe cache. |
154 | | */ |
155 | | int32_t GetStartColumnIndex(); |
156 | | |
157 | | /** set the position of the first column in this colgroup in the table |
158 | | * colframe cache. |
159 | | */ |
160 | | void SetStartColumnIndex(int32_t aIndex); |
161 | | |
162 | | /** helper method to get the span attribute for this colgroup */ |
163 | | int32_t GetSpan(); |
164 | | |
165 | | /** provide access to the mFrames list |
166 | | */ |
167 | | nsFrameList& GetWritableChildList(); |
168 | | |
169 | | /** set the column index for all frames starting at aStartColFrame, it |
170 | | * will also reset the column indices in all subsequent colgroups |
171 | | * @param aFirstColGroup - start the reset operation inside this colgroup |
172 | | * @param aFirstColIndex - first column that is reset should get this index |
173 | | * @param aStartColFrame - if specified the reset starts with this column |
174 | | * inside the colgroup; if not specified, the reset |
175 | | * starts with the first column |
176 | | */ |
177 | | static void ResetColIndices(nsIFrame* aFirstColGroup, |
178 | | int32_t aFirstColIndex, |
179 | | nsIFrame* aStartColFrame = nullptr); |
180 | | |
181 | | /** |
182 | | * Gets inner border widths before collapsing with cell borders |
183 | | * Caller must get istart border from previous column |
184 | | * GetContinuousBCBorderWidth will not overwrite aBorder.IStart |
185 | | * see nsTablePainter about continuous borders |
186 | | */ |
187 | | void GetContinuousBCBorderWidth(mozilla::WritingMode aWM, |
188 | | mozilla::LogicalMargin& aBorder); |
189 | | /** |
190 | | * Set full border widths before collapsing with cell borders |
191 | | * @param aForSide - side to set; only accepts bstart and bend |
192 | | */ |
193 | | void SetContinuousBCBorderWidth(mozilla::LogicalSide aForSide, |
194 | | BCPixelSize aPixelValue); |
195 | | |
196 | | virtual bool IsFrameOfType(uint32_t aFlags) const override |
197 | 0 | { |
198 | 0 | if (aFlags & eSupportsContainLayoutAndPaint) { |
199 | 0 | return false; |
200 | 0 | } |
201 | 0 | |
202 | 0 | return nsContainerFrame::IsFrameOfType(aFlags & ~(nsIFrame::eTablePart)); |
203 | 0 | } |
204 | | |
205 | | virtual void InvalidateFrame(uint32_t aDisplayItemKey = 0, bool aRebuildDisplayItems = true) override; |
206 | | virtual void InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey = 0, bool aRebuildDisplayItems = true) override; |
207 | 0 | virtual void InvalidateFrameForRemoval() override { InvalidateFrameSubtree(); } |
208 | | |
209 | | protected: |
210 | | explicit nsTableColGroupFrame(ComputedStyle* aStyle); |
211 | | |
212 | | void InsertColsReflow(int32_t aColIndex, |
213 | | const nsFrameList::Slice& aCols); |
214 | | |
215 | | virtual LogicalSides GetLogicalSkipSides(const ReflowInput* aReflowInput = nullptr) const override; |
216 | | |
217 | | // data members |
218 | | int32_t mColCount; |
219 | | // the starting column index this col group represents. Must be >= 0. |
220 | | int32_t mStartColIndex; |
221 | | |
222 | | // border width in pixels |
223 | | BCPixelSize mBStartContBorderWidth; |
224 | | BCPixelSize mBEndContBorderWidth; |
225 | | }; |
226 | | |
227 | | inline nsTableColGroupFrame::nsTableColGroupFrame(ComputedStyle* aStyle) |
228 | | : nsContainerFrame(aStyle, kClassID) |
229 | | , mColCount(0) |
230 | | , mStartColIndex(0) |
231 | 0 | { |
232 | 0 | } |
233 | | |
234 | | inline int32_t nsTableColGroupFrame::GetStartColumnIndex() |
235 | 0 | { |
236 | 0 | return mStartColIndex; |
237 | 0 | } |
238 | | |
239 | | inline void nsTableColGroupFrame::SetStartColumnIndex (int32_t aIndex) |
240 | 0 | { |
241 | 0 | mStartColIndex = aIndex; |
242 | 0 | } |
243 | | |
244 | | inline int32_t nsTableColGroupFrame::GetColCount() const |
245 | 0 | { |
246 | 0 | return mColCount; |
247 | 0 | } |
248 | | |
249 | | inline nsFrameList& nsTableColGroupFrame::GetWritableChildList() |
250 | 0 | { |
251 | 0 | return mFrames; |
252 | 0 | } |
253 | | |
254 | | #endif |
255 | | |