|
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/. */ |
|
5 |
|
6 #ifndef nsMathMLmfracFrame_h___ |
|
7 #define nsMathMLmfracFrame_h___ |
|
8 |
|
9 #include "mozilla/Attributes.h" |
|
10 #include "nsMathMLContainerFrame.h" |
|
11 |
|
12 // |
|
13 // <mfrac> -- form a fraction from two subexpressions |
|
14 // |
|
15 |
|
16 /* |
|
17 The MathML REC describes: |
|
18 |
|
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> |
|
23 |
|
24 Attributes of <mfrac>: |
|
25 Name values default |
|
26 linethickness number [ v-unit ] | thin | medium | thick 1 |
|
27 |
|
28 E.g., |
|
29 linethickness=2 actually means that linethickness=2*DEFAULT_THICKNESS |
|
30 (DEFAULT_THICKNESS is not specified by MathML, see below.) |
|
31 |
|
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 |
|
36 nested fractions. |
|
37 |
|
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 |
|
43 up to the renderer). |
|
44 |
|
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> |
|
49 element. |
|
50 */ |
|
51 |
|
52 class nsMathMLmfracFrame : public nsMathMLContainerFrame { |
|
53 public: |
|
54 NS_DECL_FRAMEARENA_HELPERS |
|
55 |
|
56 friend nsIFrame* NS_NewMathMLmfracFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
|
57 |
|
58 virtual eMathMLFrameType GetMathMLFrameType() MOZ_OVERRIDE; |
|
59 |
|
60 virtual nsresult |
|
61 MeasureForWidth(nsRenderingContext& aRenderingContext, |
|
62 nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; |
|
63 |
|
64 virtual nsresult |
|
65 Place(nsRenderingContext& aRenderingContext, |
|
66 bool aPlaceOrigin, |
|
67 nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; |
|
68 |
|
69 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
|
70 const nsRect& aDirtyRect, |
|
71 const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
|
72 |
|
73 NS_IMETHOD |
|
74 TransmitAutomaticData() MOZ_OVERRIDE; |
|
75 |
|
76 // override the base method so that we can deal with the fraction line |
|
77 virtual nscoord |
|
78 FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; |
|
79 |
|
80 // helper to translate the thickness attribute into a usable form |
|
81 static nscoord |
|
82 CalcLineThickness(nsPresContext* aPresContext, |
|
83 nsStyleContext* aStyleContext, |
|
84 nsString& aThicknessAttribute, |
|
85 nscoord onePixel, |
|
86 nscoord aDefaultRuleThickness); |
|
87 |
|
88 uint8_t |
|
89 ScriptIncrement(nsIFrame* aFrame) MOZ_OVERRIDE; |
|
90 |
|
91 protected: |
|
92 nsMathMLmfracFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {} |
|
93 virtual ~nsMathMLmfracFrame(); |
|
94 |
|
95 nsresult PlaceInternal(nsRenderingContext& aRenderingContext, |
|
96 bool aPlaceOrigin, |
|
97 nsHTMLReflowMetrics& aDesiredSize, |
|
98 bool aWidthOnly); |
|
99 |
|
100 // Display a slash |
|
101 void DisplaySlash(nsDisplayListBuilder* aBuilder, |
|
102 nsIFrame* aFrame, const nsRect& aRect, |
|
103 nscoord aThickness, |
|
104 const nsDisplayListSet& aLists); |
|
105 |
|
106 nsRect mLineRect; |
|
107 nsMathMLChar* mSlashChar; |
|
108 nscoord mLineThickness; |
|
109 bool mIsBevelled; |
|
110 }; |
|
111 |
|
112 #endif /* nsMathMLmfracFrame_h___ */ |