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
,
24 friend nsContainerFrame
* NS_NewMathMLmtableOuterFrame(nsIPresShell
* aPresShell
,
25 nsStyleContext
* aContext
);
28 NS_DECL_FRAMEARENA_HELPERS
30 // overloaded nsTableOuterFrame methods
33 Reflow(nsPresContext
* aPresContext
,
34 nsHTMLReflowMetrics
& aDesiredSize
,
35 const nsHTMLReflowState
& aReflowState
,
36 nsReflowStatus
& aStatus
) MOZ_OVERRIDE
;
39 AttributeChanged(int32_t aNameSpaceID
,
41 int32_t aModType
) MOZ_OVERRIDE
;
43 virtual bool IsFrameOfType(uint32_t aFlags
) const MOZ_OVERRIDE
45 return nsTableOuterFrame::IsFrameOfType(aFlags
& ~(nsIFrame::eMathML
));
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
56 GetRowFrameAt(nsPresContext
* aPresContext
,
58 }; // class nsMathMLmtableOuterFrame
62 class nsMathMLmtableFrame
: public nsTableFrame
65 NS_DECL_QUERYFRAME_TARGET(nsMathMLmtableFrame
)
67 NS_DECL_FRAMEARENA_HELPERS
69 friend nsContainerFrame
* NS_NewMathMLmtableFrame(nsIPresShell
* aPresShell
,
70 nsStyleContext
* aContext
);
72 // Overloaded nsTableFrame methods
75 SetInitialChildList(ChildListID aListID
,
76 nsFrameList
& aChildList
) MOZ_OVERRIDE
;
79 AppendFrames(ChildListID aListID
,
80 nsFrameList
& aFrameList
) MOZ_OVERRIDE
82 nsTableFrame::AppendFrames(aListID
, aFrameList
);
87 InsertFrames(ChildListID aListID
,
89 nsFrameList
& aFrameList
) MOZ_OVERRIDE
91 nsTableFrame::InsertFrames(aListID
, aPrevFrame
, aFrameList
);
96 RemoveFrame(ChildListID aListID
,
97 nsIFrame
* aOldFrame
) MOZ_OVERRIDE
99 nsTableFrame::RemoveFrame(aListID
, aOldFrame
);
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.
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
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
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
;
160 explicit nsMathMLmtableFrame(nsStyleContext
* aContext
) : nsTableFrame(aContext
) {}
161 virtual ~nsMathMLmtableFrame();
164 nsTArray
<nscoord
> mColSpacing
;
165 nsTArray
<nscoord
> mRowSpacing
;
166 nscoord mFrameSpacingX
;
167 nscoord mFrameSpacingY
;
169 }; // class nsMathMLmtableFrame
173 class nsMathMLmtrFrame
: public nsTableRowFrame
176 NS_DECL_FRAMEARENA_HELPERS
178 friend nsContainerFrame
* NS_NewMathMLmtrFrame(nsIPresShell
* aPresShell
,
179 nsStyleContext
* aContext
);
181 // overloaded nsTableRowFrame methods
184 AttributeChanged(int32_t aNameSpaceID
,
186 int32_t aModType
) MOZ_OVERRIDE
;
189 AppendFrames(ChildListID aListID
,
190 nsFrameList
& aFrameList
) MOZ_OVERRIDE
192 nsTableRowFrame::AppendFrames(aListID
, aFrameList
);
197 InsertFrames(ChildListID aListID
,
198 nsIFrame
* aPrevFrame
,
199 nsFrameList
& aFrameList
) MOZ_OVERRIDE
201 nsTableRowFrame::InsertFrames(aListID
, aPrevFrame
, aFrameList
);
206 RemoveFrame(ChildListID aListID
,
207 nsIFrame
* aOldFrame
) MOZ_OVERRIDE
209 nsTableRowFrame::RemoveFrame(aListID
, aOldFrame
);
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.
221 nsTableFrame
* tableFrame
= nsTableFrame::GetTableFrame(this);
222 if (tableFrame
&& tableFrame
->IsFrameOfType(nsIFrame::eMathML
)) {
223 // relayout the table
224 ((nsMathMLmtableFrame
*)tableFrame
)->RestyleTable();
229 explicit nsMathMLmtrFrame(nsStyleContext
* aContext
) : nsTableRowFrame(aContext
) {}
230 virtual ~nsMathMLmtrFrame();
231 }; // class nsMathMLmtrFrame
235 class nsMathMLmtdFrame
: public nsTableCellFrame
238 NS_DECL_FRAMEARENA_HELPERS
240 friend nsContainerFrame
* NS_NewMathMLmtdFrame(nsIPresShell
* aPresShell
,
241 nsStyleContext
* aContext
);
243 // overloaded nsTableCellFrame methods
246 AttributeChanged(int32_t aNameSpaceID
,
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
;
267 explicit nsMathMLmtdFrame(nsStyleContext
* aContext
) : nsTableCellFrame(aContext
) {}
268 virtual ~nsMathMLmtdFrame();
269 }; // class nsMathMLmtdFrame
273 class nsMathMLmtdInnerFrame
: public nsBlockFrame
,
274 public nsMathMLFrame
{
276 friend nsContainerFrame
* NS_NewMathMLmtdInnerFrame(nsIPresShell
* aPresShell
, nsStyleContext
* aContext
);
279 NS_DECL_FRAMEARENA_HELPERS
281 // Overloaded nsIMathMLFrame methods
284 UpdatePresentationDataFromChildAt(int32_t aFirstIndex
,
286 uint32_t aFlagsValues
,
287 uint32_t aFlagsToUpdate
) MOZ_OVERRIDE
289 nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(this,
290 aFirstIndex
, aLastIndex
, aFlagsValues
, aFlagsToUpdate
);
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
;
310 IsMrowLike() MOZ_OVERRIDE
{
311 return mFrames
.FirstChild() != mFrames
.LastChild() ||
312 !mFrames
.FirstChild();
316 explicit nsMathMLmtdInnerFrame(nsStyleContext
* aContext
);
317 virtual ~nsMathMLmtdInnerFrame();
319 nsStyleText
* mUniqueStyleText
;
321 }; // class nsMathMLmtdInnerFrame
323 #endif /* nsMathMLmtableFrame_h___ */