nsProgressFrame.h 3.5 KB

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