layout/xul/grid/nsGrid.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef nsGrid_h___
     8 #define nsGrid_h___
    10 #include "nsStackLayout.h"
    11 #include "nsIGridPart.h"
    12 #include "nsCOMPtr.h"
    14 class nsGridRowGroupLayout;
    15 class nsGridRowLayout;
    16 class nsBoxLayoutState;
    17 class nsGridCell;
    19 //#define DEBUG_grid 1
    21 /**
    22  * The grid data structure, i.e., the grid cellmap.
    23  */
    24 class nsGrid
    25 {
    26 public:
    27   nsGrid();
    28   ~nsGrid();
    30   nsGridRow* GetColumnAt(int32_t aIndex, bool aIsHorizontal = true);
    31   nsGridRow* GetRowAt(int32_t aIndex, bool aIsHorizontal = true);
    32   nsGridCell* GetCellAt(int32_t aX, int32_t aY);
    34   void NeedsRebuild(nsBoxLayoutState& aBoxLayoutState);
    35   void RebuildIfNeeded();
    37   // For all the methods taking an aIsHorizontal parameter:
    38   // * When aIsHorizontal is true, the words "rows" and (for
    39   //   GetColumnCount) "columns" refer to their normal meanings.
    40   // * When aIsHorizontal is false, the meanings are flipped.
    41   // FIXME:  Maybe eliminate GetColumnCount and change aIsHorizontal to
    42   // aIsRows?  (Calling it horizontal doesn't really make sense because
    43   // row groups and columns have vertical orientation, whereas column
    44   // groups and rows are horizontal.)
    46   nsSize GetPrefRowSize(nsBoxLayoutState& aBoxLayoutState, int32_t aRowIndex, bool aIsHorizontal = true);
    47   nsSize GetMinRowSize(nsBoxLayoutState& aBoxLayoutState, int32_t aRowIndex, bool aIsHorizontal = true);
    48   nsSize GetMaxRowSize(nsBoxLayoutState& aBoxLayoutState, int32_t aRowIndex, bool aIsHorizontal = true);
    49   nscoord GetRowFlex(nsBoxLayoutState& aBoxLayoutState, int32_t aRowIndex, bool aIsHorizontal = true);
    51   nscoord GetPrefRowHeight(nsBoxLayoutState& aBoxLayoutState, int32_t aRowIndex, bool aIsHorizontal = true);
    52   nscoord GetMinRowHeight(nsBoxLayoutState& aBoxLayoutState, int32_t aRowIndex, bool aIsHorizontal = true);
    53   nscoord GetMaxRowHeight(nsBoxLayoutState& aBoxLayoutState, int32_t aRowIndex, bool aIsHorizontal = true);
    54   void GetRowOffsets(nsBoxLayoutState& aState, int32_t aIndex, nscoord& aTop, nscoord& aBottom, bool aIsHorizontal = true);
    56   void RowAddedOrRemoved(nsBoxLayoutState& aBoxLayoutState, int32_t aIndex, bool aIsHorizontal = true);
    57   void CellAddedOrRemoved(nsBoxLayoutState& aBoxLayoutState, int32_t aIndex, bool aIsHorizontal = true);
    58   void DirtyRows(nsIFrame* aRowBox, nsBoxLayoutState& aState);
    59 #ifdef DEBUG_grid
    60   void PrintCellMap();
    61 #endif
    62   int32_t GetExtraColumnCount(bool aIsHorizontal = true);
    63   int32_t GetExtraRowCount(bool aIsHorizontal = true);
    65 // accessors
    66   void SetBox(nsIFrame* aBox) { mBox = aBox; }
    67   nsIFrame* GetBox() { return mBox; }
    68   nsIFrame* GetRowsBox() { return mRowsBox; }
    69   nsIFrame* GetColumnsBox() { return mColumnsBox; }
    70   int32_t GetRowCount(int32_t aIsHorizontal = true);
    71   int32_t GetColumnCount(int32_t aIsHorizontal = true);
    73   static nsIFrame* GetScrolledBox(nsIFrame* aChild);
    74   static nsIFrame* GetScrollBox(nsIFrame* aChild);
    75   static nsIGridPart* GetPartFromBox(nsIFrame* aBox);
    76   void GetFirstAndLastRow(nsBoxLayoutState& aState, 
    77                           int32_t& aFirstIndex, 
    78                           int32_t& aLastIndex, 
    79                           nsGridRow*& aFirstRow,
    80                           nsGridRow*& aLastRow,
    81                           bool aIsHorizontal);
    83 private:
    85   nsMargin GetBoxTotalMargin(nsIFrame* aBox, bool aIsHorizontal = true);
    87   void FreeMap();
    88   void FindRowsAndColumns(nsIFrame** aRows, nsIFrame** aColumns);
    89   void BuildRows(nsIFrame* aBox, int32_t aSize, nsGridRow** aColumnsRows, bool aIsHorizontal = true);
    90   nsGridCell* BuildCellMap(int32_t aRows, int32_t aColumns);
    91   void PopulateCellMap(nsGridRow* aRows, nsGridRow* aColumns, int32_t aRowCount, int32_t aColumnCount, bool aIsHorizontal = true);
    92   void CountRowsColumns(nsIFrame* aBox, int32_t& aRowCount, int32_t& aComputedColumnCount);
    93   void SetLargestSize(nsSize& aSize, nscoord aHeight, bool aIsHorizontal = true);
    94   void SetSmallestSize(nsSize& aSize, nscoord aHeight, bool aIsHorizontal = true);
    95   bool IsGrid(nsIFrame* aBox);
    97   // the box that implement the <grid> tag
    98   nsIFrame* mBox;
   100   // an array of row object
   101   nsGridRow* mRows;
   103   // an array of columns objects.
   104   nsGridRow* mColumns;
   106   // the first in the <grid> that implements the <rows> tag.
   107   nsIFrame* mRowsBox;
   109   // the first in the <grid> that implements the <columns> tag.
   110   nsIFrame* mColumnsBox;
   112   // a flag that is false tells us to rebuild the who grid
   113   bool mNeedsRebuild;
   115   // number of rows and columns as defined by the XUL
   116   int32_t mRowCount;
   117   int32_t mColumnCount;
   119   // number of rows and columns that are implied but not 
   120   // explicitly defined int he XUL
   121   int32_t mExtraRowCount;
   122   int32_t mExtraColumnCount;
   124   // x,y array of cells in the rows and columns
   125   nsGridCell* mCellMap;
   127   // a flag that when true suppresses all other MarkDirties. This
   128   // prevents lots of extra work being done.
   129   bool mMarkingDirty;
   130 };
   132 #endif

mercurial