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

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

Issue 460343004: Fix update of validity cache value, so that it reflects the correct state of any FormControlElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this); 467 RefPtrWillBeRawPtr<HTMLFormControlElement> protector(this);
467 RefPtrWillBeRawPtr<Document> originalDocument(document()); 468 RefPtrWillBeRawPtr<Document> originalDocument(document());
468 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam es::invalid)); 469 bool needsDefaultAction = dispatchEvent(Event::createCancelable(EventTypeNam es::invalid));
469 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin alDocument == document()) 470 if (needsDefaultAction && unhandledInvalidControls && inDocument() && origin alDocument == document())
470 unhandledInvalidControls->append(this); 471 unhandledInvalidControls->append(this);
471 return false; 472 return false;
472 } 473 }
473 474
474 bool HTMLFormControlElement::isValidFormControlElement() 475 bool HTMLFormControlElement::isValidFormControlElement()
475 { 476 {
476 // If the following assertion fails, setNeedsValidityCheck() is not called 477 if (m_validityIsDirty) {
477 // correctly when something which changes validity is updated. 478 m_isValid = valid();
478 ASSERT(m_isValid == valid()); 479 m_validityIsDirty = false;
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 }
479 return m_isValid; 485 return m_isValid;
480 } 486 }
481 487
482 void HTMLFormControlElement::setNeedsValidityCheck() 488 void HTMLFormControlElement::setNeedsValidityCheck()
483 { 489 {
484 bool newIsValid = valid(); 490 if (!m_validityIsDirty && willValidate()) {
485 if (willValidate() && newIsValid != m_isValid) {
486 // Update style for pseudo classes such as :valid :invalid. 491 // Update style for pseudo classes such as :valid :invalid.
487 setNeedsStyleRecalc(SubtreeStyleChange); 492 setNeedsStyleRecalc(SubtreeStyleChange);
493 m_validityIsDirty = true;
488 } 494 }
489 m_isValid = newIsValid;
490 495
491 // Updates only if this control already has a validation message. 496 // Updates only if this control already has a validation message.
492 if (isValidationMessageVisible()) { 497 if (isValidationMessageVisible()) {
493 // Calls updateVisibleValidationMessage() even if m_isValid is not 498 // Calls updateVisibleValidationMessage() even if m_isValid is not
494 // changed because a validation message can be changed. 499 // changed because a validation message can be changed.
495 updateVisibleValidationMessage(); 500 updateVisibleValidationMessage();
496 } 501 }
497 } 502 }
498 503
499 void HTMLFormControlElement::setCustomValidity(const String& error) 504 void HTMLFormControlElement::setCustomValidity(const String& error)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 543
539 void HTMLFormControlElement::setFocus(bool flag) 544 void HTMLFormControlElement::setFocus(bool flag)
540 { 545 {
541 LabelableElement::setFocus(flag); 546 LabelableElement::setFocus(flag);
542 547
543 if (!flag && wasChangedSinceLastFormControlChangeEvent()) 548 if (!flag && wasChangedSinceLastFormControlChangeEvent())
544 dispatchFormControlChangeEvent(); 549 dispatchFormControlChangeEvent();
545 } 550 }
546 551
547 } // namespace Webcore 552 } // namespace Webcore
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