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