1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/xul/grid/nsGridRowGroupFrame.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +// 1.10 +// Eric Vaughan 1.11 +// Netscape Communications 1.12 +// 1.13 +// See documentation in associated header file 1.14 +// 1.15 + 1.16 +#include "nsGridRowGroupFrame.h" 1.17 +#include "nsGridRowLeafLayout.h" 1.18 +#include "nsGridRow.h" 1.19 +#include "nsBoxLayoutState.h" 1.20 +#include "nsGridLayout2.h" 1.21 + 1.22 +already_AddRefed<nsBoxLayout> NS_NewGridRowGroupLayout(); 1.23 + 1.24 +nsIFrame* 1.25 +NS_NewGridRowGroupFrame(nsIPresShell* aPresShell, 1.26 + nsStyleContext* aContext) 1.27 +{ 1.28 + nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowGroupLayout(); 1.29 + return new (aPresShell) nsGridRowGroupFrame(aPresShell, aContext, layout); 1.30 +} 1.31 + 1.32 +NS_IMPL_FRAMEARENA_HELPERS(nsGridRowGroupFrame) 1.33 + 1.34 + 1.35 +/** 1.36 + * This is redefined because row groups have a funny property. If they are flexible 1.37 + * then their flex must be equal to the sum of their children's flexes. 1.38 + */ 1.39 +nscoord 1.40 +nsGridRowGroupFrame::GetFlex(nsBoxLayoutState& aState) 1.41 +{ 1.42 + // if we are flexible out flexibility is determined by our columns. 1.43 + // so first get the our flex. If not 0 then our flex is the sum of 1.44 + // our columns flexes. 1.45 + 1.46 + if (!DoesNeedRecalc(mFlex)) 1.47 + return mFlex; 1.48 + 1.49 + if (nsBoxFrame::GetFlex(aState) == 0) 1.50 + return 0; 1.51 + 1.52 + // ok we are flexible add up our children 1.53 + nscoord totalFlex = 0; 1.54 + nsIFrame* child = GetChildBox(); 1.55 + while (child) 1.56 + { 1.57 + totalFlex += child->GetFlex(aState); 1.58 + child = child->GetNextBox(); 1.59 + } 1.60 + 1.61 + mFlex = totalFlex; 1.62 + 1.63 + return totalFlex; 1.64 +} 1.65 + 1.66 +