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