layout/tables/nsTableOuterFrame.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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 nsTableOuterFrame_h__
     6 #define nsTableOuterFrame_h__
     8 #include "mozilla/Attributes.h"
     9 #include "nscore.h"
    10 #include "nsContainerFrame.h"
    11 #include "nsCellMap.h"
    12 #include "nsBlockFrame.h"
    13 #include "nsTableFrame.h"
    15 class nsTableCaptionFrame : public nsBlockFrame
    16 {
    17 public:
    18   NS_DECL_FRAMEARENA_HELPERS
    20   // nsISupports
    21   virtual nsIAtom* GetType() const MOZ_OVERRIDE;
    22   friend nsIFrame* NS_NewTableCaptionFrame(nsIPresShell* aPresShell, nsStyleContext*  aContext);
    24   virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
    25                                  nsSize aCBSize, nscoord aAvailableWidth,
    26                                  nsSize aMargin, nsSize aBorder,
    27                                  nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE;
    29   virtual nsIFrame* GetParentStyleContextFrame() const MOZ_OVERRIDE;
    31 #ifdef ACCESSIBILITY
    32   virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
    33 #endif
    35 #ifdef DEBUG_FRAME_DUMP
    36   virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
    37 #endif
    39 protected:
    40   nsTableCaptionFrame(nsStyleContext*  aContext);
    41   virtual ~nsTableCaptionFrame();
    42 };
    45 /* TODO
    46 1. decide if we'll allow subclassing.  If so, decide which methods really need to be virtual.
    47 */
    49 /**
    50  * main frame for an nsTable content object, 
    51  * the nsTableOuterFrame contains 0 or one caption frame, and a nsTableFrame
    52  * pseudo-frame (referred to as the "inner frame').
    53  */
    54 class nsTableOuterFrame : public nsContainerFrame
    55 {
    56 public:
    57   NS_DECL_QUERYFRAME
    58   NS_DECL_FRAMEARENA_HELPERS
    60   NS_DECL_QUERYFRAME_TARGET(nsTableOuterFrame)
    62   /** instantiate a new instance of nsTableRowFrame.
    63     * @param aPresShell the pres shell for this frame
    64     *
    65     * @return           the frame that was created
    66     */
    67   friend nsIFrame* NS_NewTableOuterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
    69   // nsIFrame overrides - see there for a description
    71   virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
    73   virtual nsresult SetInitialChildList(ChildListID     aListID,
    74                                        nsFrameList&    aChildList) MOZ_OVERRIDE;
    76   virtual const nsFrameList& GetChildList(ChildListID aListID) const MOZ_OVERRIDE;
    77   virtual void GetChildLists(nsTArray<ChildList>* aLists) const MOZ_OVERRIDE;
    79   virtual nsresult AppendFrames(ChildListID     aListID,
    80                                 nsFrameList&    aFrameList) MOZ_OVERRIDE;
    82   virtual nsresult InsertFrames(ChildListID     aListID,
    83                                 nsIFrame*       aPrevFrame,
    84                                 nsFrameList&    aFrameList) MOZ_OVERRIDE;
    86   virtual nsresult RemoveFrame(ChildListID     aListID,
    87                                nsIFrame*       aOldFrame) MOZ_OVERRIDE;
    89   virtual nsIFrame* GetContentInsertionFrame() MOZ_OVERRIDE {
    90     return GetFirstPrincipalChild()->GetContentInsertionFrame();
    91   }
    93 #ifdef ACCESSIBILITY
    94   virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
    95 #endif
    97   virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
    98                                 const nsRect&           aDirtyRect,
    99                                 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
   101   void BuildDisplayListForInnerTable(nsDisplayListBuilder*   aBuilder,
   102                                      const nsRect&           aDirtyRect,
   103                                      const nsDisplayListSet& aLists);
   105   virtual nscoord GetBaseline() const MOZ_OVERRIDE;
   107   virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
   108   virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
   109   virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
   110                                  nsSize aCBSize, nscoord aAvailableWidth,
   111                                  nsSize aMargin, nsSize aBorder,
   112                                  nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE;
   114   /** process a reflow command for the table.
   115     * This involves reflowing the caption and the inner table.
   116     * @see nsIFrame::Reflow */
   117   virtual nsresult Reflow(nsPresContext*          aPresContext,
   118                           nsHTMLReflowMetrics&     aDesiredSize,
   119                           const nsHTMLReflowState& aReflowState,
   120                           nsReflowStatus&          aStatus) MOZ_OVERRIDE;
   122   /**
   123    * Get the "type" of the frame
   124    *
   125    * @see nsGkAtoms::tableOuterFrame
   126    */
   127   virtual nsIAtom* GetType() const MOZ_OVERRIDE;
   129 #ifdef DEBUG_FRAME_DUMP
   130   virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
   131 #endif
   133   virtual nsIFrame* GetParentStyleContextFrame() const MOZ_OVERRIDE;
   135   /**
   136    * Return the content for the cell at the given row and column.
   137    */
   138   nsIContent* GetCellAt(uint32_t aRowIdx, uint32_t aColIdx) const;
   140   /**
   141    * Return the number of rows in the table.
   142    */
   143   int32_t GetRowCount() const
   144   {
   145     return InnerTableFrame()->GetRowCount();
   146   }
   148   /**
   149    * Return the number of columns in the table.
   150    */
   151   int32_t GetColCount() const
   152   {
   153     return InnerTableFrame()->GetColCount();
   154   }
   156   /**
   157    * Return the index of the cell at the given row and column.
   158    */
   159   int32_t GetIndexByRowAndColumn(int32_t aRowIdx, int32_t aColIdx) const
   160   {
   161     nsTableCellMap* cellMap = InnerTableFrame()->GetCellMap();
   162     if (!cellMap)
   163       return -1;
   165     return cellMap->GetIndexByRowAndColumn(aRowIdx, aColIdx);
   166   }
   168   /**
   169    * Get the row and column indices for the cell at the given index.
   170    */
   171   void GetRowAndColumnByIndex(int32_t aCellIdx, int32_t* aRowIdx,
   172                               int32_t* aColIdx) const
   173   {
   174     *aRowIdx = *aColIdx = 0;
   175     nsTableCellMap* cellMap = InnerTableFrame()->GetCellMap();
   176     if (cellMap) {
   177       cellMap->GetRowAndColumnByIndex(aCellIdx, aRowIdx, aColIdx);
   178     }
   179   }
   181   /**
   182    * return the frame for the cell at the given row and column.
   183    */
   184   nsTableCellFrame* GetCellFrameAt(uint32_t aRowIdx, uint32_t aColIdx) const
   185   {
   186     nsTableCellMap* map = InnerTableFrame()->GetCellMap();
   187     if (!map) {
   188       return nullptr;
   189     }
   191     return map->GetCellInfoAt(aRowIdx, aColIdx);
   192   }
   194   /**
   195    * Return the col span of the cell at the given row and column indices.
   196    */
   197   uint32_t GetEffectiveColSpanAt(uint32_t aRowIdx, uint32_t aColIdx) const
   198   {
   199     nsTableCellMap* map = InnerTableFrame()->GetCellMap();
   200     return map->GetEffectiveColSpan(aRowIdx, aColIdx);
   201   }
   203   /**
   204    * Return the effective row span of the cell at the given row and column.
   205    */
   206   uint32_t GetEffectiveRowSpanAt(uint32_t aRowIdx, uint32_t aColIdx) const
   207   {
   208     nsTableCellMap* map = InnerTableFrame()->GetCellMap();
   209     return map->GetEffectiveRowSpan(aRowIdx, aColIdx);
   210   }
   212 protected:
   215   nsTableOuterFrame(nsStyleContext* aContext);
   216   virtual ~nsTableOuterFrame();
   218   void InitChildReflowState(nsPresContext&    aPresContext,                     
   219                             nsHTMLReflowState& aReflowState);
   221   uint8_t GetCaptionSide(); // NS_STYLE_CAPTION_SIDE_* or NO_SIDE
   223   bool HasSideCaption() {
   224     uint8_t captionSide = GetCaptionSide();
   225     return captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
   226            captionSide == NS_STYLE_CAPTION_SIDE_RIGHT;
   227   }
   229   uint8_t GetCaptionVerticalAlign();
   231   void SetDesiredSize(uint8_t         aCaptionSide,
   232                       const nsMargin& aInnerMargin,
   233                       const nsMargin& aCaptionMargin,
   234                       nscoord&        aWidth,
   235                       nscoord&        aHeight);
   237   nsresult   GetCaptionOrigin(uint32_t         aCaptionSide,
   238                               const nsSize&    aContainBlockSize,
   239                               const nsSize&    aInnerSize, 
   240                               const nsMargin&  aInnerMargin,
   241                               const nsSize&    aCaptionSize,
   242                               nsMargin&        aCaptionMargin,
   243                               nsPoint&         aOrigin);
   245   nsresult   GetInnerOrigin(uint32_t         aCaptionSide,
   246                             const nsSize&    aContainBlockSize,
   247                             const nsSize&    aCaptionSize, 
   248                             const nsMargin&  aCaptionMargin,
   249                             const nsSize&    aInnerSize,
   250                             nsMargin&        aInnerMargin,
   251                             nsPoint&         aOrigin);
   253   // reflow the child (caption or innertable frame)
   254   void OuterBeginReflowChild(nsPresContext*           aPresContext,
   255                              nsIFrame*                aChildFrame,
   256                              const nsHTMLReflowState& aOuterRS,
   257                              void*                    aChildRSSpace,
   258                              nscoord                  aAvailWidth);
   260   nsresult OuterDoReflowChild(nsPresContext*           aPresContext,
   261                               nsIFrame*                aChildFrame,
   262                               const nsHTMLReflowState& aChildRS,
   263                               nsHTMLReflowMetrics&     aMetrics,
   264                               nsReflowStatus&          aStatus);
   266   // Set the reflow metrics
   267   void UpdateReflowMetrics(uint8_t              aCaptionSide,
   268                            nsHTMLReflowMetrics& aMet,
   269                            const nsMargin&      aInnerMargin,
   270                            const nsMargin&      aCaptionMargin);
   272   // Get the margin.  aMarginNoAuto is aMargin, but with auto 
   273   // margins set to 0
   274   void GetChildMargin(nsPresContext*           aPresContext,
   275                       const nsHTMLReflowState& aOuterRS,
   276                       nsIFrame*                aChildFrame,
   277                       nscoord                  aAvailableWidth,
   278                       nsMargin&                aMargin);
   280   virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
   281   {
   282     return nsContainerFrame::IsFrameOfType(aFlags &
   283                                            (~eCanContainOverflowContainers));
   284   }
   286   nsTableFrame* InnerTableFrame() const {
   287     return static_cast<nsTableFrame*>(mFrames.FirstChild());
   288   }
   290 private:
   291   nsFrameList   mCaptionFrames;
   292 };
   294 #endif

mercurial