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"
13 using mozilla::dom::HTMLInputElement
;
16 * nsRadioVisitor is the base class implementing nsIRadioVisitor and inherited
17 * by all radio visitors.
19 class nsRadioVisitor
: public nsIRadioVisitor
{
21 virtual ~nsRadioVisitor() = default;
24 nsRadioVisitor() = default;
28 virtual bool Visit(HTMLInputElement
* 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(HTMLInputElement
* 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 HTMLInputElement
* aExcludeElement
)
59 : mCheckedChanged(aCheckedChanged
), mExcludeElement(aExcludeElement
) {}
61 virtual bool Visit(HTMLInputElement
* aRadio
) override
;
64 bool* mCheckedChanged
;
65 HTMLInputElement
* 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(HTMLInputElement
* aExcludeElement
, bool aValidity
)
76 : mExcludeElement(aExcludeElement
), mValidity(aValidity
) {}
78 virtual bool Visit(HTMLInputElement
* aRadio
) override
;
81 HTMLInputElement
* mExcludeElement
;
85 class nsRadioUpdateStateVisitor
: public nsRadioVisitor
{
87 explicit nsRadioUpdateStateVisitor(HTMLInputElement
* aExcludeElement
)
88 : mExcludeElement(aExcludeElement
) {}
90 virtual bool Visit(HTMLInputElement
* aRadio
) override
;
93 HTMLInputElement
* mExcludeElement
;
96 #endif // _nsRadioVisitor_h__