1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
/*
* 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.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef HTMLFormElement_h
#define HTMLFormElement_h
#include "core/html/HTMLElement.h"
#include "core/html/HTMLFormControlElement.h"
#include "core/html/forms/RadioButtonGroupScope.h"
#include "core/loader/FormSubmission.h"
#include "wtf/OwnPtr.h"
#include "wtf/WeakPtr.h"
namespace blink {
class Event;
class FormAssociatedElement;
class GenericEventQueue;
class HTMLFormControlElement;
class HTMLFormControlsCollection;
class HTMLImageElement;
class RadioNodeListOrElement;
class HTMLFormElement final : public HTMLElement {
DEFINE_WRAPPERTYPEINFO();
public:
static PassRefPtrWillBeRawPtr<HTMLFormElement> create(Document&);
virtual ~HTMLFormElement();
virtual void trace(Visitor*) override;
void setNeedsValidityCheck(ValidityRecalcReason, bool isValid);
PassRefPtrWillBeRawPtr<HTMLFormControlsCollection> elements();
void getNamedElements(const AtomicString&, WillBeHeapVector<RefPtrWillBeMember<Element>>&);
unsigned length() const;
HTMLElement* item(unsigned index);
String enctype() const { return m_attributes.encodingType(); }
void setEnctype(const AtomicString&);
String encoding() const { return m_attributes.encodingType(); }
void setEncoding(const AtomicString& value) { setEnctype(value); }
bool shouldAutocomplete() const;
void associate(FormAssociatedElement&);
void disassociate(FormAssociatedElement&);
void associate(HTMLImageElement&);
void disassociate(HTMLImageElement&);
#if !ENABLE(OILPAN)
WeakPtr<HTMLFormElement> createWeakPtr();
#endif
void didAssociateByParser();
void prepareForSubmission(Event*);
void submit();
void submitFromJavaScript();
void reset();
void setDemoted(bool);
void submitImplicitly(Event*, bool fromImplicitSubmissionTrigger);
String name() const;
bool noValidate() const;
const AtomicString& action() const;
String method() const;
void setMethod(const AtomicString&);
bool wasUserSubmitted() const;
HTMLFormControlElement* defaultButton() const;
bool checkValidity();
bool reportValidity();
virtual bool matchesValidityPseudoClasses() const override final;
virtual bool isValidElement() override final;
enum AutocompleteResult {
AutocompleteResultSuccess,
AutocompleteResultErrorDisabled,
AutocompleteResultErrorCancel,
AutocompleteResultErrorInvalid,
};
void requestAutocomplete();
void finishRequestAutocomplete(AutocompleteResult);
DEFINE_ATTRIBUTE_EVENT_LISTENER(autocomplete);
DEFINE_ATTRIBUTE_EVENT_LISTENER(autocompleteerror);
RadioButtonGroupScope& radioButtonGroupScope() { return m_radioButtonGroupScope; }
const FormAssociatedElement::List& associatedElements() const;
const WillBeHeapVector<RawPtrWillBeMember<HTMLImageElement>>& imageElements();
void anonymousNamedGetter(const AtomicString& name, RadioNodeListOrElement&);
private:
explicit HTMLFormElement(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 attributeWillChange(const QualifiedName&, const AtomicString& oldValue, const AtomicString& newValue) override;
virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
virtual bool isURLAttribute(const Attribute&) const override;
virtual bool hasLegalLinkAttribute(const QualifiedName&) const override;
virtual bool shouldRegisterAsNamedItem() const override { return true; }
virtual void copyNonAttributePropertiesFromElement(const Element&) override;
void submitDialog(PassRefPtrWillBeRawPtr<FormSubmission>);
void submit(Event*, bool activateSubmitButton, bool processingUserGesture, FormSubmissionTrigger);
void scheduleFormSubmission(PassRefPtrWillBeRawPtr<FormSubmission>);
void collectAssociatedElements(Node& root, FormAssociatedElement::List&) const;
void collectImageElements(Node& root, WillBeHeapVector<RawPtrWillBeMember<HTMLImageElement>>&);
// Returns true if the submission should proceed.
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(WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElement>>*, CheckValidityEventBehavior);
Element* elementFromPastNamesMap(const AtomicString&);
void addToPastNamesMap(Element*, const AtomicString& pastName);
void removeFromPastNamesMap(HTMLElement&);
typedef WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<Element>> PastNamesMap;
FormSubmission::Attributes m_attributes;
OwnPtrWillBeMember<PastNamesMap> m_pastNamesMap;
RadioButtonGroupScope m_radioButtonGroupScope;
// Do not access m_associatedElements directly. Use associatedElements() instead.
FormAssociatedElement::List m_associatedElements;
// Do not access m_imageElements directly. Use imageElements() instead.
WillBeHeapVector<RawPtrWillBeMember<HTMLImageElement>> m_imageElements;
#if !ENABLE(OILPAN)
WeakPtrFactory<HTMLFormElement> m_weakPtrFactory;
#endif
bool m_associatedElementsAreDirty : 1;
bool m_imageElementsAreDirty : 1;
bool m_hasElementsAssociatedByParser : 1;
bool m_didFinishParsingChildren : 1;
bool m_wasUserSubmitted : 1;
bool m_isSubmittingOrInUserJSSubmitEvent : 1;
bool m_shouldSubmit : 1;
bool m_isInResetFunction : 1;
bool m_wasDemoted : 1;
// Number of invalid elements associated to the form that are candidates
// for constraint validation (their willValidate state is true).
int m_invalidControlsCount;
OwnPtrWillBeMember<GenericEventQueue> m_pendingAutocompleteEventsQueue;
};
} // namespace blink
#endif // HTMLFormElement_h
|