CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / layout / mathml / nsMathMLmfracFrame.h
blobeafdf9e5f7345b3e9c539d143aa61fb7d98919b9
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>
24 * David J. Fiddes <D.J.Fiddes@hw.ac.uk>
25 * Shyjan Mahamud <mahamud@cs.cmu.edu>
26 * Frederic Wang <fred.wang@free.fr>
28 * Alternatively, the contents of this file may be used under the terms of
29 * either of the GNU General Public License Version 2 or later (the "GPL"),
30 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31 * in which case the provisions of the GPL or the LGPL are applicable instead
32 * of those above. If you wish to allow use of your version of this file only
33 * under the terms of either the GPL or the LGPL, and not to allow others to
34 * use your version of this file under the terms of the MPL, indicate your
35 * decision by deleting the provisions above and replace them with the notice
36 * and other provisions required by the GPL or the LGPL. If you do not delete
37 * the provisions above, a recipient may use your version of this file under
38 * the terms of any one of the MPL, the GPL or the LGPL.
40 * ***** END LICENSE BLOCK ***** */
42 #ifndef nsMathMLmfracFrame_h___
43 #define nsMathMLmfracFrame_h___
45 #include "nsCOMPtr.h"
46 #include "nsMathMLContainerFrame.h"
49 // <mfrac> -- form a fraction from two subexpressions
53 The MathML REC describes:
55 The <mfrac> element is used for fractions. It can also be used to mark up
56 fraction-like objects such as binomial coefficients and Legendre symbols.
57 The syntax for <mfrac> is:
58 <mfrac> numerator denominator </mfrac>
60 Attributes of <mfrac>:
61 Name values default
62 linethickness number [ v-unit ] | thin | medium | thick 1
64 E.g.,
65 linethickness=2 actually means that linethickness=2*DEFAULT_THICKNESS
66 (DEFAULT_THICKNESS is not specified by MathML, see below.)
68 The linethickness attribute indicates the thickness of the horizontal
69 "fraction bar", or "rule", typically used to render fractions. A fraction
70 with linethickness="0" renders without the bar, and might be used within
71 binomial coefficients. A linethickness greater than one might be used with
72 nested fractions.
74 In general, the value of linethickness can be a number, as a multiplier
75 of the default thickness of the fraction bar (the default thickness is
76 not specified by MathML), or a number with a unit of vertical length (see
77 Section 2.3.3), or one of the keywords medium (same as 1), thin (thinner
78 than 1, otherwise up to the renderer), or thick (thicker than 1, otherwise
79 up to the renderer).
81 The <mfrac> element sets displaystyle to "false", or if it was already
82 false increments scriptlevel by 1, within numerator and denominator.
83 These attributes are inherited by every element from its rendering
84 environment, but can be set explicitly only on the <mstyle>
85 element.
88 class nsMathMLmfracFrame : public nsMathMLContainerFrame {
89 public:
90 NS_DECL_FRAMEARENA_HELPERS
92 friend nsIFrame* NS_NewMathMLmfracFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
94 virtual eMathMLFrameType GetMathMLFrameType();
96 NS_IMETHOD
97 AttributeChanged(PRInt32 aNameSpaceID,
98 nsIAtom* aAttribute,
99 PRInt32 aModType);
101 NS_IMETHOD
102 Init(nsIContent* aContent,
103 nsIFrame* aParent,
104 nsIFrame* aPrevInFlow);
106 virtual nsresult
107 MeasureForWidth(nsIRenderingContext& aRenderingContext,
108 nsHTMLReflowMetrics& aDesiredSize);
110 virtual nsresult
111 Place(nsIRenderingContext& aRenderingContext,
112 PRBool aPlaceOrigin,
113 nsHTMLReflowMetrics& aDesiredSize);
115 NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
116 const nsRect& aDirtyRect,
117 const nsDisplayListSet& aLists);
119 NS_IMETHOD
120 TransmitAutomaticData();
122 NS_IMETHOD
123 UpdatePresentationDataFromChildAt(PRInt32 aFirstIndex,
124 PRInt32 aLastIndex,
125 PRUint32 aFlagsValues,
126 PRUint32 aFlagsToUpdate);
128 // override the base method so that we can deal with the fraction line
129 virtual nscoord
130 FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize);
132 // helper to translate the thickness attribute into a usable form
133 static nscoord
134 CalcLineThickness(nsPresContext* aPresContext,
135 nsStyleContext* aStyleContext,
136 nsString& aThicknessAttribute,
137 nscoord onePixel,
138 nscoord aDefaultRuleThickness);
140 protected:
141 nsMathMLmfracFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {}
142 virtual ~nsMathMLmfracFrame();
144 virtual PRIntn GetSkipSides() const { return 0; }
146 PRBool
147 IsBevelled();
149 nsresult PlaceInternal(nsIRenderingContext& aRenderingContext,
150 PRBool aPlaceOrigin,
151 nsHTMLReflowMetrics& aDesiredSize,
152 PRBool aWidthOnly);
154 // Display a slash
155 nsresult DisplaySlash(nsDisplayListBuilder* aBuilder,
156 nsIFrame* aFrame, const nsRect& aRect,
157 nscoord aThickness,
158 const nsDisplayListSet& aLists);
160 nsRect mLineRect;
161 nsMathMLChar* mSlashChar;
162 nscoord mLineThickness;
163 PRPackedBool mIsBevelled;
166 #endif /* nsMathMLmfracFrame_h___ */