layout/xul/grid/nsGridRowGroupFrame.cpp

branch
TOR_BUG_9701
changeset 14
925c144e1f1f
equal deleted inserted replaced
-1:000000000000 0:9d19bdb657c9
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*
22 NS_NewGridRowGroupFrame(nsIPresShell* aPresShell,
23 nsStyleContext* aContext)
24 {
25 nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowGroupLayout();
26 return new (aPresShell) nsGridRowGroupFrame(aPresShell, aContext, layout);
27 }
28
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::GetFlex(nsBoxLayoutState& aState)
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::GetFlex(aState) == 0)
47 return 0;
48
49 // ok we are flexible add up our children
50 nscoord totalFlex = 0;
51 nsIFrame* child = GetChildBox();
52 while (child)
53 {
54 totalFlex += child->GetFlex(aState);
55 child = child->GetNextBox();
56 }
57
58 mFlex = totalFlex;
59
60 return totalFlex;
61 }
62
63

mercurial