author Mats Palmgren <>
Sun, 05 Jan 2014 23:31:14 +0000
changeset 178184 794680b9599d01635c6734a00192d9ca099f4793
parent 174010 6cc28fece8bfb6595c022ba995f92fc543b8d924
child 180558 137e02fe6f55b47f892205df124bae4f918394cc
permissions -rw-r--r--
Bug 956447 - Make it possible to get frame dumps in non-DEBUG builds. r=roc

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */

/* This Source Code is subject to the terms of the Mozilla Public License
 * version 2.0 (the "License"). You can obtain a copy of the License at
 * */

/* rendering object for CSS "display: flex" */

#ifndef nsFlexContainerFrame_h___
#define nsFlexContainerFrame_h___

#include "nsContainerFrame.h"

nsIFrame* NS_NewFlexContainerFrame(nsIPresShell* aPresShell,
                                   nsStyleContext* aContext);

typedef nsContainerFrame nsFlexContainerFrameSuper;

class FlexItem;
class FlexLine;
class FlexboxAxisTracker;
class MainAxisPositionTracker;
class SingleLineCrossAxisPositionTracker;
template <class T> class nsTArray;

class nsFlexContainerFrame : public nsFlexContainerFrameSuper {

  // Factory method:
  friend nsIFrame* NS_NewFlexContainerFrame(nsIPresShell* aPresShell,
                                            nsStyleContext* aContext);

  // nsIFrame overrides
  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                const nsRect&           aDirtyRect,
                                const nsDisplayListSet& aLists) MOZ_OVERRIDE;

  NS_IMETHOD Reflow(nsPresContext*           aPresContext,
                    nsHTMLReflowMetrics&     aDesiredSize,
                    const nsHTMLReflowState& aReflowState,
                    nsReflowStatus&          aStatus) MOZ_OVERRIDE;

  virtual nscoord
    GetMinWidth(nsRenderingContext* aRenderingContext) MOZ_OVERRIDE;
  virtual nscoord
    GetPrefWidth(nsRenderingContext* aRenderingContext) MOZ_OVERRIDE;

  virtual nsIAtom* GetType() const MOZ_OVERRIDE;
  NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
  // Flexbox-specific public methods
  bool IsHorizontal();

  // Protected constructor & destructor
  nsFlexContainerFrame(nsStyleContext* aContext) :
  virtual ~nsFlexContainerFrame();

   * Checks whether our child-frame list "mFrames" is sorted, using the given
   * IsLessThanOrEqual function, and sorts it if it's not already sorted.
   * XXXdholbert Once we support pagination, we need to make this function
   * check our continuations as well (or wrap it in a function that does).
   * @return true if we had to sort mFrames, false if it was already sorted.
  template<bool IsLessThanOrEqual(nsIFrame*, nsIFrame*)>
  bool SortChildrenIfNeeded();

  // Protected flex-container-specific methods / member-vars
#ifdef DEBUG
  void SanityCheckAnonymousFlexItems() const;
#endif // DEBUG

  FlexItem GenerateFlexItemForChild(nsPresContext* aPresContext,
                                    nsIFrame* aChildFrame,
                                    const nsHTMLReflowState& aParentReflowState,
                                    const FlexboxAxisTracker& aAxisTracker);

  // Returns nsresult because we might have to reflow aFlexItem.Frame() (to
  // get its vertical intrinsic size in a vertical flexbox), and if that
  // reflow fails (returns a failure nsresult), we want to bail out.
  nsresult ResolveFlexItemMaxContentSizing(nsPresContext* aPresContext,
                                           FlexItem& aFlexItem,
                                           const nsHTMLReflowState& aParentReflowState,
                                           const FlexboxAxisTracker& aAxisTracker);

  nsresult GenerateFlexLines(nsPresContext* aPresContext,
                             const nsHTMLReflowState& aReflowState,
                             nscoord aContentBoxMainSize,
                             nscoord aAvailableHeightForContent,
                             const FlexboxAxisTracker& aAxisTracker,
                             nsTArray<FlexLine>& aLines);

  nscoord GetMainSizeFromReflowState(const nsHTMLReflowState& aReflowState,
                                     const FlexboxAxisTracker& aAxisTracker);

  nscoord ComputeCrossSize(const nsHTMLReflowState& aReflowState,
                           const FlexboxAxisTracker& aAxisTracker,
                           const nsTArray<FlexLine>& aLines,
                           nscoord aAvailableHeightForContent,
                           bool* aIsDefinite,
                           nsReflowStatus& aStatus);

  nsresult SizeItemInCrossAxis(nsPresContext* aPresContext,
                               const FlexboxAxisTracker& aAxisTracker,
                               nsHTMLReflowState& aChildReflowState,
                               FlexItem& aItem);

  bool mChildrenHaveBeenReordered; // Have we ever had to reorder our kids
                                   // to satisfy their 'order' values?

#endif /* nsFlexContainerFrame_h___ */