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/. */
7 #ifndef nsMathMLmfracFrame_h___
8 #define nsMathMLmfracFrame_h___
10 #include "mozilla/Attributes.h"
11 #include "nsMathMLContainerFrame.h"
15 } // namespace mozilla
18 // <mfrac> -- form a fraction from two subexpressions
22 The MathML REC describes:
24 The <mfrac> element is used for fractions. It can also be used to mark up
25 fraction-like objects such as binomial coefficients and Legendre symbols.
26 The syntax for <mfrac> is:
27 <mfrac> numerator denominator </mfrac>
29 Attributes of <mfrac>:
31 linethickness number [ v-unit ] | thin | medium | thick 1
34 linethickness=2 actually means that linethickness=2*DEFAULT_THICKNESS
35 (DEFAULT_THICKNESS is not specified by MathML, see below.)
37 The linethickness attribute indicates the thickness of the horizontal
38 "fraction bar", or "rule", typically used to render fractions. A fraction
39 with linethickness="0" renders without the bar, and might be used within
40 binomial coefficients. A linethickness greater than one might be used with
43 In general, the value of linethickness can be a number, as a multiplier
44 of the default thickness of the fraction bar (the default thickness is
45 not specified by MathML), or a number with a unit of vertical length (see
46 Section 2.3.3), or one of the keywords medium (same as 1), thin (thinner
47 than 1, otherwise up to the renderer), or thick (thicker than 1, otherwise
50 The <mfrac> element sets displaystyle to "false", or if it was already
51 false increments scriptlevel by 1, within numerator and denominator.
52 These attributes are inherited by every element from its rendering
53 environment, but can be set explicitly only on the <mstyle>
57 class nsMathMLmfracFrame final
: public nsMathMLContainerFrame
{
59 NS_DECL_FRAMEARENA_HELPERS(nsMathMLmfracFrame
)
61 friend nsIFrame
* NS_NewMathMLmfracFrame(mozilla::PresShell
* aPresShell
,
62 ComputedStyle
* aStyle
);
64 virtual eMathMLFrameType
GetMathMLFrameType() override
;
66 virtual nsresult
MeasureForWidth(DrawTarget
* aDrawTarget
,
67 ReflowOutput
& aDesiredSize
) override
;
69 nsresult
Place(DrawTarget
* aDrawTarget
, const PlaceFlags
& aFlags
,
70 ReflowOutput
& aDesiredSize
) override
;
72 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
73 const nsDisplayListSet
& aLists
) override
;
75 virtual nsresult
AttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
76 int32_t aModType
) override
;
79 TransmitAutomaticData() override
;
81 // override the base method so that we can deal with the fraction line
82 virtual nscoord
FixInterFrameSpacing(ReflowOutput
& aDesiredSize
) override
;
84 // helper to translate the thickness attribute into a usable form
85 nscoord
CalcLineThickness(nsPresContext
* aPresContext
,
86 ComputedStyle
* aComputedStyle
,
87 nsString
& aThicknessAttribute
, nscoord onePixel
,
88 nscoord aDefaultRuleThickness
,
89 float aFontSizeInflation
);
91 uint8_t ScriptIncrement(nsIFrame
* aFrame
) override
;
94 explicit nsMathMLmfracFrame(ComputedStyle
* aStyle
,
95 nsPresContext
* aPresContext
)
96 : nsMathMLContainerFrame(aStyle
, aPresContext
, kClassID
),
99 virtual ~nsMathMLmfracFrame();
101 nsresult
PlaceInternal(DrawTarget
* aDrawTarget
, const PlaceFlags
& aFlags
,
102 ReflowOutput
& aDesiredSize
);
105 void DisplaySlash(nsDisplayListBuilder
* aBuilder
, const nsRect
& aRect
,
106 nscoord aThickness
, const nsDisplayListSet
& aLists
);
109 nsMathMLChar
* mSlashChar
;
110 nscoord mLineThickness
;
113 #endif /* nsMathMLmfracFrame_h___ */