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 /* factory functions for rendering object classes */
8 
9 #ifndef nsHTMLParts_h___
10 #define nsHTMLParts_h___
11 
12 #include "nscore.h"
13 #include "nsISupports.h"
14 #include "nsIFrame.h"
15 class nsComboboxControlFrame;
16 class nsCheckboxRadioFrame;
17 class nsAtom;
18 class nsNodeInfoManager;
19 class nsIContent;
20 class nsIDocument;
21 class nsIFrame;
22 class nsIHTMLContentSink;
23 class nsIFragmentContentSink;
24 class nsStyleContext;
25 class nsIURI;
26 class nsIPresShell;
27 class nsIChannel;
28 class nsTableColFrame;
29 namespace mozilla {
30 class ViewportFrame;
31 }  // namespace mozilla
32 
33 // These are all the block specific frame bits, they are copied from
34 // the prev-in-flow to a newly created next-in-flow, except for the
35 // NS_BLOCK_FLAGS_NON_INHERITED_MASK bits below.
36 #define NS_BLOCK_FLAGS_MASK                                                    \
37   (NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS | NS_BLOCK_CLIP_PAGINATED_OVERFLOW | \
38    NS_BLOCK_HAS_FIRST_LETTER_STYLE | NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET |       \
39    NS_BLOCK_HAS_FIRST_LETTER_CHILD | NS_BLOCK_FRAME_HAS_INSIDE_BULLET)
40 
41 // This is the subset of NS_BLOCK_FLAGS_MASK that is NOT inherited
42 // by default.  They should only be set on the first-in-flow.
43 // See nsBlockFrame::Init.
44 #define NS_BLOCK_FLAGS_NON_INHERITED_MASK                                \
45   (NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET | NS_BLOCK_HAS_FIRST_LETTER_CHILD | \
46    NS_BLOCK_FRAME_HAS_INSIDE_BULLET)
47 
48 // Factory methods for creating html layout objects
49 
50 // Create a frame that supports "display: block" layout behavior
51 class nsBlockFrame;
52 nsBlockFrame* NS_NewBlockFrame(nsIPresShell* aPresShell,
53                                nsStyleContext* aContext);
54 
55 // Special Generated Content Node. It contains text taken from an
56 // attribute of its *grandparent* content node.
57 nsresult NS_NewAttributeContent(nsNodeInfoManager* aNodeInfoManager,
58                                 int32_t aNameSpaceID, nsAtom* aAttrName,
59                                 nsIContent** aResult);
60 
61 // Create a basic area frame but the GetFrameForPoint is overridden to always
62 // return the option frame
63 // By default, area frames will extend
64 // their height to cover any children that "stick out".
65 nsContainerFrame* NS_NewSelectsAreaFrame(nsIPresShell* aPresShell,
66                                          nsStyleContext* aContext,
67                                          nsFrameState aFlags);
68 
69 // Create a block formatting context blockframe
70 nsBlockFrame* NS_NewBlockFormattingContext(nsIPresShell* aPresShell,
71                                            nsStyleContext* aStyleContext);
72 
73 nsIFrame* NS_NewBRFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
74 
75 nsIFrame* NS_NewCommentFrame(nsIPresShell* aPresShell,
76                              nsStyleContext* aContext);
77 
78 // <frame> and <iframe>
79 nsIFrame* NS_NewSubDocumentFrame(nsIPresShell* aPresShell,
80                                  nsStyleContext* aContext);
81 // <frameset>
82 nsIFrame* NS_NewHTMLFramesetFrame(nsIPresShell* aPresShell,
83                                   nsStyleContext* aContext);
84 
85 mozilla::ViewportFrame* NS_NewViewportFrame(nsIPresShell* aPresShell,
86                                             nsStyleContext* aContext);
87 class nsCanvasFrame;
88 nsCanvasFrame* NS_NewCanvasFrame(nsIPresShell* aPresShell,
89                                  nsStyleContext* aContext);
90 nsIFrame* NS_NewImageFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
91 class nsInlineFrame;
92 nsInlineFrame* NS_NewInlineFrame(nsIPresShell* aPresShell,
93                                  nsStyleContext* aContext);
94 nsIFrame* NS_NewObjectFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
95 nsIFrame* NS_NewTextFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
96 nsIFrame* NS_NewContinuingTextFrame(nsIPresShell* aPresShell,
97                                     nsStyleContext* aContext);
98 nsIFrame* NS_NewEmptyFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
NS_NewWBRFrame(nsIPresShell * aPresShell,nsStyleContext * aContext)99 inline nsIFrame* NS_NewWBRFrame(nsIPresShell* aPresShell,
100                                 nsStyleContext* aContext) {
101   return NS_NewEmptyFrame(aPresShell, aContext);
102 }
103 
104 nsContainerFrame* NS_NewColumnSetFrame(nsIPresShell* aPresShell,
105                                        nsStyleContext* aContext,
106                                        nsFrameState aStateFlags);
107 
108 class nsSimplePageSequenceFrame;
109 nsSimplePageSequenceFrame* NS_NewSimplePageSequenceFrame(
110     nsIPresShell* aPresShell, nsStyleContext* aContext);
111 class nsPageFrame;
112 nsPageFrame* NS_NewPageFrame(nsIPresShell* aPresShell,
113                              nsStyleContext* aContext);
114 class nsPageContentFrame;
115 nsPageContentFrame* NS_NewPageContentFrame(nsIPresShell* aPresShell,
116                                            nsStyleContext* aContext);
117 nsIFrame* NS_NewPageBreakFrame(nsIPresShell* aPresShell,
118                                nsStyleContext* aContext);
119 class nsFirstLetterFrame;
120 nsFirstLetterFrame* NS_NewFirstLetterFrame(nsIPresShell* aPresShell,
121                                            nsStyleContext* aContext);
122 class nsFirstLineFrame;
123 nsFirstLineFrame* NS_NewFirstLineFrame(nsIPresShell* aPresShell,
124                                        nsStyleContext* aContext);
125 
126 // forms
127 nsContainerFrame* NS_NewGfxButtonControlFrame(nsIPresShell* aPresShell,
128                                               nsStyleContext* aContext);
129 nsCheckboxRadioFrame* NS_NewCheckboxRadioFrame(nsIPresShell* aPresShell,
130                                                nsStyleContext* aContext);
131 nsIFrame* NS_NewImageControlFrame(nsIPresShell* aPresShell,
132                                   nsStyleContext* aContext);
133 nsContainerFrame* NS_NewHTMLButtonControlFrame(nsIPresShell* aPresShell,
134                                                nsStyleContext* aContext);
135 nsContainerFrame* NS_NewFieldSetFrame(nsIPresShell* aPresShell,
136                                       nsStyleContext* aContext);
137 nsIFrame* NS_NewFileControlFrame(nsIPresShell* aPresShell,
138                                  nsStyleContext* aContext);
139 nsIFrame* NS_NewColorControlFrame(nsIPresShell* aPresShell,
140                                   nsStyleContext* aContext);
141 nsIFrame* NS_NewLegendFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
142 nsIFrame* NS_NewTextControlFrame(nsIPresShell* aPresShell,
143                                  nsStyleContext* aContext);
144 nsContainerFrame* NS_NewListControlFrame(nsIPresShell* aPresShell,
145                                          nsStyleContext* aContext);
146 nsComboboxControlFrame* NS_NewComboboxControlFrame(nsIPresShell* aPresShell,
147                                                    nsStyleContext* aContext,
148                                                    nsFrameState aFlags);
149 nsIFrame* NS_NewProgressFrame(nsIPresShell* aPresShell,
150                               nsStyleContext* aContext);
151 nsIFrame* NS_NewMeterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
152 nsIFrame* NS_NewRangeFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
153 nsIFrame* NS_NewNumberControlFrame(nsIPresShell* aPresShell,
154                                    nsStyleContext* aContext);
155 nsIFrame* NS_NewDateTimeControlFrame(nsIPresShell* aPresShell,
156                                      nsStyleContext* aContext);
157 nsBlockFrame* NS_NewDetailsFrame(nsIPresShell* aPresShell,
158                                  nsStyleContext* aContext);
159 
160 // Table frame factories
161 class nsTableWrapperFrame;
162 nsTableWrapperFrame* NS_NewTableWrapperFrame(nsIPresShell* aPresShell,
163                                              nsStyleContext* aContext);
164 class nsTableFrame;
165 nsTableFrame* NS_NewTableFrame(nsIPresShell* aPresShell,
166                                nsStyleContext* aContext);
167 nsTableColFrame* NS_NewTableColFrame(nsIPresShell* aPresShell,
168                                      nsStyleContext* aContext);
169 class nsTableColGroupFrame;
170 nsTableColGroupFrame* NS_NewTableColGroupFrame(nsIPresShell* aPresShell,
171                                                nsStyleContext* aContext);
172 class nsTableRowFrame;
173 nsTableRowFrame* NS_NewTableRowFrame(nsIPresShell* aPresShell,
174                                      nsStyleContext* aContext);
175 class nsTableRowGroupFrame;
176 nsTableRowGroupFrame* NS_NewTableRowGroupFrame(nsIPresShell* aPresShell,
177                                                nsStyleContext* aContext);
178 class nsTableCellFrame;
179 nsTableCellFrame* NS_NewTableCellFrame(nsIPresShell* aPresShell,
180                                        nsStyleContext* aContext,
181                                        nsTableFrame* aTableFrame);
182 
183 nsresult NS_NewHTMLContentSink(nsIHTMLContentSink** aInstancePtrResult,
184                                nsIDocument* aDoc, nsIURI* aURL,
185                                nsISupports* aContainer,  // e.g. docshell
186                                nsIChannel* aChannel);
187 nsresult NS_NewHTMLFragmentContentSink(
188     nsIFragmentContentSink** aInstancePtrResult);
189 nsresult NS_NewHTMLFragmentContentSink2(
190     nsIFragmentContentSink** aInstancePtrResult);
191 
192 #endif /* nsHTMLParts_h___ */
193