layout/generic/nsAbsoluteContainingBlock.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /*
michael@0 7 * code for managing absolutely positioned children of a rendering
michael@0 8 * object that is a containing block for them
michael@0 9 */
michael@0 10
michael@0 11 #ifndef nsAbsoluteContainingBlock_h___
michael@0 12 #define nsAbsoluteContainingBlock_h___
michael@0 13
michael@0 14 #include "nsFrameList.h"
michael@0 15 #include "nsIFrame.h"
michael@0 16
michael@0 17 class nsContainerFrame;
michael@0 18 class nsHTMLReflowState;
michael@0 19 class nsPresContext;
michael@0 20
michael@0 21 /**
michael@0 22 * This class contains the logic for being an absolute containing block. This
michael@0 23 * class is used within viewport frames (for frames representing content with
michael@0 24 * fixed position) and blocks (for frames representing absolutely positioned
michael@0 25 * content), since each set of frames is absolutely positioned with respect to
michael@0 26 * its parent.
michael@0 27 *
michael@0 28 * There is no principal child list, just a named child list which contains
michael@0 29 * the absolutely positioned frames (kAbsoluteList or kFixedList).
michael@0 30 *
michael@0 31 * All functions include as the first argument the frame that is delegating
michael@0 32 * the request.
michael@0 33 */
michael@0 34 class nsAbsoluteContainingBlock
michael@0 35 {
michael@0 36 public:
michael@0 37 typedef nsIFrame::ChildListID ChildListID;
michael@0 38
michael@0 39 nsAbsoluteContainingBlock(ChildListID aChildListID)
michael@0 40 #ifdef DEBUG
michael@0 41 : mChildListID(aChildListID)
michael@0 42 #endif
michael@0 43 {
michael@0 44 MOZ_ASSERT(mChildListID == nsIFrame::kAbsoluteList ||
michael@0 45 mChildListID == nsIFrame::kFixedList,
michael@0 46 "should either represent position:fixed or absolute content");
michael@0 47 }
michael@0 48
michael@0 49 const nsFrameList& GetChildList() const { return mAbsoluteFrames; }
michael@0 50 void AppendChildList(nsTArray<nsIFrame::ChildList>* aLists,
michael@0 51 ChildListID aListID) const
michael@0 52 {
michael@0 53 NS_ASSERTION(aListID == mChildListID, "wrong list ID");
michael@0 54 GetChildList().AppendIfNonempty(aLists, aListID);
michael@0 55 }
michael@0 56
michael@0 57 nsresult SetInitialChildList(nsIFrame* aDelegatingFrame,
michael@0 58 ChildListID aListID,
michael@0 59 nsFrameList& aChildList);
michael@0 60 nsresult AppendFrames(nsIFrame* aDelegatingFrame,
michael@0 61 ChildListID aListID,
michael@0 62 nsFrameList& aFrameList);
michael@0 63 nsresult InsertFrames(nsIFrame* aDelegatingFrame,
michael@0 64 ChildListID aListID,
michael@0 65 nsIFrame* aPrevFrame,
michael@0 66 nsFrameList& aFrameList);
michael@0 67 void RemoveFrame(nsIFrame* aDelegatingFrame,
michael@0 68 ChildListID aListID,
michael@0 69 nsIFrame* aOldFrame);
michael@0 70
michael@0 71 /**
michael@0 72 * Called by the delegating frame after it has done its reflow first. This
michael@0 73 * function will reflow any absolutely positioned child frames that need to
michael@0 74 * be reflowed, e.g., because the absolutely positioned child frame has
michael@0 75 * 'auto' for an offset, or a percentage based width or height.
michael@0 76 *
michael@0 77 * @param aOverflowAreas, if non-null, is unioned with (in the local
michael@0 78 * coordinate space) the overflow areas of the absolutely positioned
michael@0 79 * children.
michael@0 80 *
michael@0 81 * @param aReflowStatus is assumed to be already-initialized, e.g. with the
michael@0 82 * status of the delegating frame's main reflow. This function merges in the
michael@0 83 * statuses of the absolutely positioned children's reflows.
michael@0 84 */
michael@0 85 nsresult Reflow(nsContainerFrame* aDelegatingFrame,
michael@0 86 nsPresContext* aPresContext,
michael@0 87 const nsHTMLReflowState& aReflowState,
michael@0 88 nsReflowStatus& aReflowStatus,
michael@0 89 const nsRect& aContainingBlock,
michael@0 90 bool aConstrainHeight,
michael@0 91 bool aCBWidthChanged,
michael@0 92 bool aCBHeightChanged,
michael@0 93 nsOverflowAreas* aOverflowAreas);
michael@0 94
michael@0 95 void DestroyFrames(nsIFrame* aDelegatingFrame,
michael@0 96 nsIFrame* aDestructRoot);
michael@0 97
michael@0 98 bool HasAbsoluteFrames() const { return mAbsoluteFrames.NotEmpty(); }
michael@0 99
michael@0 100 /**
michael@0 101 * Mark our size-dependent absolute frames with NS_FRAME_HAS_DIRTY_CHILDREN
michael@0 102 * so that we'll make sure to reflow them.
michael@0 103 */
michael@0 104 void MarkSizeDependentFramesDirty();
michael@0 105
michael@0 106 /**
michael@0 107 * Mark all our absolute frames with NS_FRAME_IS_DIRTY.
michael@0 108 */
michael@0 109 void MarkAllFramesDirty();
michael@0 110
michael@0 111 protected:
michael@0 112 /**
michael@0 113 * Returns true if the position of aFrame depends on the position of
michael@0 114 * its placeholder or if the position or size of aFrame depends on a
michael@0 115 * containing block dimension that changed.
michael@0 116 */
michael@0 117 bool FrameDependsOnContainer(nsIFrame* aFrame, bool aCBWidthChanged,
michael@0 118 bool aCBHeightChanged);
michael@0 119
michael@0 120 nsresult ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
michael@0 121 nsPresContext* aPresContext,
michael@0 122 const nsHTMLReflowState& aReflowState,
michael@0 123 const nsRect& aContainingBlockRect,
michael@0 124 bool aConstrainHeight,
michael@0 125 nsIFrame* aKidFrame,
michael@0 126 nsReflowStatus& aStatus,
michael@0 127 nsOverflowAreas* aOverflowAreas);
michael@0 128
michael@0 129 /**
michael@0 130 * Mark our absolute frames dirty.
michael@0 131 * @param aMarkAllDirty if true, all will be marked with NS_FRAME_IS_DIRTY.
michael@0 132 * Otherwise, the size-dependant ones will be marked with
michael@0 133 * NS_FRAME_HAS_DIRTY_CHILDREN.
michael@0 134 */
michael@0 135 void DoMarkFramesDirty(bool aMarkAllDirty);
michael@0 136
michael@0 137 protected:
michael@0 138 nsFrameList mAbsoluteFrames; // additional named child list
michael@0 139
michael@0 140 #ifdef DEBUG
michael@0 141 ChildListID const mChildListID; // kFixedList or kAbsoluteList
michael@0 142 #endif
michael@0 143 };
michael@0 144
michael@0 145 #endif /* nsnsAbsoluteContainingBlock_h___ */

mercurial