1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 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/. */ 6 7 // 8 // Eric Vaughan 9 // Netscape Communications 10 // 11 // See documentation in associated header file 12 // 13 14 #include "mozilla/PresShell.h" 15 #include "nsGridRowGroupFrame.h" 16 #include "nsGridRowLeafLayout.h" 17 #include "nsGridRow.h" 18 #include "nsBoxLayoutState.h" 19 #include "nsGridLayout2.h" 20 21 using namespace mozilla; 22 23 already_AddRefed<nsBoxLayout> NS_NewGridRowGroupLayout(); 24 NS_NewGridRowGroupFrame(PresShell * aPresShell,ComputedStyle * aStyle)25nsIFrame* NS_NewGridRowGroupFrame(PresShell* aPresShell, 26 ComputedStyle* aStyle) { 27 nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowGroupLayout(); 28 return new (aPresShell) 29 nsGridRowGroupFrame(aStyle, aPresShell->GetPresContext(), layout); 30 } 31 NS_IMPL_FRAMEARENA_HELPERS(nsGridRowGroupFrame)32NS_IMPL_FRAMEARENA_HELPERS(nsGridRowGroupFrame) 33 34 /** 35 * This is redefined because row groups have a funny property. If they are 36 * flexible then their flex must be equal to the sum of their children's flexes. 37 */ 38 nscoord nsGridRowGroupFrame::GetXULFlex() { 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 (!XULNeedsRecalc(mFlex)) { 44 return mFlex; 45 } 46 47 if (nsBoxFrame::GetXULFlex() == 0) { 48 return 0; 49 } 50 51 // ok we are flexible add up our children 52 nscoord totalFlex = 0; 53 nsIFrame* child = nsIFrame::GetChildXULBox(this); 54 while (child) { 55 totalFlex += child->GetXULFlex(); 56 child = GetNextXULBox(child); 57 } 58 59 mFlex = totalFlex; 60 61 return totalFlex; 62 } 63