|
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 |
|
7 #ifndef nsMathMLmencloseFrame_h___ |
|
8 #define nsMathMLmencloseFrame_h___ |
|
9 |
|
10 #include "mozilla/Attributes.h" |
|
11 #include "nsMathMLContainerFrame.h" |
|
12 |
|
13 // |
|
14 // <menclose> -- enclose content with a stretching symbol such |
|
15 // as a long division sign. |
|
16 // |
|
17 |
|
18 /* |
|
19 The MathML REC describes: |
|
20 |
|
21 The menclose element renders its content inside the enclosing notation |
|
22 specified by its notation attribute. menclose accepts any number of arguments; |
|
23 if this number is not 1, its contents are treated as a single "inferred mrow" |
|
24 containing its arguments, as described in Section 3.1.3 Required Arguments. |
|
25 */ |
|
26 |
|
27 enum nsMencloseNotation |
|
28 { |
|
29 NOTATION_LONGDIV = 0x1, |
|
30 NOTATION_RADICAL = 0x2, |
|
31 NOTATION_ROUNDEDBOX = 0x4, |
|
32 NOTATION_CIRCLE = 0x8, |
|
33 NOTATION_LEFT = 0x10, |
|
34 NOTATION_RIGHT = 0x20, |
|
35 NOTATION_TOP = 0x40, |
|
36 NOTATION_BOTTOM = 0x80, |
|
37 NOTATION_UPDIAGONALSTRIKE = 0x100, |
|
38 NOTATION_DOWNDIAGONALSTRIKE = 0x200, |
|
39 NOTATION_VERTICALSTRIKE = 0x400, |
|
40 NOTATION_HORIZONTALSTRIKE = 0x800, |
|
41 NOTATION_UPDIAGONALARROW = 0x1000 |
|
42 }; |
|
43 |
|
44 class nsMathMLmencloseFrame : public nsMathMLContainerFrame { |
|
45 public: |
|
46 NS_DECL_FRAMEARENA_HELPERS |
|
47 |
|
48 friend nsIFrame* NS_NewMathMLmencloseFrame(nsIPresShell* aPresShell, |
|
49 nsStyleContext* aContext); |
|
50 |
|
51 virtual nsresult |
|
52 Place(nsRenderingContext& aRenderingContext, |
|
53 bool aPlaceOrigin, |
|
54 nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; |
|
55 |
|
56 virtual nsresult |
|
57 MeasureForWidth(nsRenderingContext& aRenderingContext, |
|
58 nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; |
|
59 |
|
60 virtual nsresult |
|
61 AttributeChanged(int32_t aNameSpaceID, |
|
62 nsIAtom* aAttribute, |
|
63 int32_t aModType) MOZ_OVERRIDE; |
|
64 |
|
65 virtual void |
|
66 SetAdditionalStyleContext(int32_t aIndex, |
|
67 nsStyleContext* aStyleContext) MOZ_OVERRIDE; |
|
68 virtual nsStyleContext* |
|
69 GetAdditionalStyleContext(int32_t aIndex) const MOZ_OVERRIDE; |
|
70 |
|
71 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
|
72 const nsRect& aDirtyRect, |
|
73 const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
|
74 |
|
75 NS_IMETHOD |
|
76 InheritAutomaticData(nsIFrame* aParent) MOZ_OVERRIDE; |
|
77 |
|
78 NS_IMETHOD |
|
79 TransmitAutomaticData() MOZ_OVERRIDE; |
|
80 |
|
81 virtual nscoord |
|
82 FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; |
|
83 |
|
84 bool |
|
85 IsMrowLike() MOZ_OVERRIDE { |
|
86 return mFrames.FirstChild() != mFrames.LastChild() || |
|
87 !mFrames.FirstChild(); |
|
88 } |
|
89 |
|
90 protected: |
|
91 nsMathMLmencloseFrame(nsStyleContext* aContext); |
|
92 virtual ~nsMathMLmencloseFrame(); |
|
93 |
|
94 nsresult PlaceInternal(nsRenderingContext& aRenderingContext, |
|
95 bool aPlaceOrigin, |
|
96 nsHTMLReflowMetrics& aDesiredSize, |
|
97 bool aWidthOnly); |
|
98 |
|
99 // functions to parse the "notation" attribute. |
|
100 nsresult AddNotation(const nsAString& aNotation); |
|
101 void InitNotations(); |
|
102 |
|
103 // Description of the notations to draw |
|
104 uint32_t mNotationsToDraw; |
|
105 bool IsToDraw(nsMencloseNotation mask) |
|
106 { |
|
107 return mask & mNotationsToDraw; |
|
108 } |
|
109 |
|
110 nscoord mRuleThickness; |
|
111 nsTArray<nsMathMLChar> mMathMLChar; |
|
112 int8_t mLongDivCharIndex, mRadicalCharIndex; |
|
113 nscoord mContentWidth; |
|
114 nsresult AllocateMathMLChar(nsMencloseNotation mask); |
|
115 |
|
116 // Display a frame of the specified type. |
|
117 // @param aType Type of frame to display |
|
118 void DisplayNotation(nsDisplayListBuilder* aBuilder, |
|
119 nsIFrame* aFrame, const nsRect& aRect, |
|
120 const nsDisplayListSet& aLists, |
|
121 nscoord aThickness, nsMencloseNotation aType); |
|
122 }; |
|
123 |
|
124 #endif /* nsMathMLmencloseFrame_h___ */ |