2015-05-03 22:32:37 +03: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 15:12:37 +04: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 22:31:00 +04:00
|
|
|
|
|
|
|
#include "nsRadioVisitor.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2013-03-28 23:41:32 +04:00
|
|
|
#include "mozilla/dom/HTMLInputElement.h"
|
2011-04-11 22:31:00 +04:00
|
|
|
#include "nsIConstraintValidation.h"
|
|
|
|
|
2013-03-28 23:41:32 +04:00
|
|
|
using namespace mozilla::dom;
|
2011-04-11 22:31:00 +04:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsRadioVisitor, nsIRadioVisitor)
|
2011-04-11 22:31:00 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-04-11 22:31:00 +04:00
|
|
|
nsRadioSetCheckedChangedVisitor::Visit(nsIFormControl* aRadio)
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<HTMLInputElement> radio =
|
2013-03-28 23:41:32 +04:00
|
|
|
static_cast<HTMLInputElement*>(aRadio);
|
2011-04-11 22:31:00 +04:00
|
|
|
NS_ASSERTION(radio, "Visit() passed a null button!");
|
|
|
|
|
|
|
|
radio->SetCheckedChangedInternal(mCheckedChanged);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2011-04-11 22:31:00 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-04-11 22:31:00 +04:00
|
|
|
nsRadioGetCheckedChangedVisitor::Visit(nsIFormControl* aRadio)
|
|
|
|
{
|
|
|
|
if (aRadio == mExcludeElement) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2011-04-11 22:31:00 +04:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<HTMLInputElement> radio =
|
2013-03-28 23:41:32 +04:00
|
|
|
static_cast<HTMLInputElement*>(aRadio);
|
2011-04-11 22:31:00 +04:00
|
|
|
NS_ASSERTION(radio, "Visit() passed a null button!");
|
|
|
|
|
|
|
|
*mCheckedChanged = radio->GetCheckedChanged();
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-04-11 22:31:00 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-04-11 22:31:00 +04:00
|
|
|
nsRadioSetValueMissingState::Visit(nsIFormControl* aRadio)
|
|
|
|
{
|
|
|
|
if (aRadio == mExcludeElement) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2011-04-11 22:31:00 +04:00
|
|
|
}
|
|
|
|
|
2013-03-28 23:41:32 +04:00
|
|
|
HTMLInputElement* input = static_cast<HTMLInputElement*>(aRadio);
|
2011-04-11 22:31:00 +04:00
|
|
|
|
|
|
|
input->SetValidityState(nsIConstraintValidation::VALIDITY_STATE_VALUE_MISSING,
|
|
|
|
mValidity);
|
|
|
|
|
2011-06-01 05:46:57 +04:00
|
|
|
input->UpdateState(true);
|
2011-04-11 22:31:00 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2011-04-11 22:31:00 +04:00
|
|
|
}
|
|
|
|
|