/src/mozilla-central/layout/base/nsFrameManager.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | /* storage of the frame tree and information about it */ |
8 | | |
9 | | #ifndef _nsFrameManager_h_ |
10 | | #define _nsFrameManager_h_ |
11 | | |
12 | | #include "nsDebug.h" |
13 | | #include "mozilla/Attributes.h" |
14 | | #include "nsFrameList.h" |
15 | | |
16 | | class nsContainerFrame; |
17 | | class nsIFrame; |
18 | | class nsILayoutHistoryState; |
19 | | class nsIPresShell; |
20 | | class nsPlaceholderFrame; |
21 | | class nsWindowSizes; |
22 | | |
23 | | /** |
24 | | * Frame manager interface. The frame manager serves one purpose: |
25 | | * <li>handles structural modifications to the frame model. If the frame model |
26 | | * lock can be acquired, then the changes are processed immediately; otherwise, |
27 | | * they're queued and processed later. |
28 | | * |
29 | | * FIXME(emilio): The comment above doesn't make any sense, there's no "frame |
30 | | * model lock" of any sort afaict. |
31 | | */ |
32 | | class nsFrameManager |
33 | | { |
34 | | typedef mozilla::layout::FrameChildListID ChildListID; |
35 | | |
36 | | public: |
37 | | explicit nsFrameManager(nsIPresShell* aPresShell) |
38 | | : mPresShell(aPresShell) |
39 | | , mRootFrame(nullptr) |
40 | 0 | { |
41 | 0 | MOZ_ASSERT(mPresShell, "need a pres shell"); |
42 | 0 | } |
43 | | ~nsFrameManager(); |
44 | | |
45 | | /* |
46 | | * Gets and sets the root frame (typically the viewport). The lifetime of the |
47 | | * root frame is controlled by the frame manager. When the frame manager is |
48 | | * destroyed, it destroys the entire frame hierarchy. |
49 | | */ |
50 | | nsIFrame* GetRootFrame() const { return mRootFrame; } |
51 | | void SetRootFrame(nsIFrame* aRootFrame) |
52 | 0 | { |
53 | 0 | NS_ASSERTION(!mRootFrame, "already have a root frame"); |
54 | 0 | mRootFrame = aRootFrame; |
55 | 0 | } |
56 | | |
57 | | /* |
58 | | * After Destroy is called, it is an error to call any FrameManager methods. |
59 | | * Destroy should be called when the frame tree managed by the frame |
60 | | * manager is no longer being displayed. |
61 | | */ |
62 | | void Destroy(); |
63 | | |
64 | | // Functions for manipulating the frame model |
65 | | void AppendFrames(nsContainerFrame* aParentFrame, |
66 | | ChildListID aListID, |
67 | | nsFrameList& aFrameList); |
68 | | |
69 | | void InsertFrames(nsContainerFrame* aParentFrame, |
70 | | ChildListID aListID, |
71 | | nsIFrame* aPrevFrame, |
72 | | nsFrameList& aFrameList); |
73 | | |
74 | | void RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame); |
75 | | |
76 | | /* |
77 | | * Capture/restore frame state for the frame subtree rooted at aFrame. |
78 | | * aState is the document state storage object onto which each frame |
79 | | * stores its state. Callers of CaptureFrameState are responsible for |
80 | | * traversing next continuations of special siblings of aFrame as |
81 | | * needed; this method will only work with actual frametree descendants |
82 | | * of aFrame. |
83 | | */ |
84 | | |
85 | | void CaptureFrameState(nsIFrame* aFrame, nsILayoutHistoryState* aState); |
86 | | |
87 | | void RestoreFrameState(nsIFrame* aFrame, nsILayoutHistoryState* aState); |
88 | | |
89 | | /* |
90 | | * Add/restore state for one frame |
91 | | */ |
92 | | void CaptureFrameStateFor(nsIFrame* aFrame, nsILayoutHistoryState* aState); |
93 | | |
94 | | void RestoreFrameStateFor(nsIFrame* aFrame, nsILayoutHistoryState* aState); |
95 | | |
96 | | void AddSizeOfIncludingThis(nsWindowSizes& aSizes) const; |
97 | | |
98 | | protected: |
99 | | // weak link, because the pres shell owns us |
100 | | nsIPresShell* MOZ_NON_OWNING_REF mPresShell; |
101 | | nsIFrame* mRootFrame; |
102 | | }; |
103 | | |
104 | | #endif |