Chromium Code Reviews| 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(); |