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 #include "nsGridRowGroupFrame.h"
14 #include "nsGridRowLeafLayout.h"
15 #include "nsGridRow.h"
16 #include "nsBoxLayoutState.h"
17 #include "nsGridLayout2.h"
18 
19 already_AddRefed<nsBoxLayout> NS_NewGridRowGroupLayout();
20 
21 nsIFrame*
NS_NewGridRowGroupFrame(nsIPresShell * aPresShell,nsStyleContext * aContext)22 NS_NewGridRowGroupFrame(nsIPresShell* aPresShell,
23                         nsStyleContext* aContext)
24 {
25   nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowGroupLayout();
26   return new (aPresShell) nsGridRowGroupFrame(aContext, layout);
27 }
28 
NS_IMPL_FRAMEARENA_HELPERS(nsGridRowGroupFrame)29 NS_IMPL_FRAMEARENA_HELPERS(nsGridRowGroupFrame)
30 
31 
32 /**
33  * This is redefined because row groups have a funny property. If they are flexible
34  * then their flex must be equal to the sum of their children's flexes.
35  */
36 nscoord
37 nsGridRowGroupFrame::GetXULFlex()
38 {
39   // if we are flexible out flexibility is determined by our columns.
40   // so first get the our flex. If not 0 then our flex is the sum of
41   // our columns flexes.
42 
43   if (!DoesNeedRecalc(mFlex))
44      return mFlex;
45 
46   if (nsBoxFrame::GetXULFlex() == 0)
47     return 0;
48 
49   // ok we are flexible add up our children
50   nscoord totalFlex = 0;
51   nsIFrame* child = nsBox::GetChildXULBox(this);
52   while (child)
53   {
54     totalFlex += child->GetXULFlex();
55     child = GetNextXULBox(child);
56   }
57 
58   mFlex = totalFlex;
59 
60   return totalFlex;
61 }
62 
63 
64