1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* Owns the frame tree and provides APIs to manipulate it */
9 #ifndef _nsFrameManager_h_
10 #define _nsFrameManager_h_
13 #include "mozilla/Attributes.h"
14 #include "nsFrameList.h"
16 class nsContainerFrame
;
18 class nsILayoutHistoryState
;
19 class nsPlaceholderFrame
;
24 } // namespace mozilla
27 * Frame manager interface. The frame manager owns the frame tree model, and
28 * handles structural manipulations to it, such as appending and inserting a
29 * list of frames to a parent frame, or removing a child frame from a parent
32 class nsFrameManager
{
34 explicit nsFrameManager(mozilla::PresShell
* aPresShell
)
35 : mPresShell(aPresShell
), mRootFrame(nullptr) {
36 MOZ_ASSERT(mPresShell
, "need a pres shell");
41 * Gets and sets the root frame (typically the viewport). The lifetime of the
42 * root frame is controlled by the frame manager. When the frame manager is
43 * destroyed, it destroys the entire frame hierarchy.
45 nsIFrame
* GetRootFrame() const { return mRootFrame
; }
46 void SetRootFrame(nsIFrame
* aRootFrame
) {
47 NS_ASSERTION(!mRootFrame
, "already have a root frame");
48 mRootFrame
= aRootFrame
;
52 * After Destroy is called, it is an error to call any FrameManager methods.
53 * Destroy should be called when the frame tree managed by the frame
54 * manager is no longer being displayed.
58 // Functions for manipulating the frame model
59 void AppendFrames(nsContainerFrame
* aParentFrame
,
60 mozilla::FrameChildListID aListID
,
61 nsFrameList
&& aFrameList
);
63 void InsertFrames(nsContainerFrame
* aParentFrame
,
64 mozilla::FrameChildListID aListID
, nsIFrame
* aPrevFrame
,
65 nsFrameList
&& aFrameList
);
67 void RemoveFrame(mozilla::FrameChildListID aListID
, nsIFrame
* aOldFrame
);
70 * Capture/restore frame state for the frame subtree rooted at aFrame.
71 * aState is the document state storage object onto which each frame
72 * stores its state. Callers of CaptureFrameState are responsible for
73 * traversing next continuations of special siblings of aFrame as
74 * needed; this method will only work with actual frametree descendants
78 void CaptureFrameState(nsIFrame
* aFrame
, nsILayoutHistoryState
* aState
);
80 void RestoreFrameState(nsIFrame
* aFrame
, nsILayoutHistoryState
* aState
);
83 * Add/restore state for one frame
85 void CaptureFrameStateFor(nsIFrame
* aFrame
, nsILayoutHistoryState
* aState
);
87 void RestoreFrameStateFor(nsIFrame
* aFrame
, nsILayoutHistoryState
* aState
);
89 void AddSizeOfIncludingThis(nsWindowSizes
& aSizes
) const;
92 // weak link, because the pres shell owns us
93 mozilla::PresShell
* MOZ_NON_OWNING_REF mPresShell
;