nsGridRowGroupFrame.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. // Eric Vaughan
  7. // Netscape Communications
  8. //
  9. // See documentation in associated header file
  10. //
  11. #include "nsGridRowGroupFrame.h"
  12. #include "nsGridRowLeafLayout.h"
  13. #include "nsGridRow.h"
  14. #include "nsBoxLayoutState.h"
  15. #include "nsGridLayout2.h"
  16. already_AddRefed<nsBoxLayout> NS_NewGridRowGroupLayout();
  17. nsIFrame*
  18. NS_NewGridRowGroupFrame(nsIPresShell* aPresShell,
  19. nsStyleContext* aContext)
  20. {
  21. nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowGroupLayout();
  22. return new (aPresShell) nsGridRowGroupFrame(aContext, layout);
  23. }
  24. NS_IMPL_FRAMEARENA_HELPERS(nsGridRowGroupFrame)
  25. /**
  26. * This is redefined because row groups have a funny property. If they are flexible
  27. * then their flex must be equal to the sum of their children's flexes.
  28. */
  29. nscoord
  30. nsGridRowGroupFrame::GetXULFlex()
  31. {
  32. // if we are flexible out flexibility is determined by our columns.
  33. // so first get the our flex. If not 0 then our flex is the sum of
  34. // our columns flexes.
  35. if (!DoesNeedRecalc(mFlex))
  36. return mFlex;
  37. if (nsBoxFrame::GetXULFlex() == 0)
  38. return 0;
  39. // ok we are flexible add up our children
  40. nscoord totalFlex = 0;
  41. nsIFrame* child = nsBox::GetChildXULBox(this);
  42. while (child)
  43. {
  44. totalFlex += child->GetXULFlex();
  45. child = GetNextXULBox(child);
  46. }
  47. mFlex = totalFlex;
  48. return totalFlex;
  49. }