nsMeterFrame.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 nsMeterFrame_h___
  6. #define nsMeterFrame_h___
  7. #include "mozilla/Attributes.h"
  8. #include "nsContainerFrame.h"
  9. #include "nsIAnonymousContentCreator.h"
  10. #include "nsCOMPtr.h"
  11. #include "nsCSSPseudoElements.h"
  12. class nsMeterFrame : public nsContainerFrame,
  13. public nsIAnonymousContentCreator
  14. {
  15. typedef mozilla::dom::Element Element;
  16. public:
  17. NS_DECL_QUERYFRAME_TARGET(nsMeterFrame)
  18. NS_DECL_QUERYFRAME
  19. NS_DECL_FRAMEARENA_HELPERS
  20. explicit nsMeterFrame(nsStyleContext* aContext);
  21. virtual ~nsMeterFrame();
  22. virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
  23. virtual void Reflow(nsPresContext* aCX,
  24. ReflowOutput& aDesiredSize,
  25. const ReflowInput& aReflowInput,
  26. nsReflowStatus& aStatus) override;
  27. virtual nsIAtom* GetType() const override;
  28. #ifdef DEBUG_FRAME_DUMP
  29. virtual nsresult GetFrameName(nsAString& aResult) const override {
  30. return MakeFrameName(NS_LITERAL_STRING("Meter"), aResult);
  31. }
  32. #endif
  33. virtual bool IsLeaf() const override { return true; }
  34. // nsIAnonymousContentCreator
  35. virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
  36. virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
  37. uint32_t aFilter) override;
  38. virtual nsresult AttributeChanged(int32_t aNameSpaceID,
  39. nsIAtom* aAttribute,
  40. int32_t aModType) override;
  41. virtual mozilla::LogicalSize
  42. ComputeAutoSize(nsRenderingContext* aRenderingContext,
  43. mozilla::WritingMode aWM,
  44. const mozilla::LogicalSize& aCBSize,
  45. nscoord aAvailableISize,
  46. const mozilla::LogicalSize& aMargin,
  47. const mozilla::LogicalSize& aBorder,
  48. const mozilla::LogicalSize& aPadding,
  49. ComputeSizeFlags aFlags) override;
  50. virtual nscoord GetMinISize(nsRenderingContext *aRenderingContext) override;
  51. virtual nscoord GetPrefISize(nsRenderingContext *aRenderingContext) override;
  52. virtual bool IsFrameOfType(uint32_t aFlags) const override
  53. {
  54. return nsContainerFrame::IsFrameOfType(aFlags &
  55. ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
  56. }
  57. /**
  58. * Returns whether the frame and its child should use the native style.
  59. */
  60. bool ShouldUseNativeStyle() const;
  61. virtual Element* GetPseudoElement(mozilla::CSSPseudoElementType aType) override;
  62. protected:
  63. // Helper function which reflow the anonymous div frame.
  64. void ReflowBarFrame(nsIFrame* aBarFrame,
  65. nsPresContext* aPresContext,
  66. const ReflowInput& aReflowInput,
  67. nsReflowStatus& aStatus);
  68. /**
  69. * The div used to show the meter bar.
  70. * @see nsMeterFrame::CreateAnonymousContent
  71. */
  72. nsCOMPtr<Element> mBarDiv;
  73. };
  74. #endif