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