|
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 nsMathMLmfencedFrame_h |
|
7 #define nsMathMLmfencedFrame_h |
|
8 |
|
9 #include "mozilla/Attributes.h" |
|
10 #include "nsMathMLContainerFrame.h" |
|
11 |
|
12 // |
|
13 // <mfenced> -- surround content with a pair of fences |
|
14 // |
|
15 |
|
16 class nsMathMLmfencedFrame : public nsMathMLContainerFrame { |
|
17 public: |
|
18 NS_DECL_FRAMEARENA_HELPERS |
|
19 |
|
20 friend nsIFrame* NS_NewMathMLmfencedFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
|
21 |
|
22 virtual void |
|
23 SetAdditionalStyleContext(int32_t aIndex, |
|
24 nsStyleContext* aStyleContext) MOZ_OVERRIDE; |
|
25 virtual nsStyleContext* |
|
26 GetAdditionalStyleContext(int32_t aIndex) const MOZ_OVERRIDE; |
|
27 |
|
28 NS_IMETHOD |
|
29 InheritAutomaticData(nsIFrame* aParent) MOZ_OVERRIDE; |
|
30 |
|
31 virtual nsresult |
|
32 SetInitialChildList(ChildListID aListID, |
|
33 nsFrameList& aChildList) MOZ_OVERRIDE; |
|
34 |
|
35 virtual nsresult |
|
36 Reflow(nsPresContext* aPresContext, |
|
37 nsHTMLReflowMetrics& aDesiredSize, |
|
38 const nsHTMLReflowState& aReflowState, |
|
39 nsReflowStatus& aStatus) MOZ_OVERRIDE; |
|
40 |
|
41 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
|
42 const nsRect& aDirtyRect, |
|
43 const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
|
44 |
|
45 virtual void |
|
46 GetIntrinsicWidthMetrics(nsRenderingContext* aRenderingContext, |
|
47 nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; |
|
48 |
|
49 virtual nsresult |
|
50 AttributeChanged(int32_t aNameSpaceID, |
|
51 nsIAtom* aAttribute, |
|
52 int32_t aModType) MOZ_OVERRIDE; |
|
53 |
|
54 // override the base method because we must keep separators in sync |
|
55 virtual nsresult |
|
56 ChildListChanged(int32_t aModType) MOZ_OVERRIDE; |
|
57 |
|
58 // override the base method so that we can deal with fences and separators |
|
59 virtual nscoord |
|
60 FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; |
|
61 |
|
62 // helper routines to format the MathMLChars involved here |
|
63 static nsresult |
|
64 ReflowChar(nsPresContext* aPresContext, |
|
65 nsRenderingContext& aRenderingContext, |
|
66 nsMathMLChar* aMathMLChar, |
|
67 nsOperatorFlags aForm, |
|
68 int32_t aScriptLevel, |
|
69 nscoord axisHeight, |
|
70 nscoord leading, |
|
71 nscoord em, |
|
72 nsBoundingMetrics& aContainerSize, |
|
73 nscoord& aAscent, |
|
74 nscoord& aDescent, |
|
75 bool aRTL); |
|
76 |
|
77 static void |
|
78 PlaceChar(nsMathMLChar* aMathMLChar, |
|
79 nscoord aDesiredSize, |
|
80 nsBoundingMetrics& bm, |
|
81 nscoord& dx); |
|
82 |
|
83 virtual bool |
|
84 IsMrowLike() MOZ_OVERRIDE |
|
85 { |
|
86 // Always treated as an mrow with > 1 child as |
|
87 // <mfenced> <mo>%</mo> </mfenced> |
|
88 // renders equivalently to |
|
89 // <mrow> <mo> ( </mo> <mo>%</mo> <mo> ) </mo> </mrow> |
|
90 // This also holds with multiple children. (MathML3 3.3.8.1) |
|
91 return true; |
|
92 } |
|
93 |
|
94 protected: |
|
95 nsMathMLmfencedFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {} |
|
96 virtual ~nsMathMLmfencedFrame(); |
|
97 |
|
98 nsMathMLChar* mOpenChar; |
|
99 nsMathMLChar* mCloseChar; |
|
100 nsMathMLChar* mSeparatorsChar; |
|
101 int32_t mSeparatorsCount; |
|
102 |
|
103 // clean up |
|
104 void |
|
105 RemoveFencesAndSeparators(); |
|
106 |
|
107 // add fences and separators when all child frames are known |
|
108 void |
|
109 CreateFencesAndSeparators(nsPresContext* aPresContext); |
|
110 }; |
|
111 |
|
112 #endif /* nsMathMLmfencedFrame_h */ |