michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // michael@0: // Eric Vaughan michael@0: // Netscape Communications michael@0: // michael@0: // See documentation in associated header file michael@0: // michael@0: michael@0: #include "nsGridRowGroupFrame.h" michael@0: #include "nsGridRowLeafLayout.h" michael@0: #include "nsGridRow.h" michael@0: #include "nsBoxLayoutState.h" michael@0: #include "nsGridLayout2.h" michael@0: michael@0: already_AddRefed NS_NewGridRowGroupLayout(); michael@0: michael@0: nsIFrame* michael@0: NS_NewGridRowGroupFrame(nsIPresShell* aPresShell, michael@0: nsStyleContext* aContext) michael@0: { michael@0: nsCOMPtr layout = NS_NewGridRowGroupLayout(); michael@0: return new (aPresShell) nsGridRowGroupFrame(aPresShell, aContext, layout); michael@0: } michael@0: michael@0: NS_IMPL_FRAMEARENA_HELPERS(nsGridRowGroupFrame) michael@0: michael@0: michael@0: /** michael@0: * This is redefined because row groups have a funny property. If they are flexible michael@0: * then their flex must be equal to the sum of their children's flexes. michael@0: */ michael@0: nscoord michael@0: nsGridRowGroupFrame::GetFlex(nsBoxLayoutState& aState) michael@0: { michael@0: // if we are flexible out flexibility is determined by our columns. michael@0: // so first get the our flex. If not 0 then our flex is the sum of michael@0: // our columns flexes. michael@0: michael@0: if (!DoesNeedRecalc(mFlex)) michael@0: return mFlex; michael@0: michael@0: if (nsBoxFrame::GetFlex(aState) == 0) michael@0: return 0; michael@0: michael@0: // ok we are flexible add up our children michael@0: nscoord totalFlex = 0; michael@0: nsIFrame* child = GetChildBox(); michael@0: while (child) michael@0: { michael@0: totalFlex += child->GetFlex(aState); michael@0: child = child->GetNextBox(); michael@0: } michael@0: michael@0: mFlex = totalFlex; michael@0: michael@0: return totalFlex; michael@0: } michael@0: michael@0: