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

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

Issue 660783002: Implement reportValidity() (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
Index: Source/core/html/HTMLFormControlElement.cpp
diff --git a/Source/core/html/HTMLFormControlElement.cpp b/Source/core/html/HTMLFormControlElement.cpp
index bd58b9eb3ba07f2537c0ae34b21a82aa198ce43f..40e623f1e29541d88c99504bd3f16c136853293e 100644
--- a/Source/core/html/HTMLFormControlElement.cpp
+++ b/Source/core/html/HTMLFormControlElement.cpp
@@ -486,7 +486,7 @@ ValidationMessageClient* HTMLFormControlElement::validationMessageClient() const
return &page->validationMessageClient();
}
-bool HTMLFormControlElement::checkValidity(WillBeHeapVector<RefPtrWillBeMember<FormAssociatedElement> >* unhandledInvalidControls, CheckValidityEventBehavior eventBehavior)
+bool HTMLFormControlElement::checkValidity(WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElement> >* unhandledInvalidControls, CheckValidityEventBehavior eventBehavior)
{
if (!willValidate() || isValidElement())
return true;
@@ -501,6 +501,34 @@ bool HTMLFormControlElement::checkValidity(WillBeHeapVector<RefPtrWillBeMember<F
return false;
}
+bool HTMLFormControlElement::bringAttentionToInvalidElement()
keishi 2014/10/21 08:20:14 nit: I think I would prefer this to be named showV
Bartek Nowierski 2014/10/21 11:03:52 Done.
+{
+ if (isFocusable() && inDocument()) {
+ scrollIntoViewIfNeeded(false);
+ focus();
+ updateVisibleValidationMessage();
+ return true;
+ }
+ return false;
+}
+
+bool HTMLFormControlElement::reportValidity()
+{
+ WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElement> > unhandledInvalidControls;
+ bool isValid = checkValidity(&unhandledInvalidControls);
+ if (!isValid && unhandledInvalidControls.size() > 0) {
keishi 2014/10/21 08:20:15 !unhandledInvalidControls.isEmpty()
Bartek Nowierski 2014/10/21 11:03:52 Done.
+ ASSERT(unhandledInvalidControls.size() == 1);
+ ASSERT(unhandledInvalidControls[0].get() == this);
+
+ // Needs to update layout now because we'd like to call isFocusable(),
+ // which has !renderer()->needsLayout() assertion.
+ document().updateLayoutIgnorePendingStylesheets();
+ RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this);
+ bringAttentionToInvalidElement();
+ }
+ return isValid;
+}
+
bool HTMLFormControlElement::matchesValidityPseudoClasses() const
{
return willValidate();

Powered by Google App Engine
This is Rietveld 408576698