LCOV - code coverage report
Current view: top level - layout/xul/grid - nsGridRowGroupLayout.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 107 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 13 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             : //
       7             : // Eric Vaughan
       8             : // Netscape Communications
       9             : //
      10             : // See documentation in associated header file
      11             : //
      12             : 
      13             : 
      14             : /*
      15             :  * The nsGridRowGroupLayout implements the <rows> or <columns> tag in a grid.
      16             :  */
      17             : 
      18             : #include "nsGridRowGroupLayout.h"
      19             : #include "nsCOMPtr.h"
      20             : #include "nsIScrollableFrame.h"
      21             : #include "nsBox.h"
      22             : #include "nsBoxLayoutState.h"
      23             : #include "nsGridLayout2.h"
      24             : #include "nsGridRow.h"
      25             : #include "mozilla/ReflowInput.h"
      26             : 
      27           0 : already_AddRefed<nsBoxLayout> NS_NewGridRowGroupLayout()
      28             : {
      29           0 :   RefPtr<nsBoxLayout> layout = new nsGridRowGroupLayout();
      30           0 :   return layout.forget();
      31             : }
      32             : 
      33           0 : nsGridRowGroupLayout::nsGridRowGroupLayout():nsGridRowLayout(), mRowCount(0)
      34             : {
      35           0 : }
      36             : 
      37           0 : nsGridRowGroupLayout::~nsGridRowGroupLayout()
      38             : {
      39           0 : }
      40             : 
      41             : void
      42           0 : nsGridRowGroupLayout::ChildAddedOrRemoved(nsIFrame* aBox, nsBoxLayoutState& aState)
      43             : {
      44           0 :   int32_t index = 0;
      45           0 :   nsGrid* grid = GetGrid(aBox, &index);
      46           0 :   bool isHorizontal = IsXULHorizontal(aBox);
      47             : 
      48           0 :   if (grid)
      49           0 :     grid->RowAddedOrRemoved(aState, index, isHorizontal);
      50           0 : }
      51             : 
      52             : void
      53           0 : nsGridRowGroupLayout::AddWidth(nsSize& aSize, nscoord aSize2, bool aIsHorizontal)
      54             : {
      55           0 :   nscoord& size = GET_WIDTH(aSize, aIsHorizontal);
      56             : 
      57           0 :   if (size == NS_INTRINSICSIZE || aSize2 == NS_INTRINSICSIZE)
      58           0 :     size = NS_INTRINSICSIZE;
      59             :   else
      60           0 :     size += aSize2;
      61           0 : }
      62             : 
      63             : nsSize
      64           0 : nsGridRowGroupLayout::GetXULPrefSize(nsIFrame* aBox, nsBoxLayoutState& aState)
      65             : {
      66           0 :   nsSize vpref = nsGridRowLayout::GetXULPrefSize(aBox, aState);
      67             : 
      68             : 
      69             :  /* It is possible that we could have some extra columns. This is when less columns in XUL were
      70             :   * defined that needed. And example might be a grid with 3 defined columns but a row with 4 cells in
      71             :   * it. We would need an extra column to make the grid work. But because that extra column does not
      72             :   * have a box associated with it we must add its size in manually. Remember we could have extra rows
      73             :   * as well.
      74             :   */
      75             : 
      76           0 :   int32_t index = 0;
      77           0 :   nsGrid* grid = GetGrid(aBox, &index);
      78             : 
      79           0 :   if (grid)
      80             :   {
      81             :     // make sure we add in extra columns sizes as well
      82           0 :     bool isHorizontal = IsXULHorizontal(aBox);
      83           0 :     int32_t extraColumns = grid->GetExtraColumnCount(isHorizontal);
      84           0 :     int32_t start = grid->GetColumnCount(isHorizontal) - grid->GetExtraColumnCount(isHorizontal);
      85           0 :     for (int32_t i=0; i < extraColumns; i++)
      86             :     {
      87             :       nscoord pref =
      88           0 :         grid->GetPrefRowHeight(aState, i+start, !isHorizontal); // GetPrefColumnWidth
      89             : 
      90           0 :       AddWidth(vpref, pref, isHorizontal);
      91             :     }
      92             :   }
      93             : 
      94           0 :   return vpref;
      95             : }
      96             : 
      97             : nsSize
      98           0 : nsGridRowGroupLayout::GetXULMaxSize(nsIFrame* aBox, nsBoxLayoutState& aState)
      99             : {
     100           0 :  nsSize maxSize = nsGridRowLayout::GetXULMaxSize(aBox, aState);
     101             : 
     102           0 :   int32_t index = 0;
     103           0 :   nsGrid* grid = GetGrid(aBox, &index);
     104             : 
     105           0 :   if (grid)
     106             :   {
     107             :     // make sure we add in extra columns sizes as well
     108           0 :     bool isHorizontal = IsXULHorizontal(aBox);
     109           0 :     int32_t extraColumns = grid->GetExtraColumnCount(isHorizontal);
     110           0 :     int32_t start = grid->GetColumnCount(isHorizontal) - grid->GetExtraColumnCount(isHorizontal);
     111           0 :     for (int32_t i=0; i < extraColumns; i++)
     112             :     {
     113             :       nscoord max =
     114           0 :         grid->GetMaxRowHeight(aState, i+start, !isHorizontal); // GetMaxColumnWidth
     115             : 
     116           0 :       AddWidth(maxSize, max, isHorizontal);
     117             :     }
     118             :   }
     119             : 
     120           0 :   return maxSize;
     121             : }
     122             : 
     123             : nsSize
     124           0 : nsGridRowGroupLayout::GetXULMinSize(nsIFrame* aBox, nsBoxLayoutState& aState)
     125             : {
     126           0 :   nsSize minSize = nsGridRowLayout::GetXULMinSize(aBox, aState);
     127             : 
     128           0 :   int32_t index = 0;
     129           0 :   nsGrid* grid = GetGrid(aBox, &index);
     130             : 
     131           0 :   if (grid)
     132             :   {
     133             :     // make sure we add in extra columns sizes as well
     134           0 :     bool isHorizontal = IsXULHorizontal(aBox);
     135           0 :     int32_t extraColumns = grid->GetExtraColumnCount(isHorizontal);
     136           0 :     int32_t start = grid->GetColumnCount(isHorizontal) - grid->GetExtraColumnCount(isHorizontal);
     137           0 :     for (int32_t i=0; i < extraColumns; i++)
     138             :     {
     139             :       nscoord min =
     140           0 :         grid->GetMinRowHeight(aState, i+start, !isHorizontal); // GetMinColumnWidth
     141           0 :       AddWidth(minSize, min, isHorizontal);
     142             :     }
     143             :   }
     144             : 
     145           0 :   return minSize;
     146             : }
     147             : 
     148             : /*
     149             :  * Run down through our children dirtying them recursively.
     150             :  */
     151             : void
     152           0 : nsGridRowGroupLayout::DirtyRows(nsIFrame* aBox, nsBoxLayoutState& aState)
     153             : {
     154           0 :   if (aBox) {
     155             :     // mark us dirty
     156             :     // XXXldb We probably don't want to walk up the ancestor chain
     157             :     // calling MarkIntrinsicISizesDirty for every row group.
     158           0 :     aState.PresShell()->FrameNeedsReflow(aBox, nsIPresShell::eTreeChange,
     159           0 :                                          NS_FRAME_IS_DIRTY);
     160           0 :     nsIFrame* child = nsBox::GetChildXULBox(aBox);
     161             : 
     162           0 :     while(child) {
     163             : 
     164             :       // walk into scrollframes
     165           0 :       nsIFrame* deepChild = nsGrid::GetScrolledBox(child);
     166             : 
     167             :       // walk into other monuments
     168           0 :       nsIGridPart* monument = nsGrid::GetPartFromBox(deepChild);
     169           0 :       if (monument)
     170           0 :         monument->DirtyRows(deepChild, aState);
     171             : 
     172           0 :       child = nsBox::GetNextXULBox(child);
     173             :     }
     174             :   }
     175           0 : }
     176             : 
     177             : 
     178             : void
     179           0 : nsGridRowGroupLayout::CountRowsColumns(nsIFrame* aBox, int32_t& aRowCount, int32_t& aComputedColumnCount)
     180             : {
     181           0 :   if (aBox) {
     182           0 :     int32_t startCount = aRowCount;
     183             : 
     184           0 :     nsIFrame* child = nsBox::GetChildXULBox(aBox);
     185             : 
     186           0 :     while(child) {
     187             : 
     188             :       // first see if it is a scrollframe. If so walk down into it and get the scrolled child
     189           0 :       nsIFrame* deepChild = nsGrid::GetScrolledBox(child);
     190             : 
     191           0 :       nsIGridPart* monument = nsGrid::GetPartFromBox(deepChild);
     192           0 :       if (monument) {
     193           0 :         monument->CountRowsColumns(deepChild, aRowCount, aComputedColumnCount);
     194           0 :         child = nsBox::GetNextXULBox(child);
     195           0 :         deepChild = child;
     196           0 :         continue;
     197             :       }
     198             : 
     199           0 :       child = nsBox::GetNextXULBox(child);
     200             : 
     201             :       // if not a monument. Then count it. It will be a bogus row
     202           0 :       aRowCount++;
     203             :     }
     204             : 
     205           0 :     mRowCount = aRowCount - startCount;
     206             :   }
     207           0 : }
     208             : 
     209             : 
     210             : /**
     211             :  * Fill out the given row structure recursively
     212             :  */
     213             : int32_t
     214           0 : nsGridRowGroupLayout::BuildRows(nsIFrame* aBox, nsGridRow* aRows)
     215             : {
     216           0 :   int32_t rowCount = 0;
     217             : 
     218           0 :   if (aBox) {
     219           0 :     nsIFrame* child = nsBox::GetChildXULBox(aBox);
     220             : 
     221           0 :     while(child) {
     222             : 
     223             :       // first see if it is a scrollframe. If so walk down into it and get the scrolled child
     224           0 :       nsIFrame* deepChild = nsGrid::GetScrolledBox(child);
     225             : 
     226           0 :       nsIGridPart* monument = nsGrid::GetPartFromBox(deepChild);
     227           0 :       if (monument) {
     228           0 :         rowCount += monument->BuildRows(deepChild, &aRows[rowCount]);
     229           0 :         child = nsBox::GetNextXULBox(child);
     230           0 :         deepChild = child;
     231           0 :         continue;
     232             :       }
     233             : 
     234           0 :       aRows[rowCount].Init(child, true);
     235             : 
     236           0 :       child = nsBox::GetNextXULBox(child);
     237             : 
     238             :       // if not a monument. Then count it. It will be a bogus row
     239           0 :       rowCount++;
     240             :     }
     241             :   }
     242             : 
     243           0 :   return rowCount;
     244             : }
     245             : 
     246             : nsMargin
     247           0 : nsGridRowGroupLayout::GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal)
     248             : {
     249             :   // group have border and padding added to the total margin
     250             : 
     251           0 :   nsMargin margin = nsGridRowLayout::GetTotalMargin(aBox, aIsHorizontal);
     252             : 
     253             :   // make sure we have the scrollframe on the outside if it has one.
     254             :   // that's where the border is.
     255           0 :   aBox = nsGrid::GetScrollBox(aBox);
     256             : 
     257             :   // add our border/padding to it
     258           0 :   nsMargin borderPadding(0,0,0,0);
     259           0 :   aBox->GetXULBorderAndPadding(borderPadding);
     260           0 :   margin += borderPadding;
     261             : 
     262           0 :   return margin;
     263             : }
     264             : 
     265             : 

Generated by: LCOV version 1.13