michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsMathMLmtableFrame_h___ michael@0: #define nsMathMLmtableFrame_h___ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsMathMLContainerFrame.h" michael@0: #include "nsBlockFrame.h" michael@0: #include "nsTableOuterFrame.h" michael@0: #include "nsTableRowFrame.h" michael@0: #include "nsTableCellFrame.h" michael@0: michael@0: // michael@0: // -- table or matrix michael@0: // michael@0: michael@0: class nsMathMLmtableOuterFrame : public nsTableOuterFrame, michael@0: public nsMathMLFrame michael@0: { michael@0: public: michael@0: friend nsIFrame* NS_NewMathMLmtableOuterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); michael@0: michael@0: NS_DECL_QUERYFRAME michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: // overloaded nsTableOuterFrame methods michael@0: michael@0: virtual nsresult michael@0: Reflow(nsPresContext* aPresContext, michael@0: nsHTMLReflowMetrics& aDesiredSize, michael@0: const nsHTMLReflowState& aReflowState, michael@0: nsReflowStatus& aStatus) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult michael@0: AttributeChanged(int32_t aNameSpaceID, michael@0: nsIAtom* aAttribute, michael@0: int32_t aModType) MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE michael@0: { michael@0: return nsTableOuterFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML)); michael@0: } michael@0: michael@0: protected: michael@0: nsMathMLmtableOuterFrame(nsStyleContext* aContext) : nsTableOuterFrame(aContext) {} michael@0: virtual ~nsMathMLmtableOuterFrame(); michael@0: michael@0: // helper to find the row frame at a given index, positive or negative, e.g., michael@0: // 1..n means the first row down to the last row, -1..-n means the last row michael@0: // up to the first row. Used for alignments that are relative to a given row michael@0: nsIFrame* michael@0: GetRowFrameAt(nsPresContext* aPresContext, michael@0: int32_t aRowIndex); michael@0: }; // class nsMathMLmtableOuterFrame michael@0: michael@0: // -------------- michael@0: michael@0: class nsMathMLmtableFrame : public nsTableFrame michael@0: { michael@0: public: michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: friend nsIFrame* NS_NewMathMLmtableFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); michael@0: michael@0: // Overloaded nsTableFrame methods michael@0: michael@0: virtual nsresult michael@0: SetInitialChildList(ChildListID aListID, michael@0: nsFrameList& aChildList) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult michael@0: AppendFrames(ChildListID aListID, michael@0: nsFrameList& aFrameList) MOZ_OVERRIDE michael@0: { michael@0: nsresult rv = nsTableFrame::AppendFrames(aListID, aFrameList); michael@0: RestyleTable(); michael@0: return rv; michael@0: } michael@0: michael@0: virtual nsresult michael@0: InsertFrames(ChildListID aListID, michael@0: nsIFrame* aPrevFrame, michael@0: nsFrameList& aFrameList) MOZ_OVERRIDE michael@0: { michael@0: nsresult rv = nsTableFrame::InsertFrames(aListID, aPrevFrame, aFrameList); michael@0: RestyleTable(); michael@0: return rv; michael@0: } michael@0: michael@0: virtual nsresult michael@0: RemoveFrame(ChildListID aListID, michael@0: nsIFrame* aOldFrame) MOZ_OVERRIDE michael@0: { michael@0: nsresult rv = nsTableFrame::RemoveFrame(aListID, aOldFrame); michael@0: RestyleTable(); michael@0: return rv; michael@0: } michael@0: michael@0: virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE michael@0: { michael@0: return nsTableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML)); michael@0: } michael@0: michael@0: // helper to restyle and reflow the table when a row is changed -- since MathML michael@0: // attributes are inter-dependent and row/colspan can affect the table, it is michael@0: // safer (albeit grossly suboptimal) to just relayout the whole thing. michael@0: void RestyleTable(); michael@0: michael@0: protected: michael@0: nsMathMLmtableFrame(nsStyleContext* aContext) : nsTableFrame(aContext) {} michael@0: virtual ~nsMathMLmtableFrame(); michael@0: }; // class nsMathMLmtableFrame michael@0: michael@0: // -------------- michael@0: michael@0: class nsMathMLmtrFrame : public nsTableRowFrame michael@0: { michael@0: public: michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: friend nsIFrame* NS_NewMathMLmtrFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); michael@0: michael@0: // overloaded nsTableRowFrame methods michael@0: michael@0: virtual nsresult michael@0: AttributeChanged(int32_t aNameSpaceID, michael@0: nsIAtom* aAttribute, michael@0: int32_t aModType) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult michael@0: AppendFrames(ChildListID aListID, michael@0: nsFrameList& aFrameList) MOZ_OVERRIDE michael@0: { michael@0: nsresult rv = nsTableRowFrame::AppendFrames(aListID, aFrameList); michael@0: RestyleTable(); michael@0: return rv; michael@0: } michael@0: michael@0: virtual nsresult michael@0: InsertFrames(ChildListID aListID, michael@0: nsIFrame* aPrevFrame, michael@0: nsFrameList& aFrameList) MOZ_OVERRIDE michael@0: { michael@0: nsresult rv = nsTableRowFrame::InsertFrames(aListID, aPrevFrame, aFrameList); michael@0: RestyleTable(); michael@0: return rv; michael@0: } michael@0: michael@0: virtual nsresult michael@0: RemoveFrame(ChildListID aListID, michael@0: nsIFrame* aOldFrame) MOZ_OVERRIDE michael@0: { michael@0: nsresult rv = nsTableRowFrame::RemoveFrame(aListID, aOldFrame); michael@0: RestyleTable(); michael@0: return rv; michael@0: } michael@0: michael@0: virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE michael@0: { michael@0: return nsTableRowFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML)); michael@0: } michael@0: michael@0: // helper to restyle and reflow the table -- @see nsMathMLmtableFrame. michael@0: void RestyleTable() michael@0: { michael@0: nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this); michael@0: if (tableFrame && tableFrame->IsFrameOfType(nsIFrame::eMathML)) { michael@0: // relayout the table michael@0: ((nsMathMLmtableFrame*)tableFrame)->RestyleTable(); michael@0: } michael@0: } michael@0: michael@0: protected: michael@0: nsMathMLmtrFrame(nsStyleContext* aContext) : nsTableRowFrame(aContext) {} michael@0: virtual ~nsMathMLmtrFrame(); michael@0: }; // class nsMathMLmtrFrame michael@0: michael@0: // -------------- michael@0: michael@0: class nsMathMLmtdFrame : public nsTableCellFrame michael@0: { michael@0: public: michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: friend nsIFrame* NS_NewMathMLmtdFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); michael@0: michael@0: // overloaded nsTableCellFrame methods michael@0: michael@0: virtual nsresult michael@0: AttributeChanged(int32_t aNameSpaceID, michael@0: nsIAtom* aAttribute, michael@0: int32_t aModType) MOZ_OVERRIDE; michael@0: michael@0: virtual uint8_t GetVerticalAlign() const MOZ_OVERRIDE; michael@0: virtual nsresult ProcessBorders(nsTableFrame* aFrame, michael@0: nsDisplayListBuilder* aBuilder, michael@0: const nsDisplayListSet& aLists) MOZ_OVERRIDE; michael@0: michael@0: virtual int32_t GetRowSpan() MOZ_OVERRIDE; michael@0: virtual int32_t GetColSpan() MOZ_OVERRIDE; michael@0: virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE michael@0: { michael@0: return nsTableCellFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML)); michael@0: } michael@0: michael@0: virtual nsMargin* GetBorderWidth(nsMargin& aBorder) const MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: nsMathMLmtdFrame(nsStyleContext* aContext) : nsTableCellFrame(aContext) {} michael@0: virtual ~nsMathMLmtdFrame(); michael@0: }; // class nsMathMLmtdFrame michael@0: michael@0: // -------------- michael@0: michael@0: class nsMathMLmtdInnerFrame : public nsBlockFrame, michael@0: public nsMathMLFrame { michael@0: public: michael@0: friend nsIFrame* NS_NewMathMLmtdInnerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); michael@0: michael@0: NS_DECL_QUERYFRAME michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: // Overloaded nsIMathMLFrame methods michael@0: michael@0: NS_IMETHOD michael@0: UpdatePresentationDataFromChildAt(int32_t aFirstIndex, michael@0: int32_t aLastIndex, michael@0: uint32_t aFlagsValues, michael@0: uint32_t aFlagsToUpdate) MOZ_OVERRIDE michael@0: { michael@0: nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(this, michael@0: aFirstIndex, aLastIndex, aFlagsValues, aFlagsToUpdate); michael@0: return NS_OK; michael@0: } michael@0: michael@0: virtual nsresult michael@0: Reflow(nsPresContext* aPresContext, michael@0: nsHTMLReflowMetrics& aDesiredSize, michael@0: const nsHTMLReflowState& aReflowState, michael@0: nsReflowStatus& aStatus) MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE michael@0: { michael@0: return nsBlockFrame::IsFrameOfType(aFlags & michael@0: ~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace)); michael@0: } michael@0: michael@0: virtual const nsStyleText* StyleTextForLineLayout() MOZ_OVERRIDE; michael@0: virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE; michael@0: michael@0: bool michael@0: IsMrowLike() MOZ_OVERRIDE { michael@0: return mFrames.FirstChild() != mFrames.LastChild() || michael@0: !mFrames.FirstChild(); michael@0: } michael@0: michael@0: protected: michael@0: nsMathMLmtdInnerFrame(nsStyleContext* aContext); michael@0: virtual ~nsMathMLmtdInnerFrame(); michael@0: michael@0: nsStyleText* mUniqueStyleText; michael@0: michael@0: }; // class nsMathMLmtdInnerFrame michael@0: michael@0: #endif /* nsMathMLmtableFrame_h___ */