diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/html/HTMLFormControlElement.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/html/HTMLFormControlElement.h')
-rw-r--r-- | Source/WebCore/html/HTMLFormControlElement.h | 153 |
1 files changed, 82 insertions, 71 deletions
diff --git a/Source/WebCore/html/HTMLFormControlElement.h b/Source/WebCore/html/HTMLFormControlElement.h index 98398f005..50b8cd4c1 100644 --- a/Source/WebCore/html/HTMLFormControlElement.h +++ b/Source/WebCore/html/HTMLFormControlElement.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-2017 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,9 +21,9 @@ * */ -#ifndef HTMLFormControlElement_h -#define HTMLFormControlElement_h +#pragma once +#include "Autofill.h" #include "FormAssociatedElement.h" #include "LabelableElement.h" @@ -46,20 +46,22 @@ class HTMLFormControlElement : public LabelableElement, public FormAssociatedEle public: virtual ~HTMLFormControlElement(); - HTMLFormElement* form() const { return FormAssociatedElement::form(); } + HTMLFormElement* form() const final { return FormAssociatedElement::form(); } - String formEnctype() const; - void setFormEnctype(const String&); - String formMethod() const; - void setFormMethod(const String&); + WEBCORE_EXPORT String formEnctype() const; + WEBCORE_EXPORT void setFormEnctype(const String&); + WEBCORE_EXPORT String formMethod() const; + WEBCORE_EXPORT void setFormMethod(const String&); bool formNoValidate() const; + WEBCORE_EXPORT String formAction() const; + WEBCORE_EXPORT void setFormAction(const AtomicString&); - void ancestorDisabledStateWasChanged(); + void setAncestorDisabled(bool isDisabled); virtual void reset() { } - virtual bool formControlValueMatchesRenderer() const { return m_valueMatchesRenderer; } - virtual void setFormControlValueMatchesRenderer(bool b) { m_valueMatchesRenderer = b; } + bool formControlValueMatchesRenderer() const { return m_valueMatchesRenderer; } + void setFormControlValueMatchesRenderer(bool b) { m_valueMatchesRenderer = b; } bool wasChangedSinceLastFormControlChangeEvent() const { return m_wasChangedSinceLastFormControlChangeEvent; } void setChangedSinceLastFormControlChangeEvent(bool); @@ -68,10 +70,10 @@ public: void dispatchChangeEvent(); void dispatchFormControlInputEvent(); - virtual bool isDisabledFormControl() const override; + bool isDisabledFormControl() const override; - virtual bool isFocusable() const override; - virtual bool isEnumeratable() const override { return false; } + bool isFocusable() const override; + bool isEnumeratable() const override { return false; } bool isRequired() const; @@ -83,28 +85,26 @@ public: // Override in derived classes to get the encoded name=value pair for submitting. // Return true for a successful control (see HTML4-17.13.2). - virtual bool appendFormData(FormDataList&, bool) override { return false; } + bool appendFormData(FormDataList&, bool) override { return false; } virtual bool isSuccessfulSubmitButton() const { return false; } virtual bool isActivatedSubmit() const { return false; } virtual void setActivatedSubmit(bool) { } #if ENABLE(IOS_AUTOCORRECT_AND_AUTOCAPITALIZE) - bool autocorrect() const; - void setAutocorrect(bool); - - WebAutocapitalizeType autocapitalizeType() const; - const AtomicString& autocapitalize() const; - void setAutocapitalize(const AtomicString&); + WEBCORE_EXPORT bool shouldAutocorrect() const final; + WEBCORE_EXPORT AutocapitalizeType autocapitalizeType() const final; #endif - virtual bool willValidate() const override; + WEBCORE_EXPORT bool willValidate() const final; void updateVisibleValidationMessage(); void hideVisibleValidationMessage(); - bool checkValidity(Vector<RefPtr<FormAssociatedElement>>* unhandledInvalidControls = 0); + WEBCORE_EXPORT bool checkValidity(Vector<RefPtr<HTMLFormControlElement>>* unhandledInvalidControls = nullptr); + bool reportValidity(); + void focusAndShowValidationMessage(); // This must be called when a validation constraint or control value is changed. - void setNeedsValidityCheck(); - virtual void setCustomValidity(const String&) override; + void updateValidity(); + void setCustomValidity(const String&) override; bool isReadOnly() const { return m_isReadOnly; } bool isDisabledOrReadOnly() const { return isDisabledFormControl() || m_isReadOnly; } @@ -114,62 +114,78 @@ public: static HTMLFormControlElement* enclosingFormControlElement(Node*); + WEBCORE_EXPORT String autocomplete() const; + WEBCORE_EXPORT void setAutocomplete(const String&); + + AutofillMantle autofillMantle() const; + + WEBCORE_EXPORT AutofillData autofillData() const; + using Node::ref; using Node::deref; protected: HTMLFormControlElement(const QualifiedName& tagName, Document&, HTMLFormElement*); - virtual void parseAttribute(const QualifiedName&, const AtomicString&) override; - virtual void requiredAttributeChanged(); + bool disabledByAncestorFieldset() const { return m_disabledByAncestorFieldset; } + + void parseAttribute(const QualifiedName&, const AtomicString&) override; virtual void disabledAttributeChanged(); - virtual void didAttachRenderers() override; - virtual InsertionNotificationRequest insertedInto(ContainerNode&) override; - virtual void removedFrom(ContainerNode&) override; - virtual void didMoveToNewDocument(Document* oldDocument) override; + virtual void disabledStateChanged(); + virtual void readOnlyAttributeChanged(); + virtual void requiredAttributeChanged(); + void didAttachRenderers() override; + InsertionNotificationRequest insertedInto(ContainerNode&) override; + void finishedInsertingSubtree() override; + void removedFrom(ContainerNode&) override; + void didMoveToNewDocument(Document& oldDocument) override; - virtual bool supportsFocus() const override; - virtual bool isKeyboardFocusable(KeyboardEvent*) const override; - virtual bool isMouseFocusable() const override; + bool supportsFocus() const override; + bool isKeyboardFocusable(KeyboardEvent&) const override; + bool isMouseFocusable() const override; - virtual void didRecalcStyle(Style::Change) override; + void didRecalcStyle(Style::Change) override; - virtual void dispatchBlurEvent(PassRefPtr<Element> newFocusedElement) override; + void dispatchBlurEvent(RefPtr<Element>&& newFocusedElement) override; // This must be called any time the result of willValidate() has changed. void setNeedsWillValidateCheck(); - virtual bool recalcWillValidate() const; + virtual bool computeWillValidate() const; bool validationMessageShadowTreeContains(const Node&) const; + void willChangeForm() override; + void didChangeForm() override; + private: - virtual void refFormAssociatedElement() override { ref(); } - virtual void derefFormAssociatedElement() override { deref(); } + void refFormAssociatedElement() override { ref(); } + void derefFormAssociatedElement() override { deref(); } + + bool matchesValidPseudoClass() const override; + bool matchesInvalidPseudoClass() const override; - virtual bool isFormControlElement() const override { return true; } - virtual bool alwaysCreateUserAgentShadowRoot() const override { return true; } + bool isFormControlElement() const final { return true; } + bool alwaysCreateUserAgentShadowRoot() const override { return true; } - virtual short tabIndex() const override final; + int tabIndex() const final; - virtual HTMLFormElement* virtualForm() const override; - virtual bool isDefaultButtonForForm() const override; - virtual bool isValidFormControlElement() override; - void updateAncestorDisabledState() const; + bool isValidFormControlElement() const; - virtual HTMLElement& asHTMLElement() override final { return *this; } - virtual const HTMLFormControlElement& asHTMLElement() const override final { return *this; } - virtual HTMLFormControlElement* asFormNamedItem() override final { return this; } + bool computeIsDisabledByFieldsetAncestor() const; - OwnPtr<ValidationMessage> m_validationMessage; - bool m_disabled : 1; - bool m_isReadOnly : 1; - bool m_isRequired : 1; - bool m_valueMatchesRenderer : 1; + HTMLElement& asHTMLElement() final { return *this; } + const HTMLFormControlElement& asHTMLElement() const final { return *this; } + HTMLFormControlElement* asFormNamedItem() final { return this; } + + std::unique_ptr<ValidationMessage> m_validationMessage; + unsigned m_disabled : 1; + unsigned m_isReadOnly : 1; + unsigned m_isRequired : 1; + unsigned m_valueMatchesRenderer : 1; + unsigned m_disabledByAncestorFieldset : 1; - enum AncestorDisabledState { AncestorDisabledStateUnknown, AncestorDisabledStateEnabled, AncestorDisabledStateDisabled }; - mutable AncestorDisabledState m_ancestorDisabledState; enum DataListAncestorState { Unknown, InsideDataList, NotInsideDataList }; - mutable enum DataListAncestorState m_dataListAncestorState; + mutable unsigned m_dataListAncestorState : 2; // The initial value of m_willValidate depends on the derived class. We can't // initialize it with a virtual function in the constructor. m_willValidate @@ -179,22 +195,17 @@ private: // Cache of validity()->valid(). // But "candidate for constraint validation" doesn't affect m_isValid. - bool m_isValid : 1; + unsigned m_isValid : 1; - bool m_wasChangedSinceLastFormControlChangeEvent : 1; + unsigned m_wasChangedSinceLastFormControlChangeEvent : 1; - bool m_hasAutofocused : 1; + unsigned m_hasAutofocused : 1; }; -void isHTMLFormControlElement(const HTMLFormControlElement&); // Catch unnecessary runtime check of type known at compile time. -inline bool isHTMLFormControlElement(const Element& element) { return element.isFormControlElement(); } -inline bool isHTMLFormControlElement(const Node& node) { return node.isElementNode() && toElement(node).isFormControlElement(); } -template <> inline bool isElementOfType<const HTMLFormControlElement>(const Element& element) { return isHTMLFormControlElement(element); } - -NODE_TYPE_CASTS(HTMLFormControlElement) +} // namespace WebCore -FORM_ASSOCIATED_ELEMENT_TYPE_CASTS(HTMLFormControlElement, isFormControlElement()) - -} // namespace - -#endif +SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLFormControlElement) + static bool isType(const WebCore::Element& element) { return element.isFormControlElement(); } + static bool isType(const WebCore::Node& node) { return is<WebCore::Element>(node) && isType(downcast<WebCore::Element>(node)); } + static bool isType(const WebCore::FormAssociatedElement& element) { return element.isFormControlElement(); } +SPECIALIZE_TYPE_TRAITS_END() |