Chromium Code Reviews| 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 { | 462 { |
| 463 Page* page = document().page(); | 463 Page* page = document().page(); |
| 464 if (!page) | 464 if (!page) |
| 465 return 0; | 465 return 0; |
| 466 | 466 |
| 467 return &page->validationMessageClient(); | 467 return &page->validationMessageClient(); |
| 468 } | 468 } |
| 469 | 469 |
| 470 bool HTMLFormControlElement::checkValidity(WillBeHeapVector<RefPtrWillBeMember<F ormAssociatedElement> >* unhandledInvalidControls) | 470 bool HTMLFormControlElement::checkValidity(WillBeHeapVector<RefPtrWillBeMember<F ormAssociatedElement> >* unhandledInvalidControls) |
| 471 { | 471 { |
| 472 if (!willValidate() || isValidFormControlElement()) | 472 if (!willValidate() || isValidElement()) |
| 473 return true; | 473 return true; |
| 474 // An event handler can deref this object. | 474 // An event handler can deref this object. |
| 475 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); | 475 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); |
| 476 RefPtrWillBeRawPtr<Document> originalDocument(document()); | 476 RefPtrWillBeRawPtr<Document> originalDocument(document()); |
| 477 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam es::invalid)); | 477 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam es::invalid)); |
| 478 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin alDocument == document()) | 478 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin alDocument == document()) |
| 479 unhandledInvalidControls->append(this); | 479 unhandledInvalidControls->append(this); |
| 480 return false; | 480 return false; |
| 481 } | 481 } |
| 482 | 482 |
| 483 bool HTMLFormControlElement::isValidFormControlElement() | 483 bool HTMLFormControlElement::isValidElement() |
| 484 { | 484 { |
| 485 // If the following assertion fails, setNeedsValidityCheck() is not called | 485 // If the following assertion fails, setNeedsValidityCheck() is not called |
| 486 // correctly when something which changes validity is updated. | 486 // correctly when something which changes validity is updated. |
| 487 ASSERT(m_isValid == valid()); | 487 ASSERT(m_isValid == valid()); |
| 488 return m_isValid; | 488 return m_isValid; |
| 489 } | 489 } |
| 490 | 490 |
| 491 void HTMLFormControlElement::setNeedsValidityCheck() | 491 void HTMLFormControlElement::setNeedsValidityCheck() |
| 492 { | 492 { |
| 493 bool newIsValid = valid(); | 493 bool newIsValid = valid(); |
| 494 if (willValidate() && newIsValid != m_isValid) { | 494 if (willValidate() && newIsValid != m_isValid) { |
| 495 // Update style for pseudo classes such as :valid :invalid. | 495 // Update style for pseudo classes such as :valid :invalid. |
| 496 // A change here could've affected the style of the form itself and | |
| 497 // other form elemetns, so recaluclate the entire form's subtree. | |
|
keishi
2014/10/01 09:25:27
nit: /elemetns/elements/
nit: /recaluclate/recalcu
Bartek Nowierski
2014/10/02 14:26:42
Done.
| |
| 498 HTMLFormElement* form = formOwner(); | |
| 499 if (form) | |
| 500 form->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTr acing::createWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData: :Invalid)); | |
| 501 // Then recalculate the element itself (and its subtree), because | |
| 502 // it might not be in the tree of the owner form. | |
| 496 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre ateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Invalid)) ; | 503 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre ateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Invalid)) ; |
| 497 } | 504 } |
| 498 m_isValid = newIsValid; | 505 m_isValid = newIsValid; |
| 499 | 506 |
| 500 // Updates only if this control already has a validation message. | 507 // Updates only if this control already has a validation message. |
| 501 if (isValidationMessageVisible()) { | 508 if (isValidationMessageVisible()) { |
| 502 // Calls updateVisibleValidationMessage() even if m_isValid is not | 509 // Calls updateVisibleValidationMessage() even if m_isValid is not |
| 503 // changed because a validation message can be changed. | 510 // changed because a validation message can be changed. |
| 504 updateVisibleValidationMessage(); | 511 updateVisibleValidationMessage(); |
| 505 } | 512 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 | 554 |
| 548 void HTMLFormControlElement::setFocus(bool flag) | 555 void HTMLFormControlElement::setFocus(bool flag) |
| 549 { | 556 { |
| 550 LabelableElement::setFocus(flag); | 557 LabelableElement::setFocus(flag); |
| 551 | 558 |
| 552 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 559 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
| 553 dispatchFormControlChangeEvent(); | 560 dispatchFormControlChangeEvent(); |
| 554 } | 561 } |
| 555 | 562 |
| 556 } // namespace blink | 563 } // namespace blink |
| OLD | NEW |