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_validIsDirty(false) | |
tkent
2014/09/03 02:16:35
Initial value should be |true| conceptually.
spartha
2014/09/03 07:58:40
Done.
| |
61 , m_wasChangedSinceLastFormControlChangeEvent(false) | 62 , m_wasChangedSinceLastFormControlChangeEvent(false) |
62 , m_wasFocusedByMouse(false) | 63 , m_wasFocusedByMouse(false) |
63 { | 64 { |
64 setHasCustomStyleCallbacks(); | 65 setHasCustomStyleCallbacks(); |
65 associateByParser(form); | 66 associateByParser(form); |
66 } | 67 } |
67 | 68 |
68 HTMLFormControlElement::~HTMLFormControlElement() | 69 HTMLFormControlElement::~HTMLFormControlElement() |
69 { | 70 { |
70 #if !ENABLE(OILPAN) | 71 #if !ENABLE(OILPAN) |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
476 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); | 477 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); |
477 RefPtrWillBeRawPtr<Document> originalDocument(document()); | 478 RefPtrWillBeRawPtr<Document> originalDocument(document()); |
478 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam es::invalid)); | 479 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam es::invalid)); |
479 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin alDocument == document()) | 480 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin alDocument == document()) |
480 unhandledInvalidControls->append(this); | 481 unhandledInvalidControls->append(this); |
481 return false; | 482 return false; |
482 } | 483 } |
483 | 484 |
484 bool HTMLFormControlElement::isValidFormControlElement() | 485 bool HTMLFormControlElement::isValidFormControlElement() |
485 { | 486 { |
486 // If the following assertion fails, setNeedsValidityCheck() is not called | 487 if (m_validIsDirty) { |
487 // correctly when something which changes validity is updated. | 488 if (willValidate()) |
tkent
2014/09/03 02:16:35
Do we need this check? When !willValidate(), m_is
spartha
2014/09/03 07:58:40
Done.
| |
488 ASSERT(m_isValid == valid()); | 489 m_isValid = valid(); |
490 m_validIsDirty = false; | |
491 } | |
489 return m_isValid; | 492 return m_isValid; |
490 } | 493 } |
491 | 494 |
492 void HTMLFormControlElement::setNeedsValidityCheck() | 495 void HTMLFormControlElement::setNeedsValidityCheck() |
493 { | 496 { |
494 bool newIsValid = valid(); | 497 if (!m_validIsDirty && willValidate()) { |
495 if (willValidate() && newIsValid != m_isValid) { | |
496 // Update style for pseudo classes such as :valid :invalid. | 498 // Update style for pseudo classes such as :valid :invalid. |
497 setNeedsStyleRecalc(SubtreeStyleChange); | 499 setNeedsStyleRecalc(SubtreeStyleChange); |
500 m_validIsDirty = true; | |
498 } | 501 } |
499 m_isValid = newIsValid; | |
500 | 502 |
501 // Updates only if this control already has a validation message. | 503 // Updates only if this control already has a validation message. |
502 if (isValidationMessageVisible()) { | 504 if (isValidationMessageVisible()) { |
503 // Calls updateVisibleValidationMessage() even if m_isValid is not | 505 // Calls updateVisibleValidationMessage() even if m_isValid is not |
504 // changed because a validation message can be changed. | 506 // changed because a validation message can be changed. |
505 updateVisibleValidationMessage(); | 507 updateVisibleValidationMessage(); |
506 } | 508 } |
507 } | 509 } |
508 | 510 |
509 void HTMLFormControlElement::setCustomValidity(const String& error) | 511 void HTMLFormControlElement::setCustomValidity(const String& error) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 | 550 |
549 void HTMLFormControlElement::setFocus(bool flag) | 551 void HTMLFormControlElement::setFocus(bool flag) |
550 { | 552 { |
551 LabelableElement::setFocus(flag); | 553 LabelableElement::setFocus(flag); |
552 | 554 |
553 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 555 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
554 dispatchFormControlChangeEvent(); | 556 dispatchFormControlChangeEvent(); |
555 } | 557 } |
556 | 558 |
557 } // namespace Webcore | 559 } // namespace Webcore |
OLD | NEW |