Line data Source code
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 gfxContext;
15 : class nsPresContext;
16 :
17 : class nsHTMLButtonControlFrame : public nsContainerFrame,
18 : public nsIFormControlFrame
19 : {
20 : public:
21 0 : explicit nsHTMLButtonControlFrame(nsStyleContext* aContext)
22 0 : : nsHTMLButtonControlFrame(aContext, kClassID)
23 0 : {}
24 :
25 : ~nsHTMLButtonControlFrame();
26 :
27 : virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
28 :
29 : NS_DECL_QUERYFRAME
30 0 : NS_DECL_FRAMEARENA_HELPERS(nsHTMLButtonControlFrame)
31 :
32 : virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
33 : const nsRect& aDirtyRect,
34 : const nsDisplayListSet& aLists) override;
35 :
36 : virtual nscoord GetMinISize(gfxContext *aRenderingContext) override;
37 :
38 : virtual nscoord GetPrefISize(gfxContext *aRenderingContext) override;
39 :
40 : virtual void Reflow(nsPresContext* aPresContext,
41 : ReflowOutput& aDesiredSize,
42 : const ReflowInput& aReflowInput,
43 : nsReflowStatus& aStatus) override;
44 :
45 : bool GetVerticalAlignBaseline(mozilla::WritingMode aWM,
46 : nscoord* aBaseline) const override;
47 :
48 : bool GetNaturalBaselineBOffset(mozilla::WritingMode aWM,
49 : BaselineSharingGroup aBaselineGroup,
50 : nscoord* aBaseline) const override;
51 :
52 : virtual nsresult HandleEvent(nsPresContext* aPresContext,
53 : mozilla::WidgetGUIEvent* aEvent,
54 : nsEventStatus* aEventStatus) override;
55 :
56 : virtual void Init(nsIContent* aContent,
57 : nsContainerFrame* aParent,
58 : nsIFrame* aPrevInFlow) override;
59 :
60 : virtual nsStyleContext* GetAdditionalStyleContext(int32_t aIndex) const override;
61 : virtual void SetAdditionalStyleContext(int32_t aIndex,
62 : nsStyleContext* aStyleContext) override;
63 :
64 : #ifdef DEBUG
65 : virtual void AppendFrames(ChildListID aListID,
66 : nsFrameList& aFrameList) override;
67 : virtual void InsertFrames(ChildListID aListID,
68 : nsIFrame* aPrevFrame,
69 : nsFrameList& aFrameList) override;
70 : virtual void RemoveFrame(ChildListID aListID,
71 : nsIFrame* aOldFrame) override;
72 : #endif
73 :
74 : #ifdef ACCESSIBILITY
75 : virtual mozilla::a11y::AccType AccessibleType() override;
76 : #endif
77 :
78 : #ifdef DEBUG_FRAME_DUMP
79 0 : virtual nsresult GetFrameName(nsAString& aResult) const override {
80 0 : return MakeFrameName(NS_LITERAL_STRING("HTMLButtonControl"), aResult);
81 : }
82 : #endif
83 :
84 0 : virtual bool HonorPrintBackgroundSettings() override { return false; }
85 :
86 : // nsIFormControlFrame
87 : void SetFocus(bool aOn, bool aRepaint) override;
88 : virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) override;
89 :
90 : // Inserted child content gets its frames parented by our child block
91 0 : virtual nsContainerFrame* GetContentInsertionFrame() override {
92 0 : return PrincipalChildList().FirstChild()->GetContentInsertionFrame();
93 : }
94 :
95 0 : virtual bool IsFrameOfType(uint32_t aFlags) const override
96 : {
97 0 : return nsContainerFrame::IsFrameOfType(aFlags &
98 0 : ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
99 : }
100 :
101 : // Return the ::-moz-button-content anonymous box.
102 : void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
103 :
104 : protected:
105 : nsHTMLButtonControlFrame(nsStyleContext* aContext, nsIFrame::ClassID aID);
106 :
107 0 : virtual bool IsInput() { return false; }
108 :
109 : // Indicates whether we should clip our children's painting to our
110 : // border-box (either because of "overflow" or because of legacy reasons
111 : // about how <input>-flavored buttons work).
112 : bool ShouldClipPaintingToBorderBox();
113 :
114 : // Reflows the button's sole child frame, and computes the desired size
115 : // of the button itself from the results.
116 : void ReflowButtonContents(nsPresContext* aPresContext,
117 : ReflowOutput& aButtonDesiredSize,
118 : const ReflowInput& aButtonReflowInput,
119 : nsIFrame* aFirstKid);
120 :
121 : nsButtonFrameRenderer mRenderer;
122 : };
123 :
124 : #endif
125 :
126 :
127 :
128 :
|