| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 enum CheckValidityEventBehavior { CheckValidityDispatchNoEvent, CheckValidityDis
patchInvalidEvent }; | 37 enum CheckValidityEventBehavior { CheckValidityDispatchNoEvent, CheckValidityDis
patchInvalidEvent }; |
| 38 | 38 |
| 39 // HTMLFormControlElement is the default implementation of FormAssociatedElement
, | 39 // HTMLFormControlElement is the default implementation of FormAssociatedElement
, |
| 40 // and form-associated element implementations should use HTMLFormControlElement | 40 // and form-associated element implementations should use HTMLFormControlElement |
| 41 // unless there is a special reason. | 41 // unless there is a special reason. |
| 42 class CORE_EXPORT HTMLFormControlElement : public LabelableElement, public FormA
ssociatedElement { | 42 class CORE_EXPORT HTMLFormControlElement : public LabelableElement, public FormA
ssociatedElement { |
| 43 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLFormControlElement); | 43 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLFormControlElement); |
| 44 | 44 |
| 45 public: | 45 public: |
| 46 virtual ~HTMLFormControlElement(); | 46 ~HTMLFormControlElement() override; |
| 47 DECLARE_VIRTUAL_TRACE(); | 47 DECLARE_VIRTUAL_TRACE(); |
| 48 | 48 |
| 49 String formEnctype() const; | 49 String formEnctype() const; |
| 50 void setFormEnctype(const AtomicString&); | 50 void setFormEnctype(const AtomicString&); |
| 51 String formMethod() const; | 51 String formMethod() const; |
| 52 void setFormMethod(const AtomicString&); | 52 void setFormMethod(const AtomicString&); |
| 53 bool formNoValidate() const; | 53 bool formNoValidate() const; |
| 54 | 54 |
| 55 void ancestorDisabledStateWasChanged(); | 55 void ancestorDisabledStateWasChanged(); |
| 56 | 56 |
| 57 void reset(); | 57 void reset(); |
| 58 | 58 |
| 59 bool wasChangedSinceLastFormControlChangeEvent() const { return m_wasChanged
SinceLastFormControlChangeEvent; } | 59 bool wasChangedSinceLastFormControlChangeEvent() const { return m_wasChanged
SinceLastFormControlChangeEvent; } |
| 60 void setChangedSinceLastFormControlChangeEvent(bool); | 60 void setChangedSinceLastFormControlChangeEvent(bool); |
| 61 | 61 |
| 62 virtual void dispatchFormControlChangeEvent(); | 62 virtual void dispatchFormControlChangeEvent(); |
| 63 void dispatchChangeEvent(); | 63 void dispatchChangeEvent(); |
| 64 void dispatchFormControlInputEvent(); | 64 void dispatchFormControlInputEvent(); |
| 65 | 65 |
| 66 virtual HTMLFormElement* formOwner() const override final; | 66 HTMLFormElement* formOwner() const final; |
| 67 | 67 |
| 68 virtual bool isDisabledFormControl() const override; | 68 bool isDisabledFormControl() const override; |
| 69 | 69 |
| 70 virtual bool isEnumeratable() const override { return false; } | 70 bool isEnumeratable() const override { return false; } |
| 71 | 71 |
| 72 bool isRequired() const; | 72 bool isRequired() const; |
| 73 | 73 |
| 74 const AtomicString& type() const { return formControlType(); } | 74 const AtomicString& type() const { return formControlType(); } |
| 75 | 75 |
| 76 virtual const AtomicString& formControlType() const = 0; | 76 virtual const AtomicString& formControlType() const = 0; |
| 77 | 77 |
| 78 virtual bool canTriggerImplicitSubmission() const { return false; } | 78 virtual bool canTriggerImplicitSubmission() const { return false; } |
| 79 | 79 |
| 80 virtual bool isSubmittableElement() { return true; } | 80 virtual bool isSubmittableElement() { return true; } |
| 81 | 81 |
| 82 // Override in derived classes to get the encoded name=value pair for submit
ting. | 82 // Override in derived classes to get the encoded name=value pair for submit
ting. |
| 83 // Return true for a successful control (see HTML4-17.13.2). | 83 // Return true for a successful control (see HTML4-17.13.2). |
| 84 virtual bool appendFormData(FormDataList&, bool) override { return false; } | 84 bool appendFormData(FormDataList&, bool) override { return false; } |
| 85 virtual String resultForDialogSubmit(); | 85 virtual String resultForDialogSubmit(); |
| 86 | 86 |
| 87 virtual bool canBeSuccessfulSubmitButton() const { return false; } | 87 virtual bool canBeSuccessfulSubmitButton() const { return false; } |
| 88 bool isSuccessfulSubmitButton() const; | 88 bool isSuccessfulSubmitButton() const; |
| 89 virtual bool isActivatedSubmit() const { return false; } | 89 virtual bool isActivatedSubmit() const { return false; } |
| 90 virtual void setActivatedSubmit(bool) { } | 90 virtual void setActivatedSubmit(bool) { } |
| 91 | 91 |
| 92 virtual bool willValidate() const override; | 92 bool willValidate() const override; |
| 93 | 93 |
| 94 void updateVisibleValidationMessage(); | 94 void updateVisibleValidationMessage(); |
| 95 void hideVisibleValidationMessage(); | 95 void hideVisibleValidationMessage(); |
| 96 bool checkValidity(WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElemen
t>>* unhandledInvalidControls = 0, CheckValidityEventBehavior = CheckValidityDis
patchInvalidEvent); | 96 bool checkValidity(WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElemen
t>>* unhandledInvalidControls = 0, CheckValidityEventBehavior = CheckValidityDis
patchInvalidEvent); |
| 97 bool reportValidity(); | 97 bool reportValidity(); |
| 98 // This must be called only after the caller check the element is focusable. | 98 // This must be called only after the caller check the element is focusable. |
| 99 void showValidationMessage(); | 99 void showValidationMessage(); |
| 100 // This must be called when a validation constraint or control value is chan
ged. | 100 // This must be called when a validation constraint or control value is chan
ged. |
| 101 void setNeedsValidityCheck(); | 101 void setNeedsValidityCheck(); |
| 102 virtual void setCustomValidity(const String&) override final; | 102 void setCustomValidity(const String&) final; |
| 103 void findCustomValidationMessageTextDirection(const String& message, TextDir
ection &messageDir, String& subMessage, TextDirection& subMessageDir); | 103 void findCustomValidationMessageTextDirection(const String& message, TextDir
ection &messageDir, String& subMessage, TextDirection& subMessageDir); |
| 104 | 104 |
| 105 bool isReadOnly() const { return m_isReadOnly; } | 105 bool isReadOnly() const { return m_isReadOnly; } |
| 106 bool isDisabledOrReadOnly() const { return isDisabledFormControl() || m_isRe
adOnly; } | 106 bool isDisabledOrReadOnly() const { return isDisabledFormControl() || m_isRe
adOnly; } |
| 107 | 107 |
| 108 bool isAutofocusable() const; | 108 bool isAutofocusable() const; |
| 109 | 109 |
| 110 bool isAutofilled() const { return m_isAutofilled; } | 110 bool isAutofilled() const { return m_isAutofilled; } |
| 111 void setAutofilled(bool = true); | 111 void setAutofilled(bool = true); |
| 112 | 112 |
| 113 static HTMLFormControlElement* enclosingFormControlElement(Node*); | 113 static HTMLFormControlElement* enclosingFormControlElement(Node*); |
| 114 | 114 |
| 115 String nameForAutofill() const; | 115 String nameForAutofill() const; |
| 116 | 116 |
| 117 virtual void setFocus(bool flag) override; | 117 void setFocus(bool flag) override; |
| 118 virtual void copyNonAttributePropertiesFromElement(const Element&) override; | 118 void copyNonAttributePropertiesFromElement(const Element&) override; |
| 119 | 119 |
| 120 #if !ENABLE(OILPAN) | 120 #if !ENABLE(OILPAN) |
| 121 using Node::ref; | 121 using Node::ref; |
| 122 using Node::deref; | 122 using Node::deref; |
| 123 #endif | 123 #endif |
| 124 | 124 |
| 125 protected: | 125 protected: |
| 126 HTMLFormControlElement(const QualifiedName& tagName, Document&, HTMLFormElem
ent*); | 126 HTMLFormControlElement(const QualifiedName& tagName, Document&, HTMLFormElem
ent*); |
| 127 | 127 |
| 128 virtual void parseAttribute(const QualifiedName&, const AtomicString&) overr
ide; | 128 void parseAttribute(const QualifiedName&, const AtomicString&) override; |
| 129 virtual void requiredAttributeChanged(); | 129 virtual void requiredAttributeChanged(); |
| 130 virtual void disabledAttributeChanged(); | 130 virtual void disabledAttributeChanged(); |
| 131 virtual void attach(const AttachContext& = AttachContext()) override; | 131 void attach(const AttachContext& = AttachContext()) override; |
| 132 virtual InsertionNotificationRequest insertedInto(ContainerNode*) override; | 132 InsertionNotificationRequest insertedInto(ContainerNode*) override; |
| 133 virtual void removedFrom(ContainerNode*) override; | 133 void removedFrom(ContainerNode*) override; |
| 134 virtual void willChangeForm() override; | 134 void willChangeForm() override; |
| 135 virtual void didChangeForm() override; | 135 void didChangeForm() override; |
| 136 virtual void didMoveToNewDocument(Document& oldDocument) override; | 136 void didMoveToNewDocument(Document& oldDocument) override; |
| 137 | 137 |
| 138 virtual bool supportsFocus() const override; | 138 bool supportsFocus() const override; |
| 139 virtual bool isKeyboardFocusable() const override; | 139 bool isKeyboardFocusable() const override; |
| 140 virtual bool shouldShowFocusRingOnMouseFocus() const; | 140 virtual bool shouldShowFocusRingOnMouseFocus() const; |
| 141 virtual bool shouldHaveFocusAppearance() const override final; | 141 bool shouldHaveFocusAppearance() const final; |
| 142 virtual void dispatchBlurEvent(Element* newFocusedElement, WebFocusType) ove
rride; | 142 void dispatchBlurEvent(Element* newFocusedElement, WebFocusType) override; |
| 143 virtual void dispatchFocusEvent(Element* oldFocusedElement, WebFocusType) ov
erride; | 143 void dispatchFocusEvent(Element* oldFocusedElement, WebFocusType) override; |
| 144 virtual void willCallDefaultEventHandler(const Event&) override final; | 144 void willCallDefaultEventHandler(const Event&) final; |
| 145 | 145 |
| 146 virtual void didRecalcStyle(StyleRecalcChange) override final; | 146 void didRecalcStyle(StyleRecalcChange) final; |
| 147 | 147 |
| 148 // This must be called any time the result of willValidate() has changed. | 148 // This must be called any time the result of willValidate() has changed. |
| 149 void setNeedsWillValidateCheck(); | 149 void setNeedsWillValidateCheck(); |
| 150 virtual bool recalcWillValidate() const; | 150 virtual bool recalcWillValidate() const; |
| 151 | 151 |
| 152 virtual void resetImpl() { } | 152 virtual void resetImpl() { } |
| 153 virtual bool supportsAutofocus() const; | 153 virtual bool supportsAutofocus() const; |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 #if !ENABLE(OILPAN) | 156 #if !ENABLE(OILPAN) |
| 157 virtual void refFormAssociatedElement() override final { ref(); } | 157 void refFormAssociatedElement() final { ref(); } |
| 158 virtual void derefFormAssociatedElement() override final { deref(); } | 158 void derefFormAssociatedElement() final { deref(); } |
| 159 #endif | 159 #endif |
| 160 | 160 |
| 161 virtual bool isFormControlElement() const override final { return true; } | 161 bool isFormControlElement() const final { return true; } |
| 162 virtual bool alwaysCreateUserAgentShadowRoot() const override { return true;
} | 162 bool alwaysCreateUserAgentShadowRoot() const override { return true; } |
| 163 | 163 |
| 164 virtual short tabIndex() const override final; | 164 short tabIndex() const final; |
| 165 | 165 |
| 166 virtual bool isDefaultButtonForForm() const override final; | 166 bool isDefaultButtonForForm() const final; |
| 167 virtual bool isValidElement() override; | 167 bool isValidElement() override; |
| 168 virtual bool matchesValidityPseudoClasses() const override; | 168 bool matchesValidityPseudoClasses() const override; |
| 169 void updateAncestorDisabledState() const; | 169 void updateAncestorDisabledState() const; |
| 170 | 170 |
| 171 bool isValidationMessageVisible() const; | 171 bool isValidationMessageVisible() const; |
| 172 ValidationMessageClient* validationMessageClient() const; | 172 ValidationMessageClient* validationMessageClient() const; |
| 173 | 173 |
| 174 // Requests validity recalc for the form owner, if one exists. | 174 // Requests validity recalc for the form owner, if one exists. |
| 175 void formOwnerSetNeedsValidityCheck(); | 175 void formOwnerSetNeedsValidityCheck(); |
| 176 // Requests validity recalc for all ancestor fieldsets, if exist. | 176 // Requests validity recalc for all ancestor fieldsets, if exist. |
| 177 void fieldSetAncestorsSetNeedsValidityCheck(Node*); | 177 void fieldSetAncestorsSetNeedsValidityCheck(Node*); |
| 178 | 178 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 205 { | 205 { |
| 206 return element.isFormControlElement(); | 206 return element.isFormControlElement(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLFormControlElement); | 209 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLFormControlElement); |
| 210 DEFINE_TYPE_CASTS(HTMLFormControlElement, FormAssociatedElement, control, contro
l->isFormControlElement(), control.isFormControlElement()); | 210 DEFINE_TYPE_CASTS(HTMLFormControlElement, FormAssociatedElement, control, contro
l->isFormControlElement(), control.isFormControlElement()); |
| 211 | 211 |
| 212 } // namespace | 212 } // namespace |
| 213 | 213 |
| 214 #endif | 214 #endif |
| OLD | NEW |