Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: Source/core/html/HTMLFormControlElement.cpp

Issue 601633004: Revert "Revert of Fix update of validity cache value, so that it reflects the correct state of any … (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/html/HTMLFormControlElement.h ('k') | Source/core/html/HTMLInputElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); 476 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this);
476 RefPtrWillBeRawPtr<Document> originalDocument(document()); 477 RefPtrWillBeRawPtr<Document> originalDocument(document());
477 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam es::invalid)); 478 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam es::invalid));
478 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin alDocument == document()) 479 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin alDocument == document())
479 unhandledInvalidControls->append(this); 480 unhandledInvalidControls->append(this);
480 return false; 481 return false;
481 } 482 }
482 483
483 bool HTMLFormControlElement::isValidFormControlElement() 484 bool HTMLFormControlElement::isValidFormControlElement()
484 { 485 {
485 // If the following assertion fails, setNeedsValidityCheck() is not called 486 if (m_validityIsDirty) {
486 // correctly when something which changes validity is updated. 487 m_isValid = valid();
487 ASSERT(m_isValid == valid()); 488 m_validityIsDirty = false;
489 } else {
490 // If the following assertion fails, setNeedsValidityCheck() is not call ed
491 // correctly when something which changes validity is updated.
492 ASSERT(m_isValid == valid());
493 }
488 return m_isValid; 494 return m_isValid;
489 } 495 }
490 496
491 void HTMLFormControlElement::setNeedsValidityCheck() 497 void HTMLFormControlElement::setNeedsValidityCheck()
492 { 498 {
493 bool newIsValid = valid(); 499 if (willValidate()) {
494 if (willValidate() && newIsValid != m_isValid) {
495 // Update style for pseudo classes such as :valid :invalid. 500 // Update style for pseudo classes such as :valid :invalid.
496 setNeedsStyleRecalc(SubtreeStyleChange); 501 if (valid() != m_isValid)
tkent 2014/09/25 05:35:55 This is incorrect. Because setNeedsValidityCheck()
spartha 2014/09/25 06:38:05 As you suggest removing the validity cache should
502 setNeedsStyleRecalc(SubtreeStyleChange);
503 m_validityIsDirty = true;
497 } 504 }
498 m_isValid = newIsValid;
499 505
500 // Updates only if this control already has a validation message. 506 // Updates only if this control already has a validation message.
501 if (isValidationMessageVisible()) { 507 if (isValidationMessageVisible()) {
502 // Calls updateVisibleValidationMessage() even if m_isValid is not 508 // Calls updateVisibleValidationMessage() even if m_isValid is not
503 // changed because a validation message can be changed. 509 // changed because a validation message can be changed.
504 updateVisibleValidationMessage(); 510 updateVisibleValidationMessage();
505 } 511 }
506 } 512 }
507 513
508 void HTMLFormControlElement::setCustomValidity(const String& error) 514 void HTMLFormControlElement::setCustomValidity(const String& error)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 553
548 void HTMLFormControlElement::setFocus(bool flag) 554 void HTMLFormControlElement::setFocus(bool flag)
549 { 555 {
550 LabelableElement::setFocus(flag); 556 LabelableElement::setFocus(flag);
551 557
552 if (!flag && wasChangedSinceLastFormControlChangeEvent()) 558 if (!flag && wasChangedSinceLastFormControlChangeEvent())
553 dispatchFormControlChangeEvent(); 559 dispatchFormControlChangeEvent();
554 } 560 }
555 561
556 } // namespace blink 562 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/HTMLFormControlElement.h ('k') | Source/core/html/HTMLInputElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698