| 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 523 |
| 524 ValidationMessageClient* HTMLFormControlElement::validationMessageClient() const | 524 ValidationMessageClient* HTMLFormControlElement::validationMessageClient() const |
| 525 { | 525 { |
| 526 Page* page = document().page(); | 526 Page* page = document().page(); |
| 527 if (!page) | 527 if (!page) |
| 528 return nullptr; | 528 return nullptr; |
| 529 | 529 |
| 530 return &page->validationMessageClient(); | 530 return &page->validationMessageClient(); |
| 531 } | 531 } |
| 532 | 532 |
| 533 bool HTMLFormControlElement::checkValidity(WillBeHeapVector<RefPtrWillBeMember<H
TMLFormControlElement>>* unhandledInvalidControls, CheckValidityEventBehavior ev
entBehavior) | 533 bool HTMLFormControlElement::checkValidity(HeapVector<Member<HTMLFormControlElem
ent>>* unhandledInvalidControls, CheckValidityEventBehavior eventBehavior) |
| 534 { | 534 { |
| 535 if (isValidElement()) | 535 if (isValidElement()) |
| 536 return true; | 536 return true; |
| 537 if (eventBehavior != CheckValidityDispatchInvalidEvent) | 537 if (eventBehavior != CheckValidityDispatchInvalidEvent) |
| 538 return false; | 538 return false; |
| 539 // An event handler can deref this object. | 539 // An event handler can deref this object. |
| 540 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); | 540 RawPtr<HTMLFormControlElement> protector(this); |
| 541 RefPtrWillBeRawPtr<Document> originalDocument(document()); | 541 RawPtr<Document> originalDocument(document()); |
| 542 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam
es::invalid)); | 542 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam
es::invalid)); |
| 543 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin
alDocument == document()) | 543 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin
alDocument == document()) |
| 544 unhandledInvalidControls->append(this); | 544 unhandledInvalidControls->append(this); |
| 545 return false; | 545 return false; |
| 546 } | 546 } |
| 547 | 547 |
| 548 void HTMLFormControlElement::showValidationMessage() | 548 void HTMLFormControlElement::showValidationMessage() |
| 549 { | 549 { |
| 550 scrollIntoViewIfNeeded(false); | 550 scrollIntoViewIfNeeded(false); |
| 551 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); | 551 RawPtr<HTMLFormControlElement> protector(this); |
| 552 focus(); | 552 focus(); |
| 553 updateVisibleValidationMessage(); | 553 updateVisibleValidationMessage(); |
| 554 } | 554 } |
| 555 | 555 |
| 556 bool HTMLFormControlElement::reportValidity() | 556 bool HTMLFormControlElement::reportValidity() |
| 557 { | 557 { |
| 558 WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElement>> unhandledInvali
dControls; | 558 HeapVector<Member<HTMLFormControlElement>> unhandledInvalidControls; |
| 559 bool isValid = checkValidity(&unhandledInvalidControls, CheckValidityDispatc
hInvalidEvent); | 559 bool isValid = checkValidity(&unhandledInvalidControls, CheckValidityDispatc
hInvalidEvent); |
| 560 if (isValid || unhandledInvalidControls.isEmpty()) | 560 if (isValid || unhandledInvalidControls.isEmpty()) |
| 561 return isValid; | 561 return isValid; |
| 562 ASSERT(unhandledInvalidControls.size() == 1); | 562 ASSERT(unhandledInvalidControls.size() == 1); |
| 563 ASSERT(unhandledInvalidControls[0].get() == this); | 563 ASSERT(unhandledInvalidControls[0].get() == this); |
| 564 // Update layout now before calling isFocusable(), which has | 564 // Update layout now before calling isFocusable(), which has |
| 565 // !layoutObject()->needsLayout() assertion. | 565 // !layoutObject()->needsLayout() assertion. |
| 566 document().updateLayoutIgnorePendingStylesheets(); | 566 document().updateLayoutIgnorePendingStylesheets(); |
| 567 if (isFocusable()) { | 567 if (isFocusable()) { |
| 568 showValidationMessage(); | 568 showValidationMessage(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 dispatchFormControlChangeEvent(); | 662 dispatchFormControlChangeEvent(); |
| 663 } | 663 } |
| 664 | 664 |
| 665 void HTMLFormControlElement::copyNonAttributePropertiesFromElement(const Element
& source) | 665 void HTMLFormControlElement::copyNonAttributePropertiesFromElement(const Element
& source) |
| 666 { | 666 { |
| 667 HTMLElement::copyNonAttributePropertiesFromElement(source); | 667 HTMLElement::copyNonAttributePropertiesFromElement(source); |
| 668 setNeedsValidityCheck(); | 668 setNeedsValidityCheck(); |
| 669 } | 669 } |
| 670 | 670 |
| 671 } // namespace blink | 671 } // namespace blink |
| OLD | NEW |