nsProgressFrame.h (2478B)
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 "nsCOMPtr.h" 11 #include "nsContainerFrame.h" 12 #include "nsIAnonymousContentCreator.h" 13 14 namespace mozilla { 15 enum class PseudoStyleType : uint8_t; 16 } // namespace mozilla 17 18 class nsProgressFrame final : public nsContainerFrame, 19 public nsIAnonymousContentCreator { 20 using Element = mozilla::dom::Element; 21 22 public: 23 NS_DECL_QUERYFRAME 24 NS_DECL_FRAMEARENA_HELPERS(nsProgressFrame) 25 26 enum class Type : uint8_t { Progress, Meter }; 27 nsProgressFrame(ComputedStyle*, nsPresContext*, Type); 28 virtual ~nsProgressFrame(); 29 30 void Destroy(DestroyContext&) override; 31 32 void BuildDisplayList(nsDisplayListBuilder* aBuilder, 33 const nsDisplayListSet& aLists) override; 34 35 void Reflow(nsPresContext*, ReflowOutput&, const ReflowInput&, 36 nsReflowStatus&) override; 37 38 #ifdef DEBUG_FRAME_DUMP 39 nsresult GetFrameName(nsAString& aResult) const override { 40 return MakeFrameName(u"Progress"_ns, aResult); 41 } 42 #endif 43 44 // nsIAnonymousContentCreator 45 nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override; 46 void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements, 47 uint32_t aFilter) override; 48 49 nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute, 50 AttrModType aModType) override; 51 52 nscoord IntrinsicISize(const mozilla::IntrinsicSizeInput& aInput, 53 mozilla::IntrinsicISizeType aType) override; 54 55 bool ShouldUseNativeStyle() const; 56 57 protected: 58 mozilla::LogicalSize DefaultSize() const; 59 // Helper function to reflow a child frame. 60 void ReflowChildFrame(nsIFrame* aChild, nsPresContext* aPresContext, 61 const ReflowInput& aReflowInput, 62 const mozilla::LogicalSize& aParentContentBoxSize, 63 nsReflowStatus& aStatus); 64 65 /** 66 * The div used to show the progress bar. 67 * @see nsProgressFrame::CreateAnonymousContent 68 */ 69 nsCOMPtr<Element> mBarDiv; 70 71 // Whether we're a progress or a meter element. 72 const Type mType; 73 }; 74 75 #endif