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 nsFormControlFrame_h___
7 : #define nsFormControlFrame_h___
8 :
9 : #include "mozilla/Attributes.h"
10 : #include "nsIFormControlFrame.h"
11 : #include "nsAtomicContainerFrame.h"
12 : #include "nsDisplayList.h"
13 :
14 : /**
15 : * nsFormControlFrame is the base class for radio buttons and
16 : * checkboxes. It also has two static methods (RegUnRegAccessKey and
17 : * GetScreenHeight) that are used by other form controls.
18 : */
19 : class nsFormControlFrame : public nsAtomicContainerFrame,
20 : public nsIFormControlFrame
21 : {
22 : public:
23 : /**
24 : * Main constructor
25 : * @param aContent the content representing this frame
26 : * @param aParentFrame the parent frame
27 : */
28 : nsFormControlFrame(nsStyleContext*, nsIFrame::ClassID);
29 :
30 0 : virtual bool IsFrameOfType(uint32_t aFlags) const override
31 : {
32 0 : return nsAtomicContainerFrame::IsFrameOfType(aFlags &
33 0 : ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
34 : }
35 :
36 : NS_DECL_QUERYFRAME
37 : NS_DECL_ABSTRACT_FRAME(nsFormControlFrame)
38 :
39 : // nsIFrame replacements
40 0 : virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
41 : const nsRect& aDirtyRect,
42 : const nsDisplayListSet& aLists) override {
43 0 : DO_GLOBAL_REFLOW_COUNT_DSP("nsFormControlFrame");
44 0 : DisplayBorderBackgroundOutline(aBuilder, aLists);
45 0 : }
46 :
47 : /**
48 : * Both GetMinISize and GetPrefISize will return whatever GetIntrinsicISize
49 : * returns.
50 : */
51 : virtual nscoord GetMinISize(gfxContext *aRenderingContext) override;
52 : virtual nscoord GetPrefISize(gfxContext *aRenderingContext) override;
53 :
54 : /**
55 : * Our auto size is just intrinsic width and intrinsic height.
56 : */
57 : virtual mozilla::LogicalSize
58 : ComputeAutoSize(gfxContext* aRenderingContext,
59 : mozilla::WritingMode aWM,
60 : const mozilla::LogicalSize& aCBSize,
61 : nscoord aAvailableISize,
62 : const mozilla::LogicalSize& aMargin,
63 : const mozilla::LogicalSize& aBorder,
64 : const mozilla::LogicalSize& aPadding,
65 : ComputeSizeFlags aFlags) override;
66 :
67 : /**
68 : * Respond to a gui event
69 : * @see nsIFrame::HandleEvent
70 : */
71 : virtual nsresult HandleEvent(nsPresContext* aPresContext,
72 : mozilla::WidgetGUIEvent* aEvent,
73 : nsEventStatus* aEventStatus) override;
74 :
75 : virtual nscoord GetLogicalBaseline(mozilla::WritingMode aWritingMode)
76 : const override;
77 :
78 : /**
79 : * Respond to the request to resize and/or reflow
80 : * @see nsIFrame::Reflow
81 : */
82 : virtual void Reflow(nsPresContext* aCX,
83 : ReflowOutput& aDesiredSize,
84 : const ReflowInput& aReflowInput,
85 : nsReflowStatus& aStatus) override;
86 :
87 : virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
88 :
89 : // new behavior
90 :
91 : virtual void SetFocus(bool aOn = true, bool aRepaint = false) override;
92 :
93 : // nsIFormControlFrame
94 : virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) override;
95 :
96 : // AccessKey Helper function
97 : static nsresult RegUnRegAccessKey(nsIFrame * aFrame, bool aDoReg);
98 :
99 : /**
100 : * Returns the usable screen rect in app units, eg the rect where we can
101 : * draw dropdowns.
102 : */
103 : static nsRect GetUsableScreenRect(nsPresContext* aPresContext);
104 :
105 : protected:
106 :
107 : virtual ~nsFormControlFrame();
108 :
109 0 : static nscoord DefaultSize()
110 : {
111 : // XXXmats We have traditionally always returned 9px for GetMin/PrefISize
112 : // but we might want to factor in what the theme says, something like:
113 : // GetMinimumWidgetSize - GetWidgetPadding - GetWidgetBorder.
114 0 : return nsPresContext::CSSPixelsToAppUnits(9);
115 : }
116 :
117 : /**
118 : * Get the state of the checked attribute.
119 : * @param aState set to true if the checked attribute is set,
120 : * false if the checked attribute has been removed
121 : */
122 : void GetCurrentCheckState(bool* aState);
123 : };
124 :
125 : #endif
126 :
|