| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) | |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights | |
| 6 * reserved. | |
| 7 * | |
| 8 * This library is free software; you can redistribute it and/or | |
| 9 * modify it under the terms of the GNU Library General Public | |
| 10 * License as published by the Free Software Foundation; either | |
| 11 * version 2 of the License, or (at your option) any later version. | |
| 12 * | |
| 13 * This library is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 16 * Library General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU Library General Public License | |
| 19 * along with this library; see the file COPYING.LIB. If not, write to | |
| 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 21 * Boston, MA 02110-1301, USA. | |
| 22 * | |
| 23 */ | |
| 24 | |
| 25 #ifndef FormAssociatedElement_h | |
| 26 #define FormAssociatedElement_h | |
| 27 | |
| 28 #include "core/CoreExport.h" | |
| 29 #include "platform/heap/Handle.h" | |
| 30 #include "wtf/text/WTFString.h" | |
| 31 | |
| 32 namespace blink { | |
| 33 | |
| 34 class ContainerNode; | |
| 35 class Document; | |
| 36 class FormAttributeTargetObserver; | |
| 37 class FormData; | |
| 38 class HTMLElement; | |
| 39 class HTMLFormElement; | |
| 40 class Node; | |
| 41 class ValidityState; | |
| 42 | |
| 43 class CORE_EXPORT FormAssociatedElement : public GarbageCollectedMixin { | |
| 44 public: | |
| 45 virtual ~FormAssociatedElement(); | |
| 46 | |
| 47 static HTMLFormElement* findAssociatedForm(const HTMLElement*); | |
| 48 HTMLFormElement* form() const { return m_form.get(); } | |
| 49 ValidityState* validity(); | |
| 50 | |
| 51 virtual bool isFormControlElement() const = 0; | |
| 52 virtual bool isFormControlElementWithState() const; | |
| 53 virtual bool isEnumeratable() const = 0; | |
| 54 | |
| 55 // Returns the 'name' attribute value. If this element has no name | |
| 56 // attribute, it returns an empty string instead of null string. | |
| 57 // Note that the 'name' IDL attribute doesn't use this function. | |
| 58 virtual const AtomicString& name() const; | |
| 59 | |
| 60 // Override in derived classes to get the encoded name=value pair for | |
| 61 // submitting. | |
| 62 virtual void appendToFormData(FormData&) {} | |
| 63 | |
| 64 void resetFormOwner(); | |
| 65 | |
| 66 void formRemovedFromTree(const Node& formRoot); | |
| 67 | |
| 68 // ValidityState attribute implementations | |
| 69 bool customError() const; | |
| 70 | |
| 71 // Override functions for patterMismatch, rangeOverflow, rangerUnderflow, | |
| 72 // stepMismatch, tooLong, tooShort and valueMissing must call willValidate | |
| 73 // method. | |
| 74 virtual bool hasBadInput() const; | |
| 75 virtual bool patternMismatch() const; | |
| 76 virtual bool rangeOverflow() const; | |
| 77 virtual bool rangeUnderflow() const; | |
| 78 virtual bool stepMismatch() const; | |
| 79 virtual bool tooLong() const; | |
| 80 virtual bool tooShort() const; | |
| 81 virtual bool typeMismatch() const; | |
| 82 virtual bool valueMissing() const; | |
| 83 virtual String validationMessage() const; | |
| 84 virtual String validationSubMessage() const; | |
| 85 bool valid() const; | |
| 86 virtual void setCustomValidity(const String&); | |
| 87 | |
| 88 void formAttributeTargetChanged(); | |
| 89 | |
| 90 typedef HeapVector<Member<FormAssociatedElement>> List; | |
| 91 | |
| 92 DECLARE_VIRTUAL_TRACE(); | |
| 93 | |
| 94 protected: | |
| 95 FormAssociatedElement(); | |
| 96 | |
| 97 void insertedInto(ContainerNode*); | |
| 98 void removedFrom(ContainerNode*); | |
| 99 void didMoveToNewDocument(Document& oldDocument); | |
| 100 | |
| 101 // FIXME: Remove usage of setForm. resetFormOwner should be enough, and | |
| 102 // setForm is confusing. | |
| 103 void setForm(HTMLFormElement*); | |
| 104 void associateByParser(HTMLFormElement*); | |
| 105 void formAttributeChanged(); | |
| 106 | |
| 107 // If you add an override of willChangeForm() or didChangeForm() to a class | |
| 108 // derived from this one, you will need to add a call to setForm(0) to the | |
| 109 // destructor of that class. | |
| 110 virtual void willChangeForm(); | |
| 111 virtual void didChangeForm(); | |
| 112 | |
| 113 String customValidationMessage() const; | |
| 114 | |
| 115 private: | |
| 116 void setFormAttributeTargetObserver(FormAttributeTargetObserver*); | |
| 117 void resetFormAttributeTargetObserver(); | |
| 118 | |
| 119 Member<FormAttributeTargetObserver> m_formAttributeTargetObserver; | |
| 120 Member<HTMLFormElement> m_form; | |
| 121 Member<ValidityState> m_validityState; | |
| 122 String m_customValidationMessage; | |
| 123 // If m_formWasSetByParser is true, m_form is always non-null. | |
| 124 bool m_formWasSetByParser; | |
| 125 }; | |
| 126 | |
| 127 CORE_EXPORT HTMLElement* toHTMLElement(FormAssociatedElement*); | |
| 128 CORE_EXPORT HTMLElement& toHTMLElement(FormAssociatedElement&); | |
| 129 CORE_EXPORT const HTMLElement* toHTMLElement(const FormAssociatedElement*); | |
| 130 CORE_EXPORT const HTMLElement& toHTMLElement(const FormAssociatedElement&); | |
| 131 | |
| 132 } // namespace blink | |
| 133 | |
| 134 #endif // FormAssociatedElement_h | |
| OLD | NEW |