Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / layout / mathml / nsMathMLmtableFrame.h
blob1a801de8fc4328b3042d1f7ab2e5347d34d9abb1
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/. */
7 #ifndef nsMathMLmtableFrame_h___
8 #define nsMathMLmtableFrame_h___
10 #include "mozilla/Attributes.h"
11 #include "mozilla/UniquePtr.h"
12 #include "nsMathMLContainerFrame.h"
13 #include "nsBlockFrame.h"
14 #include "nsTableWrapperFrame.h"
15 #include "nsTableRowFrame.h"
16 #include "nsTableCellFrame.h"
18 namespace mozilla {
19 class nsDisplayListBuilder;
20 class nsDisplayListSet;
21 class PresShell;
22 } // namespace mozilla
25 // <mtable> -- table or matrix
28 class nsMathMLmtableWrapperFrame final : public nsTableWrapperFrame,
29 public nsMathMLFrame {
30 public:
31 friend nsContainerFrame* NS_NewMathMLmtableOuterFrame(
32 mozilla::PresShell* aPresShell, ComputedStyle* aStyle);
34 NS_DECL_QUERYFRAME
35 NS_DECL_FRAMEARENA_HELPERS(nsMathMLmtableWrapperFrame)
37 // overloaded nsTableWrapperFrame methods
39 void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
40 const ReflowInput& aReflowInput,
41 nsReflowStatus& aStatus) override;
43 nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
44 int32_t aModType) override;
46 protected:
47 explicit nsMathMLmtableWrapperFrame(ComputedStyle* aStyle,
48 nsPresContext* aPresContext)
49 : nsTableWrapperFrame(aStyle, aPresContext, kClassID) {}
51 virtual ~nsMathMLmtableWrapperFrame();
53 // helper to find the row frame at a given index, positive or negative, e.g.,
54 // 1..n means the first row down to the last row, -1..-n means the last row
55 // up to the first row. Used for alignments that are relative to a given row
56 nsIFrame* GetRowFrameAt(int32_t aRowIndex);
57 }; // class nsMathMLmtableWrapperFrame
59 // --------------
61 class nsMathMLmtableFrame final : public nsTableFrame {
62 public:
63 NS_DECL_QUERYFRAME
64 NS_DECL_FRAMEARENA_HELPERS(nsMathMLmtableFrame)
66 friend nsContainerFrame* NS_NewMathMLmtableFrame(
67 mozilla::PresShell* aPresShell, ComputedStyle* aStyle);
69 // Overloaded nsTableFrame methods
71 void SetInitialChildList(ChildListID aListID,
72 nsFrameList&& aChildList) override;
74 void AppendFrames(ChildListID aListID, nsFrameList&& aFrameList) override {
75 nsTableFrame::AppendFrames(aListID, std::move(aFrameList));
76 RestyleTable();
79 void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
80 const nsLineList::iterator* aPrevFrameLine,
81 nsFrameList&& aFrameList) override {
82 nsTableFrame::InsertFrames(aListID, aPrevFrame, aPrevFrameLine,
83 std::move(aFrameList));
84 RestyleTable();
87 void RemoveFrame(DestroyContext& aContext, ChildListID aListID,
88 nsIFrame* aOldFrame) override {
89 nsTableFrame::RemoveFrame(aContext, aListID, aOldFrame);
90 RestyleTable();
93 // helper to restyle and reflow the table when a row is changed -- since
94 // MathML attributes are inter-dependent and row/colspan can affect the table,
95 // it is safer (albeit grossly suboptimal) to just relayout the whole thing.
96 void RestyleTable();
98 /** helper to get the column spacing style value */
99 nscoord GetColSpacing(int32_t aColIndex) override;
101 /** Sums the combined cell spacing between the columns aStartColIndex to
102 * aEndColIndex.
104 nscoord GetColSpacing(int32_t aStartColIndex, int32_t aEndColIndex) override;
106 /** helper to get the row spacing style value */
107 nscoord GetRowSpacing(int32_t aRowIndex) override;
109 /** Sums the combined cell spacing between the rows aStartRowIndex to
110 * aEndRowIndex.
112 nscoord GetRowSpacing(int32_t aStartRowIndex, int32_t aEndRowIndex) override;
114 void SetColSpacingArray(const nsTArray<nscoord>& aColSpacing) {
115 mColSpacing = aColSpacing.Clone();
118 void SetRowSpacingArray(const nsTArray<nscoord>& aRowSpacing) {
119 mRowSpacing = aRowSpacing.Clone();
122 void SetFrameSpacing(nscoord aSpacingX, nscoord aSpacingY) {
123 mFrameSpacingX = aSpacingX;
124 mFrameSpacingY = aSpacingY;
127 /** Determines whether the placement of table cells is determined by CSS
128 * spacing based on padding and border-spacing, or one based upon the
129 * rowspacing, columnspacing and framespacing attributes. The second
130 * approach is used if the user specifies at least one of those attributes.
132 void SetUseCSSSpacing();
133 bool GetUseCSSSpacing() { return mUseCSSSpacing; }
135 protected:
136 explicit nsMathMLmtableFrame(ComputedStyle* aStyle,
137 nsPresContext* aPresContext)
138 : nsTableFrame(aStyle, aPresContext, kClassID),
139 mFrameSpacingX(0),
140 mFrameSpacingY(0),
141 mUseCSSSpacing(false) {}
143 virtual ~nsMathMLmtableFrame();
145 private:
146 nsTArray<nscoord> mColSpacing;
147 nsTArray<nscoord> mRowSpacing;
148 nscoord mFrameSpacingX;
149 nscoord mFrameSpacingY;
150 bool mUseCSSSpacing;
151 }; // class nsMathMLmtableFrame
153 // --------------
155 class nsMathMLmtrFrame final : public nsTableRowFrame {
156 public:
157 NS_DECL_FRAMEARENA_HELPERS(nsMathMLmtrFrame)
159 friend nsContainerFrame* NS_NewMathMLmtrFrame(mozilla::PresShell* aPresShell,
160 ComputedStyle* aStyle);
162 // overloaded nsTableRowFrame methods
164 virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
165 int32_t aModType) override;
167 void AppendFrames(ChildListID aListID, nsFrameList&& aFrameList) override {
168 nsTableRowFrame::AppendFrames(aListID, std::move(aFrameList));
169 RestyleTable();
172 void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
173 const nsLineList::iterator* aPrevFrameLine,
174 nsFrameList&& aFrameList) override {
175 nsTableRowFrame::InsertFrames(aListID, aPrevFrame, aPrevFrameLine,
176 std::move(aFrameList));
177 RestyleTable();
180 void RemoveFrame(DestroyContext& aContext, ChildListID aListID,
181 nsIFrame* aOldFrame) override {
182 nsTableRowFrame::RemoveFrame(aContext, aListID, aOldFrame);
183 RestyleTable();
186 // helper to restyle and reflow the table -- @see nsMathMLmtableFrame.
187 void RestyleTable() {
188 nsTableFrame* tableFrame = GetTableFrame();
189 if (tableFrame && tableFrame->IsMathMLFrame()) {
190 // relayout the table
191 ((nsMathMLmtableFrame*)tableFrame)->RestyleTable();
195 protected:
196 explicit nsMathMLmtrFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
197 : nsTableRowFrame(aStyle, aPresContext, kClassID) {}
199 virtual ~nsMathMLmtrFrame();
200 }; // class nsMathMLmtrFrame
202 // --------------
204 class nsMathMLmtdFrame final : public nsTableCellFrame {
205 public:
206 NS_DECL_FRAMEARENA_HELPERS(nsMathMLmtdFrame)
208 friend nsContainerFrame* NS_NewMathMLmtdFrame(mozilla::PresShell* aPresShell,
209 ComputedStyle* aStyle,
210 nsTableFrame* aTableFrame);
212 // overloaded nsTableCellFrame methods
214 void Init(nsIContent* aContent, nsContainerFrame* aParent,
215 nsIFrame* aPrevInFlow) override;
217 nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
218 int32_t aModType) override;
220 mozilla::StyleVerticalAlignKeyword GetVerticalAlign() const override;
221 void ProcessBorders(nsTableFrame* aFrame,
222 mozilla::nsDisplayListBuilder* aBuilder,
223 const mozilla::nsDisplayListSet& aLists) override;
225 LogicalMargin GetBorderWidth(WritingMode aWM) const override;
227 nsMargin GetBorderOverflow() override;
229 protected:
230 nsMathMLmtdFrame(ComputedStyle* aStyle, nsTableFrame* aTableFrame)
231 : nsTableCellFrame(aStyle, aTableFrame, kClassID) {}
233 virtual ~nsMathMLmtdFrame();
234 }; // class nsMathMLmtdFrame
236 // --------------
238 class nsMathMLmtdInnerFrame final : public nsBlockFrame, public nsMathMLFrame {
239 public:
240 friend nsContainerFrame* NS_NewMathMLmtdInnerFrame(
241 mozilla::PresShell* aPresShell, ComputedStyle* aStyle);
243 NS_DECL_QUERYFRAME
244 NS_DECL_FRAMEARENA_HELPERS(nsMathMLmtdInnerFrame)
246 // Overloaded nsIMathMLFrame methods
248 NS_IMETHOD
249 UpdatePresentationDataFromChildAt(int32_t aFirstIndex, int32_t aLastIndex,
250 uint32_t aFlagsValues,
251 uint32_t aFlagsToUpdate) override {
252 nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(
253 this, aFirstIndex, aLastIndex, aFlagsValues, aFlagsToUpdate);
254 return NS_OK;
257 void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
258 const ReflowInput& aReflowInput,
259 nsReflowStatus& aStatus) override;
261 const nsStyleText* StyleTextForLineLayout() override;
262 void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override;
264 bool IsMrowLike() override {
265 return mFrames.FirstChild() != mFrames.LastChild() || !mFrames.FirstChild();
268 protected:
269 explicit nsMathMLmtdInnerFrame(ComputedStyle* aStyle,
270 nsPresContext* aPresContext);
271 virtual ~nsMathMLmtdInnerFrame() = default;
273 mozilla::UniquePtr<nsStyleText> mUniqueStyleText;
275 }; // class nsMathMLmtdInnerFrame
277 #endif /* nsMathMLmtableFrame_h___ */