Bug 1869043 allow a device to be specified with MediaTrackGraph::NotifyWhenDeviceStar...
[gecko.git] / layout / base / nsFrameManager.h
blobfa68cb79f5b5f1f988f5abaa5345bb1b5e0255e6
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 struct FrameDestroyContext;
24 class PresShell;
25 } // namespace mozilla
27 /**
28 * Frame manager interface. The frame manager owns the frame tree model, and
29 * handles structural manipulations to it, such as appending and inserting a
30 * list of frames to a parent frame, or removing a child frame from a parent
31 * frame.
33 class nsFrameManager {
34 public:
35 using DestroyContext = mozilla::FrameDestroyContext;
37 explicit nsFrameManager(mozilla::PresShell* aPresShell)
38 : mPresShell(aPresShell), mRootFrame(nullptr) {
39 MOZ_ASSERT(mPresShell, "need a pres shell");
41 ~nsFrameManager();
44 * Gets and sets the root frame (typically the viewport). The lifetime of the
45 * root frame is controlled by the frame manager. When the frame manager is
46 * destroyed, it destroys the entire frame hierarchy.
48 nsIFrame* GetRootFrame() const { return mRootFrame; }
49 void SetRootFrame(nsIFrame* aRootFrame) {
50 NS_ASSERTION(!mRootFrame, "already have a root frame");
51 mRootFrame = aRootFrame;
55 * After Destroy is called, it is an error to call any FrameManager methods.
56 * Destroy should be called when the frame tree managed by the frame
57 * manager is no longer being displayed.
59 void Destroy();
61 // Functions for manipulating the frame model
62 void AppendFrames(nsContainerFrame* aParentFrame,
63 mozilla::FrameChildListID aListID,
64 nsFrameList&& aFrameList);
66 void InsertFrames(nsContainerFrame* aParentFrame,
67 mozilla::FrameChildListID aListID, nsIFrame* aPrevFrame,
68 nsFrameList&& aFrameList);
70 void RemoveFrame(DestroyContext&, mozilla::FrameChildListID, nsIFrame*);
73 * Capture/restore frame state for the frame subtree rooted at aFrame.
74 * aState is the document state storage object onto which each frame
75 * stores its state. Callers of CaptureFrameState are responsible for
76 * traversing next continuations of special siblings of aFrame as
77 * needed; this method will only work with actual frametree descendants
78 * of aFrame.
81 void CaptureFrameState(nsIFrame* aFrame, nsILayoutHistoryState* aState);
83 void RestoreFrameState(nsIFrame* aFrame, nsILayoutHistoryState* aState);
86 * Add/restore state for one frame
88 void CaptureFrameStateFor(nsIFrame* aFrame, nsILayoutHistoryState* aState);
90 void RestoreFrameStateFor(nsIFrame* aFrame, nsILayoutHistoryState* aState);
92 void AddSizeOfIncludingThis(nsWindowSizes& aSizes) const;
94 protected:
95 // weak link, because the pres shell owns us
96 mozilla::PresShell* MOZ_NON_OWNING_REF mPresShell;
97 nsIFrame* mRootFrame;
100 #endif