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/. */
6 #ifndef nsMeterFrame_h___
7 #define nsMeterFrame_h___
9 #include "nsContainerFrame.h"
10 #include "nsIAnonymousContentCreator.h"
13 class nsMeterFrame
: public nsContainerFrame
,
14 public nsIAnonymousContentCreator
18 NS_DECL_QUERYFRAME_TARGET(nsMeterFrame
)
20 NS_DECL_FRAMEARENA_HELPERS
22 nsMeterFrame(nsStyleContext
* aContext
);
23 virtual ~nsMeterFrame();
25 virtual void DestroyFrom(nsIFrame
* aDestructRoot
);
27 NS_IMETHOD
Reflow(nsPresContext
* aCX
,
28 nsHTMLReflowMetrics
& aDesiredSize
,
29 const nsHTMLReflowState
& aReflowState
,
30 nsReflowStatus
& aStatus
);
33 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const {
34 return MakeFrameName(NS_LITERAL_STRING("Meter"), aResult
);
38 virtual bool IsLeaf() const { return true; }
40 // nsIAnonymousContentCreator
41 virtual nsresult
CreateAnonymousContent(nsTArray
<ContentInfo
>& aElements
);
42 virtual void AppendAnonymousContentTo(nsBaseContentList
& aElements
,
45 NS_IMETHOD
AttributeChanged(PRInt32 aNameSpaceID
,
49 virtual nsSize
ComputeAutoSize(nsRenderingContext
*aRenderingContext
,
50 nsSize aCBSize
, nscoord aAvailableWidth
,
51 nsSize aMargin
, nsSize aBorder
,
52 nsSize aPadding
, bool aShrinkWrap
);
54 virtual nscoord
GetMinWidth(nsRenderingContext
*aRenderingContext
);
55 virtual nscoord
GetPrefWidth(nsRenderingContext
*aRenderingContext
);
57 virtual bool IsFrameOfType(PRUint32 aFlags
) const
59 return nsContainerFrame::IsFrameOfType(aFlags
&
60 ~(nsIFrame::eReplaced
| nsIFrame::eReplacedContainsBlock
));
64 * Returns whether the frame and its child should use the native style.
66 bool ShouldUseNativeStyle() const;
69 // Helper function which reflow the anonymous div frame.
70 void ReflowBarFrame(nsIFrame
* aBarFrame
,
71 nsPresContext
* aPresContext
,
72 const nsHTMLReflowState
& aReflowState
,
73 nsReflowStatus
& aStatus
);
75 * The div used to show the meter bar.
76 * @see nsMeterFrame::CreateAnonymousContent
78 nsCOMPtr
<nsIContent
> mBarDiv
;