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

Unified Diff: Source/core/html/HTMLFieldSetElement.cpp

Issue 646273004: Implement :valid and :invalid pseudoclass for <fieldset> (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Pull 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLFieldSetElement.h ('k') | Source/core/html/HTMLFormControlElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLFieldSetElement.cpp
diff --git a/Source/core/html/HTMLFieldSetElement.cpp b/Source/core/html/HTMLFieldSetElement.cpp
index b0949ab5c13cc46b8f4033349378111b66cea4ca..20b0a35bb3e3d3491660afbd855f3a95bd8a3854 100644
--- a/Source/core/html/HTMLFieldSetElement.cpp
+++ b/Source/core/html/HTMLFieldSetElement.cpp
@@ -58,6 +58,34 @@ void HTMLFieldSetElement::trace(Visitor* visitor)
HTMLFormControlElement::trace(visitor);
}
+bool HTMLFieldSetElement::matchesValidityPseudoClasses() const
+{
+ return true;
+}
+
+bool HTMLFieldSetElement::isValidElement()
+{
+ const FormAssociatedElement::List& elements = associatedElements();
+ for (unsigned i = 0; i < elements.size(); ++i) {
+ ASSERT(elements[i]->isFormControlElement());
tkent 2014/10/21 00:11:13 We should take care of a case that elements[i] is
Bartek Nowierski 2014/10/21 03:25:26 Obviously the assert is incorrect, I don't know wh
+ HTMLFormControlElement* control = toHTMLFormControlElement(elements[i].get());
+ if (!control->checkValidity(0, CheckValidityDispatchNoEvent))
+ return false;
+ }
+ return true;
+}
+
+void HTMLFieldSetElement::setNeedsValidityCheck()
+{
+ // For now unconditionally order style recalculation, which triggers
+ // validity recalculation. In the near future, consider implement validity
+ // cache and recalculate style only if it changed.
+ // If setNeedsStyleRecalc ends up being called conditionally here, then
+ // the caller will have to call setNeedsValidityCheck for all ancestor
+ // fieldsets, not only the furthest one.
+ setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::createWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Invalid));
+}
+
void HTMLFieldSetElement::invalidateDisabledStateUnder(Element& base)
{
for (HTMLFormControlElement* element = Traversal<HTMLFormControlElement>::firstWithin(base); element; element = Traversal<HTMLFormControlElement>::next(*element, &base))
« no previous file with comments | « Source/core/html/HTMLFieldSetElement.h ('k') | Source/core/html/HTMLFormControlElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698