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