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

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

Issue 2258033002: Replace ASSERT()s with DCHECK*() in core/html/*.{cpp,h}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace ASSERT()s with DCHECK*() in core/html/*.{cpp,h}. Created 4 years, 4 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
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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } 442 }
443 443
444 bool HTMLFormControlElement::willValidate() const 444 bool HTMLFormControlElement::willValidate() const
445 { 445 {
446 if (!m_willValidateInitialized || m_dataListAncestorState == Unknown) { 446 if (!m_willValidateInitialized || m_dataListAncestorState == Unknown) {
447 const_cast<HTMLFormControlElement*>(this)->setNeedsWillValidateCheck(); 447 const_cast<HTMLFormControlElement*>(this)->setNeedsWillValidateCheck();
448 } else { 448 } else {
449 // If the following assertion fails, setNeedsWillValidateCheck() is not 449 // If the following assertion fails, setNeedsWillValidateCheck() is not
450 // called correctly when something which changes recalcWillValidate() re sult 450 // called correctly when something which changes recalcWillValidate() re sult
451 // is updated. 451 // is updated.
452 ASSERT(m_willValidate == recalcWillValidate()); 452 DCHECK_EQ(m_willValidate, recalcWillValidate());
453 } 453 }
454 return m_willValidate; 454 return m_willValidate;
455 } 455 }
456 456
457 void HTMLFormControlElement::setNeedsWillValidateCheck() 457 void HTMLFormControlElement::setNeedsWillValidateCheck()
458 { 458 {
459 // We need to recalculate willValidate immediately because willValidate chan ge can causes style change. 459 // We need to recalculate willValidate immediately because willValidate chan ge can causes style change.
460 bool newWillValidate = recalcWillValidate(); 460 bool newWillValidate = recalcWillValidate();
461 if (m_willValidateInitialized && m_willValidate == newWillValidate) 461 if (m_willValidateInitialized && m_willValidate == newWillValidate)
462 return; 462 return;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 focus(); 557 focus();
558 updateVisibleValidationMessage(); 558 updateVisibleValidationMessage();
559 } 559 }
560 560
561 bool HTMLFormControlElement::reportValidity() 561 bool HTMLFormControlElement::reportValidity()
562 { 562 {
563 HeapVector<Member<HTMLFormControlElement>> unhandledInvalidControls; 563 HeapVector<Member<HTMLFormControlElement>> unhandledInvalidControls;
564 bool isValid = checkValidity(&unhandledInvalidControls, CheckValidityDispatc hInvalidEvent); 564 bool isValid = checkValidity(&unhandledInvalidControls, CheckValidityDispatc hInvalidEvent);
565 if (isValid || unhandledInvalidControls.isEmpty()) 565 if (isValid || unhandledInvalidControls.isEmpty())
566 return isValid; 566 return isValid;
567 ASSERT(unhandledInvalidControls.size() == 1); 567 DCHECK_EQ(unhandledInvalidControls.size(), 1u);
568 ASSERT(unhandledInvalidControls[0].get() == this); 568 DCHECK_EQ(unhandledInvalidControls[0].get(), this);
569 // Update layout now before calling isFocusable(), which has 569 // Update layout now before calling isFocusable(), which has
570 // !layoutObject()->needsLayout() assertion. 570 // !layoutObject()->needsLayout() assertion.
571 document().updateStyleAndLayoutIgnorePendingStylesheets(); 571 document().updateStyleAndLayoutIgnorePendingStylesheets();
572 if (isFocusable()) { 572 if (isFocusable()) {
573 showValidationMessage(); 573 showValidationMessage();
574 return false; 574 return false;
575 } 575 }
576 if (document().frame()) { 576 if (document().frame()) {
577 String message("An invalid form control with name='%name' is not focusab le."); 577 String message("An invalid form control with name='%name' is not focusab le.");
578 message.replace("%name", name()); 578 message.replace("%name", name());
579 document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSour ce, ErrorMessageLevel, message)); 579 document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSour ce, ErrorMessageLevel, message));
580 } 580 }
581 return false; 581 return false;
582 } 582 }
583 583
584 bool HTMLFormControlElement::matchesValidityPseudoClasses() const 584 bool HTMLFormControlElement::matchesValidityPseudoClasses() const
585 { 585 {
586 return willValidate(); 586 return willValidate();
587 } 587 }
588 588
589 bool HTMLFormControlElement::isValidElement() 589 bool HTMLFormControlElement::isValidElement()
590 { 590 {
591 if (m_validityIsDirty) { 591 if (m_validityIsDirty) {
592 m_isValid = !willValidate() || valid(); 592 m_isValid = !willValidate() || valid();
593 m_validityIsDirty = false; 593 m_validityIsDirty = false;
594 } else { 594 } else {
595 // If the following assertion fails, setNeedsValidityCheck() is not 595 // If the following assertion fails, setNeedsValidityCheck() is not
596 // called correctly when something which changes validity is updated. 596 // called correctly when something which changes validity is updated.
597 ASSERT(m_isValid == (!willValidate() || valid())); 597 DCHECK_EQ(m_isValid, (!willValidate() || valid()));
598 } 598 }
599 return m_isValid; 599 return m_isValid;
600 } 600 }
601 601
602 void HTMLFormControlElement::setNeedsValidityCheck() 602 void HTMLFormControlElement::setNeedsValidityCheck()
603 { 603 {
604 if (!m_validityIsDirty) { 604 if (!m_validityIsDirty) {
605 m_validityIsDirty = true; 605 m_validityIsDirty = true;
606 formOwnerSetNeedsValidityCheck(); 606 formOwnerSetNeedsValidityCheck();
607 fieldSetAncestorsSetNeedsValidityCheck(parentNode()); 607 fieldSetAncestorsSetNeedsValidityCheck(parentNode());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 dispatchFormControlChangeEvent(); 662 dispatchFormControlChangeEvent();
663 } 663 }
664 664
665 void HTMLFormControlElement::copyNonAttributePropertiesFromElement(const Element & source) 665 void HTMLFormControlElement::copyNonAttributePropertiesFromElement(const Element & source)
666 { 666 {
667 HTMLElement::copyNonAttributePropertiesFromElement(source); 667 HTMLElement::copyNonAttributePropertiesFromElement(source);
668 setNeedsValidityCheck(); 668 setNeedsValidityCheck();
669 } 669 }
670 670
671 } // namespace blink 671 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698