| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 | 527 |
| 528 ValidationMessageClient* HTMLFormControlElement::validationMessageClient() const | 528 ValidationMessageClient* HTMLFormControlElement::validationMessageClient() const |
| 529 { | 529 { |
| 530 Page* page = document().page(); | 530 Page* page = document().page(); |
| 531 if (!page) | 531 if (!page) |
| 532 return nullptr; | 532 return nullptr; |
| 533 | 533 |
| 534 return &page->validationMessageClient(); | 534 return &page->validationMessageClient(); |
| 535 } | 535 } |
| 536 | 536 |
| 537 bool HTMLFormControlElement::checkValidity(WillBeHeapVector<RefPtrWillBeMember<H
TMLFormControlElement>>* unhandledInvalidControls, CheckValidityEventBehavior ev
entBehavior) | 537 bool HTMLFormControlElement::checkValidity(HeapVector<Member<HTMLFormControlElem
ent>>* unhandledInvalidControls, CheckValidityEventBehavior eventBehavior) |
| 538 { | 538 { |
| 539 if (isValidElement()) | 539 if (isValidElement()) |
| 540 return true; | 540 return true; |
| 541 if (eventBehavior != CheckValidityDispatchInvalidEvent) | 541 if (eventBehavior != CheckValidityDispatchInvalidEvent) |
| 542 return false; | 542 return false; |
| 543 // An event handler can deref this object. | 543 // An event handler can deref this object. |
| 544 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); | 544 RawPtr<HTMLFormControlElement> protector(this); |
| 545 RefPtrWillBeRawPtr<Document> originalDocument(document()); | 545 RawPtr<Document> originalDocument(document()); |
| 546 DispatchEventResult dispatchResult = dispatchEvent(Event::createCancelable(E
ventTypeNames::invalid)); | 546 DispatchEventResult dispatchResult = dispatchEvent(Event::createCancelable(E
ventTypeNames::invalid)); |
| 547 if (dispatchResult == DispatchEventResult::NotCanceled && unhandledInvalidCo
ntrols && inDocument() && originalDocument == document()) | 547 if (dispatchResult == DispatchEventResult::NotCanceled && unhandledInvalidCo
ntrols && inDocument() && originalDocument == document()) |
| 548 unhandledInvalidControls->append(this); | 548 unhandledInvalidControls->append(this); |
| 549 return false; | 549 return false; |
| 550 } | 550 } |
| 551 | 551 |
| 552 void HTMLFormControlElement::showValidationMessage() | 552 void HTMLFormControlElement::showValidationMessage() |
| 553 { | 553 { |
| 554 scrollIntoViewIfNeeded(false); | 554 scrollIntoViewIfNeeded(false); |
| 555 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); | 555 RawPtr<HTMLFormControlElement> protector(this); |
| 556 focus(); | 556 focus(); |
| 557 updateVisibleValidationMessage(); | 557 updateVisibleValidationMessage(); |
| 558 } | 558 } |
| 559 | 559 |
| 560 bool HTMLFormControlElement::reportValidity() | 560 bool HTMLFormControlElement::reportValidity() |
| 561 { | 561 { |
| 562 WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElement>> unhandledInvali
dControls; | 562 HeapVector<Member<HTMLFormControlElement>> unhandledInvalidControls; |
| 563 bool isValid = checkValidity(&unhandledInvalidControls, CheckValidityDispatc
hInvalidEvent); | 563 bool isValid = checkValidity(&unhandledInvalidControls, CheckValidityDispatc
hInvalidEvent); |
| 564 if (isValid || unhandledInvalidControls.isEmpty()) | 564 if (isValid || unhandledInvalidControls.isEmpty()) |
| 565 return isValid; | 565 return isValid; |
| 566 ASSERT(unhandledInvalidControls.size() == 1); | 566 ASSERT(unhandledInvalidControls.size() == 1); |
| 567 ASSERT(unhandledInvalidControls[0].get() == this); | 567 ASSERT(unhandledInvalidControls[0].get() == this); |
| 568 // Update layout now before calling isFocusable(), which has | 568 // Update layout now before calling isFocusable(), which has |
| 569 // !layoutObject()->needsLayout() assertion. | 569 // !layoutObject()->needsLayout() assertion. |
| 570 document().updateLayoutIgnorePendingStylesheets(); | 570 document().updateLayoutIgnorePendingStylesheets(); |
| 571 if (isFocusable()) { | 571 if (isFocusable()) { |
| 572 showValidationMessage(); | 572 showValidationMessage(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 dispatchFormControlChangeEvent(); | 661 dispatchFormControlChangeEvent(); |
| 662 } | 662 } |
| 663 | 663 |
| 664 void HTMLFormControlElement::copyNonAttributePropertiesFromElement(const Element
& source) | 664 void HTMLFormControlElement::copyNonAttributePropertiesFromElement(const Element
& source) |
| 665 { | 665 { |
| 666 HTMLElement::copyNonAttributePropertiesFromElement(source); | 666 HTMLElement::copyNonAttributePropertiesFromElement(source); |
| 667 setNeedsValidityCheck(); | 667 setNeedsValidityCheck(); |
| 668 } | 668 } |
| 669 | 669 |
| 670 } // namespace blink | 670 } // namespace blink |
| OLD | NEW |