|
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 nsHTMLButtonControlFrame_h___ |
|
7 #define nsHTMLButtonControlFrame_h___ |
|
8 |
|
9 #include "mozilla/Attributes.h" |
|
10 #include "nsContainerFrame.h" |
|
11 #include "nsIFormControlFrame.h" |
|
12 #include "nsButtonFrameRenderer.h" |
|
13 |
|
14 class nsRenderingContext; |
|
15 class nsPresContext; |
|
16 |
|
17 class nsHTMLButtonControlFrame : public nsContainerFrame, |
|
18 public nsIFormControlFrame |
|
19 { |
|
20 public: |
|
21 nsHTMLButtonControlFrame(nsStyleContext* aContext); |
|
22 ~nsHTMLButtonControlFrame(); |
|
23 |
|
24 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; |
|
25 |
|
26 NS_DECL_QUERYFRAME |
|
27 NS_DECL_FRAMEARENA_HELPERS |
|
28 |
|
29 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
|
30 const nsRect& aDirtyRect, |
|
31 const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
|
32 |
|
33 virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
|
34 |
|
35 virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
|
36 |
|
37 virtual nsresult Reflow(nsPresContext* aPresContext, |
|
38 nsHTMLReflowMetrics& aDesiredSize, |
|
39 const nsHTMLReflowState& aReflowState, |
|
40 nsReflowStatus& aStatus) MOZ_OVERRIDE; |
|
41 |
|
42 virtual nsresult HandleEvent(nsPresContext* aPresContext, |
|
43 mozilla::WidgetGUIEvent* aEvent, |
|
44 nsEventStatus* aEventStatus) MOZ_OVERRIDE; |
|
45 |
|
46 virtual void Init(nsIContent* aContent, |
|
47 nsIFrame* aParent, |
|
48 nsIFrame* asPrevInFlow) MOZ_OVERRIDE; |
|
49 |
|
50 virtual nsStyleContext* GetAdditionalStyleContext(int32_t aIndex) const MOZ_OVERRIDE; |
|
51 virtual void SetAdditionalStyleContext(int32_t aIndex, |
|
52 nsStyleContext* aStyleContext) MOZ_OVERRIDE; |
|
53 |
|
54 virtual nsresult AppendFrames(ChildListID aListID, |
|
55 nsFrameList& aFrameList) MOZ_OVERRIDE; |
|
56 |
|
57 virtual nsresult InsertFrames(ChildListID aListID, |
|
58 nsIFrame* aPrevFrame, |
|
59 nsFrameList& aFrameList) MOZ_OVERRIDE; |
|
60 |
|
61 virtual nsresult RemoveFrame(ChildListID aListID, |
|
62 nsIFrame* aOldFrame) MOZ_OVERRIDE; |
|
63 |
|
64 #ifdef ACCESSIBILITY |
|
65 virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE; |
|
66 #endif |
|
67 |
|
68 virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
|
69 |
|
70 #ifdef DEBUG_FRAME_DUMP |
|
71 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE { |
|
72 return MakeFrameName(NS_LITERAL_STRING("HTMLButtonControl"), aResult); |
|
73 } |
|
74 #endif |
|
75 |
|
76 virtual bool HonorPrintBackgroundSettings() MOZ_OVERRIDE { return false; } |
|
77 |
|
78 // nsIFormControlFrame |
|
79 void SetFocus(bool aOn, bool aRepaint) MOZ_OVERRIDE; |
|
80 virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) MOZ_OVERRIDE; |
|
81 |
|
82 // Inserted child content gets its frames parented by our child block |
|
83 virtual nsIFrame* GetContentInsertionFrame() MOZ_OVERRIDE { |
|
84 return GetFirstPrincipalChild()->GetContentInsertionFrame(); |
|
85 } |
|
86 |
|
87 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE |
|
88 { |
|
89 return nsContainerFrame::IsFrameOfType(aFlags & |
|
90 ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock)); |
|
91 } |
|
92 |
|
93 protected: |
|
94 virtual bool IsInput() { return false; } |
|
95 // Reflows the button's sole child frame, and computes the desired size |
|
96 // of the button itself from the results. |
|
97 void ReflowButtonContents(nsPresContext* aPresContext, |
|
98 nsHTMLReflowMetrics& aButtonDesiredSize, |
|
99 const nsHTMLReflowState& aButtonReflowState, |
|
100 nsIFrame* aFirstKid); |
|
101 |
|
102 nsButtonFrameRenderer mRenderer; |
|
103 }; |
|
104 |
|
105 #endif |
|
106 |
|
107 |
|
108 |
|
109 |