Bumping manifests a=b2g-bump
[gecko.git] / layout / mathml / nsMathMLmtableFrame.h
blob883be70e1a96eac358251790891e2e9c3c7a825d
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 #ifndef nsMathMLmtableFrame_h___
7 #define nsMathMLmtableFrame_h___
9 #include "mozilla/Attributes.h"
10 #include "nsMathMLContainerFrame.h"
11 #include "nsBlockFrame.h"
12 #include "nsTableOuterFrame.h"
13 #include "nsTableRowFrame.h"
14 #include "nsTableCellFrame.h"
17 // <mtable> -- table or matrix
20 class nsMathMLmtableOuterFrame : public nsTableOuterFrame,
21 public nsMathMLFrame
23 public:
24 friend nsContainerFrame* NS_NewMathMLmtableOuterFrame(nsIPresShell* aPresShell,
25 nsStyleContext* aContext);
27 NS_DECL_QUERYFRAME
28 NS_DECL_FRAMEARENA_HELPERS
30 // overloaded nsTableOuterFrame methods
32 virtual void
33 Reflow(nsPresContext* aPresContext,
34 nsHTMLReflowMetrics& aDesiredSize,
35 const nsHTMLReflowState& aReflowState,
36 nsReflowStatus& aStatus) MOZ_OVERRIDE;
38 virtual nsresult
39 AttributeChanged(int32_t aNameSpaceID,
40 nsIAtom* aAttribute,
41 int32_t aModType) MOZ_OVERRIDE;
43 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
45 return nsTableOuterFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
48 protected:
49 explicit nsMathMLmtableOuterFrame(nsStyleContext* aContext) : nsTableOuterFrame(aContext) {}
50 virtual ~nsMathMLmtableOuterFrame();
52 // helper to find the row frame at a given index, positive or negative, e.g.,
53 // 1..n means the first row down to the last row, -1..-n means the last row
54 // up to the first row. Used for alignments that are relative to a given row
55 nsIFrame*
56 GetRowFrameAt(nsPresContext* aPresContext,
57 int32_t aRowIndex);
58 }; // class nsMathMLmtableOuterFrame
60 // --------------
62 class nsMathMLmtableFrame : public nsTableFrame
64 public:
65 NS_DECL_QUERYFRAME_TARGET(nsMathMLmtableFrame)
66 NS_DECL_QUERYFRAME
67 NS_DECL_FRAMEARENA_HELPERS
69 friend nsContainerFrame* NS_NewMathMLmtableFrame(nsIPresShell* aPresShell,
70 nsStyleContext* aContext);
72 // Overloaded nsTableFrame methods
74 virtual void
75 SetInitialChildList(ChildListID aListID,
76 nsFrameList& aChildList) MOZ_OVERRIDE;
78 virtual void
79 AppendFrames(ChildListID aListID,
80 nsFrameList& aFrameList) MOZ_OVERRIDE
82 nsTableFrame::AppendFrames(aListID, aFrameList);
83 RestyleTable();
86 virtual void
87 InsertFrames(ChildListID aListID,
88 nsIFrame* aPrevFrame,
89 nsFrameList& aFrameList) MOZ_OVERRIDE
91 nsTableFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
92 RestyleTable();
95 virtual void
96 RemoveFrame(ChildListID aListID,
97 nsIFrame* aOldFrame) MOZ_OVERRIDE
99 nsTableFrame::RemoveFrame(aListID, aOldFrame);
100 RestyleTable();
103 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
105 return nsTableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
108 // helper to restyle and reflow the table when a row is changed -- since MathML
109 // attributes are inter-dependent and row/colspan can affect the table, it is
110 // safer (albeit grossly suboptimal) to just relayout the whole thing.
111 void RestyleTable();
113 /** helper to get the cell spacing X style value */
114 nscoord GetCellSpacingX(int32_t aColIndex) MOZ_OVERRIDE;
116 /** Sums the combined cell spacing between the columns aStartColIndex to
117 * aEndColIndex.
119 nscoord GetCellSpacingX(int32_t aStartColIndex,
120 int32_t aEndColIndex) MOZ_OVERRIDE;
122 /** helper to get the cell spacing Y style value */
123 nscoord GetCellSpacingY(int32_t aRowIndex) MOZ_OVERRIDE;
125 /** Sums the combined cell spacing between the rows aStartRowIndex to
126 * aEndRowIndex.
128 nscoord GetCellSpacingY(int32_t aStartRowIndex,
129 int32_t aEndRowIndex) MOZ_OVERRIDE;
131 void SetColSpacingArray(const nsTArray<nscoord>& aColSpacing)
133 mColSpacing = aColSpacing;
136 void SetRowSpacingArray(const nsTArray<nscoord>& aRowSpacing)
138 mRowSpacing = aRowSpacing;
141 void SetFrameSpacing(nscoord aSpacingX, nscoord aSpacingY)
143 mFrameSpacingX = aSpacingX;
144 mFrameSpacingY = aSpacingY;
147 /** Determines whether the placement of table cells is determined by CSS
148 * spacing based on padding and border-spacing, or one based upon the
149 * rowspacing, columnspacing and framespacing attributes. The second
150 * approach is used if the user specifies at least one of those attributes.
152 void SetUseCSSSpacing();
154 bool GetUseCSSSpacing()
156 return mUseCSSSpacing;
159 protected:
160 explicit nsMathMLmtableFrame(nsStyleContext* aContext) : nsTableFrame(aContext) {}
161 virtual ~nsMathMLmtableFrame();
163 private:
164 nsTArray<nscoord> mColSpacing;
165 nsTArray<nscoord> mRowSpacing;
166 nscoord mFrameSpacingX;
167 nscoord mFrameSpacingY;
168 bool mUseCSSSpacing;
169 }; // class nsMathMLmtableFrame
171 // --------------
173 class nsMathMLmtrFrame : public nsTableRowFrame
175 public:
176 NS_DECL_FRAMEARENA_HELPERS
178 friend nsContainerFrame* NS_NewMathMLmtrFrame(nsIPresShell* aPresShell,
179 nsStyleContext* aContext);
181 // overloaded nsTableRowFrame methods
183 virtual nsresult
184 AttributeChanged(int32_t aNameSpaceID,
185 nsIAtom* aAttribute,
186 int32_t aModType) MOZ_OVERRIDE;
188 virtual void
189 AppendFrames(ChildListID aListID,
190 nsFrameList& aFrameList) MOZ_OVERRIDE
192 nsTableRowFrame::AppendFrames(aListID, aFrameList);
193 RestyleTable();
196 virtual void
197 InsertFrames(ChildListID aListID,
198 nsIFrame* aPrevFrame,
199 nsFrameList& aFrameList) MOZ_OVERRIDE
201 nsTableRowFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
202 RestyleTable();
205 virtual void
206 RemoveFrame(ChildListID aListID,
207 nsIFrame* aOldFrame) MOZ_OVERRIDE
209 nsTableRowFrame::RemoveFrame(aListID, aOldFrame);
210 RestyleTable();
213 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
215 return nsTableRowFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
218 // helper to restyle and reflow the table -- @see nsMathMLmtableFrame.
219 void RestyleTable()
221 nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
222 if (tableFrame && tableFrame->IsFrameOfType(nsIFrame::eMathML)) {
223 // relayout the table
224 ((nsMathMLmtableFrame*)tableFrame)->RestyleTable();
228 protected:
229 explicit nsMathMLmtrFrame(nsStyleContext* aContext) : nsTableRowFrame(aContext) {}
230 virtual ~nsMathMLmtrFrame();
231 }; // class nsMathMLmtrFrame
233 // --------------
235 class nsMathMLmtdFrame : public nsTableCellFrame
237 public:
238 NS_DECL_FRAMEARENA_HELPERS
240 friend nsContainerFrame* NS_NewMathMLmtdFrame(nsIPresShell* aPresShell,
241 nsStyleContext* aContext);
243 // overloaded nsTableCellFrame methods
245 virtual nsresult
246 AttributeChanged(int32_t aNameSpaceID,
247 nsIAtom* aAttribute,
248 int32_t aModType) MOZ_OVERRIDE;
250 virtual uint8_t GetVerticalAlign() const MOZ_OVERRIDE;
251 virtual nsresult ProcessBorders(nsTableFrame* aFrame,
252 nsDisplayListBuilder* aBuilder,
253 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
255 virtual int32_t GetRowSpan() MOZ_OVERRIDE;
256 virtual int32_t GetColSpan() MOZ_OVERRIDE;
257 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
259 return nsTableCellFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
262 virtual nsMargin* GetBorderWidth(nsMargin& aBorder) const MOZ_OVERRIDE;
264 virtual nsMargin GetBorderOverflow() MOZ_OVERRIDE;
266 protected:
267 explicit nsMathMLmtdFrame(nsStyleContext* aContext) : nsTableCellFrame(aContext) {}
268 virtual ~nsMathMLmtdFrame();
269 }; // class nsMathMLmtdFrame
271 // --------------
273 class nsMathMLmtdInnerFrame : public nsBlockFrame,
274 public nsMathMLFrame {
275 public:
276 friend nsContainerFrame* NS_NewMathMLmtdInnerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
278 NS_DECL_QUERYFRAME
279 NS_DECL_FRAMEARENA_HELPERS
281 // Overloaded nsIMathMLFrame methods
283 NS_IMETHOD
284 UpdatePresentationDataFromChildAt(int32_t aFirstIndex,
285 int32_t aLastIndex,
286 uint32_t aFlagsValues,
287 uint32_t aFlagsToUpdate) MOZ_OVERRIDE
289 nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(this,
290 aFirstIndex, aLastIndex, aFlagsValues, aFlagsToUpdate);
291 return NS_OK;
294 virtual void
295 Reflow(nsPresContext* aPresContext,
296 nsHTMLReflowMetrics& aDesiredSize,
297 const nsHTMLReflowState& aReflowState,
298 nsReflowStatus& aStatus) MOZ_OVERRIDE;
300 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
302 return nsBlockFrame::IsFrameOfType(aFlags &
303 ~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
306 virtual const nsStyleText* StyleTextForLineLayout() MOZ_OVERRIDE;
307 virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
309 bool
310 IsMrowLike() MOZ_OVERRIDE {
311 return mFrames.FirstChild() != mFrames.LastChild() ||
312 !mFrames.FirstChild();
315 protected:
316 explicit nsMathMLmtdInnerFrame(nsStyleContext* aContext);
317 virtual ~nsMathMLmtdInnerFrame();
319 nsStyleText* mUniqueStyleText;
321 }; // class nsMathMLmtdInnerFrame
323 #endif /* nsMathMLmtableFrame_h___ */