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(); |