layout/generic/nsAbsoluteContainingBlock.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/generic/nsAbsoluteContainingBlock.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,145 @@
     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 + * code for managing absolutely positioned children of a rendering
    1.11 + * object that is a containing block for them
    1.12 + */
    1.13 +
    1.14 +#ifndef nsAbsoluteContainingBlock_h___
    1.15 +#define nsAbsoluteContainingBlock_h___
    1.16 +
    1.17 +#include "nsFrameList.h"
    1.18 +#include "nsIFrame.h"
    1.19 +
    1.20 +class nsContainerFrame;
    1.21 +class nsHTMLReflowState;
    1.22 +class nsPresContext;
    1.23 +
    1.24 +/**
    1.25 + * This class contains the logic for being an absolute containing block.  This
    1.26 + * class is used within viewport frames (for frames representing content with
    1.27 + * fixed position) and blocks (for frames representing absolutely positioned
    1.28 + * content), since each set of frames is absolutely positioned with respect to
    1.29 + * its parent.
    1.30 + *
    1.31 + * There is no principal child list, just a named child list which contains
    1.32 + * the absolutely positioned frames (kAbsoluteList or kFixedList).
    1.33 + *
    1.34 + * All functions include as the first argument the frame that is delegating
    1.35 + * the request.
    1.36 + */
    1.37 +class nsAbsoluteContainingBlock
    1.38 +{
    1.39 +public:
    1.40 +  typedef nsIFrame::ChildListID ChildListID;
    1.41 +
    1.42 +  nsAbsoluteContainingBlock(ChildListID aChildListID)
    1.43 +#ifdef DEBUG
    1.44 +    : mChildListID(aChildListID)
    1.45 +#endif
    1.46 +  {
    1.47 +    MOZ_ASSERT(mChildListID == nsIFrame::kAbsoluteList ||
    1.48 +               mChildListID == nsIFrame::kFixedList,
    1.49 +               "should either represent position:fixed or absolute content");
    1.50 +  }
    1.51 +
    1.52 +  const nsFrameList& GetChildList() const { return mAbsoluteFrames; }
    1.53 +  void AppendChildList(nsTArray<nsIFrame::ChildList>* aLists,
    1.54 +                       ChildListID aListID) const
    1.55 +  {
    1.56 +    NS_ASSERTION(aListID == mChildListID, "wrong list ID");
    1.57 +    GetChildList().AppendIfNonempty(aLists, aListID);
    1.58 +  }
    1.59 +
    1.60 +  nsresult SetInitialChildList(nsIFrame*       aDelegatingFrame,
    1.61 +                               ChildListID     aListID,
    1.62 +                               nsFrameList&    aChildList);
    1.63 +  nsresult AppendFrames(nsIFrame*      aDelegatingFrame,
    1.64 +                        ChildListID    aListID,
    1.65 +                        nsFrameList&   aFrameList);
    1.66 +  nsresult InsertFrames(nsIFrame*      aDelegatingFrame,
    1.67 +                        ChildListID    aListID,
    1.68 +                        nsIFrame*      aPrevFrame,
    1.69 +                        nsFrameList&   aFrameList);
    1.70 +  void RemoveFrame(nsIFrame*      aDelegatingFrame,
    1.71 +                   ChildListID    aListID,
    1.72 +                   nsIFrame*      aOldFrame);
    1.73 +
    1.74 +  /**
    1.75 +   * Called by the delegating frame after it has done its reflow first. This
    1.76 +   * function will reflow any absolutely positioned child frames that need to
    1.77 +   * be reflowed, e.g., because the absolutely positioned child frame has
    1.78 +   * 'auto' for an offset, or a percentage based width or height.
    1.79 +   *
    1.80 +   * @param aOverflowAreas, if non-null, is unioned with (in the local
    1.81 +   * coordinate space) the overflow areas of the absolutely positioned
    1.82 +   * children.
    1.83 +   *
    1.84 +   * @param aReflowStatus is assumed to be already-initialized, e.g. with the
    1.85 +   * status of the delegating frame's main reflow. This function merges in the
    1.86 +   * statuses of the absolutely positioned children's reflows.
    1.87 +   */
    1.88 +  nsresult Reflow(nsContainerFrame*        aDelegatingFrame,
    1.89 +                  nsPresContext*           aPresContext,
    1.90 +                  const nsHTMLReflowState& aReflowState,
    1.91 +                  nsReflowStatus&          aReflowStatus,
    1.92 +                  const nsRect&            aContainingBlock,
    1.93 +                  bool                     aConstrainHeight,
    1.94 +                  bool                     aCBWidthChanged,
    1.95 +                  bool                     aCBHeightChanged,
    1.96 +                  nsOverflowAreas*         aOverflowAreas);
    1.97 +
    1.98 +  void DestroyFrames(nsIFrame* aDelegatingFrame,
    1.99 +                     nsIFrame* aDestructRoot);
   1.100 +
   1.101 +  bool HasAbsoluteFrames() const { return mAbsoluteFrames.NotEmpty(); }
   1.102 +
   1.103 +  /**
   1.104 +   * Mark our size-dependent absolute frames with NS_FRAME_HAS_DIRTY_CHILDREN
   1.105 +   * so that we'll make sure to reflow them.
   1.106 +   */
   1.107 +  void MarkSizeDependentFramesDirty();
   1.108 +
   1.109 +  /**
   1.110 +   * Mark all our absolute frames with NS_FRAME_IS_DIRTY.
   1.111 +   */
   1.112 +  void MarkAllFramesDirty();
   1.113 +
   1.114 +protected:
   1.115 +  /**
   1.116 +   * Returns true if the position of aFrame depends on the position of
   1.117 +   * its placeholder or if the position or size of aFrame depends on a
   1.118 +   * containing block dimension that changed.
   1.119 +   */
   1.120 +  bool FrameDependsOnContainer(nsIFrame* aFrame, bool aCBWidthChanged,
   1.121 +                               bool aCBHeightChanged);
   1.122 +
   1.123 +  nsresult ReflowAbsoluteFrame(nsIFrame*                aDelegatingFrame,
   1.124 +                               nsPresContext*           aPresContext,
   1.125 +                               const nsHTMLReflowState& aReflowState,
   1.126 +                               const nsRect&            aContainingBlockRect,
   1.127 +                               bool                     aConstrainHeight,
   1.128 +                               nsIFrame*                aKidFrame,
   1.129 +                               nsReflowStatus&          aStatus,
   1.130 +                               nsOverflowAreas*         aOverflowAreas);
   1.131 +
   1.132 +  /**
   1.133 +   * Mark our absolute frames dirty.
   1.134 +   * @param aMarkAllDirty if true, all will be marked with NS_FRAME_IS_DIRTY.
   1.135 +   * Otherwise, the size-dependant ones will be marked with
   1.136 +   * NS_FRAME_HAS_DIRTY_CHILDREN.
   1.137 +   */
   1.138 +  void DoMarkFramesDirty(bool aMarkAllDirty);
   1.139 +
   1.140 +protected:
   1.141 +  nsFrameList mAbsoluteFrames;  // additional named child list
   1.142 +
   1.143 +#ifdef DEBUG
   1.144 +  ChildListID const mChildListID; // kFixedList or kAbsoluteList
   1.145 +#endif
   1.146 +};
   1.147 +
   1.148 +#endif /* nsnsAbsoluteContainingBlock_h___ */

mercurial