1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsMathMLmfracFrame_h___
7 #define nsMathMLmfracFrame_h___
9 #include "mozilla/Attributes.h"
10 #include "nsMathMLContainerFrame.h"
13 // <mfrac> -- form a fraction from two subexpressions
17 The MathML REC describes:
19 The <mfrac> element is used for fractions. It can also be used to mark up
20 fraction-like objects such as binomial coefficients and Legendre symbols.
21 The syntax for <mfrac> is:
22 <mfrac> numerator denominator </mfrac>
24 Attributes of <mfrac>:
26 linethickness number [ v-unit ] | thin | medium | thick 1
29 linethickness=2 actually means that linethickness=2*DEFAULT_THICKNESS
30 (DEFAULT_THICKNESS is not specified by MathML, see below.)
32 The linethickness attribute indicates the thickness of the horizontal
33 "fraction bar", or "rule", typically used to render fractions. A fraction
34 with linethickness="0" renders without the bar, and might be used within
35 binomial coefficients. A linethickness greater than one might be used with
38 In general, the value of linethickness can be a number, as a multiplier
39 of the default thickness of the fraction bar (the default thickness is
40 not specified by MathML), or a number with a unit of vertical length (see
41 Section 2.3.3), or one of the keywords medium (same as 1), thin (thinner
42 than 1, otherwise up to the renderer), or thick (thicker than 1, otherwise
45 The <mfrac> element sets displaystyle to "false", or if it was already
46 false increments scriptlevel by 1, within numerator and denominator.
47 These attributes are inherited by every element from its rendering
48 environment, but can be set explicitly only on the <mstyle>
52 class nsMathMLmfracFrame
: public nsMathMLContainerFrame
{
54 NS_DECL_FRAMEARENA_HELPERS
56 friend nsIFrame
* NS_NewMathMLmfracFrame(nsIPresShell
* aPresShell
, nsStyleContext
* aContext
);
58 virtual eMathMLFrameType
GetMathMLFrameType() MOZ_OVERRIDE
;
61 MeasureForWidth(nsRenderingContext
& aRenderingContext
,
62 nsHTMLReflowMetrics
& aDesiredSize
) MOZ_OVERRIDE
;
65 Place(nsRenderingContext
& aRenderingContext
,
67 nsHTMLReflowMetrics
& aDesiredSize
) MOZ_OVERRIDE
;
69 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
70 const nsRect
& aDirtyRect
,
71 const nsDisplayListSet
& aLists
) MOZ_OVERRIDE
;
74 TransmitAutomaticData() MOZ_OVERRIDE
;
76 // override the base method so that we can deal with the fraction line
78 FixInterFrameSpacing(nsHTMLReflowMetrics
& aDesiredSize
) MOZ_OVERRIDE
;
80 // helper to translate the thickness attribute into a usable form
82 CalcLineThickness(nsPresContext
* aPresContext
,
83 nsStyleContext
* aStyleContext
,
84 nsString
& aThicknessAttribute
,
86 nscoord aDefaultRuleThickness
);
89 ScriptIncrement(nsIFrame
* aFrame
) MOZ_OVERRIDE
;
92 nsMathMLmfracFrame(nsStyleContext
* aContext
) : nsMathMLContainerFrame(aContext
) {}
93 virtual ~nsMathMLmfracFrame();
95 nsresult
PlaceInternal(nsRenderingContext
& aRenderingContext
,
97 nsHTMLReflowMetrics
& aDesiredSize
,
101 void DisplaySlash(nsDisplayListBuilder
* aBuilder
,
102 nsIFrame
* aFrame
, const nsRect
& aRect
,
104 const nsDisplayListSet
& aLists
);
107 nsMathMLChar
* mSlashChar
;
108 nscoord mLineThickness
;
112 #endif /* nsMathMLmfracFrame_h___ */