2011-04-11 11:31:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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 11:31:00 -07:00
|
|
|
|
|
|
|
#include "nsRadioVisitor.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2013-03-28 12:41:32 -07:00
|
|
|
#include "mozilla/dom/HTMLInputElement.h"
|
2011-04-11 11:31:00 -07:00
|
|
|
#include "nsIConstraintValidation.h"
|
|
|
|
|
2013-03-28 12:41:32 -07:00
|
|
|
using namespace mozilla::dom;
|
2011-04-11 11:31:00 -07:00
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(nsRadioVisitor, nsIRadioVisitor)
|
2011-04-11 11:31:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2011-04-11 11:31:00 -07:00
|
|
|
nsRadioSetCheckedChangedVisitor::Visit(nsIFormControl* aRadio)
|
|
|
|
{
|
2013-03-28 12:41:32 -07:00
|
|
|
nsRefPtr<HTMLInputElement> radio =
|
|
|
|
static_cast<HTMLInputElement*>(aRadio);
|
2011-04-11 11:31:00 -07:00
|
|
|
NS_ASSERTION(radio, "Visit() passed a null button!");
|
|
|
|
|
|
|
|
radio->SetCheckedChangedInternal(mCheckedChanged);
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2011-04-11 11:31:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2011-04-11 11:31:00 -07:00
|
|
|
nsRadioGetCheckedChangedVisitor::Visit(nsIFormControl* aRadio)
|
|
|
|
{
|
|
|
|
if (aRadio == mExcludeElement) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2011-04-11 11:31:00 -07:00
|
|
|
}
|
|
|
|
|
2013-03-28 12:41:32 -07:00
|
|
|
nsRefPtr<HTMLInputElement> radio =
|
|
|
|
static_cast<HTMLInputElement*>(aRadio);
|
2011-04-11 11:31:00 -07:00
|
|
|
NS_ASSERTION(radio, "Visit() passed a null button!");
|
|
|
|
|
|
|
|
*mCheckedChanged = radio->GetCheckedChanged();
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2011-04-11 11:31:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2011-04-11 11:31:00 -07:00
|
|
|
nsRadioSetValueMissingState::Visit(nsIFormControl* aRadio)
|
|
|
|
{
|
|
|
|
if (aRadio == mExcludeElement) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2011-04-11 11:31:00 -07:00
|
|
|
}
|
|
|
|
|
2013-03-28 12:41:32 -07:00
|
|
|
HTMLInputElement* input = static_cast<HTMLInputElement*>(aRadio);
|
2011-04-11 11:31:00 -07:00
|
|
|
|
|
|
|
input->SetValidityState(nsIConstraintValidation::VALIDITY_STATE_VALUE_MISSING,
|
|
|
|
mValidity);
|
|
|
|
|
2011-05-31 18:46:57 -07:00
|
|
|
input->UpdateState(true);
|
2011-04-11 11:31:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2011-04-11 11:31:00 -07:00
|
|
|
}
|
|
|
|
|