Bug 1380415 part 2. Remove XPCOM constraint validation APIs. r=mccr8

This commit is contained in:
Boris Zbarsky 2017-07-13 23:46:28 -04:00
parent 80f71b7baf
commit d821ab4d73
27 changed files with 38 additions and 180 deletions

View File

@ -87,17 +87,12 @@ NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLButtonElement)
nsIConstraintValidation)
NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLFormElementWithState)
// nsIConstraintValidation
NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(HTMLButtonElement)
NS_IMETHODIMP
void
HTMLButtonElement::SetCustomValidity(const nsAString& aError)
{
nsIConstraintValidation::SetCustomValidity(aError);
UpdateState(true);
return NS_OK;
}
void

View File

@ -163,13 +163,9 @@ public:
SetHTMLAttr(nsGkAtoms::value, aValue, aRv);
}
// nsIConstraintValidation::WillValidate is fine.
// nsIConstraintValidation::Validity() is fine.
// nsIConstraintValidation::GetValidationMessage() is fine.
// nsIConstraintValidation::CheckValidity() is fine.
using nsIConstraintValidation::CheckValidity;
using nsIConstraintValidation::ReportValidity;
// nsIConstraintValidation::SetCustomValidity() is fine.
// Override SetCustomValidity so we update our state properly when it's called
// via bindings.
void SetCustomValidity(const nsAString& aError);
protected:
virtual ~HTMLButtonElement();

View File

@ -59,9 +59,6 @@ NS_IMPL_ELEMENT_CLONE(HTMLFieldSetElement)
NS_IMPL_BOOL_ATTR(HTMLFieldSetElement, Disabled, disabled)
NS_IMPL_STRING_ATTR(HTMLFieldSetElement, Name, name)
// nsIConstraintValidation
NS_IMPL_NSICONSTRAINTVALIDATION(HTMLFieldSetElement)
bool
HTMLFieldSetElement::IsDisabledForEvents(EventMessage aMessage)
{

View File

@ -24,10 +24,8 @@ class HTMLFieldSetElement final : public nsGenericHTMLFormElement,
{
public:
using nsGenericHTMLFormElement::GetForm;
using nsIConstraintValidation::Validity;
using nsIConstraintValidation::CheckValidity;
using nsIConstraintValidation::ReportValidity;
using nsIConstraintValidation::GetValidationMessage;
using nsIConstraintValidation::SetCustomValidity;
explicit HTMLFieldSetElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);

View File

@ -1277,9 +1277,6 @@ NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLInputElement)
nsIConstraintValidation)
NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLFormElementWithState)
// nsIConstraintValidation
NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(HTMLInputElement)
// nsIDOMNode
nsresult
@ -7123,14 +7120,12 @@ HTMLInputElement::GetStep() const
// nsIConstraintValidation
NS_IMETHODIMP
void
HTMLInputElement::SetCustomValidity(const nsAString& aError)
{
nsIConstraintValidation::SetCustomValidity(aError);
UpdateState(true);
return NS_OK;
}
bool
@ -7336,13 +7331,6 @@ HTMLInputElement::UpdateBarredFromConstraintValidation()
IsDisabled());
}
void
HTMLInputElement::GetValidationMessage(nsAString& aValidationMessage,
ErrorResult& aRv)
{
aRv = GetValidationMessage(aValidationMessage);
}
nsresult
HTMLInputElement::GetValidationMessage(nsAString& aValidationMessage,
ValidityStateType aType)

View File

@ -136,10 +136,6 @@ class HTMLInputElement final : public nsGenericHTMLFormElementWithState,
public:
using nsIConstraintValidation::GetValidationMessage;
using nsIConstraintValidation::CheckValidity;
using nsIConstraintValidation::ReportValidity;
using nsIConstraintValidation::WillValidate;
using nsIConstraintValidation::Validity;
using nsGenericHTMLFormElementWithState::GetForm;
enum class FromClone { no, yes };
@ -365,6 +361,11 @@ public:
void UpdateBarredFromConstraintValidation();
nsresult GetValidationMessage(nsAString& aValidationMessage,
ValidityStateType aType) override;
// Override SetCustomValidity so we update our state properly when it's called
// via bindings.
void SetCustomValidity(const nsAString& aError);
/**
* Update the value missing validity state for radio elements when they have
* a group.
@ -763,10 +764,6 @@ public:
*/
Decimal GetStep() const;
void GetValidationMessage(nsAString& aValidationMessage, ErrorResult& aRv);
// XPCOM GetCustomVisibility() is OK
already_AddRefed<nsINodeList> GetLabels();
void Select();

View File

@ -115,9 +115,6 @@ NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLFormElement)
NS_IMPL_ELEMENT_CLONE(HTMLObjectElement)
// nsIConstraintValidation
NS_IMPL_NSICONSTRAINTVALIDATION(HTMLObjectElement)
#ifdef XP_MACOSX
static nsIWidget* GetWidget(Element* aElement)

View File

@ -154,9 +154,8 @@ public:
nsPIDOMWindowOuter*
GetContentWindow(nsIPrincipal& aSubjectPrincipal);
using nsIConstraintValidation::CheckValidity;
using nsIConstraintValidation::ReportValidity;
using nsIConstraintValidation::GetValidationMessage;
using nsIConstraintValidation::SetCustomValidity;
void GetAlign(DOMString& aValue)
{
GetHTMLAttr(nsGkAtoms::align, aValue);

View File

@ -181,17 +181,12 @@ NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLFormElementWithState)
NS_IMPL_ELEMENT_CLONE(HTMLSelectElement)
// nsIConstraintValidation
NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(HTMLSelectElement)
NS_IMETHODIMP
void
HTMLSelectElement::SetCustomValidity(const nsAString& aError)
{
nsIConstraintValidation::SetCustomValidity(aError);
UpdateState(true);
return NS_OK;
}
void

View File

@ -275,13 +275,9 @@ public:
void GetValue(DOMString& aValue);
// Uses XPCOM SetValue.
// nsIConstraintValidation::WillValidate is fine.
// nsIConstraintValidation::Validity() is fine.
// nsIConstraintValidation::GetValidationMessage() is fine.
// nsIConstraintValidation::CheckValidity() is fine.
using nsIConstraintValidation::CheckValidity;
using nsIConstraintValidation::ReportValidity;
// nsIConstraintValidation::SetCustomValidity() is fine.
// Override SetCustomValidity so we update our state properly when it's called
// via bindings.
void SetCustomValidity(const nsAString& aError);
using nsINode::Remove;

View File

@ -128,10 +128,6 @@ HTMLTextAreaElement::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
return NS_OK;
}
// nsIConstraintValidation
NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(HTMLTextAreaElement)
NS_IMETHODIMP
HTMLTextAreaElement::GetForm(nsIDOMHTMLFormElement** aForm)
{
@ -1158,16 +1154,12 @@ HTMLTextAreaElement::IsValueEmpty() const
return value.IsEmpty();
}
// nsIConstraintValidation
NS_IMETHODIMP
void
HTMLTextAreaElement::SetCustomValidity(const nsAString& aError)
{
nsIConstraintValidation::SetCustomValidity(aError);
UpdateState(true);
return NS_OK;
}
bool

View File

@ -286,13 +286,11 @@ public:
void SetDefaultValue(const nsAString& aDefaultValue, ErrorResult& aError);
// XPCOM GetValue/SetValue are fine
uint32_t GetTextLength();
// nsIConstraintValidation::WillValidate is fine.
// nsIConstraintValidation::Validity() is fine.
// nsIConstraintValidation::GetValidationMessage() is fine.
// nsIConstraintValidation::CheckValidity() is fine.
using nsIConstraintValidation::CheckValidity;
using nsIConstraintValidation::ReportValidity;
// nsIConstraintValidation::SetCustomValidity() is fine.
// Override SetCustomValidity so we update our state properly when it's called
// via bindings.
void SetCustomValidity(const nsAString& aError);
// XPCOM Select is fine
Nullable<uint32_t> GetSelectionStart(ErrorResult& aError);
void SetSelectionStart(const Nullable<uint32_t>& aSelectionStart, ErrorResult& aError);

View File

@ -8,6 +8,7 @@
#include "nsAString.h"
#include "nsGenericHTMLElement.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/HTMLFormElement.h"
#include "mozilla/dom/HTMLFieldSetElement.h"
#include "mozilla/dom/HTMLInputElement.h"
@ -54,8 +55,9 @@ nsIConstraintValidation::GetValidity(nsIDOMValidityState** aValidity)
return NS_OK;
}
NS_IMETHODIMP
nsIConstraintValidation::GetValidationMessage(nsAString& aValidationMessage)
void
nsIConstraintValidation::GetValidationMessage(nsAString& aValidationMessage,
ErrorResult& aError)
{
aValidationMessage.Truncate();
@ -97,13 +99,12 @@ nsIConstraintValidation::GetValidationMessage(nsAString& aValidationMessage)
GetValidationMessage(aValidationMessage, VALIDITY_STATE_BAD_INPUT);
} else {
// There should not be other validity states.
return NS_ERROR_UNEXPECTED;
aError.Throw(NS_ERROR_UNEXPECTED);
return;
}
} else {
aValidationMessage.Truncate();
}
return NS_OK;
}
bool

View File

@ -13,6 +13,7 @@
class nsIDOMValidityState;
namespace mozilla {
class ErrorResult;
namespace dom {
class ValidityState;
} // namespace dom
@ -47,7 +48,8 @@ public:
return !mBarredFromConstraintValidation;
}
NS_IMETHOD GetValidationMessage(nsAString& aValidationMessage);
void GetValidationMessage(nsAString& aValidationMessage,
mozilla::ErrorResult& aError);
enum ValidityStateType
{
@ -120,57 +122,6 @@ private:
nsString mCustomValidity;
};
/**
* Use these macro for class inheriting from nsIConstraintValidation to forward
* functions to nsIConstraintValidation.
*/
#define NS_FORWARD_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY \
NS_IMETHOD GetValidity(nsIDOMValidityState** aValidity) { \
return nsIConstraintValidation::GetValidity(aValidity); \
} \
NS_IMETHOD GetWillValidate(bool* aWillValidate) { \
*aWillValidate = WillValidate(); \
return NS_OK; \
} \
NS_IMETHOD GetValidationMessage(nsAString& aValidationMessage) { \
return nsIConstraintValidation::GetValidationMessage(aValidationMessage); \
} \
using nsIConstraintValidation::CheckValidity; \
NS_IMETHOD CheckValidity(bool* aValidity) { \
return nsIConstraintValidation::CheckValidity(aValidity); \
}
#define NS_FORWARD_NSICONSTRAINTVALIDATION \
NS_FORWARD_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY \
NS_IMETHOD SetCustomValidity(const nsAString& aError) { \
nsIConstraintValidation::SetCustomValidity(aError); \
return NS_OK; \
}
/* Use these macro when class declares functions from nsIConstraintValidation */
#define NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(_from) \
NS_IMETHODIMP _from::GetValidity(nsIDOMValidityState** aValidity) { \
return nsIConstraintValidation::GetValidity(aValidity); \
} \
NS_IMETHODIMP _from::GetWillValidate(bool* aWillValidate) { \
*aWillValidate = WillValidate(); \
return NS_OK; \
} \
NS_IMETHODIMP _from::GetValidationMessage(nsAString& aValidationMessage) { \
return nsIConstraintValidation::GetValidationMessage(aValidationMessage); \
} \
NS_IMETHODIMP _from::CheckValidity(bool* aValidity) { \
return nsIConstraintValidation::CheckValidity(aValidity); \
}
#define NS_IMPL_NSICONSTRAINTVALIDATION(_from) \
NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(_from) \
NS_IMETHODIMP _from::SetCustomValidity(const nsAString& aError) { \
nsIConstraintValidation::SetCustomValidity(aError); \
return NS_OK; \
}
NS_DEFINE_STATIC_IID_ACCESSOR(nsIConstraintValidation,
NS_ICONSTRAINTVALIDATION_IID)

View File

@ -33,13 +33,5 @@ interface nsIDOMHTMLButtonElement : nsISupports
attribute DOMString name;
attribute DOMString type;
attribute DOMString value;
// The following lines are part of the constraint validation API, see:
// http://www.whatwg.org/specs/web-apps/current-work/#the-constraint-validation-api
readonly attribute boolean willValidate;
readonly attribute nsIDOMValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(in DOMString error);
};

View File

@ -28,12 +28,4 @@ interface nsIDOMHTMLFieldSetElement : nsISupports
readonly attribute DOMString type;
readonly attribute nsIDOMHTMLCollection elements;
// The following lines are parte of the constraint validation API, see:
// http://www.whatwg.org/specs/web-apps/current-work/#the-constraint-validation-api
readonly attribute boolean willValidate;
readonly attribute nsIDOMValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(in DOMString error);
};

View File

@ -36,13 +36,5 @@ interface nsIDOMHTMLInputElement : nsISupports
attribute boolean readOnly;
// The following lines are part of the constraint validation API, see:
// http://www.whatwg.org/specs/web-apps/current-work/#the-constraint-validation-api
readonly attribute boolean willValidate;
readonly attribute nsIDOMValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(in DOMString error);
readonly attribute nsIControllers controllers;
};

View File

@ -40,12 +40,4 @@ interface nsIDOMHTMLObjectElement : nsISupports
attribute DOMString width;
// Introduced in DOM Level 2:
readonly attribute nsIDOMDocument contentDocument;
// The following lines are parte of the constraint validation API, see:
// http://www.whatwg.org/specs/web-apps/current-work/#the-constraint-validation-api
readonly attribute boolean willValidate;
readonly attribute nsIDOMValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(in DOMString error);
};

View File

@ -48,13 +48,5 @@ interface nsIDOMHTMLSelectElement : nsISupports
attribute long selectedIndex;
attribute DOMString value;
// The following lines are part of the constraint validation API, see:
// http://www.whatwg.org/specs/web-apps/current-work/#the-constraint-validation-api
readonly attribute boolean willValidate;
readonly attribute nsIDOMValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(in DOMString error);
attribute boolean required;
};

View File

@ -45,14 +45,6 @@ interface nsIDOMHTMLTextAreaElement : nsISupports
attribute DOMString value;
readonly attribute long textLength;
// The following lines are part of the constraint validation API, see:
// http://www.whatwg.org/specs/web-apps/current-work/#the-constraint-validation-api
readonly attribute boolean willValidate;
readonly attribute nsIDOMValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(in DOMString error);
void select();
// Mozilla extensions

View File

@ -38,6 +38,7 @@ interface HTMLButtonElement : HTMLElement {
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
[Throws]
readonly attribute DOMString validationMessage;
boolean checkValidity();
boolean reportValidity();

View File

@ -25,6 +25,7 @@ interface HTMLFieldSetElement : HTMLElement {
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
[Throws]
readonly attribute DOMString validationMessage;
boolean checkValidity();

View File

@ -107,7 +107,7 @@ interface HTMLInputElement : HTMLElement {
readonly attribute boolean willValidate;
[Pure]
readonly attribute ValidityState validity;
[GetterThrows]
[Throws]
readonly attribute DOMString validationMessage;
boolean checkValidity();
boolean reportValidity();

View File

@ -40,6 +40,7 @@ interface HTMLObjectElement : HTMLElement {
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
[Throws]
readonly attribute DOMString validationMessage;
boolean checkValidity();
boolean reportValidity();

View File

@ -29,6 +29,7 @@ interface HTMLOutputElement : HTMLElement {
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
[Throws]
readonly attribute DOMString validationMessage;
boolean checkValidity();
boolean reportValidity();

View File

@ -50,6 +50,7 @@ interface HTMLSelectElement : HTMLElement {
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
[Throws]
readonly attribute DOMString validationMessage;
boolean checkValidity();
boolean reportValidity();

View File

@ -53,6 +53,7 @@ interface HTMLTextAreaElement : HTMLElement {
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
[Throws]
readonly attribute DOMString validationMessage;
boolean checkValidity();
boolean reportValidity();