Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
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"
16 //
17 // <mtable> -- table or matrix
18 //
20 class nsMathMLmtableOuterFrame : public nsTableOuterFrame,
21 public nsMathMLFrame
22 {
23 public:
24 friend nsIFrame* NS_NewMathMLmtableOuterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
26 NS_DECL_QUERYFRAME
27 NS_DECL_FRAMEARENA_HELPERS
29 // overloaded nsTableOuterFrame methods
31 virtual nsresult
32 Reflow(nsPresContext* aPresContext,
33 nsHTMLReflowMetrics& aDesiredSize,
34 const nsHTMLReflowState& aReflowState,
35 nsReflowStatus& aStatus) MOZ_OVERRIDE;
37 virtual nsresult
38 AttributeChanged(int32_t aNameSpaceID,
39 nsIAtom* aAttribute,
40 int32_t aModType) MOZ_OVERRIDE;
42 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
43 {
44 return nsTableOuterFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
45 }
47 protected:
48 nsMathMLmtableOuterFrame(nsStyleContext* aContext) : nsTableOuterFrame(aContext) {}
49 virtual ~nsMathMLmtableOuterFrame();
51 // helper to find the row frame at a given index, positive or negative, e.g.,
52 // 1..n means the first row down to the last row, -1..-n means the last row
53 // up to the first row. Used for alignments that are relative to a given row
54 nsIFrame*
55 GetRowFrameAt(nsPresContext* aPresContext,
56 int32_t aRowIndex);
57 }; // class nsMathMLmtableOuterFrame
59 // --------------
61 class nsMathMLmtableFrame : public nsTableFrame
62 {
63 public:
64 NS_DECL_FRAMEARENA_HELPERS
66 friend nsIFrame* NS_NewMathMLmtableFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
68 // Overloaded nsTableFrame methods
70 virtual nsresult
71 SetInitialChildList(ChildListID aListID,
72 nsFrameList& aChildList) MOZ_OVERRIDE;
74 virtual nsresult
75 AppendFrames(ChildListID aListID,
76 nsFrameList& aFrameList) MOZ_OVERRIDE
77 {
78 nsresult rv = nsTableFrame::AppendFrames(aListID, aFrameList);
79 RestyleTable();
80 return rv;
81 }
83 virtual nsresult
84 InsertFrames(ChildListID aListID,
85 nsIFrame* aPrevFrame,
86 nsFrameList& aFrameList) MOZ_OVERRIDE
87 {
88 nsresult rv = nsTableFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
89 RestyleTable();
90 return rv;
91 }
93 virtual nsresult
94 RemoveFrame(ChildListID aListID,
95 nsIFrame* aOldFrame) MOZ_OVERRIDE
96 {
97 nsresult rv = nsTableFrame::RemoveFrame(aListID, aOldFrame);
98 RestyleTable();
99 return rv;
100 }
102 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
103 {
104 return nsTableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
105 }
107 // helper to restyle and reflow the table when a row is changed -- since MathML
108 // attributes are inter-dependent and row/colspan can affect the table, it is
109 // safer (albeit grossly suboptimal) to just relayout the whole thing.
110 void RestyleTable();
112 protected:
113 nsMathMLmtableFrame(nsStyleContext* aContext) : nsTableFrame(aContext) {}
114 virtual ~nsMathMLmtableFrame();
115 }; // class nsMathMLmtableFrame
117 // --------------
119 class nsMathMLmtrFrame : public nsTableRowFrame
120 {
121 public:
122 NS_DECL_FRAMEARENA_HELPERS
124 friend nsIFrame* NS_NewMathMLmtrFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
126 // overloaded nsTableRowFrame methods
128 virtual nsresult
129 AttributeChanged(int32_t aNameSpaceID,
130 nsIAtom* aAttribute,
131 int32_t aModType) MOZ_OVERRIDE;
133 virtual nsresult
134 AppendFrames(ChildListID aListID,
135 nsFrameList& aFrameList) MOZ_OVERRIDE
136 {
137 nsresult rv = nsTableRowFrame::AppendFrames(aListID, aFrameList);
138 RestyleTable();
139 return rv;
140 }
142 virtual nsresult
143 InsertFrames(ChildListID aListID,
144 nsIFrame* aPrevFrame,
145 nsFrameList& aFrameList) MOZ_OVERRIDE
146 {
147 nsresult rv = nsTableRowFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
148 RestyleTable();
149 return rv;
150 }
152 virtual nsresult
153 RemoveFrame(ChildListID aListID,
154 nsIFrame* aOldFrame) MOZ_OVERRIDE
155 {
156 nsresult rv = nsTableRowFrame::RemoveFrame(aListID, aOldFrame);
157 RestyleTable();
158 return rv;
159 }
161 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
162 {
163 return nsTableRowFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
164 }
166 // helper to restyle and reflow the table -- @see nsMathMLmtableFrame.
167 void RestyleTable()
168 {
169 nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
170 if (tableFrame && tableFrame->IsFrameOfType(nsIFrame::eMathML)) {
171 // relayout the table
172 ((nsMathMLmtableFrame*)tableFrame)->RestyleTable();
173 }
174 }
176 protected:
177 nsMathMLmtrFrame(nsStyleContext* aContext) : nsTableRowFrame(aContext) {}
178 virtual ~nsMathMLmtrFrame();
179 }; // class nsMathMLmtrFrame
181 // --------------
183 class nsMathMLmtdFrame : public nsTableCellFrame
184 {
185 public:
186 NS_DECL_FRAMEARENA_HELPERS
188 friend nsIFrame* NS_NewMathMLmtdFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
190 // overloaded nsTableCellFrame methods
192 virtual nsresult
193 AttributeChanged(int32_t aNameSpaceID,
194 nsIAtom* aAttribute,
195 int32_t aModType) MOZ_OVERRIDE;
197 virtual uint8_t GetVerticalAlign() const MOZ_OVERRIDE;
198 virtual nsresult ProcessBorders(nsTableFrame* aFrame,
199 nsDisplayListBuilder* aBuilder,
200 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
202 virtual int32_t GetRowSpan() MOZ_OVERRIDE;
203 virtual int32_t GetColSpan() MOZ_OVERRIDE;
204 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
205 {
206 return nsTableCellFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
207 }
209 virtual nsMargin* GetBorderWidth(nsMargin& aBorder) const MOZ_OVERRIDE;
211 protected:
212 nsMathMLmtdFrame(nsStyleContext* aContext) : nsTableCellFrame(aContext) {}
213 virtual ~nsMathMLmtdFrame();
214 }; // class nsMathMLmtdFrame
216 // --------------
218 class nsMathMLmtdInnerFrame : public nsBlockFrame,
219 public nsMathMLFrame {
220 public:
221 friend nsIFrame* NS_NewMathMLmtdInnerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
223 NS_DECL_QUERYFRAME
224 NS_DECL_FRAMEARENA_HELPERS
226 // Overloaded nsIMathMLFrame methods
228 NS_IMETHOD
229 UpdatePresentationDataFromChildAt(int32_t aFirstIndex,
230 int32_t aLastIndex,
231 uint32_t aFlagsValues,
232 uint32_t aFlagsToUpdate) MOZ_OVERRIDE
233 {
234 nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(this,
235 aFirstIndex, aLastIndex, aFlagsValues, aFlagsToUpdate);
236 return NS_OK;
237 }
239 virtual nsresult
240 Reflow(nsPresContext* aPresContext,
241 nsHTMLReflowMetrics& aDesiredSize,
242 const nsHTMLReflowState& aReflowState,
243 nsReflowStatus& aStatus) MOZ_OVERRIDE;
245 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
246 {
247 return nsBlockFrame::IsFrameOfType(aFlags &
248 ~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
249 }
251 virtual const nsStyleText* StyleTextForLineLayout() MOZ_OVERRIDE;
252 virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
254 bool
255 IsMrowLike() MOZ_OVERRIDE {
256 return mFrames.FirstChild() != mFrames.LastChild() ||
257 !mFrames.FirstChild();
258 }
260 protected:
261 nsMathMLmtdInnerFrame(nsStyleContext* aContext);
262 virtual ~nsMathMLmtdInnerFrame();
264 nsStyleText* mUniqueStyleText;
266 }; // class nsMathMLmtdInnerFrame
268 #endif /* nsMathMLmtableFrame_h___ */