layout/tables/nsTableColGroupFrame.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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 nsTableColGroupFrame_h__
     6 #define nsTableColGroupFrame_h__
     8 #include "mozilla/Attributes.h"
     9 #include "nscore.h"
    10 #include "nsContainerFrame.h"
    11 #include "nsTableColFrame.h"
    13 class nsTableFrame;
    14 class nsTableColFrame;
    16 enum nsTableColGroupType {
    17   eColGroupContent            = 0, // there is real col group content associated   
    18   eColGroupAnonymousCol       = 1, // the result of a col
    19   eColGroupAnonymousCell      = 2  // the result of a cell alone
    20 };
    22 /**
    23  * nsTableColGroupFrame
    24  * data structure to maintain information about a single table cell's frame
    25  *
    26  * @author  sclark
    27  */
    28 class nsTableColGroupFrame : public nsContainerFrame
    29 {
    30 public:
    31   NS_DECL_FRAMEARENA_HELPERS
    33   // default constructor supplied by the compiler
    35   /** instantiate a new instance of nsTableRowFrame.
    36     * @param aPresShell the pres shell for this frame
    37     *
    38     * @return           the frame that was created
    39     */
    40   friend nsIFrame* NS_NewTableColGroupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
    42   /** Initialize the colgroup frame with a set of children.
    43     * @see nsIFrame::SetInitialChildList
    44     */
    45   virtual nsresult SetInitialChildList(ChildListID     aListID,
    46                                        nsFrameList&    aChildList) MOZ_OVERRIDE;
    48   /**
    49    * ColGroups never paint anything, nor receive events.
    50    */
    51   virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
    52                                 const nsRect&           aDirtyRect,
    53                                 const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
    55   /** A colgroup can be caused by three things:
    56     * 1)	An element with table-column-group display
    57     * 2)	An element with a table-column display without a
    58 	   *    table-column-group parent
    59     * 3)	Cells that are not in a column (and hence get an anonymous
    60 	   *    column and colgroup).
    61     * @return colgroup type
    62     */
    63   nsTableColGroupType GetColType() const;
    65   /** Set the colgroup type based on the creation cause
    66     * @param aType - the reason why this colgroup is needed
    67     */
    68   void SetColType(nsTableColGroupType aType);
    70   /** Real in this context are colgroups that come from an element
    71     * with table-column-group display or wrap around columns that
    72     * come from an element with table-column display. Colgroups
    73     * that are the result of wrapping cells in an anonymous
    74     * column and colgroup are not considered real here.
    75     * @param aTableFrame - the table parent of the colgroups
    76     * @return the last real colgroup
    77     */
    78   static nsTableColGroupFrame* GetLastRealColGroup(nsTableFrame* aTableFrame);
    80   /** @see nsIFrame::DidSetStyleContext */
    81   virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
    83   /** @see nsIFrame::AppendFrames, InsertFrames, RemoveFrame
    84     */
    85   virtual nsresult AppendFrames(ChildListID     aListID,
    86                                 nsFrameList&    aFrameList) MOZ_OVERRIDE;
    87   virtual nsresult InsertFrames(ChildListID     aListID,
    88                                 nsIFrame*       aPrevFrame,
    89                                 nsFrameList&    aFrameList) MOZ_OVERRIDE;
    90   virtual nsresult RemoveFrame(ChildListID     aListID,
    91                                nsIFrame*       aOldFrame) MOZ_OVERRIDE;
    93   /** remove the column aChild from the column group, if requested renumber
    94     * the subsequent columns in this column group and all following column
    95     * groups. see also ResetColIndices for this
    96     * @param aChild       - the column frame that needs to be removed
    97     * @param aResetSubsequentColIndices - if true the columns that follow
    98     *                                     after aChild will be reenumerated
    99     */
   100   void RemoveChild(nsTableColFrame& aChild,
   101                    bool             aResetSubsequentColIndices);
   103   /** reflow of a column group is a trivial matter of reflowing
   104     * the col group's children (columns), and setting this frame
   105     * to 0-size.  Since tables are row-centric, column group frames
   106     * don't play directly in the rendering game.  They do however
   107     * maintain important state that effects table and cell layout.
   108     */
   109   virtual nsresult Reflow(nsPresContext*          aPresContext,
   110                           nsHTMLReflowMetrics&     aDesiredSize,
   111                           const nsHTMLReflowState& aReflowState,
   112                           nsReflowStatus&          aStatus) MOZ_OVERRIDE;
   114   /**
   115    * Get the "type" of the frame
   116    *
   117    * @see nsGkAtoms::tableColGroupFrame
   118    */
   119   virtual nsIAtom* GetType() const MOZ_OVERRIDE;
   121   /** Add column frames to the table storages: colframe cache and cellmap
   122     * this doesn't change the mFrames of the colgroup frame.
   123     * @param aFirstColIndex - the index at which aFirstFrame should be inserted
   124     *                         into the colframe cache.
   125     * @param aResetSubsequentColIndices - the indices of the col frames
   126     *                                     after the insertion might need
   127     *                                     an update
   128     * @param aCols - an iterator that can be used to iterate over the col
   129     *                frames to be added.  Once this is done, the frames on the
   130     *                sbling chain of its .get() at that point will still need
   131     *                their col indices updated.
   132     * @result            - if there is no table frame or the table frame is not
   133     *                      the first in flow it will return an error
   134     */
   135   nsresult AddColsToTable(int32_t                   aFirstColIndex,
   136                           bool                      aResetSubsequentColIndices,
   137                           const nsFrameList::Slice& aCols);
   139 #ifdef DEBUG_FRAME_DUMP
   140   virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
   141   void Dump(int32_t aIndent);
   142 #endif
   144   /** returns the number of columns represented by this group.
   145     * if there are col children, count them (taking into account the span of each)
   146     * else, check my own span attribute.
   147     */
   148   virtual int32_t GetColCount() const;
   150   /** first column on the child list */
   151   nsTableColFrame * GetFirstColumn();
   152   /** next sibling to aChildFrame that is a column frame, first column frame
   153     * in the column group if aChildFrame is null
   154     */
   155   nsTableColFrame * GetNextColumn(nsIFrame *aChildFrame);
   157   /** @return - the position of the first column in this colgroup in the table
   158     * colframe cache.
   159     */
   160   int32_t GetStartColumnIndex();
   162   /** set the position of the first column in this colgroup in the table
   163     * colframe cache.
   164     */
   165   void SetStartColumnIndex(int32_t aIndex);
   167   /** helper method to get the span attribute for this colgroup */
   168   int32_t GetSpan();
   170   /** provide access to the mFrames list
   171     */
   172   nsFrameList& GetWritableChildList();
   174   /** set the column index for all frames starting at aStartColFrame, it
   175     * will also reset the column indices in all subsequent colgroups
   176     * @param aFirstColGroup - start the reset operation inside this colgroup
   177     * @param aFirstColIndex - first column that is reset should get this index
   178     * @param aStartColFrame - if specified the reset starts with this column
   179     *                         inside the colgroup; if not specified, the reset
   180     *                         starts with the first column
   181     */
   182   static void ResetColIndices(nsIFrame*       aFirstColGroup,
   183                               int32_t         aFirstColIndex,
   184                               nsIFrame*       aStartColFrame = nullptr);
   186   /**
   187    * Gets inner border widths before collapsing with cell borders
   188    * Caller must get left border from previous column
   189    * GetContinuousBCBorderWidth will not overwrite aBorder.left
   190    * see nsTablePainter about continuous borders
   191    */
   192   void GetContinuousBCBorderWidth(nsMargin& aBorder);
   193   /**
   194    * Set full border widths before collapsing with cell borders
   195    * @param aForSide - side to set; only accepts top and bottom
   196    */
   197   void SetContinuousBCBorderWidth(uint8_t     aForSide,
   198                                   BCPixelSize aPixelValue);
   200   virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
   201   {
   202     return nsContainerFrame::IsFrameOfType(aFlags & ~(nsIFrame::eTablePart));
   203   }
   205   virtual void InvalidateFrame(uint32_t aDisplayItemKey = 0) MOZ_OVERRIDE;
   206   virtual void InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey = 0) MOZ_OVERRIDE;
   207   virtual void InvalidateFrameForRemoval() MOZ_OVERRIDE { InvalidateFrameSubtree(); }
   209 protected:
   210   nsTableColGroupFrame(nsStyleContext* aContext);
   212   void InsertColsReflow(int32_t                   aColIndex,
   213                         const nsFrameList::Slice& aCols);
   215   virtual int GetLogicalSkipSides(const nsHTMLReflowState* aReflowState = nullptr) const MOZ_OVERRIDE;
   217   // data members
   218   int32_t mColCount;
   219   // the starting column index this col group represents. Must be >= 0. 
   220   int32_t mStartColIndex;
   222   // border width in pixels
   223   BCPixelSize mTopContBorderWidth;
   224   BCPixelSize mBottomContBorderWidth;
   225 };
   227 inline nsTableColGroupFrame::nsTableColGroupFrame(nsStyleContext *aContext)
   228 : nsContainerFrame(aContext), mColCount(0), mStartColIndex(0)
   229 { 
   230   SetColType(eColGroupContent);
   231 }
   233 inline int32_t nsTableColGroupFrame::GetStartColumnIndex()
   234 {  
   235   return mStartColIndex;
   236 }
   238 inline void nsTableColGroupFrame::SetStartColumnIndex (int32_t aIndex)
   239 {
   240   mStartColIndex = aIndex;
   241 }
   243 inline int32_t nsTableColGroupFrame::GetColCount() const
   244 {  
   245   return mColCount;
   246 }
   248 inline nsFrameList& nsTableColGroupFrame::GetWritableChildList()
   249 {  
   250   return mFrames;
   251 }
   253 #endif

mercurial