#ifndef FormAssociatedElement_h
#define FormAssociatedElement_h
#include "wtf/WeakPtr.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class ContainerNode;
class Document;
class FormAttributeTargetObserver;
class FormDataList;
class HTMLElement;
class HTMLFormElement;
class Node;
class ValidationMessage;
class ValidityState;
class VisibleSelection;
class FormAssociatedElement {
public:
virtual ~FormAssociatedElement();
void ref() { refFormAssociatedElement(); }
void deref() { derefFormAssociatedElement(); }
static HTMLFormElement* findAssociatedForm(const HTMLElement*);
HTMLFormElement* form() const { return m_form.get(); }
ValidityState* validity();
virtual bool isFormControlElement() const = 0;
virtual bool isFormControlElementWithState() const;
virtual bool isEnumeratable() const = 0;
virtual const AtomicString& name() const;
virtual bool appendFormData(FormDataList&, bool) { return false; }
void resetFormOwner();
void formRemovedFromTree(const Node& formRoot);
bool customError() const;
virtual bool hasBadInput() const;
virtual bool patternMismatch() const;
virtual bool rangeOverflow() const;
virtual bool rangeUnderflow() const;
virtual bool stepMismatch() const;
virtual bool tooLong() const;
virtual bool typeMismatch() const;
virtual bool valueMissing() const;
virtual String validationMessage() const;
bool valid() const;
virtual void setCustomValidity(const String&);
void formAttributeTargetChanged();
protected:
FormAssociatedElement();
void insertedInto(ContainerNode*);
void removedFrom(ContainerNode*);
void didMoveToNewDocument(Document& oldDocument);
void setForm(HTMLFormElement*);
void associateByParser(HTMLFormElement*);
void formAttributeChanged();
virtual void willChangeForm();
virtual void didChangeForm();
String customValidationMessage() const;
private:
virtual void refFormAssociatedElement() = 0;
virtual void derefFormAssociatedElement() = 0;
void resetFormAttributeTargetObserver();
OwnPtr<FormAttributeTargetObserver> m_formAttributeTargetObserver;
WeakPtr<HTMLFormElement> m_form;
OwnPtr<ValidityState> m_validityState;
String m_customValidationMessage;
bool m_formWasSetByParser;
};
HTMLElement* toHTMLElement(FormAssociatedElement*);
HTMLElement& toHTMLElement(FormAssociatedElement&);
const HTMLElement* toHTMLElement(const FormAssociatedElement*);
const HTMLElement& toHTMLElement(const FormAssociatedElement&);
}
#endif