Bug 1839338 [wpt PR 40636] - Clone encoded WebRTC audio frame when deserializing...
[gecko.git] / layout / base / nsFrameManager.h
blob009623ff5df0a7ee9192c01494e6eb5efb71dac3
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_
12 #include "nsDebug.h"
13 #include "mozilla/Attributes.h"
14 #include "nsFrameList.h"
16 class nsContainerFrame;
17 class nsIFrame;
18 class nsILayoutHistoryState;
19 class nsPlaceholderFrame;
20 class nsWindowSizes;
22 namespace mozilla {
23 class PresShell;
24 } // namespace mozilla
26 /**
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
30 * frame.
32 class nsFrameManager {
33 public:
34 explicit nsFrameManager(mozilla::PresShell* aPresShell)
35 : mPresShell(aPresShell), mRootFrame(nullptr) {
36 MOZ_ASSERT(mPresShell, "need a pres shell");
38 ~nsFrameManager();
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.
56 void Destroy();
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
75 * of aFrame.
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;
91 protected:
92 // weak link, because the pres shell owns us
93 mozilla::PresShell* MOZ_NON_OWNING_REF mPresShell;
94 nsIFrame* mRootFrame;
97 #endif