/src/mozilla-central/layout/mathml/nsMathMLmfencedFrame.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef nsMathMLmfencedFrame_h |
8 | | #define nsMathMLmfencedFrame_h |
9 | | |
10 | | #include "mozilla/Attributes.h" |
11 | | #include "nsMathMLContainerFrame.h" |
12 | | |
13 | | class nsFontMetrics; |
14 | | |
15 | | // |
16 | | // <mfenced> -- surround content with a pair of fences |
17 | | // |
18 | | |
19 | | class nsMathMLmfencedFrame final : public nsMathMLContainerFrame { |
20 | | public: |
21 | | NS_DECL_FRAMEARENA_HELPERS(nsMathMLmfencedFrame) |
22 | | |
23 | | friend nsIFrame* NS_NewMathMLmfencedFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle); |
24 | | |
25 | | void DestroyFrom(nsIFrame* aDestructRoot, |
26 | | PostDestroyData& aPostDestroyData) override; |
27 | | |
28 | | virtual void |
29 | | SetAdditionalComputedStyle(int32_t aIndex, |
30 | | ComputedStyle* aComputedStyle) override; |
31 | | virtual ComputedStyle* |
32 | | GetAdditionalComputedStyle(int32_t aIndex) const override; |
33 | | |
34 | | NS_IMETHOD |
35 | | InheritAutomaticData(nsIFrame* aParent) override; |
36 | | |
37 | | virtual void |
38 | | SetInitialChildList(ChildListID aListID, |
39 | | nsFrameList& aChildList) override; |
40 | | |
41 | | virtual void |
42 | | Reflow(nsPresContext* aPresContext, |
43 | | ReflowOutput& aDesiredSize, |
44 | | const ReflowInput& aReflowInput, |
45 | | nsReflowStatus& aStatus) override; |
46 | | |
47 | | virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
48 | | const nsDisplayListSet& aLists) override; |
49 | | |
50 | | virtual void |
51 | | GetIntrinsicISizeMetrics(gfxContext* aRenderingContext, |
52 | | ReflowOutput& aDesiredSize) override; |
53 | | |
54 | | virtual nsresult |
55 | | AttributeChanged(int32_t aNameSpaceID, |
56 | | nsAtom* aAttribute, |
57 | | int32_t aModType) override; |
58 | | |
59 | | // override the base method because we must keep separators in sync |
60 | | virtual nsresult |
61 | | ChildListChanged(int32_t aModType) override; |
62 | | |
63 | | // override the base method so that we can deal with fences and separators |
64 | | virtual nscoord |
65 | | FixInterFrameSpacing(ReflowOutput& aDesiredSize) override; |
66 | | |
67 | | // helper routines to format the MathMLChars involved here |
68 | | nsresult |
69 | | ReflowChar(DrawTarget* aDrawTarget, |
70 | | nsFontMetrics& aFontMetrics, |
71 | | float aFontSizeInflation, |
72 | | nsMathMLChar* aMathMLChar, |
73 | | nsOperatorFlags aForm, |
74 | | int32_t aScriptLevel, |
75 | | nscoord axisHeight, |
76 | | nscoord leading, |
77 | | nscoord em, |
78 | | nsBoundingMetrics& aContainerSize, |
79 | | nscoord& aAscent, |
80 | | nscoord& aDescent, |
81 | | bool aRTL); |
82 | | |
83 | | static void |
84 | | PlaceChar(nsMathMLChar* aMathMLChar, |
85 | | nscoord aDesiredSize, |
86 | | nsBoundingMetrics& bm, |
87 | | nscoord& dx); |
88 | | |
89 | | virtual bool |
90 | | IsMrowLike() override |
91 | 0 | { |
92 | 0 | // Always treated as an mrow with > 1 child as |
93 | 0 | // <mfenced> <mo>%</mo> </mfenced> |
94 | 0 | // renders equivalently to |
95 | 0 | // <mrow> <mo> ( </mo> <mo>%</mo> <mo> ) </mo> </mrow> |
96 | 0 | // This also holds with multiple children. (MathML3 3.3.8.1) |
97 | 0 | return true; |
98 | 0 | } |
99 | | |
100 | | protected: |
101 | | explicit nsMathMLmfencedFrame(ComputedStyle* aStyle) |
102 | | : nsMathMLContainerFrame(aStyle, kClassID) |
103 | | , mOpenChar(nullptr) |
104 | | , mCloseChar(nullptr) |
105 | | , mSeparatorsChar(nullptr) |
106 | | , mSeparatorsCount(0) |
107 | 0 | {} |
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 */ |