LCOV - code coverage report
Current view: top level - layout/mathml - nsMathMLmtableFrame.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 76 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 26 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/. */
       5             : 
       6             : #ifndef nsMathMLmtableFrame_h___
       7             : #define nsMathMLmtableFrame_h___
       8             : 
       9             : #include "mozilla/Attributes.h"
      10             : #include "nsMathMLContainerFrame.h"
      11             : #include "nsBlockFrame.h"
      12             : #include "nsTableWrapperFrame.h"
      13             : #include "nsTableRowFrame.h"
      14             : #include "nsTableCellFrame.h"
      15             : 
      16             : //
      17             : // <mtable> -- table or matrix
      18             : //
      19             : 
      20             : class nsMathMLmtableWrapperFrame final
      21             :   : public nsTableWrapperFrame
      22             :   , public nsMathMLFrame
      23             : {
      24             : public:
      25             :   friend nsContainerFrame*
      26             :   NS_NewMathMLmtableOuterFrame(nsIPresShell*   aPresShell,
      27             :                                nsStyleContext* aContext);
      28             : 
      29             :   NS_DECL_QUERYFRAME
      30           0 :   NS_DECL_FRAMEARENA_HELPERS(nsMathMLmtableWrapperFrame)
      31             : 
      32             :   // overloaded nsTableWrapperFrame methods
      33             : 
      34             :   virtual void
      35             :   Reflow(nsPresContext*           aPresContext,
      36             :          ReflowOutput&     aDesiredSize,
      37             :          const ReflowInput& aReflowInput,
      38             :          nsReflowStatus&          aStatus) override;
      39             : 
      40             :   virtual nsresult
      41             :   AttributeChanged(int32_t  aNameSpaceID,
      42             :                    nsIAtom* aAttribute,
      43             :                    int32_t  aModType) override;
      44             : 
      45           0 :   virtual bool IsFrameOfType(uint32_t aFlags) const override
      46             :   {
      47           0 :     return nsTableWrapperFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
      48             :   }
      49             : 
      50             : protected:
      51           0 :   explicit nsMathMLmtableWrapperFrame(nsStyleContext* aContext)
      52           0 :     : nsTableWrapperFrame(aContext, kClassID)
      53           0 :   {}
      54             : 
      55             :   virtual ~nsMathMLmtableWrapperFrame();
      56             : 
      57             :   // helper to find the row frame at a given index, positive or negative, e.g.,
      58             :   // 1..n means the first row down to the last row, -1..-n means the last row
      59             :   // up to the first row. Used for alignments that are relative to a given row
      60             :   nsIFrame*
      61             :   GetRowFrameAt(int32_t aRowIndex);
      62             : }; // class nsMathMLmtableWrapperFrame
      63             : 
      64             : // --------------
      65             : 
      66             : class nsMathMLmtableFrame final : public nsTableFrame
      67             : {
      68             : public:
      69             :   NS_DECL_QUERYFRAME
      70           0 :   NS_DECL_FRAMEARENA_HELPERS(nsMathMLmtableFrame)
      71             : 
      72             :   friend nsContainerFrame*
      73             :   NS_NewMathMLmtableFrame(nsIPresShell*   aPresShell,
      74             :                           nsStyleContext* aContext);
      75             : 
      76             :   // Overloaded nsTableFrame methods
      77             : 
      78             :   virtual void
      79             :   SetInitialChildList(ChildListID  aListID,
      80             :                       nsFrameList& aChildList) override;
      81             : 
      82             :   virtual void
      83           0 :   AppendFrames(ChildListID  aListID,
      84             :                nsFrameList& aFrameList) override
      85             :   {
      86           0 :     nsTableFrame::AppendFrames(aListID, aFrameList);
      87           0 :     RestyleTable();
      88           0 :   }
      89             : 
      90             :   virtual void
      91           0 :   InsertFrames(ChildListID aListID,
      92             :                nsIFrame* aPrevFrame,
      93             :                nsFrameList& aFrameList) override
      94             :   {
      95           0 :     nsTableFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
      96           0 :     RestyleTable();
      97           0 :   }
      98             : 
      99             :   virtual void
     100           0 :   RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) override
     101             :   {
     102           0 :     nsTableFrame::RemoveFrame(aListID, aOldFrame);
     103           0 :     RestyleTable();
     104           0 :   }
     105             : 
     106           0 :   virtual bool IsFrameOfType(uint32_t aFlags) const override
     107             :   {
     108           0 :     return nsTableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
     109             :   }
     110             : 
     111             :   // helper to restyle and reflow the table when a row is changed -- since MathML
     112             :   // attributes are inter-dependent and row/colspan can affect the table, it is
     113             :   // safer (albeit grossly suboptimal) to just relayout the whole thing.
     114             :   void RestyleTable();
     115             : 
     116             :   /** helper to get the column spacing style value */
     117             :   nscoord GetColSpacing(int32_t aColIndex) override;
     118             : 
     119             :   /** Sums the combined cell spacing between the columns aStartColIndex to
     120             :    *  aEndColIndex.
     121             :    */
     122             :   nscoord GetColSpacing(int32_t aStartColIndex,
     123             :                         int32_t aEndColIndex) override;
     124             : 
     125             :   /** helper to get the row spacing style value */
     126             :   nscoord GetRowSpacing(int32_t aRowIndex) override;
     127             : 
     128             :   /** Sums the combined cell spacing between the rows aStartRowIndex to
     129             :    *  aEndRowIndex.
     130             :    */
     131             :   nscoord GetRowSpacing(int32_t aStartRowIndex,
     132             :                         int32_t aEndRowIndex) override;
     133             : 
     134           0 :   void SetColSpacingArray(const nsTArray<nscoord>& aColSpacing)
     135             :   {
     136           0 :     mColSpacing = aColSpacing;
     137           0 :   }
     138             : 
     139           0 :   void SetRowSpacingArray(const nsTArray<nscoord>& aRowSpacing)
     140             :   {
     141           0 :     mRowSpacing = aRowSpacing;
     142           0 :   }
     143             : 
     144           0 :   void SetFrameSpacing(nscoord aSpacingX, nscoord aSpacingY)
     145             :   {
     146           0 :     mFrameSpacingX = aSpacingX;
     147           0 :     mFrameSpacingY = aSpacingY;
     148           0 :   }
     149             : 
     150             :   /** Determines whether the placement of table cells is determined by CSS
     151             :    * spacing based on padding and border-spacing, or one based upon the
     152             :    * rowspacing, columnspacing and framespacing attributes.  The second
     153             :    * approach is used if the user specifies at least one of those attributes.
     154             :    */
     155             :   void SetUseCSSSpacing();
     156             :   bool GetUseCSSSpacing() { return mUseCSSSpacing; }
     157             : 
     158             : protected:
     159           0 :   explicit nsMathMLmtableFrame(nsStyleContext* aContext)
     160           0 :     : nsTableFrame(aContext, kClassID)
     161             :     , mFrameSpacingX(0)
     162             :     , mFrameSpacingY(0)
     163           0 :     , mUseCSSSpacing(false)
     164           0 :   {}
     165             : 
     166             :   virtual ~nsMathMLmtableFrame();
     167             : 
     168             : private:
     169             :   nsTArray<nscoord> mColSpacing;
     170             :   nsTArray<nscoord> mRowSpacing;
     171             :   nscoord mFrameSpacingX;
     172             :   nscoord mFrameSpacingY;
     173             :   bool mUseCSSSpacing;
     174             : }; // class nsMathMLmtableFrame
     175             : 
     176             : // --------------
     177             : 
     178             : class nsMathMLmtrFrame final : public nsTableRowFrame
     179             : {
     180             : public:
     181           0 :   NS_DECL_FRAMEARENA_HELPERS(nsMathMLmtrFrame)
     182             : 
     183             :   friend nsContainerFrame*
     184             :   NS_NewMathMLmtrFrame(nsIPresShell*   aPresShell,
     185             :                        nsStyleContext* aContext);
     186             : 
     187             :   // overloaded nsTableRowFrame methods
     188             : 
     189             :   virtual nsresult
     190             :   AttributeChanged(int32_t  aNameSpaceID,
     191             :                    nsIAtom* aAttribute,
     192             :                    int32_t  aModType) override;
     193             : 
     194             :   virtual void
     195           0 :   AppendFrames(ChildListID  aListID,
     196             :                nsFrameList& aFrameList) override
     197             :   {
     198           0 :     nsTableRowFrame::AppendFrames(aListID, aFrameList);
     199           0 :     RestyleTable();
     200           0 :   }
     201             : 
     202             :   virtual void
     203           0 :   InsertFrames(ChildListID  aListID,
     204             :                nsIFrame*    aPrevFrame,
     205             :                nsFrameList& aFrameList) override
     206             :   {
     207           0 :     nsTableRowFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
     208           0 :     RestyleTable();
     209           0 :   }
     210             : 
     211             :   virtual void
     212           0 :   RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) override
     213             :   {
     214           0 :     nsTableRowFrame::RemoveFrame(aListID, aOldFrame);
     215           0 :     RestyleTable();
     216           0 :   }
     217             : 
     218           0 :   virtual bool IsFrameOfType(uint32_t aFlags) const override
     219             :   {
     220           0 :     return nsTableRowFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
     221             :   }
     222             : 
     223             :   // helper to restyle and reflow the table -- @see nsMathMLmtableFrame.
     224           0 :   void RestyleTable()
     225             :   {
     226           0 :     nsTableFrame* tableFrame = GetTableFrame();
     227           0 :     if (tableFrame && tableFrame->IsFrameOfType(nsIFrame::eMathML)) {
     228             :       // relayout the table
     229           0 :       ((nsMathMLmtableFrame*)tableFrame)->RestyleTable();
     230             :     }
     231           0 :   }
     232             : 
     233             : protected:
     234           0 :   explicit nsMathMLmtrFrame(nsStyleContext* aContext)
     235           0 :     : nsTableRowFrame(aContext, kClassID)
     236           0 :   {}
     237             : 
     238             :   virtual ~nsMathMLmtrFrame();
     239             : }; // class nsMathMLmtrFrame
     240             : 
     241             : // --------------
     242             : 
     243             : class nsMathMLmtdFrame : public nsTableCellFrame
     244             : {
     245             : public:
     246           0 :   NS_DECL_FRAMEARENA_HELPERS(nsMathMLmtdFrame)
     247             : 
     248             :   friend nsContainerFrame*
     249             :   NS_NewMathMLmtdFrame(nsIPresShell*   aPresShell,
     250             :                        nsStyleContext* aContext,
     251             :                        nsTableFrame*   aTableFrame);
     252             : 
     253             :   // overloaded nsTableCellFrame methods
     254             : 
     255             :   virtual void Init(nsIContent*       aContent,
     256             :                     nsContainerFrame* aParent,
     257             :                     nsIFrame*         aPrevInFlow) override;
     258             : 
     259             :   virtual nsresult
     260             :   AttributeChanged(int32_t  aNameSpaceID,
     261             :                    nsIAtom* aAttribute,
     262             :                    int32_t  aModType) override;
     263             : 
     264             :   virtual uint8_t GetVerticalAlign() const override;
     265             :   virtual nsresult ProcessBorders(nsTableFrame*           aFrame,
     266             :                                   nsDisplayListBuilder*   aBuilder,
     267             :                                   const nsDisplayListSet& aLists) override;
     268             : 
     269           0 :   virtual bool IsFrameOfType(uint32_t aFlags) const override
     270             :   {
     271           0 :     return nsTableCellFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
     272             :   }
     273             : 
     274             :   virtual LogicalMargin GetBorderWidth(WritingMode aWM) const override;
     275             : 
     276             :   virtual nsMargin GetBorderOverflow() override;
     277             : 
     278             : protected:
     279           0 :   nsMathMLmtdFrame(nsStyleContext* aContext, nsTableFrame* aTableFrame)
     280           0 :     : nsTableCellFrame(aContext, aTableFrame, kClassID)
     281             :   {
     282           0 :   }
     283             : 
     284             :   virtual ~nsMathMLmtdFrame();
     285             : }; // class nsMathMLmtdFrame
     286             : 
     287             : // --------------
     288             : 
     289             : class nsMathMLmtdInnerFrame final
     290             :   : public nsBlockFrame
     291             :   , public nsMathMLFrame
     292             : {
     293             : public:
     294             :   friend nsContainerFrame*
     295             :   NS_NewMathMLmtdInnerFrame(nsIPresShell*   aPresShell,
     296             :                             nsStyleContext* aContext);
     297             : 
     298             :   NS_DECL_QUERYFRAME
     299           0 :   NS_DECL_FRAMEARENA_HELPERS(nsMathMLmtdInnerFrame)
     300             : 
     301             :   // Overloaded nsIMathMLFrame methods
     302             : 
     303             :   NS_IMETHOD
     304           0 :   UpdatePresentationDataFromChildAt(int32_t  aFirstIndex,
     305             :                                     int32_t  aLastIndex,
     306             :                                     uint32_t aFlagsValues,
     307             :                                     uint32_t aFlagsToUpdate) override
     308             :   {
     309           0 :     nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(this,
     310           0 :       aFirstIndex, aLastIndex, aFlagsValues, aFlagsToUpdate);
     311           0 :     return NS_OK;
     312             :   }
     313             : 
     314             :   virtual void
     315             :   Reflow(nsPresContext*           aPresContext,
     316             :          ReflowOutput&     aDesiredSize,
     317             :          const ReflowInput& aReflowInput,
     318             :          nsReflowStatus&          aStatus) override;
     319             : 
     320           0 :   virtual bool IsFrameOfType(uint32_t aFlags) const override
     321             :   {
     322           0 :     return nsBlockFrame::IsFrameOfType(aFlags &
     323           0 :       ~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
     324             :   }
     325             : 
     326             :   virtual const nsStyleText* StyleTextForLineLayout() override;
     327             :   virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) override;
     328             : 
     329             :   bool
     330           0 :   IsMrowLike() override
     331             :   {
     332           0 :     return mFrames.FirstChild() !=
     333           0 :            mFrames.LastChild() ||
     334           0 :            !mFrames.FirstChild();
     335             :   }
     336             : 
     337             : protected:
     338             :   explicit nsMathMLmtdInnerFrame(nsStyleContext* aContext);
     339             :   virtual ~nsMathMLmtdInnerFrame();
     340             : 
     341             :   nsStyleText* mUniqueStyleText;
     342             : 
     343             : };  // class nsMathMLmtdInnerFrame
     344             : 
     345             : #endif /* nsMathMLmtableFrame_h___ */

Generated by: LCOV version 1.13