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 nsHTMLButtonControlFrame_h___
8 #define nsHTMLButtonControlFrame_h___
10 #include "mozilla/Attributes.h"
11 #include "nsContainerFrame.h"
12 #include "nsIFormControlFrame.h"
13 #include "nsButtonFrameRenderer.h"
18 class nsHTMLButtonControlFrame
: public nsContainerFrame
,
19 public nsIFormControlFrame
{
21 explicit nsHTMLButtonControlFrame(ComputedStyle
* aStyle
,
22 nsPresContext
* aPresContext
)
23 : nsHTMLButtonControlFrame(aStyle
, aPresContext
, kClassID
) {}
25 ~nsHTMLButtonControlFrame();
28 NS_DECL_FRAMEARENA_HELPERS(nsHTMLButtonControlFrame
)
30 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
31 const nsDisplayListSet
& aLists
) override
;
33 virtual nscoord
GetMinISize(gfxContext
* aRenderingContext
) override
;
35 virtual nscoord
GetPrefISize(gfxContext
* aRenderingContext
) override
;
37 virtual void Reflow(nsPresContext
* aPresContext
, ReflowOutput
& aDesiredSize
,
38 const ReflowInput
& aReflowInput
,
39 nsReflowStatus
& aStatus
) override
;
41 bool GetVerticalAlignBaseline(mozilla::WritingMode aWM
,
42 nscoord
* aBaseline
) const override
;
44 bool GetNaturalBaselineBOffset(mozilla::WritingMode aWM
,
45 BaselineSharingGroup aBaselineGroup
,
46 nscoord
* aBaseline
) const override
;
48 virtual nsresult
HandleEvent(nsPresContext
* aPresContext
,
49 mozilla::WidgetGUIEvent
* aEvent
,
50 nsEventStatus
* aEventStatus
) override
;
52 virtual void Init(nsIContent
* aContent
, nsContainerFrame
* aParent
,
53 nsIFrame
* aPrevInFlow
) override
;
55 ComputedStyle
* GetAdditionalComputedStyle(int32_t aIndex
) const override
;
56 void SetAdditionalComputedStyle(int32_t aIndex
,
57 ComputedStyle
* aComputedStyle
) override
;
60 virtual void AppendFrames(ChildListID aListID
,
61 nsFrameList
& aFrameList
) override
;
62 virtual void InsertFrames(ChildListID aListID
, nsIFrame
* aPrevFrame
,
63 const nsLineList::iterator
* aPrevFrameLine
,
64 nsFrameList
& aFrameList
) override
;
65 virtual void RemoveFrame(ChildListID aListID
, nsIFrame
* aOldFrame
) override
;
69 virtual mozilla::a11y::AccType
AccessibleType() override
;
72 #ifdef DEBUG_FRAME_DUMP
73 virtual nsresult
GetFrameName(nsAString
& aResult
) const override
{
74 return MakeFrameName(u
"HTMLButtonControl"_ns
, aResult
);
78 virtual bool HonorPrintBackgroundSettings() const override
{ return false; }
80 // nsIFormControlFrame
81 void SetFocus(bool aOn
, bool aRepaint
) override
;
82 virtual nsresult
SetFormProperty(nsAtom
* aName
,
83 const nsAString
& aValue
) override
;
85 // Inserted child content gets its frames parented by our child block
86 virtual nsContainerFrame
* GetContentInsertionFrame() override
{
87 return PrincipalChildList().FirstChild()->GetContentInsertionFrame();
90 virtual bool IsFrameOfType(uint32_t aFlags
) const override
{
91 return nsContainerFrame::IsFrameOfType(
92 aFlags
& ~(nsIFrame::eReplaced
| nsIFrame::eReplacedContainsBlock
));
95 // Return the ::-moz-button-content anonymous box.
96 void AppendDirectlyOwnedAnonBoxes(nsTArray
<OwnedAnonBox
>& aResult
) override
;
99 nsHTMLButtonControlFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
,
100 nsIFrame::ClassID aID
);
102 virtual bool IsInput() { return false; }
104 // Indicates whether we should clip our children's painting to our
105 // border-box (either because of "overflow" or because of legacy reasons
106 // about how <input>-flavored buttons work).
107 bool ShouldClipPaintingToBorderBox();
109 // Reflows the button's sole child frame, and computes the desired size
110 // of the button itself from the results.
111 void ReflowButtonContents(nsPresContext
* aPresContext
,
112 ReflowOutput
& aButtonDesiredSize
,
113 const ReflowInput
& aButtonReflowInput
,
114 nsIFrame
* aFirstKid
);
116 nsButtonFrameRenderer mRenderer
;