layout/mathml/nsMathMLmtableFrame.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsMathMLmtableFrame_h___
michael@0 7 #define nsMathMLmtableFrame_h___
michael@0 8
michael@0 9 #include "mozilla/Attributes.h"
michael@0 10 #include "nsMathMLContainerFrame.h"
michael@0 11 #include "nsBlockFrame.h"
michael@0 12 #include "nsTableOuterFrame.h"
michael@0 13 #include "nsTableRowFrame.h"
michael@0 14 #include "nsTableCellFrame.h"
michael@0 15
michael@0 16 //
michael@0 17 // <mtable> -- table or matrix
michael@0 18 //
michael@0 19
michael@0 20 class nsMathMLmtableOuterFrame : public nsTableOuterFrame,
michael@0 21 public nsMathMLFrame
michael@0 22 {
michael@0 23 public:
michael@0 24 friend nsIFrame* NS_NewMathMLmtableOuterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
michael@0 25
michael@0 26 NS_DECL_QUERYFRAME
michael@0 27 NS_DECL_FRAMEARENA_HELPERS
michael@0 28
michael@0 29 // overloaded nsTableOuterFrame methods
michael@0 30
michael@0 31 virtual nsresult
michael@0 32 Reflow(nsPresContext* aPresContext,
michael@0 33 nsHTMLReflowMetrics& aDesiredSize,
michael@0 34 const nsHTMLReflowState& aReflowState,
michael@0 35 nsReflowStatus& aStatus) MOZ_OVERRIDE;
michael@0 36
michael@0 37 virtual nsresult
michael@0 38 AttributeChanged(int32_t aNameSpaceID,
michael@0 39 nsIAtom* aAttribute,
michael@0 40 int32_t aModType) MOZ_OVERRIDE;
michael@0 41
michael@0 42 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
michael@0 43 {
michael@0 44 return nsTableOuterFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
michael@0 45 }
michael@0 46
michael@0 47 protected:
michael@0 48 nsMathMLmtableOuterFrame(nsStyleContext* aContext) : nsTableOuterFrame(aContext) {}
michael@0 49 virtual ~nsMathMLmtableOuterFrame();
michael@0 50
michael@0 51 // helper to find the row frame at a given index, positive or negative, e.g.,
michael@0 52 // 1..n means the first row down to the last row, -1..-n means the last row
michael@0 53 // up to the first row. Used for alignments that are relative to a given row
michael@0 54 nsIFrame*
michael@0 55 GetRowFrameAt(nsPresContext* aPresContext,
michael@0 56 int32_t aRowIndex);
michael@0 57 }; // class nsMathMLmtableOuterFrame
michael@0 58
michael@0 59 // --------------
michael@0 60
michael@0 61 class nsMathMLmtableFrame : public nsTableFrame
michael@0 62 {
michael@0 63 public:
michael@0 64 NS_DECL_FRAMEARENA_HELPERS
michael@0 65
michael@0 66 friend nsIFrame* NS_NewMathMLmtableFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
michael@0 67
michael@0 68 // Overloaded nsTableFrame methods
michael@0 69
michael@0 70 virtual nsresult
michael@0 71 SetInitialChildList(ChildListID aListID,
michael@0 72 nsFrameList& aChildList) MOZ_OVERRIDE;
michael@0 73
michael@0 74 virtual nsresult
michael@0 75 AppendFrames(ChildListID aListID,
michael@0 76 nsFrameList& aFrameList) MOZ_OVERRIDE
michael@0 77 {
michael@0 78 nsresult rv = nsTableFrame::AppendFrames(aListID, aFrameList);
michael@0 79 RestyleTable();
michael@0 80 return rv;
michael@0 81 }
michael@0 82
michael@0 83 virtual nsresult
michael@0 84 InsertFrames(ChildListID aListID,
michael@0 85 nsIFrame* aPrevFrame,
michael@0 86 nsFrameList& aFrameList) MOZ_OVERRIDE
michael@0 87 {
michael@0 88 nsresult rv = nsTableFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
michael@0 89 RestyleTable();
michael@0 90 return rv;
michael@0 91 }
michael@0 92
michael@0 93 virtual nsresult
michael@0 94 RemoveFrame(ChildListID aListID,
michael@0 95 nsIFrame* aOldFrame) MOZ_OVERRIDE
michael@0 96 {
michael@0 97 nsresult rv = nsTableFrame::RemoveFrame(aListID, aOldFrame);
michael@0 98 RestyleTable();
michael@0 99 return rv;
michael@0 100 }
michael@0 101
michael@0 102 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
michael@0 103 {
michael@0 104 return nsTableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
michael@0 105 }
michael@0 106
michael@0 107 // helper to restyle and reflow the table when a row is changed -- since MathML
michael@0 108 // attributes are inter-dependent and row/colspan can affect the table, it is
michael@0 109 // safer (albeit grossly suboptimal) to just relayout the whole thing.
michael@0 110 void RestyleTable();
michael@0 111
michael@0 112 protected:
michael@0 113 nsMathMLmtableFrame(nsStyleContext* aContext) : nsTableFrame(aContext) {}
michael@0 114 virtual ~nsMathMLmtableFrame();
michael@0 115 }; // class nsMathMLmtableFrame
michael@0 116
michael@0 117 // --------------
michael@0 118
michael@0 119 class nsMathMLmtrFrame : public nsTableRowFrame
michael@0 120 {
michael@0 121 public:
michael@0 122 NS_DECL_FRAMEARENA_HELPERS
michael@0 123
michael@0 124 friend nsIFrame* NS_NewMathMLmtrFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
michael@0 125
michael@0 126 // overloaded nsTableRowFrame methods
michael@0 127
michael@0 128 virtual nsresult
michael@0 129 AttributeChanged(int32_t aNameSpaceID,
michael@0 130 nsIAtom* aAttribute,
michael@0 131 int32_t aModType) MOZ_OVERRIDE;
michael@0 132
michael@0 133 virtual nsresult
michael@0 134 AppendFrames(ChildListID aListID,
michael@0 135 nsFrameList& aFrameList) MOZ_OVERRIDE
michael@0 136 {
michael@0 137 nsresult rv = nsTableRowFrame::AppendFrames(aListID, aFrameList);
michael@0 138 RestyleTable();
michael@0 139 return rv;
michael@0 140 }
michael@0 141
michael@0 142 virtual nsresult
michael@0 143 InsertFrames(ChildListID aListID,
michael@0 144 nsIFrame* aPrevFrame,
michael@0 145 nsFrameList& aFrameList) MOZ_OVERRIDE
michael@0 146 {
michael@0 147 nsresult rv = nsTableRowFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
michael@0 148 RestyleTable();
michael@0 149 return rv;
michael@0 150 }
michael@0 151
michael@0 152 virtual nsresult
michael@0 153 RemoveFrame(ChildListID aListID,
michael@0 154 nsIFrame* aOldFrame) MOZ_OVERRIDE
michael@0 155 {
michael@0 156 nsresult rv = nsTableRowFrame::RemoveFrame(aListID, aOldFrame);
michael@0 157 RestyleTable();
michael@0 158 return rv;
michael@0 159 }
michael@0 160
michael@0 161 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
michael@0 162 {
michael@0 163 return nsTableRowFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
michael@0 164 }
michael@0 165
michael@0 166 // helper to restyle and reflow the table -- @see nsMathMLmtableFrame.
michael@0 167 void RestyleTable()
michael@0 168 {
michael@0 169 nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
michael@0 170 if (tableFrame && tableFrame->IsFrameOfType(nsIFrame::eMathML)) {
michael@0 171 // relayout the table
michael@0 172 ((nsMathMLmtableFrame*)tableFrame)->RestyleTable();
michael@0 173 }
michael@0 174 }
michael@0 175
michael@0 176 protected:
michael@0 177 nsMathMLmtrFrame(nsStyleContext* aContext) : nsTableRowFrame(aContext) {}
michael@0 178 virtual ~nsMathMLmtrFrame();
michael@0 179 }; // class nsMathMLmtrFrame
michael@0 180
michael@0 181 // --------------
michael@0 182
michael@0 183 class nsMathMLmtdFrame : public nsTableCellFrame
michael@0 184 {
michael@0 185 public:
michael@0 186 NS_DECL_FRAMEARENA_HELPERS
michael@0 187
michael@0 188 friend nsIFrame* NS_NewMathMLmtdFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
michael@0 189
michael@0 190 // overloaded nsTableCellFrame methods
michael@0 191
michael@0 192 virtual nsresult
michael@0 193 AttributeChanged(int32_t aNameSpaceID,
michael@0 194 nsIAtom* aAttribute,
michael@0 195 int32_t aModType) MOZ_OVERRIDE;
michael@0 196
michael@0 197 virtual uint8_t GetVerticalAlign() const MOZ_OVERRIDE;
michael@0 198 virtual nsresult ProcessBorders(nsTableFrame* aFrame,
michael@0 199 nsDisplayListBuilder* aBuilder,
michael@0 200 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
michael@0 201
michael@0 202 virtual int32_t GetRowSpan() MOZ_OVERRIDE;
michael@0 203 virtual int32_t GetColSpan() MOZ_OVERRIDE;
michael@0 204 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
michael@0 205 {
michael@0 206 return nsTableCellFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
michael@0 207 }
michael@0 208
michael@0 209 virtual nsMargin* GetBorderWidth(nsMargin& aBorder) const MOZ_OVERRIDE;
michael@0 210
michael@0 211 protected:
michael@0 212 nsMathMLmtdFrame(nsStyleContext* aContext) : nsTableCellFrame(aContext) {}
michael@0 213 virtual ~nsMathMLmtdFrame();
michael@0 214 }; // class nsMathMLmtdFrame
michael@0 215
michael@0 216 // --------------
michael@0 217
michael@0 218 class nsMathMLmtdInnerFrame : public nsBlockFrame,
michael@0 219 public nsMathMLFrame {
michael@0 220 public:
michael@0 221 friend nsIFrame* NS_NewMathMLmtdInnerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
michael@0 222
michael@0 223 NS_DECL_QUERYFRAME
michael@0 224 NS_DECL_FRAMEARENA_HELPERS
michael@0 225
michael@0 226 // Overloaded nsIMathMLFrame methods
michael@0 227
michael@0 228 NS_IMETHOD
michael@0 229 UpdatePresentationDataFromChildAt(int32_t aFirstIndex,
michael@0 230 int32_t aLastIndex,
michael@0 231 uint32_t aFlagsValues,
michael@0 232 uint32_t aFlagsToUpdate) MOZ_OVERRIDE
michael@0 233 {
michael@0 234 nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(this,
michael@0 235 aFirstIndex, aLastIndex, aFlagsValues, aFlagsToUpdate);
michael@0 236 return NS_OK;
michael@0 237 }
michael@0 238
michael@0 239 virtual nsresult
michael@0 240 Reflow(nsPresContext* aPresContext,
michael@0 241 nsHTMLReflowMetrics& aDesiredSize,
michael@0 242 const nsHTMLReflowState& aReflowState,
michael@0 243 nsReflowStatus& aStatus) MOZ_OVERRIDE;
michael@0 244
michael@0 245 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
michael@0 246 {
michael@0 247 return nsBlockFrame::IsFrameOfType(aFlags &
michael@0 248 ~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
michael@0 249 }
michael@0 250
michael@0 251 virtual const nsStyleText* StyleTextForLineLayout() MOZ_OVERRIDE;
michael@0 252 virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
michael@0 253
michael@0 254 bool
michael@0 255 IsMrowLike() MOZ_OVERRIDE {
michael@0 256 return mFrames.FirstChild() != mFrames.LastChild() ||
michael@0 257 !mFrames.FirstChild();
michael@0 258 }
michael@0 259
michael@0 260 protected:
michael@0 261 nsMathMLmtdInnerFrame(nsStyleContext* aContext);
michael@0 262 virtual ~nsMathMLmtdInnerFrame();
michael@0 263
michael@0 264 nsStyleText* mUniqueStyleText;
michael@0 265
michael@0 266 }; // class nsMathMLmtdInnerFrame
michael@0 267
michael@0 268 #endif /* nsMathMLmtableFrame_h___ */

mercurial