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) | |
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_validityIsDirty) { |
487 // correctly when something which changes validity is updated. | 488 m_isValid = valid(); |
488 ASSERT(m_isValid == valid()); | 489 m_validityIsDirty = false; |
490 } | |
tkent
2014/09/03 08:04:44
We should keep the ASSERT if !m_validityIsDirty.
spartha
2014/09/03 08:50:57
Wouldn't two calls to element.checkValidity() caus
tkent
2014/09/03 09:11:27
I don't think so.
spartha
2014/09/03 14:47:33
Done. You are right. I missed the placement of the
| |
489 return m_isValid; | 491 return m_isValid; |
490 } | 492 } |
491 | 493 |
492 void HTMLFormControlElement::setNeedsValidityCheck() | 494 void HTMLFormControlElement::setNeedsValidityCheck() |
493 { | 495 { |
494 bool newIsValid = valid(); | 496 if (!m_validityIsDirty && willValidate()) { |
495 if (willValidate() && newIsValid != m_isValid) { | |
496 // Update style for pseudo classes such as :valid :invalid. | 497 // Update style for pseudo classes such as :valid :invalid. |
497 setNeedsStyleRecalc(SubtreeStyleChange); | 498 setNeedsStyleRecalc(SubtreeStyleChange); |
499 m_validityIsDirty = true; | |
498 } | 500 } |
499 m_isValid = newIsValid; | |
500 | 501 |
501 // Updates only if this control already has a validation message. | 502 // Updates only if this control already has a validation message. |
502 if (isValidationMessageVisible()) { | 503 if (isValidationMessageVisible()) { |
503 // Calls updateVisibleValidationMessage() even if m_isValid is not | 504 // Calls updateVisibleValidationMessage() even if m_isValid is not |
504 // changed because a validation message can be changed. | 505 // changed because a validation message can be changed. |
505 updateVisibleValidationMessage(); | 506 updateVisibleValidationMessage(); |
506 } | 507 } |
507 } | 508 } |
508 | 509 |
509 void HTMLFormControlElement::setCustomValidity(const String& error) | 510 void HTMLFormControlElement::setCustomValidity(const String& error) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 | 549 |
549 void HTMLFormControlElement::setFocus(bool flag) | 550 void HTMLFormControlElement::setFocus(bool flag) |
550 { | 551 { |
551 LabelableElement::setFocus(flag); | 552 LabelableElement::setFocus(flag); |
552 | 553 |
553 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 554 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
554 dispatchFormControlChangeEvent(); | 555 dispatchFormControlChangeEvent(); |
555 } | 556 } |
556 | 557 |
557 } // namespace Webcore | 558 } // namespace Webcore |
OLD | NEW |