nsMathMLmencloseFrame.h 3.9 KB

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