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