/src/mozilla-central/dom/html/nsRadioVisitor.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 _nsRadioVisitor_h__ |
8 | | #define _nsRadioVisitor_h__ |
9 | | |
10 | | #include "mozilla/Attributes.h" |
11 | | #include "nsIRadioVisitor.h" |
12 | | |
13 | | class nsIFormControl; |
14 | | |
15 | | /** |
16 | | * nsRadioVisitor is the base class implementing nsIRadioVisitor and inherited |
17 | | * by all radio visitors. |
18 | | */ |
19 | | class nsRadioVisitor : public nsIRadioVisitor |
20 | | { |
21 | | protected: |
22 | 0 | virtual ~nsRadioVisitor() { } |
23 | | |
24 | | public: |
25 | 0 | nsRadioVisitor() { } |
26 | | |
27 | | NS_DECL_ISUPPORTS |
28 | | |
29 | | virtual bool Visit(nsIFormControl* aRadio) override = 0; |
30 | | }; |
31 | | |
32 | | /** |
33 | | * The following declarations are radio visitors inheriting from nsRadioVisitor. |
34 | | */ |
35 | | |
36 | | /** |
37 | | * nsRadioSetCheckedChangedVisitor is calling SetCheckedChanged with the given |
38 | | * parameter to all radio elements in the group. |
39 | | */ |
40 | | class nsRadioSetCheckedChangedVisitor : public nsRadioVisitor |
41 | | { |
42 | | public: |
43 | | explicit nsRadioSetCheckedChangedVisitor(bool aCheckedChanged) |
44 | | : mCheckedChanged(aCheckedChanged) |
45 | 0 | { } |
46 | | |
47 | | virtual bool Visit(nsIFormControl* aRadio) override; |
48 | | |
49 | | protected: |
50 | | bool mCheckedChanged; |
51 | | }; |
52 | | |
53 | | /** |
54 | | * nsRadioGetCheckedChangedVisitor is getting the current checked changed value. |
55 | | * Getting it from one radio element is the group is enough given that all |
56 | | * elements should have the same value. |
57 | | */ |
58 | | class nsRadioGetCheckedChangedVisitor : public nsRadioVisitor |
59 | | { |
60 | | public: |
61 | | nsRadioGetCheckedChangedVisitor(bool* aCheckedChanged, |
62 | | nsIFormControl* aExcludeElement) |
63 | | : mCheckedChanged(aCheckedChanged) |
64 | | , mExcludeElement(aExcludeElement) |
65 | 0 | { } |
66 | | |
67 | | virtual bool Visit(nsIFormControl* aRadio) override; |
68 | | |
69 | | protected: |
70 | | bool* mCheckedChanged; |
71 | | nsIFormControl* mExcludeElement; |
72 | | }; |
73 | | |
74 | | /** |
75 | | * nsRadioSetValueMissingState is calling SetValueMissingState with the given |
76 | | * parameter to all radio elements in the group. |
77 | | * It is also calling ContentStatesChanged if needed. |
78 | | */ |
79 | | class nsRadioSetValueMissingState : public nsRadioVisitor |
80 | | { |
81 | | public: |
82 | | nsRadioSetValueMissingState(nsIFormControl* aExcludeElement, |
83 | | bool aValidity, bool aNotify) |
84 | | : mExcludeElement(aExcludeElement) |
85 | | , mValidity(aValidity) |
86 | | , mNotify(aNotify) |
87 | 0 | { } |
88 | | |
89 | | virtual bool Visit(nsIFormControl* aRadio) override; |
90 | | |
91 | | protected: |
92 | | nsIFormControl* mExcludeElement; |
93 | | bool mValidity; |
94 | | bool mNotify; |
95 | | }; |
96 | | |
97 | | class nsRadioUpdateStateVisitor : public nsRadioVisitor |
98 | | { |
99 | | public: |
100 | | explicit nsRadioUpdateStateVisitor(nsIFormControl* aExcludeElement) |
101 | | : mExcludeElement(aExcludeElement) |
102 | 0 | { } |
103 | | |
104 | | virtual bool Visit(nsIFormControl* aRadio) override; |
105 | | |
106 | | protected: |
107 | | nsIFormControl* mExcludeElement; |
108 | | }; |
109 | | |
110 | | #endif // _nsRadioVisitor_h__ |
111 | | |