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