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
4 : *
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/
9 : *
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.
14 : *
15 : * The Original Code is Mozilla MathML Project.
16 : *
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.
21 : *
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>
27 : *
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.
39 : *
40 : * ***** END LICENSE BLOCK ***** */
41 :
42 : #ifndef nsMathMLmfracFrame_h___
43 : #define nsMathMLmfracFrame_h___
44 :
45 : #include "nsCOMPtr.h"
46 : #include "nsMathMLContainerFrame.h"
47 :
48 : //
49 : // <mfrac> -- form a fraction from two subexpressions
50 : //
51 :
52 : /*
53 : The MathML REC describes:
54 :
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>
59 :
60 : Attributes of <mfrac>:
61 : Name values default
62 : linethickness number [ v-unit ] | thin | medium | thick 1
63 :
64 : E.g.,
65 : linethickness=2 actually means that linethickness=2*DEFAULT_THICKNESS
66 : (DEFAULT_THICKNESS is not specified by MathML, see below.)
67 :
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.
73 :
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).
80 :
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.
86 : */
87 :
88 : class nsMathMLmfracFrame : public nsMathMLContainerFrame {
89 : public:
90 : NS_DECL_FRAMEARENA_HELPERS
91 :
92 : friend nsIFrame* NS_NewMathMLmfracFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
93 :
94 : virtual eMathMLFrameType GetMathMLFrameType();
95 :
96 : virtual nsresult
97 : MeasureForWidth(nsRenderingContext& aRenderingContext,
98 : nsHTMLReflowMetrics& aDesiredSize);
99 :
100 : virtual nsresult
101 : Place(nsRenderingContext& aRenderingContext,
102 : bool aPlaceOrigin,
103 : nsHTMLReflowMetrics& aDesiredSize);
104 :
105 : NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
106 : const nsRect& aDirtyRect,
107 : const nsDisplayListSet& aLists);
108 :
109 : NS_IMETHOD
110 : TransmitAutomaticData();
111 :
112 : NS_IMETHOD
113 : UpdatePresentationDataFromChildAt(PRInt32 aFirstIndex,
114 : PRInt32 aLastIndex,
115 : PRUint32 aFlagsValues,
116 : PRUint32 aFlagsToUpdate);
117 :
118 : // override the base method so that we can deal with the fraction line
119 : virtual nscoord
120 : FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize);
121 :
122 : // helper to translate the thickness attribute into a usable form
123 : static nscoord
124 : CalcLineThickness(nsPresContext* aPresContext,
125 : nsStyleContext* aStyleContext,
126 : nsString& aThicknessAttribute,
127 : nscoord onePixel,
128 : nscoord aDefaultRuleThickness);
129 :
130 : protected:
131 0 : nsMathMLmfracFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {}
132 : virtual ~nsMathMLmfracFrame();
133 :
134 0 : virtual PRIntn GetSkipSides() const { return 0; }
135 :
136 : nsresult PlaceInternal(nsRenderingContext& aRenderingContext,
137 : bool aPlaceOrigin,
138 : nsHTMLReflowMetrics& aDesiredSize,
139 : bool aWidthOnly);
140 :
141 : // Display a slash
142 : nsresult DisplaySlash(nsDisplayListBuilder* aBuilder,
143 : nsIFrame* aFrame, const nsRect& aRect,
144 : nscoord aThickness,
145 : const nsDisplayListSet& aLists);
146 :
147 : nsRect mLineRect;
148 : nsMathMLChar* mSlashChar;
149 : nscoord mLineThickness;
150 : bool mIsBevelled;
151 : };
152 :
153 : #endif /* nsMathMLmfracFrame_h___ */
|