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 // A change here could've affected the style of the form itself and |
496 setNeedsStyleRecalc(SubtreeStyleChange); | 496 // other form elemetns, so recaluclate the entire form's subtree. |
497 formOwner()->setNeedsStyleRecalc(SubtreeStyleChange); | |
keishi
2014/09/29 13:20:43
Form controls can use form attribute to get associ
Bartek Nowierski
2014/10/01 08:23:01
Done.
| |
497 } | 498 } |
498 m_isValid = newIsValid; | 499 m_isValid = newIsValid; |
499 | 500 |
500 // Updates only if this control already has a validation message. | 501 // Updates only if this control already has a validation message. |
501 if (isValidationMessageVisible()) { | 502 if (isValidationMessageVisible()) { |
502 // Calls updateVisibleValidationMessage() even if m_isValid is not | 503 // Calls updateVisibleValidationMessage() even if m_isValid is not |
503 // changed because a validation message can be changed. | 504 // changed because a validation message can be changed. |
504 updateVisibleValidationMessage(); | 505 updateVisibleValidationMessage(); |
505 } | 506 } |
506 } | 507 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 | 548 |
548 void HTMLFormControlElement::setFocus(bool flag) | 549 void HTMLFormControlElement::setFocus(bool flag) |
549 { | 550 { |
550 LabelableElement::setFocus(flag); | 551 LabelableElement::setFocus(flag); |
551 | 552 |
552 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 553 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
553 dispatchFormControlChangeEvent(); | 554 dispatchFormControlChangeEvent(); |
554 } | 555 } |
555 | 556 |
556 } // namespace blink | 557 } // namespace blink |
OLD | NEW |