Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / layout / base / nsFrameManager.h
blobe31e282d61b844613b6dedf103db7412a514bd50
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 "mozilla/Attributes.h"
13 #include "nsDebug.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 class ViewportFrame;
26 } // namespace mozilla
28 /**
29 * Frame manager interface. The frame manager owns the frame tree model, and
30 * handles structural manipulations to it, such as appending and inserting a
31 * list of frames to a parent frame, or removing a child frame from a parent
32 * frame.
34 class nsFrameManager {
35 public:
36 using DestroyContext = mozilla::FrameDestroyContext;
38 explicit nsFrameManager(mozilla::PresShell* aPresShell)
39 : mPresShell(aPresShell) {
40 MOZ_ASSERT(mPresShell, "need a pres shell");
42 ~nsFrameManager();
45 * Gets and sets the root frame (i.e. ViewportFrame). The lifetime of the
46 * root frame is controlled by the frame manager. When the frame manager is
47 * destroyed, it destroys the entire frame hierarchy.
49 nsIFrame* GetRootFrame() const { return mRootFrame; }
50 void SetRootFrame(mozilla::ViewportFrame* aRootFrame);
53 * After Destroy is called, it is an error to call any FrameManager methods.
54 * Destroy should be called when the frame tree managed by the frame
55 * manager is no longer being displayed.
57 void Destroy();
59 // Functions for manipulating the frame model
60 void AppendFrames(nsContainerFrame* aParentFrame,
61 mozilla::FrameChildListID aListID,
62 nsFrameList&& aFrameList);
64 void InsertFrames(nsContainerFrame* aParentFrame,
65 mozilla::FrameChildListID aListID, nsIFrame* aPrevFrame,
66 nsFrameList&& aFrameList);
68 void RemoveFrame(DestroyContext&, mozilla::FrameChildListID, nsIFrame*);
71 * Capture/restore frame state for the frame subtree rooted at aFrame.
72 * aState is the document state storage object onto which each frame
73 * stores its state. Callers of CaptureFrameState are responsible for
74 * traversing next continuations of special siblings of aFrame as
75 * needed; this method will only work with actual frametree descendants
76 * of aFrame.
79 void CaptureFrameState(nsIFrame* aFrame, nsILayoutHistoryState* aState);
81 void RestoreFrameState(nsIFrame* aFrame, nsILayoutHistoryState* aState);
84 * Add/restore state for one frame
86 void CaptureFrameStateFor(nsIFrame* aFrame, nsILayoutHistoryState* aState);
88 void RestoreFrameStateFor(nsIFrame* aFrame, nsILayoutHistoryState* aState);
90 void AddSizeOfIncludingThis(nsWindowSizes& aSizes) const;
92 protected:
93 // weak link, because the pres shell owns us
94 mozilla::PresShell* MOZ_NON_OWNING_REF mPresShell;
96 // Note: We use nsIFrame* instead of ViewportFrame* for mRootFrame to avoid
97 // exposing ViewportFrame to the callers via GetRootFrame(), since they do not
98 // depend on any ViewportFrame-specific APIs or details.
99 nsIFrame* mRootFrame = nullptr;
102 #endif