зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1727631 - Part 2: Make nsIRadioVisitor and subclasses use HTMLInputElement directly; r=smaug
Depends on D123681 Differential Revision: https://phabricator.services.mozilla.com/D123686
This commit is contained in:
Родитель
dcc9800af0
Коммит
c6c971a4fd
|
@ -8,7 +8,10 @@
|
|||
#define nsIRadioVisitor_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsIFormControl;
|
||||
|
||||
namespace mozilla::dom {
|
||||
class HTMLInputElement;
|
||||
} // namespace mozilla::dom
|
||||
|
||||
// IID for the nsIRadioControl interface
|
||||
#define NS_IRADIOVISITOR_IID \
|
||||
|
@ -37,7 +40,7 @@ class nsIRadioVisitor : public nsISupports {
|
|||
* @param aRadio the radio button in question (must be nullptr and QI'able to
|
||||
* nsIRadioControlElement)
|
||||
*/
|
||||
virtual bool Visit(nsIFormControl* aRadio) = 0;
|
||||
virtual bool Visit(mozilla::dom::HTMLInputElement* aRadio) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIRadioVisitor, NS_IRADIOVISITOR_IID)
|
||||
|
|
|
@ -12,48 +12,38 @@ using namespace mozilla::dom;
|
|||
|
||||
NS_IMPL_ISUPPORTS(nsRadioVisitor, nsIRadioVisitor)
|
||||
|
||||
bool nsRadioSetCheckedChangedVisitor::Visit(nsIFormControl* aRadio) {
|
||||
RefPtr<HTMLInputElement> radio = static_cast<HTMLInputElement*>(aRadio);
|
||||
NS_ASSERTION(radio, "Visit() passed a null button!");
|
||||
|
||||
radio->SetCheckedChangedInternal(mCheckedChanged);
|
||||
bool nsRadioSetCheckedChangedVisitor::Visit(HTMLInputElement* aRadio) {
|
||||
NS_ASSERTION(aRadio, "Visit() passed a null button!");
|
||||
aRadio->SetCheckedChangedInternal(mCheckedChanged);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool nsRadioGetCheckedChangedVisitor::Visit(nsIFormControl* aRadio) {
|
||||
bool nsRadioGetCheckedChangedVisitor::Visit(HTMLInputElement* aRadio) {
|
||||
if (aRadio == mExcludeElement) {
|
||||
return true;
|
||||
}
|
||||
|
||||
RefPtr<HTMLInputElement> radio = static_cast<HTMLInputElement*>(aRadio);
|
||||
NS_ASSERTION(radio, "Visit() passed a null button!");
|
||||
|
||||
*mCheckedChanged = radio->GetCheckedChanged();
|
||||
NS_ASSERTION(aRadio, "Visit() passed a null button!");
|
||||
*mCheckedChanged = aRadio->GetCheckedChanged();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool nsRadioSetValueMissingState::Visit(nsIFormControl* aRadio) {
|
||||
bool nsRadioSetValueMissingState::Visit(HTMLInputElement* aRadio) {
|
||||
if (aRadio == mExcludeElement) {
|
||||
return true;
|
||||
}
|
||||
|
||||
HTMLInputElement* input = static_cast<HTMLInputElement*>(aRadio);
|
||||
|
||||
input->SetValidityState(nsIConstraintValidation::VALIDITY_STATE_VALUE_MISSING,
|
||||
mValidity);
|
||||
|
||||
input->UpdateState(true);
|
||||
|
||||
aRadio->SetValidityState(
|
||||
nsIConstraintValidation::VALIDITY_STATE_VALUE_MISSING, mValidity);
|
||||
aRadio->UpdateState(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool nsRadioUpdateStateVisitor::Visit(nsIFormControl* aRadio) {
|
||||
bool nsRadioUpdateStateVisitor::Visit(HTMLInputElement* aRadio) {
|
||||
if (aRadio == mExcludeElement) {
|
||||
return true;
|
||||
}
|
||||
|
||||
HTMLInputElement* input = static_cast<HTMLInputElement*>(aRadio);
|
||||
input->UpdateState(true);
|
||||
|
||||
aRadio->UpdateState(true);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "nsIRadioVisitor.h"
|
||||
|
||||
class nsIFormControl;
|
||||
using mozilla::dom::HTMLInputElement;
|
||||
|
||||
/**
|
||||
* nsRadioVisitor is the base class implementing nsIRadioVisitor and inherited
|
||||
|
@ -25,7 +25,7 @@ class nsRadioVisitor : public nsIRadioVisitor {
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual bool Visit(nsIFormControl* aRadio) override = 0;
|
||||
virtual bool Visit(HTMLInputElement* aRadio) override = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,7 @@ class nsRadioSetCheckedChangedVisitor : public nsRadioVisitor {
|
|||
explicit nsRadioSetCheckedChangedVisitor(bool aCheckedChanged)
|
||||
: mCheckedChanged(aCheckedChanged) {}
|
||||
|
||||
virtual bool Visit(nsIFormControl* aRadio) override;
|
||||
virtual bool Visit(HTMLInputElement* aRadio) override;
|
||||
|
||||
protected:
|
||||
bool mCheckedChanged;
|
||||
|
@ -55,14 +55,14 @@ class nsRadioSetCheckedChangedVisitor : public nsRadioVisitor {
|
|||
class nsRadioGetCheckedChangedVisitor : public nsRadioVisitor {
|
||||
public:
|
||||
nsRadioGetCheckedChangedVisitor(bool* aCheckedChanged,
|
||||
nsIFormControl* aExcludeElement)
|
||||
HTMLInputElement* aExcludeElement)
|
||||
: mCheckedChanged(aCheckedChanged), mExcludeElement(aExcludeElement) {}
|
||||
|
||||
virtual bool Visit(nsIFormControl* aRadio) override;
|
||||
virtual bool Visit(HTMLInputElement* aRadio) override;
|
||||
|
||||
protected:
|
||||
bool* mCheckedChanged;
|
||||
nsIFormControl* mExcludeElement;
|
||||
HTMLInputElement* mExcludeElement;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -72,25 +72,25 @@ class nsRadioGetCheckedChangedVisitor : public nsRadioVisitor {
|
|||
*/
|
||||
class nsRadioSetValueMissingState : public nsRadioVisitor {
|
||||
public:
|
||||
nsRadioSetValueMissingState(nsIFormControl* aExcludeElement, bool aValidity)
|
||||
nsRadioSetValueMissingState(HTMLInputElement* aExcludeElement, bool aValidity)
|
||||
: mExcludeElement(aExcludeElement), mValidity(aValidity) {}
|
||||
|
||||
virtual bool Visit(nsIFormControl* aRadio) override;
|
||||
virtual bool Visit(HTMLInputElement* aRadio) override;
|
||||
|
||||
protected:
|
||||
nsIFormControl* mExcludeElement;
|
||||
HTMLInputElement* mExcludeElement;
|
||||
bool mValidity;
|
||||
};
|
||||
|
||||
class nsRadioUpdateStateVisitor : public nsRadioVisitor {
|
||||
public:
|
||||
explicit nsRadioUpdateStateVisitor(nsIFormControl* aExcludeElement)
|
||||
explicit nsRadioUpdateStateVisitor(HTMLInputElement* aExcludeElement)
|
||||
: mExcludeElement(aExcludeElement) {}
|
||||
|
||||
virtual bool Visit(nsIFormControl* aRadio) override;
|
||||
virtual bool Visit(HTMLInputElement* aRadio) override;
|
||||
|
||||
protected:
|
||||
nsIFormControl* mExcludeElement;
|
||||
HTMLInputElement* mExcludeElement;
|
||||
};
|
||||
|
||||
#endif // _nsRadioVisitor_h__
|
||||
|
|
Загрузка…
Ссылка в новой задаче