summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLFormElement.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/html/HTMLFormElement.h')
-rw-r--r--Source/WebCore/html/HTMLFormElement.h142
1 files changed, 81 insertions, 61 deletions
diff --git a/Source/WebCore/html/HTMLFormElement.h b/Source/WebCore/html/HTMLFormElement.h
index e63898455..5de195eb9 100644
--- a/Source/WebCore/html/HTMLFormElement.h
+++ b/Source/WebCore/html/HTMLFormElement.h
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2016 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -21,14 +21,13 @@
*
*/
-#ifndef HTMLFormElement_h
-#define HTMLFormElement_h
+#pragma once
-#include "CheckedRadioButtons.h"
#include "FormState.h"
#include "FormSubmission.h"
#include "HTMLElement.h"
-#include <wtf/OwnPtr.h>
+#include "RadioButtonGroups.h"
+#include <memory>
#if ENABLE(IOS_AUTOCORRECT_AND_AUTOCAPITALIZE)
#include "Autocapitalize.h"
@@ -38,57 +37,55 @@ namespace WebCore {
class Event;
class FormAssociatedElement;
-class FormData;
class HTMLFormControlElement;
+class HTMLFormControlsCollection;
class HTMLImageElement;
-class HTMLInputElement;
-class TextEncoding;
class HTMLFormElement final : public HTMLElement {
public:
- static PassRefPtr<HTMLFormElement> create(Document&);
- static PassRefPtr<HTMLFormElement> create(const QualifiedName&, Document&);
+ static Ref<HTMLFormElement> create(Document&);
+ static Ref<HTMLFormElement> create(const QualifiedName&, Document&);
virtual ~HTMLFormElement();
- PassRefPtr<HTMLCollection> elements();
- bool hasNamedElement(const AtomicString&);
- void getNamedElements(const AtomicString&, Vector<Ref<Element>>&);
+ Ref<HTMLFormControlsCollection> elements();
+ WEBCORE_EXPORT Ref<HTMLCollection> elementsForNativeBindings();
+ Vector<Ref<Element>> namedElements(const AtomicString&);
- unsigned length() const;
- Node* item(unsigned index);
+ WEBCORE_EXPORT unsigned length() const;
+ HTMLElement* item(unsigned index);
+ std::optional<Variant<RefPtr<RadioNodeList>, RefPtr<Element>>> namedItem(const AtomicString&);
+ Vector<AtomicString> supportedPropertyNames() const;
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); }
+ WEBCORE_EXPORT void setEnctype(const String&);
bool shouldAutocomplete() const;
-#if ENABLE(IOS_AUTOCORRECT_AND_AUTOCAPITALIZE)
- bool autocorrect() const;
- void setAutocorrect(bool);
+ WEBCORE_EXPORT void setAutocomplete(const AtomicString&);
+ WEBCORE_EXPORT const AtomicString& autocomplete() const;
- WebAutocapitalizeType autocapitalizeType() const;
- const AtomicString& autocapitalize() const;
- void setAutocapitalize(const AtomicString&);
+#if ENABLE(IOS_AUTOCORRECT_AND_AUTOCAPITALIZE)
+ WEBCORE_EXPORT bool shouldAutocorrect() const final;
#endif
// FIXME: Should rename these two functions to say "form control" or "form-associated element" instead of "form element".
void registerFormElement(FormAssociatedElement*);
void removeFormElement(FormAssociatedElement*);
+ void registerInvalidAssociatedFormControl(const HTMLFormControlElement&);
+ void removeInvalidAssociatedFormControlIfNeeded(const HTMLFormControlElement&);
+
void registerImgElement(HTMLImageElement*);
void removeImgElement(HTMLImageElement*);
- bool prepareForSubmission(Event*);
- void submit();
+ void prepareForSubmission(Event&); // FIXME: This function doesn't only prepare, it sometimes calls submit() itself.
+ WEBCORE_EXPORT void submit();
void submitFromJavaScript();
- void reset();
+ WEBCORE_EXPORT void reset();
void setDemoted(bool demoted) { m_wasDemoted = demoted; }
- void submitImplicitly(Event*, bool fromImplicitSubmissionTrigger);
+ void submitImplicitly(Event&, bool fromImplicitSubmissionTrigger);
bool formWouldHaveSecureSubmission(const String& url);
String name() const;
@@ -101,86 +98,109 @@ public:
String action() const;
void setAction(const String&);
- String method() const;
- void setMethod(const String&);
+ WEBCORE_EXPORT String method() const;
+ WEBCORE_EXPORT void setMethod(const String&);
- virtual String target() const override;
+ String target() const final;
bool wasUserSubmitted() const;
HTMLFormControlElement* defaultButton() const;
+ void resetDefaultButton();
- bool checkValidity();
+ WEBCORE_EXPORT bool checkValidity();
+ bool reportValidity();
+
+#if ENABLE(REQUEST_AUTOCOMPLETE)
+ enum class AutocompleteResult {
+ Success,
+ ErrorDisabled,
+ ErrorCancel,
+ ErrorInvalid,
+ };
+
+ void requestAutocomplete();
+ void finishRequestAutocomplete(AutocompleteResult);
+#endif
- CheckedRadioButtons& checkedRadioButtons() { return m_checkedRadioButtons; }
+ RadioButtonGroups& radioButtonGroups() { return m_radioButtonGroups; }
const Vector<FormAssociatedElement*>& associatedElements() const { return m_associatedElements; }
const Vector<HTMLImageElement*>& imageElements() const { return m_imageElements; }
- void getTextFieldValues(StringPairVector& fieldNamesAndValues) const;
+ StringPairVector textFieldValues() 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;
+ bool rendererIsNeeded(const RenderStyle&) final;
+ InsertionNotificationRequest insertedInto(ContainerNode&) final;
+ void removedFrom(ContainerNode&) final;
+ void finishParsingChildren() final;
- virtual void handleLocalEvents(Event&) override;
+ void handleLocalEvents(Event&) final;
- virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
- virtual bool isURLAttribute(const Attribute&) const override;
+ void parseAttribute(const QualifiedName&, const AtomicString&) final;
+ bool isURLAttribute(const Attribute&) const final;
- virtual void documentDidResumeFromPageCache() override;
+ void resumeFromDocumentSuspension() final;
- virtual void didMoveToNewDocument(Document* oldDocument) override;
+ void didMoveToNewDocument(Document& oldDocument) final;
- virtual void copyNonAttributePropertiesFromElement(const Element&) override;
+ void copyNonAttributePropertiesFromElement(const Element&) final;
void submit(Event*, bool activateSubmitButton, bool processingUserGesture, FormSubmissionTrigger);
unsigned formElementIndexWithFormAttribute(Element*, unsigned rangeStart, unsigned rangeEnd);
unsigned formElementIndex(FormAssociatedElement*);
- // Returns true if the submission should proceed.
- bool validateInteractively(Event*);
+ bool validateInteractively();
// Validates each of the controls, and stores controls of which 'invalid'
// event was not canceled to the specified vector. Returns true if there
// are any invalid controls in this form.
- bool checkInvalidControlsAndCollectUnhandled(Vector<RefPtr<FormAssociatedElement>>&);
+ bool checkInvalidControlsAndCollectUnhandled(Vector<RefPtr<HTMLFormControlElement>>&);
HTMLElement* elementFromPastNamesMap(const AtomicString&) const;
void addToPastNamesMap(FormNamedItem*, const AtomicString& pastName);
void assertItemCanBeInPastNamesMap(FormNamedItem*) const;
void removeFromPastNamesMap(FormNamedItem*);
+ bool matchesValidPseudoClass() const final;
+ bool matchesInvalidPseudoClass() const final;
+
+ void resetAssociatedFormControlElements();
+
typedef HashMap<RefPtr<AtomicStringImpl>, FormNamedItem*> PastNamesMap;
FormSubmission::Attributes m_attributes;
- OwnPtr<PastNamesMap> m_pastNamesMap;
+ std::unique_ptr<PastNamesMap> m_pastNamesMap;
- CheckedRadioButtons m_checkedRadioButtons;
+ RadioButtonGroups m_radioButtonGroups;
+ mutable HTMLFormControlElement* m_defaultButton { nullptr };
- unsigned m_associatedElementsBeforeIndex;
- unsigned m_associatedElementsAfterIndex;
+ unsigned m_associatedElementsBeforeIndex { 0 };
+ unsigned m_associatedElementsAfterIndex { 0 };
Vector<FormAssociatedElement*> m_associatedElements;
Vector<HTMLImageElement*> m_imageElements;
+ HashSet<const HTMLFormControlElement*> m_invalidAssociatedFormControls;
- bool m_wasUserSubmitted;
- bool m_isSubmittingOrPreparingForSubmission;
- bool m_shouldSubmit;
+ bool m_wasUserSubmitted { false };
+ bool m_isSubmittingOrPreparingForSubmission { false };
+ bool m_shouldSubmit { false };
- bool m_isInResetFunction;
+ bool m_isInResetFunction { false };
- bool m_wasDemoted;
-};
+ bool m_wasDemoted { false };
-NODE_TYPE_CASTS(HTMLFormElement)
+#if ENABLE(REQUEST_AUTOCOMPLETE)
+ void requestAutocompleteTimerFired();
-} // namespace WebCore
+ Vector<RefPtr<Event>> m_pendingAutocompleteEvents;
+ Timer m_requestAutocompleteTimer;
+#endif
+};
-#endif // HTMLFormElement_h
+} // namespace WebCore