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/. */
7 #ifndef nsMeterFrame_h___
8 #define nsMeterFrame_h___
10 #include "mozilla/Attributes.h"
11 #include "nsContainerFrame.h"
12 #include "nsIAnonymousContentCreator.h"
14 #include "nsCSSPseudoElements.h"
16 class nsMeterFrame final
: public nsContainerFrame
,
17 public nsIAnonymousContentCreator
20 typedef mozilla::dom::Element Element
;
24 NS_DECL_FRAMEARENA_HELPERS(nsMeterFrame
)
26 explicit nsMeterFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
);
27 virtual ~nsMeterFrame();
29 void Destroy(DestroyContext
&) override
;
31 virtual void Reflow(nsPresContext
* aCX
, ReflowOutput
& aDesiredSize
,
32 const ReflowInput
& aReflowInput
,
33 nsReflowStatus
& aStatus
) override
;
35 #ifdef DEBUG_FRAME_DUMP
36 virtual nsresult
GetFrameName(nsAString
& aResult
) const override
{
37 return MakeFrameName(u
"Meter"_ns
, aResult
);
41 // nsIAnonymousContentCreator
42 virtual nsresult
CreateAnonymousContent(
43 nsTArray
<ContentInfo
>& aElements
) override
;
44 virtual void AppendAnonymousContentTo(nsTArray
<nsIContent
*>& aElements
,
45 uint32_t aFilter
) override
;
47 virtual nsresult
AttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
48 int32_t aModType
) override
;
50 virtual mozilla::LogicalSize
ComputeAutoSize(
51 gfxContext
* aRenderingContext
, mozilla::WritingMode aWM
,
52 const mozilla::LogicalSize
& aCBSize
, nscoord aAvailableISize
,
53 const mozilla::LogicalSize
& aMargin
,
54 const mozilla::LogicalSize
& aBorderPadding
,
55 const mozilla::StyleSizeOverrides
& aSizeOverrides
,
56 mozilla::ComputeSizeFlags aFlags
) override
;
58 virtual nscoord
GetMinISize(gfxContext
* aRenderingContext
) override
;
59 virtual nscoord
GetPrefISize(gfxContext
* aRenderingContext
) override
;
62 * Returns whether the frame and its child should use the native style.
64 bool ShouldUseNativeStyle() const;
67 // Helper function which reflow the anonymous div frame.
68 void ReflowBarFrame(nsIFrame
* aBarFrame
, nsPresContext
* aPresContext
,
69 const ReflowInput
& aReflowInput
, nsReflowStatus
& aStatus
);
71 * The div used to show the meter bar.
72 * @see nsMeterFrame::CreateAnonymousContent
74 nsCOMPtr
<Element
> mBarDiv
;