Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: Source/core/html/HTMLFormControlElement.h

Issue 672163002: Fix bug where form/fieldset :valid/:invalid won't be recalculated upon control's willValidate change Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add layout tests to catch the problem Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 16 matching lines...) Expand all
27 #include "core/html/FormAssociatedElement.h" 27 #include "core/html/FormAssociatedElement.h"
28 #include "core/html/LabelableElement.h" 28 #include "core/html/LabelableElement.h"
29 29
30 namespace blink { 30 namespace blink {
31 31
32 class FormDataList; 32 class FormDataList;
33 class HTMLFormElement; 33 class HTMLFormElement;
34 class ValidationMessageClient; 34 class ValidationMessageClient;
35 35
36 enum CheckValidityEventBehavior { CheckValidityDispatchNoEvent, CheckValidityDis patchInvalidEvent }; 36 enum CheckValidityEventBehavior { CheckValidityDispatchNoEvent, CheckValidityDis patchInvalidEvent };
37 enum ValidityChangeAction { ElementAddition, ElementRemoval, ElementModification };
keishi 2014/10/24 10:25:49 nit: It might be just me. The name * Action gives
Bartek Nowierski 2014/10/24 10:48:30 Reason seems like a much better option. Done.
37 38
38 // HTMLFormControlElement is the default implementation of FormAssociatedElement , 39 // HTMLFormControlElement is the default implementation of FormAssociatedElement ,
39 // and form-associated element implementations should use HTMLFormControlElement 40 // and form-associated element implementations should use HTMLFormControlElement
40 // unless there is a special reason. 41 // unless there is a special reason.
41 class HTMLFormControlElement : public LabelableElement, public FormAssociatedEle ment { 42 class HTMLFormControlElement : public LabelableElement, public FormAssociatedEle ment {
42 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLFormControlElement); 43 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLFormControlElement);
43 44
44 public: 45 public:
45 virtual ~HTMLFormControlElement(); 46 virtual ~HTMLFormControlElement();
46 virtual void trace(Visitor*) override; 47 virtual void trace(Visitor*) override;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 121
121 protected: 122 protected:
122 HTMLFormControlElement(const QualifiedName& tagName, Document&, HTMLFormElem ent*); 123 HTMLFormControlElement(const QualifiedName& tagName, Document&, HTMLFormElem ent*);
123 124
124 virtual void parseAttribute(const QualifiedName&, const AtomicString&) overr ide; 125 virtual void parseAttribute(const QualifiedName&, const AtomicString&) overr ide;
125 virtual void requiredAttributeChanged(); 126 virtual void requiredAttributeChanged();
126 virtual void disabledAttributeChanged(); 127 virtual void disabledAttributeChanged();
127 virtual void attach(const AttachContext& = AttachContext()) override; 128 virtual void attach(const AttachContext& = AttachContext()) override;
128 virtual InsertionNotificationRequest insertedInto(ContainerNode*) override; 129 virtual InsertionNotificationRequest insertedInto(ContainerNode*) override;
129 virtual void removedFrom(ContainerNode*) override; 130 virtual void removedFrom(ContainerNode*) override;
130 virtual void willChangeForm() override; 131 virtual void didChangeForm(HTMLFormElement* oldForm) override;
131 virtual void didChangeForm() override;
132 virtual void didMoveToNewDocument(Document& oldDocument) override; 132 virtual void didMoveToNewDocument(Document& oldDocument) override;
133 133
134 virtual bool supportsFocus() const override; 134 virtual bool supportsFocus() const override;
135 virtual bool isKeyboardFocusable() const override; 135 virtual bool isKeyboardFocusable() const override;
136 virtual bool shouldShowFocusRingOnMouseFocus() const; 136 virtual bool shouldShowFocusRingOnMouseFocus() const;
137 virtual bool shouldHaveFocusAppearance() const override final; 137 virtual bool shouldHaveFocusAppearance() const override final;
138 virtual void dispatchBlurEvent(Element* newFocusedElement) override; 138 virtual void dispatchBlurEvent(Element* newFocusedElement) override;
139 virtual void dispatchFocusEvent(Element* oldFocusedElement, FocusType) overr ide; 139 virtual void dispatchFocusEvent(Element* oldFocusedElement, FocusType) overr ide;
140 virtual void willCallDefaultEventHandler(const Event&) override final; 140 virtual void willCallDefaultEventHandler(const Event&) override final;
141 141
(...skipping 13 matching lines...) Expand all
155 #endif 155 #endif
156 156
157 virtual bool isFormControlElement() const override final { return true; } 157 virtual bool isFormControlElement() const override final { return true; }
158 virtual bool alwaysCreateUserAgentShadowRoot() const override { return true; } 158 virtual bool alwaysCreateUserAgentShadowRoot() const override { return true; }
159 159
160 virtual short tabIndex() const override final; 160 virtual short tabIndex() const override final;
161 161
162 virtual bool isDefaultButtonForForm() const override final; 162 virtual bool isDefaultButtonForForm() const override final;
163 virtual bool isValidElement() override; 163 virtual bool isValidElement() override;
164 virtual bool matchesValidityPseudoClasses() const override; 164 virtual bool matchesValidityPseudoClasses() const override;
165 // Refreshes willValidate cache. Returns true if anything changed.
166 bool refreshWillValidate();
165 void updateAncestorDisabledState() const; 167 void updateAncestorDisabledState() const;
166 168
167 bool isValidationMessageVisible() const; 169 bool isValidationMessageVisible() const;
168 ValidationMessageClient* validationMessageClient() const; 170 ValidationMessageClient* validationMessageClient() const;
169 171
170 // Requests validity recalc for the form owner, if one exists. 172 // Requests validity recalc for the form owner, if one exists.
171 void formOwnerSetNeedsValidityCheck(); 173 void formOwnerSetNeedsValidityCheck(ValidityChangeAction, bool isValid);
172 // Requests validity recalc for all ancestor fieldsets, if exist. 174 // Requests validity recalc for all ancestor fieldsets, if exist.
173 void fieldSetAncestorsSetNeedsValidityCheck(Node*); 175 void fieldSetAncestorsSetNeedsValidityCheck(Node*);
174 176
175 bool m_disabled : 1; 177 bool m_disabled : 1;
176 bool m_isAutofilled : 1; 178 bool m_isAutofilled : 1;
177 bool m_isReadOnly : 1; 179 bool m_isReadOnly : 1;
178 bool m_isRequired : 1; 180 bool m_isRequired : 1;
179 bool m_hasValidationMessage : 1; 181 bool m_hasValidationMessage : 1;
180 182
181 enum AncestorDisabledState { AncestorDisabledStateUnknown, AncestorDisabledS tateEnabled, AncestorDisabledStateDisabled }; 183 enum AncestorDisabledState { AncestorDisabledStateUnknown, AncestorDisabledS tateEnabled, AncestorDisabledStateDisabled };
(...skipping 19 matching lines...) Expand all
201 { 203 {
202 return element.isFormControlElement(); 204 return element.isFormControlElement();
203 } 205 }
204 206
205 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLFormControlElement); 207 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLFormControlElement);
206 DEFINE_TYPE_CASTS(HTMLFormControlElement, FormAssociatedElement, control, contro l->isFormControlElement(), control.isFormControlElement()); 208 DEFINE_TYPE_CASTS(HTMLFormControlElement, FormAssociatedElement, control, contro l->isFormControlElement(), control.isFormControlElement());
207 209
208 } // namespace 210 } // namespace
209 211
210 #endif 212 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698