nsMathMLmpaddedFrame.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 nsMathMLmpaddedFrame_h___
  6. #define nsMathMLmpaddedFrame_h___
  7. #include "mozilla/Attributes.h"
  8. #include "nsMathMLContainerFrame.h"
  9. //
  10. // <mpadded> -- adjust space around content
  11. //
  12. class nsMathMLmpaddedFrame : public nsMathMLContainerFrame {
  13. public:
  14. NS_DECL_FRAMEARENA_HELPERS
  15. friend nsIFrame* NS_NewMathMLmpaddedFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
  16. NS_IMETHOD
  17. InheritAutomaticData(nsIFrame* aParent) override;
  18. NS_IMETHOD
  19. TransmitAutomaticData() override {
  20. return TransmitAutomaticDataForMrowLikeElement();
  21. }
  22. virtual void
  23. Reflow(nsPresContext* aPresContext,
  24. ReflowOutput& aDesiredSize,
  25. const ReflowInput& aReflowInput,
  26. nsReflowStatus& aStatus) override;
  27. virtual nsresult
  28. Place(DrawTarget* aDrawTarget,
  29. bool aPlaceOrigin,
  30. ReflowOutput& aDesiredSize) override;
  31. bool
  32. IsMrowLike() override {
  33. return mFrames.FirstChild() != mFrames.LastChild() ||
  34. !mFrames.FirstChild();
  35. }
  36. protected:
  37. explicit nsMathMLmpaddedFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {}
  38. virtual ~nsMathMLmpaddedFrame();
  39. virtual nsresult
  40. MeasureForWidth(DrawTarget* aDrawTarget,
  41. ReflowOutput& aDesiredSize) override;
  42. private:
  43. nsCSSValue mWidth;
  44. nsCSSValue mHeight;
  45. nsCSSValue mDepth;
  46. nsCSSValue mLeadingSpace;
  47. nsCSSValue mVerticalOffset;
  48. int32_t mWidthSign;
  49. int32_t mHeightSign;
  50. int32_t mDepthSign;
  51. int32_t mLeadingSpaceSign;
  52. int32_t mVerticalOffsetSign;
  53. int32_t mWidthPseudoUnit;
  54. int32_t mHeightPseudoUnit;
  55. int32_t mDepthPseudoUnit;
  56. int32_t mLeadingSpacePseudoUnit;
  57. int32_t mVerticalOffsetPseudoUnit;
  58. // helpers to process the attributes
  59. void
  60. ProcessAttributes();
  61. static bool
  62. ParseAttribute(nsString& aString,
  63. int32_t& aSign,
  64. nsCSSValue& aCSSValue,
  65. int32_t& aPseudoUnit);
  66. void
  67. UpdateValue(int32_t aSign,
  68. int32_t aPseudoUnit,
  69. const nsCSSValue& aCSSValue,
  70. const ReflowOutput& aDesiredSize,
  71. nscoord& aValueToUpdate,
  72. float aFontSizeInflation) const;
  73. };
  74. #endif /* nsMathMLmpaddedFrame_h___ */