|
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 |
|
6 #ifndef nsMeterFrame_h___ |
|
7 #define nsMeterFrame_h___ |
|
8 |
|
9 #include "mozilla/Attributes.h" |
|
10 #include "nsContainerFrame.h" |
|
11 #include "nsIAnonymousContentCreator.h" |
|
12 #include "nsCOMPtr.h" |
|
13 |
|
14 class nsMeterFrame : public nsContainerFrame, |
|
15 public nsIAnonymousContentCreator |
|
16 |
|
17 { |
|
18 typedef mozilla::dom::Element Element; |
|
19 |
|
20 public: |
|
21 NS_DECL_QUERYFRAME_TARGET(nsMeterFrame) |
|
22 NS_DECL_QUERYFRAME |
|
23 NS_DECL_FRAMEARENA_HELPERS |
|
24 |
|
25 nsMeterFrame(nsStyleContext* aContext); |
|
26 virtual ~nsMeterFrame(); |
|
27 |
|
28 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; |
|
29 |
|
30 virtual nsresult Reflow(nsPresContext* aCX, |
|
31 nsHTMLReflowMetrics& aDesiredSize, |
|
32 const nsHTMLReflowState& aReflowState, |
|
33 nsReflowStatus& aStatus) MOZ_OVERRIDE; |
|
34 |
|
35 #ifdef DEBUG_FRAME_DUMP |
|
36 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE { |
|
37 return MakeFrameName(NS_LITERAL_STRING("Meter"), aResult); |
|
38 } |
|
39 #endif |
|
40 |
|
41 virtual bool IsLeaf() const MOZ_OVERRIDE { return true; } |
|
42 |
|
43 // nsIAnonymousContentCreator |
|
44 virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE; |
|
45 virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, |
|
46 uint32_t aFilter) MOZ_OVERRIDE; |
|
47 |
|
48 virtual nsresult AttributeChanged(int32_t aNameSpaceID, |
|
49 nsIAtom* aAttribute, |
|
50 int32_t aModType) MOZ_OVERRIDE; |
|
51 |
|
52 virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext, |
|
53 nsSize aCBSize, nscoord aAvailableWidth, |
|
54 nsSize aMargin, nsSize aBorder, |
|
55 nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE; |
|
56 |
|
57 virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
|
58 virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
|
59 |
|
60 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE |
|
61 { |
|
62 return nsContainerFrame::IsFrameOfType(aFlags & |
|
63 ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock)); |
|
64 } |
|
65 |
|
66 /** |
|
67 * Returns whether the frame and its child should use the native style. |
|
68 */ |
|
69 bool ShouldUseNativeStyle() const; |
|
70 |
|
71 virtual Element* GetPseudoElement(nsCSSPseudoElements::Type aType) MOZ_OVERRIDE; |
|
72 |
|
73 protected: |
|
74 // Helper function which reflow the anonymous div frame. |
|
75 void ReflowBarFrame(nsIFrame* aBarFrame, |
|
76 nsPresContext* aPresContext, |
|
77 const nsHTMLReflowState& aReflowState, |
|
78 nsReflowStatus& aStatus); |
|
79 /** |
|
80 * The div used to show the meter bar. |
|
81 * @see nsMeterFrame::CreateAnonymousContent |
|
82 */ |
|
83 nsCOMPtr<Element> mBarDiv; |
|
84 }; |
|
85 |
|
86 #endif |