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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 , m_disabled(false) | 51 , m_disabled(false) |
52 , m_isAutofilled(false) | 52 , m_isAutofilled(false) |
53 , m_isReadOnly(false) | 53 , m_isReadOnly(false) |
54 , m_isRequired(false) | 54 , m_isRequired(false) |
55 , m_hasValidationMessage(false) | 55 , m_hasValidationMessage(false) |
56 , m_ancestorDisabledState(AncestorDisabledStateUnknown) | 56 , m_ancestorDisabledState(AncestorDisabledStateUnknown) |
57 , m_dataListAncestorState(Unknown) | 57 , m_dataListAncestorState(Unknown) |
58 , m_willValidateInitialized(false) | 58 , m_willValidateInitialized(false) |
59 , m_willValidate(true) | 59 , m_willValidate(true) |
60 , m_isValid(true) | 60 , m_isValid(true) |
61 , m_validityIsDirty(true) | |
62 , m_wasChangedSinceLastFormControlChangeEvent(false) | 61 , m_wasChangedSinceLastFormControlChangeEvent(false) |
63 , m_wasFocusedByMouse(false) | 62 , m_wasFocusedByMouse(false) |
64 { | 63 { |
65 setHasCustomStyleCallbacks(); | 64 setHasCustomStyleCallbacks(); |
66 associateByParser(form); | 65 associateByParser(form); |
67 } | 66 } |
68 | 67 |
69 HTMLFormControlElement::~HTMLFormControlElement() | 68 HTMLFormControlElement::~HTMLFormControlElement() |
70 { | 69 { |
71 #if !ENABLE(OILPAN) | 70 #if !ENABLE(OILPAN) |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); | 466 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); |
468 RefPtrWillBeRawPtr<Document> originalDocument(document()); | 467 RefPtrWillBeRawPtr<Document> originalDocument(document()); |
469 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam
es::invalid)); | 468 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam
es::invalid)); |
470 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin
alDocument == document()) | 469 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin
alDocument == document()) |
471 unhandledInvalidControls->append(this); | 470 unhandledInvalidControls->append(this); |
472 return false; | 471 return false; |
473 } | 472 } |
474 | 473 |
475 bool HTMLFormControlElement::isValidFormControlElement() | 474 bool HTMLFormControlElement::isValidFormControlElement() |
476 { | 475 { |
477 if (m_validityIsDirty) { | 476 // If the following assertion fails, setNeedsValidityCheck() is not called |
478 m_isValid = valid(); | 477 // correctly when something which changes validity is updated. |
479 m_validityIsDirty = false; | 478 ASSERT(m_isValid == valid()); |
480 } else { | |
481 // If the following assertion fails, setNeedsValidityCheck() is not call
ed | |
482 // correctly when something which changes validity is updated. | |
483 ASSERT(m_isValid == valid()); | |
484 } | |
485 return m_isValid; | 479 return m_isValid; |
486 } | 480 } |
487 | 481 |
488 void HTMLFormControlElement::setNeedsValidityCheck() | 482 void HTMLFormControlElement::setNeedsValidityCheck() |
489 { | 483 { |
490 if (!m_validityIsDirty && willValidate()) { | 484 bool newIsValid = valid(); |
| 485 if (willValidate() && newIsValid != m_isValid) { |
491 // Update style for pseudo classes such as :valid :invalid. | 486 // Update style for pseudo classes such as :valid :invalid. |
492 setNeedsStyleRecalc(SubtreeStyleChange); | 487 setNeedsStyleRecalc(SubtreeStyleChange); |
493 m_validityIsDirty = true; | |
494 } | 488 } |
| 489 m_isValid = newIsValid; |
495 | 490 |
496 // Updates only if this control already has a validation message. | 491 // Updates only if this control already has a validation message. |
497 if (isValidationMessageVisible()) { | 492 if (isValidationMessageVisible()) { |
498 // Calls updateVisibleValidationMessage() even if m_isValid is not | 493 // Calls updateVisibleValidationMessage() even if m_isValid is not |
499 // changed because a validation message can be changed. | 494 // changed because a validation message can be changed. |
500 updateVisibleValidationMessage(); | 495 updateVisibleValidationMessage(); |
501 } | 496 } |
502 } | 497 } |
503 | 498 |
504 void HTMLFormControlElement::setCustomValidity(const String& error) | 499 void HTMLFormControlElement::setCustomValidity(const String& error) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 | 538 |
544 void HTMLFormControlElement::setFocus(bool flag) | 539 void HTMLFormControlElement::setFocus(bool flag) |
545 { | 540 { |
546 LabelableElement::setFocus(flag); | 541 LabelableElement::setFocus(flag); |
547 | 542 |
548 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 543 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
549 dispatchFormControlChangeEvent(); | 544 dispatchFormControlChangeEvent(); |
550 } | 545 } |
551 | 546 |
552 } // namespace Webcore | 547 } // namespace Webcore |
OLD | NEW |