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 _nsRadioVisitor_h__
8 #define _nsRadioVisitor_h__
10 #include "mozilla/Attributes.h"
11 #include "nsIRadioVisitor.h"
16 * nsRadioVisitor is the base class implementing nsIRadioVisitor and inherited
17 * by all radio visitors.
19 class nsRadioVisitor
: public nsIRadioVisitor
{
21 virtual ~nsRadioVisitor() {}
28 virtual bool Visit(nsIFormControl
* aRadio
) override
= 0;
32 * The following declarations are radio visitors inheriting from nsRadioVisitor.
36 * nsRadioSetCheckedChangedVisitor is calling SetCheckedChanged with the given
37 * parameter to all radio elements in the group.
39 class nsRadioSetCheckedChangedVisitor
: public nsRadioVisitor
{
41 explicit nsRadioSetCheckedChangedVisitor(bool aCheckedChanged
)
42 : mCheckedChanged(aCheckedChanged
) {}
44 virtual bool Visit(nsIFormControl
* aRadio
) override
;
51 * nsRadioGetCheckedChangedVisitor is getting the current checked changed value.
52 * Getting it from one radio element is the group is enough given that all
53 * elements should have the same value.
55 class nsRadioGetCheckedChangedVisitor
: public nsRadioVisitor
{
57 nsRadioGetCheckedChangedVisitor(bool* aCheckedChanged
,
58 nsIFormControl
* aExcludeElement
)
59 : mCheckedChanged(aCheckedChanged
), mExcludeElement(aExcludeElement
) {}
61 virtual bool Visit(nsIFormControl
* aRadio
) override
;
64 bool* mCheckedChanged
;
65 nsIFormControl
* mExcludeElement
;
69 * nsRadioSetValueMissingState is calling SetValueMissingState with the given
70 * parameter to all radio elements in the group.
71 * It is also calling ContentStatesChanged if needed.
73 class nsRadioSetValueMissingState
: public nsRadioVisitor
{
75 nsRadioSetValueMissingState(nsIFormControl
* aExcludeElement
, bool aValidity
,
77 : mExcludeElement(aExcludeElement
),
81 virtual bool Visit(nsIFormControl
* aRadio
) override
;
84 nsIFormControl
* mExcludeElement
;
89 class nsRadioUpdateStateVisitor
: public nsRadioVisitor
{
91 explicit nsRadioUpdateStateVisitor(nsIFormControl
* aExcludeElement
)
92 : mExcludeElement(aExcludeElement
) {}
94 virtual bool Visit(nsIFormControl
* aRadio
) override
;
97 nsIFormControl
* mExcludeElement
;
100 #endif // _nsRadioVisitor_h__