LCOV - code coverage report
Current view: top level - layout/tables - nsTableWrapperFrame.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 49 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 14 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             : #ifndef nsTableWrapperFrame_h__
       6             : #define nsTableWrapperFrame_h__
       7             : 
       8             : #include "mozilla/Attributes.h"
       9             : #include "mozilla/Maybe.h"
      10             : #include "nscore.h"
      11             : #include "nsContainerFrame.h"
      12             : #include "nsCellMap.h"
      13             : #include "nsTableFrame.h"
      14             : 
      15             : /**
      16             :  * Primary frame for a table element,
      17             :  * the nsTableWrapperFrame contains 0 or one caption frame, and a nsTableFrame
      18             :  * pseudo-frame (referred to as the "inner frame').
      19             :  */
      20             : class nsTableWrapperFrame : public nsContainerFrame
      21             : {
      22             : public:
      23             :   NS_DECL_QUERYFRAME
      24           0 :   NS_DECL_FRAMEARENA_HELPERS(nsTableWrapperFrame)
      25             : 
      26             :   /** instantiate a new instance of nsTableRowFrame.
      27             :     * @param aPresShell the pres shell for this frame
      28             :     *
      29             :     * @return           the frame that was created
      30             :     */
      31             :   friend nsTableWrapperFrame* NS_NewTableWrapperFrame(nsIPresShell* aPresShell,
      32             :                                                       nsStyleContext* aContext);
      33             : 
      34             :   // nsIFrame overrides - see there for a description
      35             : 
      36             :   virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
      37             : 
      38             :   virtual const nsFrameList& GetChildList(ChildListID aListID) const override;
      39             :   virtual void GetChildLists(nsTArray<ChildList>* aLists) const override;
      40             : 
      41             :   virtual void SetInitialChildList(ChildListID     aListID,
      42             :                                    nsFrameList&    aChildList) override;
      43             :   virtual void AppendFrames(ChildListID     aListID,
      44             :                             nsFrameList&    aFrameList) override;
      45             :   virtual void InsertFrames(ChildListID     aListID,
      46             :                             nsIFrame*       aPrevFrame,
      47             :                             nsFrameList&    aFrameList) override;
      48             :   virtual void RemoveFrame(ChildListID     aListID,
      49             :                            nsIFrame*       aOldFrame) override;
      50             : 
      51           0 :   virtual nsContainerFrame* GetContentInsertionFrame() override {
      52           0 :     return PrincipalChildList().FirstChild()->GetContentInsertionFrame();
      53             :   }
      54             : 
      55             : #ifdef ACCESSIBILITY
      56             :   virtual mozilla::a11y::AccType AccessibleType() override;
      57             : #endif
      58             : 
      59             :   virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
      60             :                                 const nsRect&           aDirtyRect,
      61             :                                 const nsDisplayListSet& aLists) override;
      62             : 
      63             :   void BuildDisplayListForInnerTable(nsDisplayListBuilder*   aBuilder,
      64             :                                      const nsRect&           aDirtyRect,
      65             :                                      const nsDisplayListSet& aLists);
      66             : 
      67             :   virtual nscoord GetLogicalBaseline(mozilla::WritingMode aWritingMode) const override;
      68             : 
      69           0 :   bool GetNaturalBaselineBOffset(mozilla::WritingMode aWM,
      70             :                                  BaselineSharingGroup aBaselineGroup,
      71             :                                  nscoord*             aBaseline) const override
      72             :   {
      73           0 :     auto innerTable = InnerTableFrame();
      74             :     nscoord offset;
      75           0 :     if (innerTable->GetNaturalBaselineBOffset(aWM, aBaselineGroup, &offset)) {
      76           0 :       auto bStart = innerTable->BStart(aWM, mRect.Size());
      77           0 :       if (aBaselineGroup == BaselineSharingGroup::eFirst) {
      78           0 :         *aBaseline = offset + bStart;
      79             :       } else {
      80           0 :         auto bEnd = bStart + innerTable->BSize(aWM);
      81           0 :         *aBaseline = BSize(aWM) - (bEnd - offset);
      82             :       }
      83           0 :       return true;
      84             :     }
      85           0 :     return false;
      86             :   }
      87             : 
      88             :   virtual nscoord GetMinISize(gfxContext *aRenderingContext) override;
      89             :   virtual nscoord GetPrefISize(gfxContext *aRenderingContext) override;
      90             : 
      91             :   virtual mozilla::LogicalSize
      92             :   ComputeAutoSize(gfxContext*                 aRenderingContext,
      93             :                   mozilla::WritingMode        aWM,
      94             :                   const mozilla::LogicalSize& aCBSize,
      95             :                   nscoord                     aAvailableISize,
      96             :                   const mozilla::LogicalSize& aMargin,
      97             :                   const mozilla::LogicalSize& aBorder,
      98             :                   const mozilla::LogicalSize& aPadding,
      99             :                   ComputeSizeFlags            aFlags) override;
     100             : 
     101             :   /** process a reflow command for the table.
     102             :     * This involves reflowing the caption and the inner table.
     103             :     * @see nsIFrame::Reflow */
     104             :   virtual void Reflow(nsPresContext*           aPresContext,
     105             :                       ReflowOutput&     aDesiredSize,
     106             :                       const ReflowInput& aReflowInput,
     107             :                       nsReflowStatus&          aStatus) override;
     108             : 
     109             : #ifdef DEBUG_FRAME_DUMP
     110             :   virtual nsresult GetFrameName(nsAString& aResult) const override;
     111             : #endif
     112             : 
     113             :   virtual nsStyleContext* GetParentStyleContext(nsIFrame** aProviderFrame) const override;
     114             : 
     115             :   /**
     116             :    * Return the content for the cell at the given row and column.
     117             :    */
     118             :   nsIContent* GetCellAt(uint32_t aRowIdx, uint32_t aColIdx) const;
     119             : 
     120             :   /**
     121             :    * Return the number of rows in the table.
     122             :    */
     123           0 :   int32_t GetRowCount() const
     124             :   {
     125           0 :     return InnerTableFrame()->GetRowCount();
     126             :   }
     127             : 
     128             :   /**
     129             :    * Return the number of columns in the table.
     130             :    */
     131           0 :   int32_t GetColCount() const
     132             :   {
     133           0 :     return InnerTableFrame()->GetColCount();
     134             :   }
     135             : 
     136             :   /**
     137             :    * Return the index of the cell at the given row and column.
     138             :    */
     139           0 :   int32_t GetIndexByRowAndColumn(int32_t aRowIdx, int32_t aColIdx) const
     140             :   {
     141           0 :     nsTableCellMap* cellMap = InnerTableFrame()->GetCellMap();
     142           0 :     if (!cellMap)
     143           0 :       return -1;
     144             : 
     145           0 :     return cellMap->GetIndexByRowAndColumn(aRowIdx, aColIdx);
     146             :   }
     147             : 
     148             :   /**
     149             :    * Get the row and column indices for the cell at the given index.
     150             :    */
     151           0 :   void GetRowAndColumnByIndex(int32_t aCellIdx, int32_t* aRowIdx,
     152             :                               int32_t* aColIdx) const
     153             :   {
     154           0 :     *aRowIdx = *aColIdx = 0;
     155           0 :     nsTableCellMap* cellMap = InnerTableFrame()->GetCellMap();
     156           0 :     if (cellMap) {
     157           0 :       cellMap->GetRowAndColumnByIndex(aCellIdx, aRowIdx, aColIdx);
     158             :     }
     159           0 :   }
     160             : 
     161             :   /**
     162             :    * return the frame for the cell at the given row and column.
     163             :    */
     164           0 :   nsTableCellFrame* GetCellFrameAt(uint32_t aRowIdx, uint32_t aColIdx) const
     165             :   {
     166           0 :     nsTableCellMap* map = InnerTableFrame()->GetCellMap();
     167           0 :     if (!map) {
     168           0 :       return nullptr;
     169             :     }
     170             : 
     171           0 :     return map->GetCellInfoAt(aRowIdx, aColIdx);
     172             :   }
     173             : 
     174             :   /**
     175             :    * Return the col span of the cell at the given row and column indices.
     176             :    */
     177           0 :   uint32_t GetEffectiveColSpanAt(uint32_t aRowIdx, uint32_t aColIdx) const
     178             :   {
     179           0 :     nsTableCellMap* map = InnerTableFrame()->GetCellMap();
     180           0 :     return map->GetEffectiveColSpan(aRowIdx, aColIdx);
     181             :   }
     182             : 
     183             :   /**
     184             :    * Return the effective row span of the cell at the given row and column.
     185             :    */
     186           0 :   uint32_t GetEffectiveRowSpanAt(uint32_t aRowIdx, uint32_t aColIdx) const
     187             :   {
     188           0 :     nsTableCellMap* map = InnerTableFrame()->GetCellMap();
     189           0 :     return map->GetEffectiveRowSpan(aRowIdx, aColIdx);
     190             :   }
     191             : 
     192             :   /**
     193             :    * The CB size to use for the inner table frame if we're a grid item.
     194             :    */
     195           0 :   NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridItemCBSizeProperty, mozilla::LogicalSize);
     196             : 
     197             : protected:
     198             : 
     199             :   explicit nsTableWrapperFrame(nsStyleContext* aContext, ClassID aID = kClassID);
     200             :   virtual ~nsTableWrapperFrame();
     201             : 
     202             :   void InitChildReflowInput(nsPresContext&     aPresContext,
     203             :                             const ReflowInput& aOuterRS,
     204             :                             ReflowInput& aReflowInput);
     205             : 
     206             :   // Get a NS_STYLE_CAPTION_SIDE_* value, or NO_SIDE if no caption is present.
     207             :   // (Remember that caption-side values are interpreted logically, despite
     208             :   // having "physical" names.)
     209             :   uint8_t GetCaptionSide();
     210             : 
     211           0 :   bool HasSideCaption() {
     212           0 :     uint8_t captionSide = GetCaptionSide();
     213           0 :     return captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
     214           0 :            captionSide == NS_STYLE_CAPTION_SIDE_RIGHT;
     215             :   }
     216             : 
     217             :   uint8_t GetCaptionVerticalAlign();
     218             : 
     219             :   void SetDesiredSize(uint8_t                       aCaptionSide,
     220             :                       const mozilla::LogicalSize&   aInnerSize,
     221             :                       const mozilla::LogicalSize&   aCaptionSize,
     222             :                       const mozilla::LogicalMargin& aInnerMargin,
     223             :                       const mozilla::LogicalMargin& aCaptionMargin,
     224             :                       nscoord&                      aISize,
     225             :                       nscoord&                      aBSize,
     226             :                       mozilla::WritingMode          aWM);
     227             : 
     228             :   nsresult   GetCaptionOrigin(uint32_t         aCaptionSide,
     229             :                               const mozilla::LogicalSize&    aContainBlockSize,
     230             :                               const mozilla::LogicalSize&    aInnerSize,
     231             :                               const mozilla::LogicalMargin&  aInnerMargin,
     232             :                               const mozilla::LogicalSize&    aCaptionSize,
     233             :                               mozilla::LogicalMargin&        aCaptionMargin,
     234             :                               mozilla::LogicalPoint&         aOrigin,
     235             :                               mozilla::WritingMode           aWM);
     236             : 
     237             :   nsresult   GetInnerOrigin(uint32_t         aCaptionSide,
     238             :                             const mozilla::LogicalSize&    aContainBlockSize,
     239             :                             const mozilla::LogicalSize&    aCaptionSize,
     240             :                             const mozilla::LogicalMargin&  aCaptionMargin,
     241             :                             const mozilla::LogicalSize&    aInnerSize,
     242             :                             mozilla::LogicalMargin&        aInnerMargin,
     243             :                             mozilla::LogicalPoint&         aOrigin,
     244             :                             mozilla::WritingMode           aWM);
     245             : 
     246             :   // reflow the child (caption or innertable frame)
     247             :   void OuterBeginReflowChild(nsPresContext*                     aPresContext,
     248             :                              nsIFrame*                          aChildFrame,
     249             :                              const ReflowInput&           aOuterRI,
     250             :                              mozilla::Maybe<ReflowInput>& aChildRI,
     251             :                              nscoord                            aAvailISize);
     252             : 
     253             :   void OuterDoReflowChild(nsPresContext*           aPresContext,
     254             :                           nsIFrame*                aChildFrame,
     255             :                           const ReflowInput& aChildRI,
     256             :                           ReflowOutput&     aMetrics,
     257             :                           nsReflowStatus&          aStatus);
     258             : 
     259             :   // Set the overflow areas in our reflow metrics
     260             :   void UpdateOverflowAreas(ReflowOutput& aMet);
     261             : 
     262             :   // Get the margin.
     263             :   void GetChildMargin(nsPresContext*           aPresContext,
     264             :                       const ReflowInput& aOuterRI,
     265             :                       nsIFrame*                aChildFrame,
     266             :                       nscoord                  aAvailableWidth,
     267             :                       mozilla::LogicalMargin&  aMargin);
     268             : 
     269           0 :   virtual bool IsFrameOfType(uint32_t aFlags) const override
     270             :   {
     271           0 :     return nsContainerFrame::IsFrameOfType(aFlags &
     272           0 :                                            (~eCanContainOverflowContainers));
     273             :   }
     274             : 
     275           0 :   nsTableFrame* InnerTableFrame() const
     276             :   {
     277           0 :     return static_cast<nsTableFrame*>(mFrames.FirstChild());
     278             :   }
     279             : 
     280             :   /**
     281             :    * Helper for ComputeAutoSize.
     282             :    * Compute the margin-box inline size of aChildFrame given the inputs.
     283             :    * If aMarginResult is non-null, fill it with the part of the
     284             :    * margin-isize that was contributed by the margin.
     285             :    */
     286             :   nscoord ChildShrinkWrapISize(gfxContext*          aRenderingContext,
     287             :                                nsIFrame*            aChildFrame,
     288             :                                mozilla::WritingMode aWM,
     289             :                                mozilla::LogicalSize aCBSize,
     290             :                                nscoord              aAvailableISize,
     291             :                                nscoord*             aMarginResult = nullptr) const;
     292             : 
     293             : private:
     294             :   nsFrameList   mCaptionFrames;
     295             : };
     296             : 
     297             : #endif

Generated by: LCOV version 1.13