Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim:cindent:ts=2:et:sw=2:
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 *
8 * This Original Code has been modified by IBM Corporation. Modifications made
9 * by IBM described herein are Copyright (c) International Business Machines
10 * Corporation, 2000. Modifications to Mozilla code or documentation identified
11 * per MPL Section 3.3
12 *
13 * Date Modified by Description of modification
14 * 04/20/2000 IBM Corp. OS/2 VisualAge build.
15 */
17 /* storage of the frame tree and information about it */
19 #ifndef _nsFrameManager_h_
20 #define _nsFrameManager_h_
22 #include "nsIFrame.h"
23 #include "nsFrameManagerBase.h"
24 #include "nsIContent.h"
26 namespace mozilla {
27 /**
28 * Node in a linked list, containing the style for an element that
29 * does not have a frame but whose parent does have a frame.
30 */
31 struct UndisplayedNode {
32 UndisplayedNode(nsIContent* aContent, nsStyleContext* aStyle)
33 : mContent(aContent),
34 mStyle(aStyle),
35 mNext(nullptr)
36 {
37 MOZ_COUNT_CTOR(mozilla::UndisplayedNode);
38 }
40 NS_HIDDEN ~UndisplayedNode()
41 {
42 MOZ_COUNT_DTOR(mozilla::UndisplayedNode);
44 // Delete mNext iteratively to avoid blowing up the stack (bug 460461).
45 UndisplayedNode* cur = mNext;
46 while (cur) {
47 UndisplayedNode* next = cur->mNext;
48 cur->mNext = nullptr;
49 delete cur;
50 cur = next;
51 }
52 }
54 nsCOMPtr<nsIContent> mContent;
55 nsRefPtr<nsStyleContext> mStyle;
56 UndisplayedNode* mNext;
57 };
59 } // namespace mozilla
61 /**
62 * Frame manager interface. The frame manager serves two purposes:
63 * <li>provides a service for mapping from content to frame and from
64 * out-of-flow frame to placeholder frame.
65 * <li>handles structural modifications to the frame model. If the frame model
66 * lock can be acquired, then the changes are processed immediately; otherwise,
67 * they're queued and processed later.
68 *
69 * Do not add virtual methods to this class, or bryner will punish you.
70 */
72 class nsFrameManager : public nsFrameManagerBase
73 {
74 typedef nsIFrame::ChildListID ChildListID;
76 public:
77 nsFrameManager(nsIPresShell *aPresShell, nsStyleSet* aStyleSet) NS_HIDDEN {
78 mPresShell = aPresShell;
79 mStyleSet = aStyleSet;
80 MOZ_ASSERT(mPresShell, "need a pres shell");
81 MOZ_ASSERT(mStyleSet, "need a style set");
82 }
83 ~nsFrameManager() NS_HIDDEN;
85 /*
86 * After Destroy is called, it is an error to call any FrameManager methods.
87 * Destroy should be called when the frame tree managed by the frame
88 * manager is no longer being displayed.
89 */
90 NS_HIDDEN_(void) Destroy();
92 // Placeholder frame functions
93 NS_HIDDEN_(nsPlaceholderFrame*) GetPlaceholderFrameFor(const nsIFrame* aFrame);
94 NS_HIDDEN_(nsresult)
95 RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame);
97 NS_HIDDEN_(void)
98 UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame);
100 NS_HIDDEN_(void) ClearPlaceholderFrameMap();
102 // Mapping undisplayed content
103 NS_HIDDEN_(nsStyleContext*) GetUndisplayedContent(nsIContent* aContent);
104 NS_HIDDEN_(mozilla::UndisplayedNode*)
105 GetAllUndisplayedContentIn(nsIContent* aParentContent);
106 NS_HIDDEN_(void) SetUndisplayedContent(nsIContent* aContent,
107 nsStyleContext* aStyleContext);
108 NS_HIDDEN_(void) ChangeUndisplayedContent(nsIContent* aContent,
109 nsStyleContext* aStyleContext);
110 NS_HIDDEN_(void) ClearUndisplayedContentIn(nsIContent* aContent,
111 nsIContent* aParentContent);
112 NS_HIDDEN_(void) ClearAllUndisplayedContentIn(nsIContent* aParentContent);
114 // Functions for manipulating the frame model
115 NS_HIDDEN_(nsresult) AppendFrames(nsIFrame* aParentFrame,
116 ChildListID aListID,
117 nsFrameList& aFrameList);
119 NS_HIDDEN_(nsresult) InsertFrames(nsIFrame* aParentFrame,
120 ChildListID aListID,
121 nsIFrame* aPrevFrame,
122 nsFrameList& aFrameList);
124 NS_HIDDEN_(nsresult) RemoveFrame(ChildListID aListID,
125 nsIFrame* aOldFrame);
127 /*
128 * Notification that a frame is about to be destroyed. This allows any
129 * outstanding references to the frame to be cleaned up.
130 */
131 NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame);
133 /*
134 * Capture/restore frame state for the frame subtree rooted at aFrame.
135 * aState is the document state storage object onto which each frame
136 * stores its state. Callers of CaptureFrameState are responsible for
137 * traversing next continuations of special siblings of aFrame as
138 * needed; this method will only work with actual frametree descendants
139 * of aFrame.
140 */
142 NS_HIDDEN_(void) CaptureFrameState(nsIFrame* aFrame,
143 nsILayoutHistoryState* aState);
145 NS_HIDDEN_(void) RestoreFrameState(nsIFrame* aFrame,
146 nsILayoutHistoryState* aState);
148 /*
149 * Add/restore state for one frame
150 */
151 NS_HIDDEN_(void) CaptureFrameStateFor(nsIFrame* aFrame,
152 nsILayoutHistoryState* aState);
154 NS_HIDDEN_(void) RestoreFrameStateFor(nsIFrame* aFrame,
155 nsILayoutHistoryState* aState);
157 NS_HIDDEN_(nsIPresShell*) GetPresShell() const { return mPresShell; }
158 NS_HIDDEN_(nsPresContext*) GetPresContext() const {
159 return mPresShell->GetPresContext();
160 }
161 };
163 #endif