Bug 1516621 [wpt PR 14683] - Update wpt metadata, a=testonly
[gecko.git] / layout / forms / nsCheckboxRadioFrame.h
blobd88d3b7d00723d0fb3a4e8a73158932ac1416546
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 nsCheckboxRadioFrame_h___
8 #define nsCheckboxRadioFrame_h___
10 #include "mozilla/Attributes.h"
11 #include "nsIFormControlFrame.h"
12 #include "nsAtomicContainerFrame.h"
13 #include "nsDisplayList.h"
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.
20 class nsCheckboxRadioFrame final : public nsAtomicContainerFrame,
21 public nsIFormControlFrame {
22 public:
23 NS_DECL_QUERYFRAME
24 NS_DECL_FRAMEARENA_HELPERS(nsCheckboxRadioFrame)
26 explicit nsCheckboxRadioFrame(ComputedStyle* aStyle);
28 // nsIFrame replacements
29 virtual bool IsFrameOfType(uint32_t aFlags) const override {
30 return nsAtomicContainerFrame::IsFrameOfType(
31 aFlags & ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
34 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
35 const nsDisplayListSet& aLists) override {
36 DO_GLOBAL_REFLOW_COUNT_DSP("nsCheckboxRadioFrame");
37 DisplayBorderBackgroundOutline(aBuilder, aLists);
40 /**
41 * Both GetMinISize and GetPrefISize will return whatever GetIntrinsicISize
42 * returns.
44 virtual nscoord GetMinISize(gfxContext* aRenderingContext) override;
45 virtual nscoord GetPrefISize(gfxContext* aRenderingContext) override;
47 /**
48 * Our auto size is just intrinsic width and intrinsic height.
50 virtual mozilla::LogicalSize ComputeAutoSize(
51 gfxContext* aRenderingContext, mozilla::WritingMode aWM,
52 const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize,
53 const mozilla::LogicalSize& aMargin, const mozilla::LogicalSize& aBorder,
54 const mozilla::LogicalSize& aPadding, ComputeSizeFlags aFlags) override;
56 /**
57 * Respond to a gui event
58 * @see nsIFrame::HandleEvent
60 virtual nsresult HandleEvent(nsPresContext* aPresContext,
61 mozilla::WidgetGUIEvent* aEvent,
62 nsEventStatus* aEventStatus) override;
64 virtual nscoord GetLogicalBaseline(
65 mozilla::WritingMode aWritingMode) const override;
67 /**
68 * Respond to the request to resize and/or reflow
69 * @see nsIFrame::Reflow
71 virtual void Reflow(nsPresContext* aCX, ReflowOutput& aDesiredSize,
72 const ReflowInput& aReflowInput,
73 nsReflowStatus& aStatus) override;
75 virtual void DestroyFrom(nsIFrame* aDestructRoot,
76 PostDestroyData& aPostDestroyData) override;
78 // new behavior
80 virtual void SetFocus(bool aOn = true, bool aRepaint = false) override;
82 // nsIFormControlFrame
83 virtual nsresult SetFormProperty(nsAtom* aName,
84 const nsAString& aValue) override;
86 // AccessKey Helper function
87 static nsresult RegUnRegAccessKey(nsIFrame* aFrame, bool aDoReg);
89 /**
90 * Returns the usable screen rect in app units, eg the rect where we can
91 * draw dropdowns.
93 static nsRect GetUsableScreenRect(nsPresContext* aPresContext);
95 protected:
96 virtual ~nsCheckboxRadioFrame();
98 static nscoord DefaultSize() {
99 // XXXmats We have traditionally always returned 9px for GetMin/PrefISize
100 // but we might want to factor in what the theme says, something like:
101 // GetMinimumWidgetSize - GetWidgetPadding - GetWidgetBorder.
102 return nsPresContext::CSSPixelsToAppUnits(9);
106 * Get the state of the checked attribute.
107 * @param aState set to true if the checked attribute is set,
108 * false if the checked attribute has been removed
110 void GetCurrentCheckState(bool* aState);
113 #endif