Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / layout / mathml / base / src / nsIMathMLFrame.h
blob042616d7f9c457d4a1cf38a202125d5fd98b935b
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Mozilla MathML Project.
17 * The Initial Developer of the Original Code is
18 * The University Of Queensland.
19 * Portions created by the Initial Developer are Copyright (C) 1999
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Roger B. Sidje <rbs@maths.uq.edu.au>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
38 //#define SHOW_BOUNDING_BOX 1
39 #ifndef nsIMathMLFrame_h___
40 #define nsIMathMLFrame_h___
42 #include "nsIRenderingContext.h"
43 #include "nsIFrame.h"
45 struct nsPresentationData;
46 struct nsEmbellishData;
47 struct nsHTMLReflowMetrics;
49 // a781ed45-4338-43cb-9739-a7a8f8418ff3
50 #define NS_IMATHMLFRAME_IID \
51 { 0xa781ed45, 0x4338, 0x43cb, \
52 { 0x97, 0x39, 0xa7, 0xa8, 0xf8, 0x41, 0x8f, 0xf3 } }
54 static NS_DEFINE_IID(kIMathMLFrameIID, NS_IMATHMLFRAME_IID);
56 // For MathML, this 'type' will be used to determine the spacing between frames
57 // Subclasses can return a 'type' that will give them a particular spacing
58 enum eMathMLFrameType {
59 eMathMLFrameType_UNKNOWN = -1,
60 eMathMLFrameType_Ordinary,
61 eMathMLFrameType_OperatorOrdinary,
62 eMathMLFrameType_OperatorInvisible,
63 eMathMLFrameType_OperatorUserDefined,
64 eMathMLFrameType_Inner,
65 eMathMLFrameType_ItalicIdentifier,
66 eMathMLFrameType_UprightIdentifier,
67 eMathMLFrameType_COUNT
70 // Abstract base class that provides additional methods for MathML frames
71 class nsIMathMLFrame : public nsISupports {
72 public:
73 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMATHMLFRAME_IID)
75 /* SUPPORT FOR PRECISE POSITIONING */
76 /*====================================================================*/
78 /* Metrics that _exactly_ enclose the text of the frame.
79 * The frame *must* have *already* being reflowed, before you can call
80 * the GetBoundingMetrics() method.
81 * Note that for a frame with nested children, the bounding metrics
82 * will exactly enclose its children. For example, the bounding metrics
83 * of msub is the smallest rectangle that exactly encloses both the
84 * base and the subscript.
86 NS_IMETHOD
87 GetBoundingMetrics(nsBoundingMetrics& aBoundingMetrics) = 0;
89 NS_IMETHOD
90 SetBoundingMetrics(const nsBoundingMetrics& aBoundingMetrics) = 0;
92 NS_IMETHOD
93 GetReference(nsPoint& aReference) = 0;
95 NS_IMETHOD
96 SetReference(const nsPoint& aReference) = 0;
98 virtual eMathMLFrameType GetMathMLFrameType() = 0;
100 /* SUPPORT FOR STRETCHY ELEMENTS */
101 /*====================================================================*/
103 /* Stretch :
104 * Called to ask a stretchy MathML frame to stretch itself depending
105 * on its context.
107 * An embellished frame is treated in a special way. When it receives a
108 * Stretch() command, it passes the command to its embellished child and
109 * the stretched size is bubbled up from the inner-most <mo> frame. In other
110 * words, the stretch command descend through the embellished hierarchy.
112 * @param aStretchDirection [in] the direction where to attempt to
113 * stretch.
114 * @param aContainerSize [in] struct that suggests the maximumn size for
115 * the stretched frame. Only member data of the struct that are
116 * relevant to the direction are used (the rest is ignored).
117 * @param aDesiredStretchSize [in/out] On input the current size
118 * of the frame, on output the size after stretching.
120 NS_IMETHOD
121 Stretch(nsIRenderingContext& aRenderingContext,
122 nsStretchDirection aStretchDirection,
123 nsBoundingMetrics& aContainerSize,
124 nsHTMLReflowMetrics& aDesiredStretchSize) = 0;
126 /* GetEmbellishData/SetEmbellishData :
127 * Get/Set the mEmbellishData member variable.
130 NS_IMETHOD
131 GetEmbellishData(nsEmbellishData& aEmbellishData) = 0;
133 NS_IMETHOD
134 SetEmbellishData(const nsEmbellishData& aEmbellishData) = 0;
137 /* SUPPORT FOR SCRIPTING ELEMENTS */
138 /*====================================================================*/
140 /* GetPresentationData/SetPresentationData :
141 * Get/Set the mPresentationData member variable.
144 NS_IMETHOD
145 GetPresentationData(nsPresentationData& aPresentationData) = 0;
147 NS_IMETHOD
148 SetPresentationData(const nsPresentationData& aPresentationData) = 0;
150 /* InheritAutomaticData() / TransmitAutomaticData() :
151 * There are precise rules governing each MathML frame and its children.
152 * Properties such as the scriptlevel or the embellished nature of a frame
153 * depend on those rules. Also, certain properties that we use to emulate
154 * TeX rendering rules are frame-dependent too. These two methods are meant
155 * to be implemented by frame classes that need to assert specific properties
156 * within their subtrees.
158 * InheritAutomaticData() is called in a top-down manner [like nsIFrame::Init],
159 * as we descend the frame tree, whereas TransmitAutomaticData() is called in a
160 * bottom-up manner, as we ascend the tree [like nsIFrame::SetInitialChildList].
161 * However, unlike Init() and SetInitialChildList() which are called only once
162 * during the life-time of a frame (when initially constructing the frame tree),
163 * these two methods are called to build automatic data after the <math>...</math>
164 * subtree has been constructed fully, and are called again as we walk a child's
165 * subtree to handle dynamic changes that happen in the content model.
167 * As a rule of thumb:
169 * 1. Use InheritAutomaticData() to set properties related to your ancestors:
170 * - set properties that are intrinsic to yourself
171 * - set properties that depend on the state that you expect your ancestors
172 * to have already reached in their own InheritAutomaticData().
173 * - set properties that your descendants assume that you would have set in
174 * your InheritAutomaticData() -- this way, they can safely query them and
175 * the process will feed upon itself.
177 * 2. Use TransmitAutomaticData() to set properties related to your descendants:
178 * - set properties that depend on the state that you expect your descendants
179 * to have reached upon processing their own TransmitAutomaticData().
180 * - transmit properties that your descendants expect that you will transmit to
181 * them in your TransmitAutomaticData() -- this way, they remain up-to-date.
182 * - set properties that your ancestors expect that you would set in your
183 * TransmitAutomaticData() -- this way, they can safely query them and the
184 * process will feed upon itself.
187 NS_IMETHOD
188 InheritAutomaticData(nsIFrame* aParent) = 0;
190 NS_IMETHOD
191 TransmitAutomaticData() = 0;
193 /* UpdatePresentationData :
194 * Updates the frame's displaystyle and compression flags. The displaystyle
195 * flag of an environment gets updated according to the MathML specification.
196 * A frame becomes "compressed" (or "cramped") according to TeX rendering
197 * rules (TeXBook, Ch.17, p.140-141).
199 * Note that <mstyle> is the only tag which allows to set
200 * <mstyle displaystyle="true|false">
201 * Therefore <mstyle> has its own peculiar version of this method.
203 * @param aFlagsValues [in]
204 * The new values (e.g., display, compress) that are going to be
205 * updated.
207 * @param aWhichFlags [in]
208 * The flags that are relevant to this call. Since not all calls
209 * are meant to update all flags at once, aWhichFlags is used
210 * to distinguish flags that need to retain their existing values
211 * from flags that need to be turned on (or turned off). If a bit
212 * is set in aWhichFlags, then the corresponding value (which
213 * can be 0 or 1) is taken from aFlagsValues and applied to the
214 * frame. Therefore, by setting their bits in aWhichFlags, and
215 * setting their desired values in aFlagsValues, it is possible to
216 * update some flags in the frame, leaving the other flags unchanged.
218 NS_IMETHOD
219 UpdatePresentationData(PRUint32 aFlagsValues,
220 PRUint32 aWhichFlags) = 0;
222 /* UpdatePresentationDataFromChildAt :
223 * Sets displaystyle and compression flags on the whole tree. For child frames
224 * at aFirstIndex up to aLastIndex, this method sets their displaystyle and
225 * compression flags. The update is propagated down the subtrees of each of
226 * these child frames.
228 * Note that <mstyle> is the only tag which allows
229 * <mstyle displaystyle="true|false">
230 * Therefore <mstyle> has its own peculiar version of this method.
232 * @param aFirstIndex [in]
233 * Index of the first child from where the update is propagated.
235 * @param aLastIndex [in]
236 * Index of the last child where to stop the update.
237 * A value of -1 means up to last existing child.
239 * @param aFlagsValues [in]
240 * The new values (e.g., display, compress) that are going to be
241 * assigned in the whole sub-trees.
243 * @param aWhichFlags [in]
244 * The flags that are relevant to this call. See UpdatePresentationData()
245 * for more details about this parameter.
247 NS_IMETHOD
248 UpdatePresentationDataFromChildAt(PRInt32 aFirstIndex,
249 PRInt32 aLastIndex,
250 PRUint32 aFlagsValues,
251 PRUint32 aWhichFlags) = 0;
254 // struct used by a container frame to keep track of its embellishments.
255 // By convention, the data that we keep here is bubbled from the embellished
256 // hierarchy, and it remains unchanged unless we have to recover from a change
257 // that occurs in the embellished hierarchy. The struct remains in its nil
258 // state in those frames that are not part of the embellished hierarchy.
259 struct nsEmbellishData {
260 // bits used to mark certain properties of our embellishments
261 PRUint32 flags;
263 // pointer on the <mo> frame at the core of the embellished hierarchy
264 nsIFrame* coreFrame;
266 // stretchy direction that the nsMathMLChar owned by the core <mo> supports
267 nsStretchDirection direction;
269 // spacing that may come from <mo> depending on its 'form'. Since
270 // the 'form' may also depend on the position of the outermost
271 // embellished ancestor, the set up of these values may require
272 // looking up the position of our ancestors.
273 nscoord leftSpace;
274 nscoord rightSpace;
276 nsEmbellishData() {
277 flags = 0;
278 coreFrame = nsnull;
279 direction = NS_STRETCH_DIRECTION_UNSUPPORTED;
280 leftSpace = 0;
281 rightSpace = 0;
285 // struct used by a container frame to modulate its presentation.
286 // By convention, the data that we keep in this struct can change depending
287 // on any of our ancestors and/or descendants. If a data can be resolved
288 // solely from the embellished hierarchy, and it remains immutable once
289 // resolved, we put it in |nsEmbellishData|. If it can be affected by other
290 // things, it comes here. This struct is updated as we receive information
291 // transmitted by our ancestors and is kept in sync with changes in our
292 // descendants that affects us.
293 struct nsPresentationData {
294 // bits for: displaystyle, compressed, etc
295 PRUint32 flags;
297 // handy pointer on our base child (the 'nucleus' in TeX), but it may be
298 // null here (e.g., tags like <mrow>, <mfrac>, <mtable>, etc, won't
299 // pick a particular child in their child list to be the base)
300 nsIFrame* baseFrame;
302 // up-pointer on the mstyle frame, if any, that defines the scope
303 nsIFrame* mstyle;
305 nsPresentationData() {
306 flags = 0;
307 baseFrame = nsnull;
308 mstyle = nsnull;
312 NS_DEFINE_STATIC_IID_ACCESSOR(nsIMathMLFrame, NS_IMATHMLFRAME_IID)
315 // ==========================================================================
316 // Bits used for the presentation flags -- these bits are set
317 // in their relevant situation as they become available
319 // This bit is set if the frame is in the *context* of displaystyle=true.
320 // Note: This doesn't mean that the frame has displaystyle=true as attribute,
321 // the displaystyle attribute is only allowed on <mstyle> and <mtable>.
322 // The bit merely tells the context of the frame. In the context of
323 // displaystyle="false", it is intended to slightly alter how the
324 // rendering is done in inline mode.
325 #define NS_MATHML_DISPLAYSTYLE 0x00000001U
327 // This bit is used to emulate TeX rendering.
328 // Internal use only, cannot be set by the user with an attribute.
329 #define NS_MATHML_COMPRESSED 0x00000002U
331 // This bit is set if the frame will fire a vertical stretch
332 // command on all its (non-empty) children.
333 // Tags like <mrow> (or an inferred mrow), mpadded, etc, will fire a
334 // vertical stretch command on all their non-empty children
335 #define NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY 0x00000004U
337 // This bit is set if the frame will fire a horizontal stretch
338 // command on all its (non-empty) children.
339 // Tags like munder, mover, munderover, will fire a
340 // horizontal stretch command on all their non-empty children
341 #define NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY 0x00000008U
343 // This bit is set if the frame has the explicit attribute
344 // displaystyle="true" or "false". It is only relevant to <mstyle> and <mtable>
345 // because they are the only tags where the attribute is allowed by the spec.
346 #define NS_MATHML_EXPLICIT_DISPLAYSTYLE 0x00000020U
348 // This bit is set when the frame cannot be formatted due to an
349 // error (e.g., invalid markup such as a <msup> without an overscript).
350 // When set, a visual feedback will be provided to the user.
351 #define NS_MATHML_ERROR 0x80000000U
353 // a bit used for debug
354 #define NS_MATHML_STRETCH_DONE 0x20000000U
356 // This bit is used for visual debug. When set, the bounding box
357 // of your frame is painted. This visual debug enable to ensure that
358 // you have properly filled your mReference and mBoundingMetrics in
359 // Place().
360 #define NS_MATHML_SHOW_BOUNDING_METRICS 0x10000000U
362 // Macros that retrieve those bits
364 #define NS_MATHML_IS_DISPLAYSTYLE(_flags) \
365 (NS_MATHML_DISPLAYSTYLE == ((_flags) & NS_MATHML_DISPLAYSTYLE))
367 #define NS_MATHML_IS_COMPRESSED(_flags) \
368 (NS_MATHML_COMPRESSED == ((_flags) & NS_MATHML_COMPRESSED))
370 #define NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY(_flags) \
371 (NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY == ((_flags) & NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY))
373 #define NS_MATHML_WILL_STRETCH_ALL_CHILDREN_HORIZONTALLY(_flags) \
374 (NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY == ((_flags) & NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY))
376 #define NS_MATHML_HAS_EXPLICIT_DISPLAYSTYLE(_flags) \
377 (NS_MATHML_EXPLICIT_DISPLAYSTYLE == ((_flags) & NS_MATHML_EXPLICIT_DISPLAYSTYLE))
379 #define NS_MATHML_HAS_ERROR(_flags) \
380 (NS_MATHML_ERROR == ((_flags) & NS_MATHML_ERROR))
382 #define NS_MATHML_STRETCH_WAS_DONE(_flags) \
383 (NS_MATHML_STRETCH_DONE == ((_flags) & NS_MATHML_STRETCH_DONE))
385 #define NS_MATHML_PAINT_BOUNDING_METRICS(_flags) \
386 (NS_MATHML_SHOW_BOUNDING_METRICS == ((_flags) & NS_MATHML_SHOW_BOUNDING_METRICS))
388 // ==========================================================================
389 // Bits used for the embellish flags -- these bits are set
390 // in their relevant situation as they become available
392 // This bit is set if the frame is an embellished operator.
393 #define NS_MATHML_EMBELLISH_OPERATOR 0x00000001
395 // This bit is set if the frame is an <mo> frame or an embellihsed
396 // operator for which the core <mo> has movablelimits="true"
397 #define NS_MATHML_EMBELLISH_MOVABLELIMITS 0x00000002
399 // This bit is set if the frame is an <mo> frame or an embellihsed
400 // operator for which the core <mo> has accent="true"
401 #define NS_MATHML_EMBELLISH_ACCENT 0x00000004
403 // This bit is set if the frame is an <mover> or <munderover> with
404 // an accent frame
405 #define NS_MATHML_EMBELLISH_ACCENTOVER 0x00000008
407 // This bit is set if the frame is an <munder> or <munderover> with
408 // an accentunder frame
409 #define NS_MATHML_EMBELLISH_ACCENTUNDER 0x00000010
411 // Macros that retrieve those bits
413 #define NS_MATHML_IS_EMBELLISH_OPERATOR(_flags) \
414 (NS_MATHML_EMBELLISH_OPERATOR == ((_flags) & NS_MATHML_EMBELLISH_OPERATOR))
416 #define NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(_flags) \
417 (NS_MATHML_EMBELLISH_MOVABLELIMITS == ((_flags) & NS_MATHML_EMBELLISH_MOVABLELIMITS))
419 #define NS_MATHML_EMBELLISH_IS_ACCENT(_flags) \
420 (NS_MATHML_EMBELLISH_ACCENT == ((_flags) & NS_MATHML_EMBELLISH_ACCENT))
422 #define NS_MATHML_EMBELLISH_IS_ACCENTOVER(_flags) \
423 (NS_MATHML_EMBELLISH_ACCENTOVER == ((_flags) & NS_MATHML_EMBELLISH_ACCENTOVER))
425 #define NS_MATHML_EMBELLISH_IS_ACCENTUNDER(_flags) \
426 (NS_MATHML_EMBELLISH_ACCENTUNDER == ((_flags) & NS_MATHML_EMBELLISH_ACCENTUNDER))
428 #endif /* nsIMathMLFrame_h___ */