Line data Source code
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 : #include "nsRadioVisitor.h"
8 : #include "mozilla/dom/HTMLInputElement.h"
9 : #include "nsIConstraintValidation.h"
10 :
11 : using namespace mozilla::dom;
12 :
13 0 : NS_IMPL_ISUPPORTS(nsRadioVisitor, nsIRadioVisitor)
14 :
15 : bool
16 0 : nsRadioSetCheckedChangedVisitor::Visit(nsIFormControl* aRadio)
17 : {
18 : RefPtr<HTMLInputElement> radio =
19 0 : static_cast<HTMLInputElement*>(aRadio);
20 0 : NS_ASSERTION(radio, "Visit() passed a null button!");
21 :
22 0 : radio->SetCheckedChangedInternal(mCheckedChanged);
23 0 : return true;
24 : }
25 :
26 : bool
27 0 : nsRadioGetCheckedChangedVisitor::Visit(nsIFormControl* aRadio)
28 : {
29 0 : if (aRadio == mExcludeElement) {
30 0 : return true;
31 : }
32 :
33 : RefPtr<HTMLInputElement> radio =
34 0 : static_cast<HTMLInputElement*>(aRadio);
35 0 : NS_ASSERTION(radio, "Visit() passed a null button!");
36 :
37 0 : *mCheckedChanged = radio->GetCheckedChanged();
38 0 : return false;
39 : }
40 :
41 : bool
42 0 : nsRadioSetValueMissingState::Visit(nsIFormControl* aRadio)
43 : {
44 0 : if (aRadio == mExcludeElement) {
45 0 : return true;
46 : }
47 :
48 0 : HTMLInputElement* input = static_cast<HTMLInputElement*>(aRadio);
49 :
50 0 : input->SetValidityState(nsIConstraintValidation::VALIDITY_STATE_VALUE_MISSING,
51 0 : mValidity);
52 :
53 0 : input->UpdateState(true);
54 :
55 0 : return true;
56 : }
57 :
58 : bool
59 0 : nsRadioUpdateStateVisitor::Visit(nsIFormControl* aRadio)
60 : {
61 0 : if (aRadio == mExcludeElement) {
62 0 : return true;
63 : }
64 :
65 0 : HTMLInputElement* input = static_cast<HTMLInputElement*>(aRadio);
66 0 : input->UpdateState(true);
67 :
68 0 : return true;
69 : }
|