2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-04-11 18:31:00 +00:00
|
|
|
|
|
|
|
#include "nsRadioVisitor.h"
|
2013-03-28 19:41:32 +00:00
|
|
|
#include "mozilla/dom/HTMLInputElement.h"
|
2011-04-11 18:31:00 +00:00
|
|
|
#include "nsIConstraintValidation.h"
|
|
|
|
|
2013-03-28 19:41:32 +00:00
|
|
|
using namespace mozilla::dom;
|
2011-04-11 18:31:00 +00:00
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(nsRadioVisitor, nsIRadioVisitor)
|
2011-04-11 18:31:00 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2011-04-11 18:31:00 +00:00
|
|
|
nsRadioSetCheckedChangedVisitor::Visit(nsIFormControl* aRadio)
|
|
|
|
{
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<HTMLInputElement> radio =
|
2013-03-28 19:41:32 +00:00
|
|
|
static_cast<HTMLInputElement*>(aRadio);
|
2011-04-11 18:31:00 +00:00
|
|
|
NS_ASSERTION(radio, "Visit() passed a null button!");
|
|
|
|
|
|
|
|
radio->SetCheckedChangedInternal(mCheckedChanged);
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2011-04-11 18:31:00 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2011-04-11 18:31:00 +00:00
|
|
|
nsRadioGetCheckedChangedVisitor::Visit(nsIFormControl* aRadio)
|
|
|
|
{
|
|
|
|
if (aRadio == mExcludeElement) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2011-04-11 18:31:00 +00:00
|
|
|
}
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<HTMLInputElement> radio =
|
2013-03-28 19:41:32 +00:00
|
|
|
static_cast<HTMLInputElement*>(aRadio);
|
2011-04-11 18:31:00 +00:00
|
|
|
NS_ASSERTION(radio, "Visit() passed a null button!");
|
|
|
|
|
|
|
|
*mCheckedChanged = radio->GetCheckedChanged();
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2011-04-11 18:31:00 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2011-04-11 18:31:00 +00:00
|
|
|
nsRadioSetValueMissingState::Visit(nsIFormControl* aRadio)
|
|
|
|
{
|
|
|
|
if (aRadio == mExcludeElement) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2011-04-11 18:31:00 +00:00
|
|
|
}
|
|
|
|
|
2013-03-28 19:41:32 +00:00
|
|
|
HTMLInputElement* input = static_cast<HTMLInputElement*>(aRadio);
|
2011-04-11 18:31:00 +00:00
|
|
|
|
|
|
|
input->SetValidityState(nsIConstraintValidation::VALIDITY_STATE_VALUE_MISSING,
|
|
|
|
mValidity);
|
|
|
|
|
2011-06-01 01:46:57 +00:00
|
|
|
input->UpdateState(true);
|
2011-04-11 18:31:00 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2011-04-11 18:31:00 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 22:39:00 +00:00
|
|
|
bool
|
|
|
|
nsRadioUpdateStateVisitor::Visit(nsIFormControl* aRadio)
|
|
|
|
{
|
|
|
|
if (aRadio == mExcludeElement) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
HTMLInputElement* input = static_cast<HTMLInputElement*>(aRadio);
|
|
|
|
input->UpdateState(true);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|