#ifndef HTMLFormElement_h
#define HTMLFormElement_h
#include "CheckedRadioButtons.h"
#include "FormState.h"
#include "FormSubmission.h"
#include "HTMLElement.h"
#include <memory>
#if ENABLE(IOS_AUTOCORRECT_AND_AUTOCAPITALIZE)
#include "Autocapitalize.h"
#endif
namespace WebCore {
class Event;
class FormAssociatedElement;
class FormData;
class HTMLFormControlElement;
class HTMLImageElement;
class HTMLInputElement;
class TextEncoding;
class HTMLFormElement final : public HTMLElement {
public:
static PassRefPtr<HTMLFormElement> create(Document&);
static PassRefPtr<HTMLFormElement> create(const QualifiedName&, Document&);
virtual ~HTMLFormElement();
PassRefPtr<HTMLCollection> elements();
bool hasNamedElement(const AtomicString&);
void getNamedElements(const AtomicString&, Vector<Ref<Element>>&);
unsigned length() const;
Node* item(unsigned index);
String enctype() const { return m_attributes.encodingType(); }
void setEnctype(const String&);
String encoding() const { return m_attributes.encodingType(); }
void setEncoding(const String& value) { setEnctype(value); }
bool shouldAutocomplete() const;
#if ENABLE(IOS_AUTOCORRECT_AND_AUTOCAPITALIZE)
bool autocorrect() const;
void setAutocorrect(bool);
WebAutocapitalizeType autocapitalizeType() const;
const AtomicString& autocapitalize() const;
void setAutocapitalize(const AtomicString&);
#endif
void registerFormElement(FormAssociatedElement*);
void removeFormElement(FormAssociatedElement*);
void registerImgElement(HTMLImageElement*);
void removeImgElement(HTMLImageElement*);
void prepareForSubmission(Event*); void submit();
void submitFromJavaScript();
void reset();
void setDemoted(bool demoted) { m_wasDemoted = demoted; }
void submitImplicitly(Event*, bool fromImplicitSubmissionTrigger);
bool formWouldHaveSecureSubmission(const String& url);
String name() const;
bool noValidate() const;
String acceptCharset() const { return m_attributes.acceptCharset(); }
void setAcceptCharset(const String&);
String action() const;
void setAction(const String&);
String method() const;
void setMethod(const String&);
virtual String target() const override;
bool wasUserSubmitted() const;
HTMLFormControlElement* defaultButton() const;
bool checkValidity();
CheckedRadioButtons& checkedRadioButtons() { return m_checkedRadioButtons; }
const Vector<FormAssociatedElement*>& associatedElements() const { return m_associatedElements; }
const Vector<HTMLImageElement*>& imageElements() const { return m_imageElements; }
void getTextFieldValues(StringPairVector& fieldNamesAndValues) const;
static HTMLFormElement* findClosestFormAncestor(const Element&);
private:
HTMLFormElement(const QualifiedName&, Document&);
virtual bool rendererIsNeeded(const RenderStyle&) override;
virtual InsertionNotificationRequest insertedInto(ContainerNode&) override;
virtual void removedFrom(ContainerNode&) override;
virtual void finishParsingChildren() override;
virtual void handleLocalEvents(Event&) override;
virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
virtual bool isURLAttribute(const Attribute&) const override;
virtual void documentDidResumeFromPageCache() override;
virtual void didMoveToNewDocument(Document* oldDocument) override;
virtual void copyNonAttributePropertiesFromElement(const Element&) override;
void submit(Event*, bool activateSubmitButton, bool processingUserGesture, FormSubmissionTrigger);
unsigned formElementIndexWithFormAttribute(Element*, unsigned rangeStart, unsigned rangeEnd);
unsigned formElementIndex(FormAssociatedElement*);
bool validateInteractively(Event*);
bool checkInvalidControlsAndCollectUnhandled(Vector<RefPtr<FormAssociatedElement>>&);
HTMLElement* elementFromPastNamesMap(const AtomicString&) const;
void addToPastNamesMap(FormNamedItem*, const AtomicString& pastName);
void assertItemCanBeInPastNamesMap(FormNamedItem*) const;
void removeFromPastNamesMap(FormNamedItem*);
typedef HashMap<RefPtr<AtomicStringImpl>, FormNamedItem*> PastNamesMap;
FormSubmission::Attributes m_attributes;
std::unique_ptr<PastNamesMap> m_pastNamesMap;
CheckedRadioButtons m_checkedRadioButtons;
unsigned m_associatedElementsBeforeIndex;
unsigned m_associatedElementsAfterIndex;
Vector<FormAssociatedElement*> m_associatedElements;
Vector<HTMLImageElement*> m_imageElements;
bool m_wasUserSubmitted;
bool m_isSubmittingOrPreparingForSubmission;
bool m_shouldSubmit;
bool m_isInResetFunction;
bool m_wasDemoted;
};
NODE_TYPE_CASTS(HTMLFormElement)
}
#endif // HTMLFormElement_h