Bug 561634 - Rename nsConstraintValidation to nsIConstraintValidation. r=sicking a2.0=blocking

--HG--
rename : content/html/content/src/nsConstraintValidation.cpp => content/html/content/src/nsIConstraintValidation.cpp
rename : content/html/content/src/nsConstraintValidation.h => content/html/content/src/nsIConstraintValidation.h
This commit is contained in:
Mounir Lamouri 2010-08-21 20:52:49 +02:00
Родитель 00b52d9848
Коммит 37ee17acc8
14 изменённых файлов: 101 добавлений и 100 удалений

Просмотреть файл

@ -113,7 +113,7 @@ CPPSRCS = \
nsHTMLTimeRanges.cpp \ nsHTMLTimeRanges.cpp \
nsHTMLTitleElement.cpp \ nsHTMLTitleElement.cpp \
nsDOMValidityState.cpp \ nsDOMValidityState.cpp \
nsConstraintValidation.cpp \ nsIConstraintValidation.cpp \
$(NULL) $(NULL)
ifdef MOZ_MEDIA ifdef MOZ_MEDIA

Просмотреть файл

@ -51,7 +51,7 @@ NS_INTERFACE_MAP_BEGIN(nsDOMValidityState)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ValidityState) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ValidityState)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END
nsDOMValidityState::nsDOMValidityState(nsConstraintValidation* aConstraintValidation) nsDOMValidityState::nsDOMValidityState(nsIConstraintValidation* aConstraintValidation)
: mConstraintValidation(aConstraintValidation) : mConstraintValidation(aConstraintValidation)
{ {
} }
@ -59,56 +59,56 @@ nsDOMValidityState::nsDOMValidityState(nsConstraintValidation* aConstraintValida
NS_IMETHODIMP NS_IMETHODIMP
nsDOMValidityState::GetValueMissing(PRBool* aValueMissing) nsDOMValidityState::GetValueMissing(PRBool* aValueMissing)
{ {
*aValueMissing = GetValidityState(nsConstraintValidation::VALIDITY_STATE_VALUE_MISSING); *aValueMissing = GetValidityState(nsIConstraintValidation::VALIDITY_STATE_VALUE_MISSING);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMValidityState::GetTypeMismatch(PRBool* aTypeMismatch) nsDOMValidityState::GetTypeMismatch(PRBool* aTypeMismatch)
{ {
*aTypeMismatch = GetValidityState(nsConstraintValidation::VALIDITY_STATE_TYPE_MISMATCH); *aTypeMismatch = GetValidityState(nsIConstraintValidation::VALIDITY_STATE_TYPE_MISMATCH);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMValidityState::GetPatternMismatch(PRBool* aPatternMismatch) nsDOMValidityState::GetPatternMismatch(PRBool* aPatternMismatch)
{ {
*aPatternMismatch = GetValidityState(nsConstraintValidation::VALIDITY_STATE_PATTERN_MISMATCH); *aPatternMismatch = GetValidityState(nsIConstraintValidation::VALIDITY_STATE_PATTERN_MISMATCH);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMValidityState::GetTooLong(PRBool* aTooLong) nsDOMValidityState::GetTooLong(PRBool* aTooLong)
{ {
*aTooLong = GetValidityState(nsConstraintValidation::VALIDITY_STATE_TOO_LONG); *aTooLong = GetValidityState(nsIConstraintValidation::VALIDITY_STATE_TOO_LONG);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMValidityState::GetRangeUnderflow(PRBool* aRangeUnderflow) nsDOMValidityState::GetRangeUnderflow(PRBool* aRangeUnderflow)
{ {
*aRangeUnderflow = GetValidityState(nsConstraintValidation::VALIDITY_STATE_RANGE_UNDERFLOW); *aRangeUnderflow = GetValidityState(nsIConstraintValidation::VALIDITY_STATE_RANGE_UNDERFLOW);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMValidityState::GetRangeOverflow(PRBool* aRangeOverflow) nsDOMValidityState::GetRangeOverflow(PRBool* aRangeOverflow)
{ {
*aRangeOverflow = GetValidityState(nsConstraintValidation::VALIDITY_STATE_RANGE_OVERFLOW); *aRangeOverflow = GetValidityState(nsIConstraintValidation::VALIDITY_STATE_RANGE_OVERFLOW);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMValidityState::GetStepMismatch(PRBool* aStepMismatch) nsDOMValidityState::GetStepMismatch(PRBool* aStepMismatch)
{ {
*aStepMismatch = GetValidityState(nsConstraintValidation::VALIDITY_STATE_STEP_MISMATCH); *aStepMismatch = GetValidityState(nsIConstraintValidation::VALIDITY_STATE_STEP_MISMATCH);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMValidityState::GetCustomError(PRBool* aCustomError) nsDOMValidityState::GetCustomError(PRBool* aCustomError)
{ {
*aCustomError = GetValidityState(nsConstraintValidation::VALIDITY_STATE_CUSTOM_ERROR); *aCustomError = GetValidityState(nsIConstraintValidation::VALIDITY_STATE_CUSTOM_ERROR);
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -39,7 +39,7 @@
#define nsDOMValidityState_h__ #define nsDOMValidityState_h__
#include "nsIDOMValidityState.h" #include "nsIDOMValidityState.h"
#include "nsConstraintValidation.h" #include "nsIConstraintValidation.h"
class nsDOMValidityState : public nsIDOMValidityState class nsDOMValidityState : public nsIDOMValidityState
@ -48,13 +48,13 @@ public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIDOMVALIDITYSTATE NS_DECL_NSIDOMVALIDITYSTATE
friend class nsConstraintValidation; friend class nsIConstraintValidation;
protected: protected:
nsDOMValidityState(nsConstraintValidation* aConstraintValidation); nsDOMValidityState(nsIConstraintValidation* aConstraintValidation);
/** /**
* This function should be called by nsConstraintValidation * This function should be called by nsIConstraintValidation
* to set mConstraintValidation to null to be sure * to set mConstraintValidation to null to be sure
* it will not be used when the object is destroyed. * it will not be used when the object is destroyed.
*/ */
@ -66,14 +66,14 @@ protected:
/** /**
* Helper function to get a validity state from constraint validation instance. * Helper function to get a validity state from constraint validation instance.
*/ */
inline PRBool GetValidityState(nsConstraintValidation::ValidityStateType aState) const inline PRBool GetValidityState(nsIConstraintValidation::ValidityStateType aState) const
{ {
return mConstraintValidation && return mConstraintValidation &&
mConstraintValidation->GetValidityState(aState); mConstraintValidation->GetValidityState(aState);
} }
// Weak reference to owner which will call Disconnect() when being destroyed. // Weak reference to owner which will call Disconnect() when being destroyed.
nsConstraintValidation* mConstraintValidation; nsIConstraintValidation* mConstraintValidation;
}; };
#endif // nsDOMValidityState_h__ #endif // nsDOMValidityState_h__

Просмотреть файл

@ -62,7 +62,7 @@
#include "nsLayoutErrors.h" #include "nsLayoutErrors.h"
#include "nsFocusManager.h" #include "nsFocusManager.h"
#include "nsHTMLFormElement.h" #include "nsHTMLFormElement.h"
#include "nsConstraintValidation.h" #include "nsIConstraintValidation.h"
#define NS_IN_SUBMIT_CLICK (1 << 0) #define NS_IN_SUBMIT_CLICK (1 << 0)
#define NS_OUTER_ACTIVATE_EVENT (1 << 1) #define NS_OUTER_ACTIVATE_EVENT (1 << 1)
@ -79,7 +79,7 @@ static const nsAttrValue::EnumTable* kButtonDefaultType = &kButtonTypeTable[2];
class nsHTMLButtonElement : public nsGenericHTMLFormElement, class nsHTMLButtonElement : public nsGenericHTMLFormElement,
public nsIDOMHTMLButtonElement, public nsIDOMHTMLButtonElement,
public nsConstraintValidation public nsIConstraintValidation
{ {
public: public:
nsHTMLButtonElement(already_AddRefed<nsINodeInfo> aNodeInfo); nsHTMLButtonElement(already_AddRefed<nsINodeInfo> aNodeInfo);
@ -133,7 +133,7 @@ public:
virtual void DoneCreatingElement(); virtual void DoneCreatingElement();
virtual nsXPCClassInfo* GetClassInfo(); virtual nsXPCClassInfo* GetClassInfo();
// nsConstraintValidation // nsIConstraintValidation
PRBool IsBarredFromConstraintValidation() const; PRBool IsBarredFromConstraintValidation() const;
protected: protected:
@ -185,13 +185,13 @@ DOMCI_NODE_DATA(HTMLButtonElement, nsHTMLButtonElement)
NS_INTERFACE_TABLE_HEAD(nsHTMLButtonElement) NS_INTERFACE_TABLE_HEAD(nsHTMLButtonElement)
NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLButtonElement, NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLButtonElement,
nsIDOMHTMLButtonElement, nsIDOMHTMLButtonElement,
nsConstraintValidation) nsIConstraintValidation)
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLButtonElement, NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLButtonElement,
nsGenericHTMLFormElement) nsGenericHTMLFormElement)
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLButtonElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLButtonElement)
// nsConstraintValidation // nsIConstraintValidation
NS_IMPL_NSCONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(nsHTMLButtonElement) NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(nsHTMLButtonElement)
// nsIDOMHTMLButtonElement // nsIDOMHTMLButtonElement
@ -671,12 +671,12 @@ nsHTMLButtonElement::IntrinsicState() const
return state | NS_EVENT_STATE_OPTIONAL; return state | NS_EVENT_STATE_OPTIONAL;
} }
// nsConstraintValidation // nsIConstraintValidation
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLButtonElement::SetCustomValidity(const nsAString& aError) nsHTMLButtonElement::SetCustomValidity(const nsAString& aError)
{ {
nsConstraintValidation::SetCustomValidity(aError); nsIConstraintValidation::SetCustomValidity(aError);
nsIDocument* doc = GetCurrentDoc(); nsIDocument* doc = GetCurrentDoc();
if (doc) { if (doc) {

Просмотреть файл

@ -41,12 +41,12 @@
#include "nsStyleConsts.h" #include "nsStyleConsts.h"
#include "nsIForm.h" #include "nsIForm.h"
#include "nsIFormControl.h" #include "nsIFormControl.h"
#include "nsConstraintValidation.h" #include "nsIConstraintValidation.h"
class nsHTMLFieldSetElement : public nsGenericHTMLFormElement, class nsHTMLFieldSetElement : public nsGenericHTMLFormElement,
public nsIDOMHTMLFieldSetElement, public nsIDOMHTMLFieldSetElement,
public nsConstraintValidation public nsIConstraintValidation
{ {
public: public:
nsHTMLFieldSetElement(already_AddRefed<nsINodeInfo> aNodeInfo); nsHTMLFieldSetElement(already_AddRefed<nsINodeInfo> aNodeInfo);
@ -74,7 +74,7 @@ public:
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo(); virtual nsXPCClassInfo* GetClassInfo();
// nsConstraintValidation // nsIConstraintValidation
PRBool IsBarredFromConstraintValidation() const { return PR_TRUE; }; PRBool IsBarredFromConstraintValidation() const { return PR_TRUE; };
}; };
@ -104,7 +104,7 @@ DOMCI_NODE_DATA(HTMLFieldSetElement, nsHTMLFieldSetElement)
NS_INTERFACE_TABLE_HEAD(nsHTMLFieldSetElement) NS_INTERFACE_TABLE_HEAD(nsHTMLFieldSetElement)
NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLFieldSetElement, NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLFieldSetElement,
nsIDOMHTMLFieldSetElement, nsIDOMHTMLFieldSetElement,
nsConstraintValidation) nsIConstraintValidation)
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLFieldSetElement, NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLFieldSetElement,
nsGenericHTMLFormElement) nsGenericHTMLFormElement)
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLFieldSetElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLFieldSetElement)
@ -112,8 +112,8 @@ NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLFieldSetElement)
// nsIDOMHTMLFieldSetElement // nsIDOMHTMLFieldSetElement
// nsConstraintValidation // nsIConstraintValidation
NS_IMPL_NSCONSTRAINTVALIDATION(nsHTMLFieldSetElement) NS_IMPL_NSICONSTRAINTVALIDATION(nsHTMLFieldSetElement)
NS_IMPL_ELEMENT_CLONE(nsHTMLFieldSetElement) NS_IMPL_ELEMENT_CLONE(nsHTMLFieldSetElement)

Просмотреть файл

@ -79,7 +79,7 @@
#include "mozAutoDocUpdate.h" #include "mozAutoDocUpdate.h"
#include "nsIHTMLCollection.h" #include "nsIHTMLCollection.h"
#include "nsConstraintValidation.h" #include "nsIConstraintValidation.h"
static const int NS_FORM_CONTROL_LIST_HASHTABLE_SIZE = 16; static const int NS_FORM_CONTROL_LIST_HASHTABLE_SIZE = 16;
@ -1579,7 +1579,7 @@ nsHTMLFormElement::CheckFormValidity() const
continue; continue;
} }
nsCOMPtr<nsConstraintValidation> cvElmt = nsCOMPtr<nsIConstraintValidation> cvElmt =
do_QueryInterface((nsGenericHTMLElement*)sortedControls[i]); do_QueryInterface((nsGenericHTMLElement*)sortedControls[i]);
if (cvElmt && cvElmt->IsCandidateForConstraintValidation() && if (cvElmt && cvElmt->IsCandidateForConstraintValidation() &&
!cvElmt->IsValid()) { !cvElmt->IsValid()) {

Просмотреть файл

@ -306,13 +306,13 @@ NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLInputElement)
nsIImageLoadingContent, nsIImageLoadingContent,
imgIContainerObserver, imgIContainerObserver,
nsIDOMNSEditableElement, nsIDOMNSEditableElement,
nsConstraintValidation) nsIConstraintValidation)
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLInputElement, NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLInputElement,
nsGenericHTMLFormElement) nsGenericHTMLFormElement)
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLInputElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLInputElement)
// nsConstraintValidation // nsIConstraintValidation
NS_IMPL_NSCONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(nsHTMLInputElement) NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(nsHTMLInputElement)
// nsIDOMNode // nsIDOMNode
@ -3178,12 +3178,12 @@ nsHTMLInputElement::DoesPatternApply() const
return IsSingleLineTextControl(PR_FALSE); return IsSingleLineTextControl(PR_FALSE);
} }
// nsConstraintValidation // nsIConstraintValidation
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLInputElement::SetCustomValidity(const nsAString& aError) nsHTMLInputElement::SetCustomValidity(const nsAString& aError)
{ {
nsConstraintValidation::SetCustomValidity(aError); nsIConstraintValidation::SetCustomValidity(aError);
nsIDocument* doc = GetCurrentDoc(); nsIDocument* doc = GetCurrentDoc();
if (doc) { if (doc) {
@ -3449,7 +3449,7 @@ nsHTMLInputElement::GetValidationMessage(nsAString& aValidationMessage,
break; break;
} }
default: default:
rv = nsConstraintValidation::GetValidationMessage(aValidationMessage, aType); rv = nsIConstraintValidation::GetValidationMessage(aValidationMessage, aType);
} }
return rv; return rv;

Просмотреть файл

@ -49,7 +49,7 @@
#include "nsTextEditorState.h" #include "nsTextEditorState.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsConstraintValidation.h" #include "nsIConstraintValidation.h"
// //
// Accessors for mBitField // Accessors for mBitField
@ -82,7 +82,7 @@ class nsHTMLInputElement : public nsGenericHTMLFormElement,
public nsIPhonetic, public nsIPhonetic,
public nsIDOMNSEditableElement, public nsIDOMNSEditableElement,
public nsIFileControlElement, public nsIFileControlElement,
public nsConstraintValidation public nsIConstraintValidation
{ {
public: public:
nsHTMLInputElement(already_AddRefed<nsINodeInfo> aNodeInfo, nsHTMLInputElement(already_AddRefed<nsINodeInfo> aNodeInfo,
@ -211,7 +211,7 @@ public:
virtual nsXPCClassInfo* GetClassInfo(); virtual nsXPCClassInfo* GetClassInfo();
// nsConstraintValidation // nsIConstraintValidation
PRBool IsTooLong(); PRBool IsTooLong();
PRBool IsValueMissing(); PRBool IsValueMissing();
PRBool HasTypeMismatch(); PRBool HasTypeMismatch();

Просмотреть файл

@ -40,13 +40,13 @@
#include "nsFormSubmission.h" #include "nsFormSubmission.h"
#include "nsDOMSettableTokenList.h" #include "nsDOMSettableTokenList.h"
#include "nsStubMutationObserver.h" #include "nsStubMutationObserver.h"
#include "nsConstraintValidation.h" #include "nsIConstraintValidation.h"
class nsHTMLOutputElement : public nsGenericHTMLFormElement, class nsHTMLOutputElement : public nsGenericHTMLFormElement,
public nsIDOMHTMLOutputElement, public nsIDOMHTMLOutputElement,
public nsStubMutationObserver, public nsStubMutationObserver,
public nsConstraintValidation public nsIConstraintValidation
{ {
public: public:
nsHTMLOutputElement(already_AddRefed<nsINodeInfo> aNodeInfo); nsHTMLOutputElement(already_AddRefed<nsINodeInfo> aNodeInfo);
@ -81,7 +81,7 @@ public:
// has to be used to update the defaultValue attribute. // has to be used to update the defaultValue attribute.
void DescendantsChanged(); void DescendantsChanged();
// nsConstraintValidation // nsIConstraintValidation
PRBool IsBarredFromConstraintValidation() const { return PR_TRUE; } PRBool IsBarredFromConstraintValidation() const { return PR_TRUE; }
// nsIMutationObserver // nsIMutationObserver
@ -133,7 +133,7 @@ NS_INTERFACE_TABLE_HEAD(nsHTMLOutputElement)
NS_HTML_CONTENT_INTERFACE_TABLE3(nsHTMLOutputElement, NS_HTML_CONTENT_INTERFACE_TABLE3(nsHTMLOutputElement,
nsIDOMHTMLOutputElement, nsIDOMHTMLOutputElement,
nsIMutationObserver, nsIMutationObserver,
nsConstraintValidation) nsIConstraintValidation)
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLOutputElement, NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLOutputElement,
nsGenericHTMLFormElement) nsGenericHTMLFormElement)
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLOutputElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLOutputElement)
@ -143,8 +143,8 @@ NS_IMPL_ELEMENT_CLONE(nsHTMLOutputElement)
NS_IMPL_STRING_ATTR(nsHTMLOutputElement, Name, name) NS_IMPL_STRING_ATTR(nsHTMLOutputElement, Name, name)
// nsConstraintValidation // nsIConstraintValidation
NS_IMPL_NSCONSTRAINTVALIDATION(nsHTMLOutputElement) NS_IMPL_NSICONSTRAINTVALIDATION(nsHTMLOutputElement)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLOutputElement::Reset() nsHTMLOutputElement::Reset()

Просмотреть файл

@ -184,7 +184,7 @@ NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLSelectElement)
NS_HTML_CONTENT_INTERFACE_TABLE3(nsHTMLSelectElement, NS_HTML_CONTENT_INTERFACE_TABLE3(nsHTMLSelectElement,
nsIDOMHTMLSelectElement, nsIDOMHTMLSelectElement,
nsISelectElement, nsISelectElement,
nsConstraintValidation) nsIConstraintValidation)
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLSelectElement, NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLSelectElement,
nsGenericHTMLFormElement) nsGenericHTMLFormElement)
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLSelectElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLSelectElement)
@ -195,13 +195,13 @@ NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLSelectElement)
NS_IMPL_ELEMENT_CLONE(nsHTMLSelectElement) NS_IMPL_ELEMENT_CLONE(nsHTMLSelectElement)
// nsConstraintValidation // nsIConstraintValidation
NS_IMPL_NSCONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(nsHTMLSelectElement) NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(nsHTMLSelectElement)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLSelectElement::SetCustomValidity(const nsAString& aError) nsHTMLSelectElement::SetCustomValidity(const nsAString& aError)
{ {
nsConstraintValidation::SetCustomValidity(aError); nsIConstraintValidation::SetCustomValidity(aError);
nsIDocument* doc = GetCurrentDoc(); nsIDocument* doc = GetCurrentDoc();
if (doc) { if (doc) {

Просмотреть файл

@ -52,7 +52,7 @@
#include "nsISelectControlFrame.h" #include "nsISelectControlFrame.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsIHTMLCollection.h" #include "nsIHTMLCollection.h"
#include "nsConstraintValidation.h" #include "nsIConstraintValidation.h"
// PresState // PresState
#include "nsXPCOM.h" #include "nsXPCOM.h"
@ -238,7 +238,7 @@ private:
class nsHTMLSelectElement : public nsGenericHTMLFormElement, class nsHTMLSelectElement : public nsGenericHTMLFormElement,
public nsIDOMHTMLSelectElement, public nsIDOMHTMLSelectElement,
public nsISelectElement, public nsISelectElement,
public nsConstraintValidation public nsIConstraintValidation
{ {
public: public:
nsHTMLSelectElement(already_AddRefed<nsINodeInfo> aNodeInfo, nsHTMLSelectElement(already_AddRefed<nsINodeInfo> aNodeInfo,

Просмотреть файл

@ -77,7 +77,7 @@
#include "mozAutoDocUpdate.h" #include "mozAutoDocUpdate.h"
#include "nsISupportsPrimitives.h" #include "nsISupportsPrimitives.h"
#include "nsContentCreatorFunctions.h" #include "nsContentCreatorFunctions.h"
#include "nsConstraintValidation.h" #include "nsIConstraintValidation.h"
#include "nsTextEditorState.h" #include "nsTextEditorState.h"
@ -91,7 +91,7 @@ class nsHTMLTextAreaElement : public nsGenericHTMLFormElement,
public nsITextControlElement, public nsITextControlElement,
public nsIDOMNSEditableElement, public nsIDOMNSEditableElement,
public nsStubMutationObserver, public nsStubMutationObserver,
public nsConstraintValidation public nsIConstraintValidation
{ {
public: public:
nsHTMLTextAreaElement(already_AddRefed<nsINodeInfo> aNodeInfo, nsHTMLTextAreaElement(already_AddRefed<nsINodeInfo> aNodeInfo,
@ -201,7 +201,7 @@ public:
virtual nsXPCClassInfo* GetClassInfo(); virtual nsXPCClassInfo* GetClassInfo();
// nsConstraintValidation // nsIConstraintValidation
PRBool IsTooLong(); PRBool IsTooLong();
PRBool IsValueMissing() const; PRBool IsValueMissing() const;
void UpdateTooLongValidityState(); void UpdateTooLongValidityState();
@ -306,7 +306,7 @@ NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLTextAreaElement)
nsITextControlElement, nsITextControlElement,
nsIDOMNSEditableElement, nsIDOMNSEditableElement,
nsIMutationObserver, nsIMutationObserver,
nsConstraintValidation) nsIConstraintValidation)
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTextAreaElement, NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTextAreaElement,
nsGenericHTMLFormElement) nsGenericHTMLFormElement)
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTextAreaElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTextAreaElement)
@ -317,8 +317,8 @@ NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTextAreaElement)
NS_IMPL_ELEMENT_CLONE(nsHTMLTextAreaElement) NS_IMPL_ELEMENT_CLONE(nsHTMLTextAreaElement)
// nsConstraintValidation // nsIConstraintValidation
NS_IMPL_NSCONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(nsHTMLTextAreaElement) NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(nsHTMLTextAreaElement)
NS_IMETHODIMP NS_IMETHODIMP
@ -1091,12 +1091,12 @@ nsHTMLTextAreaElement::IsMutable() const
!HasAttr(kNameSpaceID_None, nsGkAtoms::disabled)); !HasAttr(kNameSpaceID_None, nsGkAtoms::disabled));
} }
// nsConstraintValidation // nsIConstraintValidation
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLTextAreaElement::SetCustomValidity(const nsAString& aError) nsHTMLTextAreaElement::SetCustomValidity(const nsAString& aError)
{ {
nsConstraintValidation::SetCustomValidity(aError); nsIConstraintValidation::SetCustomValidity(aError);
nsIDocument* doc = GetCurrentDoc(); nsIDocument* doc = GetCurrentDoc();
if (doc) { if (doc) {
@ -1193,7 +1193,7 @@ nsHTMLTextAreaElement::GetValidationMessage(nsAString& aValidationMessage,
} }
break; break;
default: default:
rv = nsConstraintValidation::GetValidationMessage(aValidationMessage, aType); rv = nsIConstraintValidation::GetValidationMessage(aValidationMessage, aType);
} }
return rv; return rv;

Просмотреть файл

@ -35,7 +35,7 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "nsConstraintValidation.h" #include "nsIConstraintValidation.h"
#include "nsAString.h" #include "nsAString.h"
#include "nsGenericHTMLElement.h" #include "nsGenericHTMLElement.h"
@ -43,13 +43,13 @@
#include "nsDOMValidityState.h" #include "nsDOMValidityState.h"
nsConstraintValidation::nsConstraintValidation() nsIConstraintValidation::nsIConstraintValidation()
: mValidityBitField(0) : mValidityBitField(0)
, mValidity(nsnull) , mValidity(nsnull)
{ {
} }
nsConstraintValidation::~nsConstraintValidation() nsIConstraintValidation::~nsIConstraintValidation()
{ {
if (mValidity) { if (mValidity) {
mValidity->Disconnect(); mValidity->Disconnect();
@ -57,7 +57,7 @@ nsConstraintValidation::~nsConstraintValidation()
} }
nsresult nsresult
nsConstraintValidation::GetValidity(nsIDOMValidityState** aValidity) nsIConstraintValidation::GetValidity(nsIDOMValidityState** aValidity)
{ {
if (!mValidity) { if (!mValidity) {
mValidity = new nsDOMValidityState(this); mValidity = new nsDOMValidityState(this);
@ -69,7 +69,7 @@ nsConstraintValidation::GetValidity(nsIDOMValidityState** aValidity)
} }
nsresult nsresult
nsConstraintValidation::GetValidationMessage(nsAString& aValidationMessage) nsIConstraintValidation::GetValidationMessage(nsAString& aValidationMessage)
{ {
aValidationMessage.Truncate(); aValidationMessage.Truncate();
@ -98,7 +98,7 @@ nsConstraintValidation::GetValidationMessage(nsAString& aValidationMessage)
} }
nsresult nsresult
nsConstraintValidation::CheckValidity(PRBool* aValidity) nsIConstraintValidation::CheckValidity(PRBool* aValidity)
{ {
if (!IsCandidateForConstraintValidation() || IsValid()) { if (!IsCandidateForConstraintValidation() || IsValid()) {
*aValidity = PR_TRUE; *aValidity = PR_TRUE;
@ -116,14 +116,14 @@ nsConstraintValidation::CheckValidity(PRBool* aValidity)
} }
void void
nsConstraintValidation::SetCustomValidity(const nsAString& aError) nsIConstraintValidation::SetCustomValidity(const nsAString& aError)
{ {
mCustomValidity.Assign(aError); mCustomValidity.Assign(aError);
SetValidityState(VALIDITY_STATE_CUSTOM_ERROR, !mCustomValidity.IsEmpty()); SetValidityState(VALIDITY_STATE_CUSTOM_ERROR, !mCustomValidity.IsEmpty());
} }
PRBool PRBool
nsConstraintValidation::IsCandidateForConstraintValidation() const nsIConstraintValidation::IsCandidateForConstraintValidation() const
{ {
/** /**
* An element is never candidate for constraint validation if: * An element is never candidate for constraint validation if:
@ -134,7 +134,7 @@ nsConstraintValidation::IsCandidateForConstraintValidation() const
*/ */
nsCOMPtr<nsIContent> content = nsCOMPtr<nsIContent> content =
do_QueryInterface(const_cast<nsConstraintValidation*>(this)); do_QueryInterface(const_cast<nsIConstraintValidation*>(this));
NS_ASSERTION(content, "This class should be inherited by HTML elements only!"); NS_ASSERTION(content, "This class should be inherited by HTML elements only!");
// For the moment, all elements that are not barred from constraint validation // For the moment, all elements that are not barred from constraint validation

Просмотреть файл

@ -35,8 +35,8 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#ifndef nsConstraintValidition_h___ #ifndef nsIConstraintValidition_h___
#define nsConstraintValidition_h___ #define nsIConstraintValidition_h___
#include "nsISupports.h" #include "nsISupports.h"
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
@ -46,26 +46,26 @@ class nsDOMValidityState;
class nsIDOMValidityState; class nsIDOMValidityState;
class nsGenericHTMLFormElement; class nsGenericHTMLFormElement;
#define NS_CONSTRAINTVALIDATION_IID \ #define NS_ICONSTRAINTVALIDATION_IID \
{ 0xca3824dc, 0x4f5c, 0x4878, \ { 0xca3824dc, 0x4f5c, 0x4878, \
{ 0xa6, 0x8a, 0x95, 0x54, 0x5f, 0xfa, 0x4b, 0xf9 } } { 0xa6, 0x8a, 0x95, 0x54, 0x5f, 0xfa, 0x4b, 0xf9 } }
/** /**
* This class is used for form elements implementing the * This interface is for form elements implementing the validity constraint API.
* validity constraint API.
* See: http://dev.w3.org/html5/spec/forms.html#the-constraint-validation-api * See: http://dev.w3.org/html5/spec/forms.html#the-constraint-validation-api
* *
* This class has to be used by all elements implementing the API. * This interface has to be implemented by all elements implementing the API
* and only them.
*/ */
class nsConstraintValidation : public nsISupports class nsIConstraintValidation : public nsISupports
{ {
public: public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_CONSTRAINTVALIDATION_IID); NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONSTRAINTVALIDATION_IID);
friend class nsDOMValidityState; friend class nsDOMValidityState;
virtual ~nsConstraintValidation(); virtual ~nsIConstraintValidation();
PRBool IsValid() const { return mValidityBitField == 0; } PRBool IsValid() const { return mValidityBitField == 0; }
@ -86,7 +86,7 @@ protected:
}; };
// You can't instantiate an object from that class. // You can't instantiate an object from that class.
nsConstraintValidation(); nsIConstraintValidation();
nsresult GetValidity(nsIDOMValidityState** aValidity); nsresult GetValidity(nsIDOMValidityState** aValidity);
nsresult GetValidationMessage(nsAString& aValidationMessage); nsresult GetValidationMessage(nsAString& aValidationMessage);
@ -132,56 +132,57 @@ private:
}; };
/** /**
* Use these macro for class inherit from nsConstraintValidation to forward * Use these macro for class inheriting from nsIConstraintValidation to forward
* functions to nsConstraintValidation. * functions to nsIConstraintValidation.
*/ */
#define NS_FORWARD_NSCONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY \ #define NS_FORWARD_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY \
NS_IMETHOD GetValidity(nsIDOMValidityState** aValidity) { \ NS_IMETHOD GetValidity(nsIDOMValidityState** aValidity) { \
return nsConstraintValidation::GetValidity(aValidity); \ return nsIConstraintValidation::GetValidity(aValidity); \
} \ } \
NS_IMETHOD GetWillValidate(PRBool* aWillValidate) { \ NS_IMETHOD GetWillValidate(PRBool* aWillValidate) { \
*aWillValidate = IsCandidateForConstraintValidation(); \ *aWillValidate = IsCandidateForConstraintValidation(); \
return NS_OK; \ return NS_OK; \
} \ } \
NS_IMETHOD GetValidationMessage(nsAString& aValidationMessage) { \ NS_IMETHOD GetValidationMessage(nsAString& aValidationMessage) { \
return nsConstraintValidation::GetValidationMessage(aValidationMessage); \ return nsIConstraintValidation::GetValidationMessage(aValidationMessage); \
} \ } \
NS_IMETHOD CheckValidity(PRBool* aValidity) { \ NS_IMETHOD CheckValidity(PRBool* aValidity) { \
return nsConstraintValidation::CheckValidity(aValidity); \ return nsIConstraintValidation::CheckValidity(aValidity); \
} }
#define NS_FORWARD_NSCONSTRAINTVALIDATION \ #define NS_FORWARD_NSICONSTRAINTVALIDATION \
NS_FORWARD_NSCONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY \ NS_FORWARD_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY \
NS_IMETHOD SetCustomValidity(const nsAString& aError) { \ NS_IMETHOD SetCustomValidity(const nsAString& aError) { \
nsConstraintValidation::SetCustomValidity(aError); \ nsIConstraintValidation::SetCustomValidity(aError); \
return NS_OK; \ return NS_OK; \
} }
/* Use these macro when class declares functions from nsConstraintValidation */ /* Use these macro when class declares functions from nsIConstraintValidation */
#define NS_IMPL_NSCONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(_from) \ #define NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(_from) \
NS_IMETHODIMP _from::GetValidity(nsIDOMValidityState** aValidity) { \ NS_IMETHODIMP _from::GetValidity(nsIDOMValidityState** aValidity) { \
return nsConstraintValidation::GetValidity(aValidity); \ return nsIConstraintValidation::GetValidity(aValidity); \
} \ } \
NS_IMETHODIMP _from::GetWillValidate(PRBool* aWillValidate) { \ NS_IMETHODIMP _from::GetWillValidate(PRBool* aWillValidate) { \
*aWillValidate = IsCandidateForConstraintValidation(); \ *aWillValidate = IsCandidateForConstraintValidation(); \
return NS_OK; \ return NS_OK; \
} \ } \
NS_IMETHODIMP _from::GetValidationMessage(nsAString& aValidationMessage) { \ NS_IMETHODIMP _from::GetValidationMessage(nsAString& aValidationMessage) { \
return nsConstraintValidation::GetValidationMessage(aValidationMessage); \ return nsIConstraintValidation::GetValidationMessage(aValidationMessage); \
} \ } \
NS_IMETHODIMP _from::CheckValidity(PRBool* aValidity) { \ NS_IMETHODIMP _from::CheckValidity(PRBool* aValidity) { \
return nsConstraintValidation::CheckValidity(aValidity); \ return nsIConstraintValidation::CheckValidity(aValidity); \
} }
#define NS_IMPL_NSCONSTRAINTVALIDATION(_from) \ #define NS_IMPL_NSICONSTRAINTVALIDATION(_from) \
NS_IMPL_NSCONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(_from) \ NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(_from) \
NS_IMETHODIMP _from::SetCustomValidity(const nsAString& aError) { \ NS_IMETHODIMP _from::SetCustomValidity(const nsAString& aError) { \
nsConstraintValidation::SetCustomValidity(aError); \ nsIConstraintValidation::SetCustomValidity(aError); \
return NS_OK; \ return NS_OK; \
} }
NS_DEFINE_STATIC_IID_ACCESSOR(nsConstraintValidation, NS_CONSTRAINTVALIDATION_IID) NS_DEFINE_STATIC_IID_ACCESSOR(nsIConstraintValidation,
NS_ICONSTRAINTVALIDATION_IID)
#endif // nsConstraintValidation_h___ #endif // nsIConstraintValidation_h___