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 :
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 : NOTATION_PHASORANGLE = 0x2000
43 : };
44 :
45 : class nsMathMLmencloseFrame : public nsMathMLContainerFrame {
46 : public:
47 0 : NS_DECL_FRAMEARENA_HELPERS(nsMathMLmencloseFrame)
48 :
49 : friend nsIFrame* NS_NewMathMLmencloseFrame(nsIPresShell* aPresShell,
50 : nsStyleContext* aContext);
51 :
52 : virtual nsresult
53 : Place(DrawTarget* aDrawTarget,
54 : bool aPlaceOrigin,
55 : ReflowOutput& aDesiredSize) override;
56 :
57 : virtual nsresult
58 : MeasureForWidth(DrawTarget* aDrawTarget,
59 : ReflowOutput& aDesiredSize) override;
60 :
61 : virtual nsresult
62 : AttributeChanged(int32_t aNameSpaceID,
63 : nsIAtom* aAttribute,
64 : int32_t aModType) override;
65 :
66 : virtual void
67 : SetAdditionalStyleContext(int32_t aIndex,
68 : nsStyleContext* aStyleContext) override;
69 : virtual nsStyleContext*
70 : GetAdditionalStyleContext(int32_t aIndex) const override;
71 :
72 : virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
73 : const nsRect& aDirtyRect,
74 : const nsDisplayListSet& aLists) override;
75 :
76 : NS_IMETHOD
77 : InheritAutomaticData(nsIFrame* aParent) override;
78 :
79 : NS_IMETHOD
80 : TransmitAutomaticData() override;
81 :
82 : virtual nscoord
83 : FixInterFrameSpacing(ReflowOutput& aDesiredSize) override;
84 :
85 : bool
86 0 : IsMrowLike() override {
87 0 : return mFrames.FirstChild() != mFrames.LastChild() ||
88 0 : !mFrames.FirstChild();
89 : }
90 :
91 : protected:
92 : explicit nsMathMLmencloseFrame(nsStyleContext* aContext, ClassID aID = kClassID);
93 : virtual ~nsMathMLmencloseFrame();
94 :
95 : nsresult PlaceInternal(DrawTarget* aDrawTarget,
96 : bool aPlaceOrigin,
97 : ReflowOutput& aDesiredSize,
98 : bool aWidthOnly);
99 :
100 : // functions to parse the "notation" attribute.
101 : nsresult AddNotation(const nsAString& aNotation);
102 : void InitNotations();
103 :
104 : // Description of the notations to draw
105 : uint32_t mNotationsToDraw;
106 0 : bool IsToDraw(nsMencloseNotation mask)
107 : {
108 0 : return mask & mNotationsToDraw;
109 : }
110 :
111 : nscoord mRuleThickness;
112 : nscoord mRadicalRuleThickness;
113 : nsTArray<nsMathMLChar> mMathMLChar;
114 : int8_t mLongDivCharIndex, mRadicalCharIndex;
115 : nscoord mContentWidth;
116 : nsresult AllocateMathMLChar(nsMencloseNotation mask);
117 :
118 : // Display a frame of the specified type.
119 : // @param aType Type of frame to display
120 : void DisplayNotation(nsDisplayListBuilder* aBuilder,
121 : nsIFrame* aFrame, const nsRect& aRect,
122 : const nsDisplayListSet& aLists,
123 : nscoord aThickness, nsMencloseNotation aType);
124 : };
125 :
126 : #endif /* nsMathMLmencloseFrame_h___ */
|