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

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

Issue 660783002: Implement reportValidity() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Apply tkent's comments 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/HTMLFormControlElement.h ('k') | Source/core/html/HTMLFormElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLFormControlElement.cpp
diff --git a/Source/core/html/HTMLFormControlElement.cpp b/Source/core/html/HTMLFormControlElement.cpp
index bd58b9eb3ba07f2537c0ae34b21a82aa198ce43f..c138b2c87078f1d326604ecfedff32f78c726051 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,38 @@ bool HTMLFormControlElement::checkValidity(WillBeHeapVector<RefPtrWillBeMember<F
return false;
}
+void HTMLFormControlElement::showValidationMessage()
+{
+ scrollIntoViewIfNeeded(false);
+ RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this);
+ focus();
+ updateVisibleValidationMessage();
+}
+
+bool HTMLFormControlElement::reportValidity()
+{
+ WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElement> > unhandledInvalidControls;
+ RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this);
tkent 2014/10/22 05:41:37 Ah, I found |unhandledInvalidControls[0] kept a re
Bartek Nowierski 2014/10/22 06:17:08 Done.
+ bool isValid = checkValidity(&unhandledInvalidControls, CheckValidityDispatchInvalidEvent);
+ if (isValid || unhandledInvalidControls.isEmpty())
+ return isValid;
+ ASSERT(unhandledInvalidControls.size() == 1);
+ ASSERT(unhandledInvalidControls[0].get() == this);
+ // Update layout now vefore calling isFocusable(), which has
tkent 2014/10/22 05:41:37 vefore -> before
Bartek Nowierski 2014/10/22 06:17:08 Done.
+ // !renderer()->needsLayout() assertion.
+ document().updateLayoutIgnorePendingStylesheets();
+ if (isFocusable()) {
+ showValidationMessage();
+ return false;
+ }
+ if (document().frame()) {
+ String message("An invalid form control with name='%name' is not focusable.");
+ message.replace("%name", name());
+ document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSource, ErrorMessageLevel, message));
+ }
+ return false;
+}
+
bool HTMLFormControlElement::matchesValidityPseudoClasses() const
{
return willValidate();
« no previous file with comments | « Source/core/html/HTMLFormControlElement.h ('k') | Source/core/html/HTMLFormElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698