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 : * Vilya Harvey <vilya@nag.co.uk>
26 : * Shyjan Mahamud <mahamud@cs.cmu.edu>
27 : * Frederic Wang <fred.wang@free.fr> - extension of <msqrt/> to <menclose/>
28 : *
29 : * Alternatively, the contents of this file may be used under the terms of
30 : * either of the GNU General Public License Version 2 or later (the "GPL"),
31 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
32 : * in which case the provisions of the GPL or the LGPL are applicable instead
33 : * of those above. If you wish to allow use of your version of this file only
34 : * under the terms of either the GPL or the LGPL, and not to allow others to
35 : * use your version of this file under the terms of the MPL, indicate your
36 : * decision by deleting the provisions above and replace them with the notice
37 : * and other provisions required by the GPL or the LGPL. If you do not delete
38 : * the provisions above, a recipient may use your version of this file under
39 : * the terms of any one of the MPL, the GPL or the LGPL.
40 : *
41 : * ***** END LICENSE BLOCK ***** */
42 :
43 :
44 : #ifndef nsMathMLmencloseFrame_h___
45 : #define nsMathMLmencloseFrame_h___
46 :
47 : #include "nsCOMPtr.h"
48 : #include "nsMathMLContainerFrame.h"
49 :
50 : //
51 : // <menclose> -- enclose content with a stretching symbol such
52 : // as a long division sign.
53 : //
54 :
55 : /*
56 : The MathML REC describes:
57 :
58 : The menclose element renders its content inside the enclosing notation
59 : specified by its notation attribute. menclose accepts any number of arguments;
60 : if this number is not 1, its contents are treated as a single "inferred mrow"
61 : containing its arguments, as described in Section 3.1.3 Required Arguments.
62 : */
63 :
64 : enum nsMencloseNotation
65 : {
66 : NOTATION_LONGDIV = 0x1,
67 : NOTATION_RADICAL = 0x2,
68 : NOTATION_ROUNDEDBOX = 0x4,
69 : NOTATION_CIRCLE = 0x8,
70 : NOTATION_LEFT = 0x10,
71 : NOTATION_RIGHT = 0x20,
72 : NOTATION_TOP = 0x40,
73 : NOTATION_BOTTOM = 0x80,
74 : NOTATION_UPDIAGONALSTRIKE = 0x100,
75 : NOTATION_DOWNDIAGONALSTRIKE = 0x200,
76 : NOTATION_VERTICALSTRIKE = 0x400,
77 : NOTATION_HORIZONTALSTRIKE = 0x800
78 : };
79 :
80 : class nsMathMLmencloseFrame : public nsMathMLContainerFrame {
81 : public:
82 : NS_DECL_FRAMEARENA_HELPERS
83 :
84 : friend nsIFrame* NS_NewMathMLmencloseFrame(nsIPresShell* aPresShell,
85 : nsStyleContext* aContext);
86 :
87 : virtual nsresult
88 : Place(nsRenderingContext& aRenderingContext,
89 : bool aPlaceOrigin,
90 : nsHTMLReflowMetrics& aDesiredSize);
91 :
92 : virtual nsresult
93 : MeasureForWidth(nsRenderingContext& aRenderingContext,
94 : nsHTMLReflowMetrics& aDesiredSize);
95 :
96 : NS_IMETHOD
97 : AttributeChanged(PRInt32 aNameSpaceID,
98 : nsIAtom* aAttribute,
99 : PRInt32 aModType);
100 :
101 : virtual void
102 : SetAdditionalStyleContext(PRInt32 aIndex,
103 : nsStyleContext* aStyleContext);
104 : virtual nsStyleContext*
105 : GetAdditionalStyleContext(PRInt32 aIndex) const;
106 :
107 : NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
108 : const nsRect& aDirtyRect,
109 : const nsDisplayListSet& aLists);
110 :
111 : NS_IMETHOD
112 : InheritAutomaticData(nsIFrame* aParent);
113 :
114 : NS_IMETHOD
115 : TransmitAutomaticData();
116 :
117 : virtual nscoord
118 : FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize);
119 :
120 : protected:
121 : nsMathMLmencloseFrame(nsStyleContext* aContext);
122 : virtual ~nsMathMLmencloseFrame();
123 :
124 : nsresult PlaceInternal(nsRenderingContext& aRenderingContext,
125 : bool aPlaceOrigin,
126 : nsHTMLReflowMetrics& aDesiredSize,
127 : bool aWidthOnly);
128 :
129 : // functions to parse the "notation" attribute.
130 : nsresult AddNotation(const nsAString& aNotation);
131 : void InitNotations();
132 :
133 : // Description of the notations to draw
134 : PRUint32 mNotationsToDraw;
135 0 : bool IsToDraw(nsMencloseNotation mask)
136 : {
137 0 : return mask & mNotationsToDraw;
138 : }
139 :
140 : nscoord mRuleThickness;
141 : nsTArray<nsMathMLChar> mMathMLChar;
142 : PRInt8 mLongDivCharIndex, mRadicalCharIndex;
143 : nscoord mContentWidth;
144 : nsresult AllocateMathMLChar(nsMencloseNotation mask);
145 :
146 : // Display a frame of the specified type.
147 : // @param aType Type of frame to display
148 : nsresult DisplayNotation(nsDisplayListBuilder* aBuilder,
149 : nsIFrame* aFrame, const nsRect& aRect,
150 : const nsDisplayListSet& aLists,
151 : nscoord aThickness, nsMencloseNotation aType);
152 : };
153 :
154 : #endif /* nsMathMLmencloseFrame_h___ */
|