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

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

Issue 646543004: Implement :valid and :invalid pseudoclass for <form> (resubmitting) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Reorder matchesValidityPseudoClasses() Created 6 years, 2 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/HTMLFormElement.h ('k') | no next file » | 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, 2008, 2009 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 #if ENABLE(OILPAN) 102 #if ENABLE(OILPAN)
103 visitor->trace(m_pastNamesMap); 103 visitor->trace(m_pastNamesMap);
104 visitor->trace(m_radioButtonGroupScope); 104 visitor->trace(m_radioButtonGroupScope);
105 visitor->trace(m_associatedElements); 105 visitor->trace(m_associatedElements);
106 visitor->trace(m_imageElements); 106 visitor->trace(m_imageElements);
107 visitor->trace(m_pendingAutocompleteEventsQueue); 107 visitor->trace(m_pendingAutocompleteEventsQueue);
108 #endif 108 #endif
109 HTMLElement::trace(visitor); 109 HTMLElement::trace(visitor);
110 } 110 }
111 111
112 bool HTMLFormElement::matchesValidityPseudoClasses() const
113 {
114 return true;
115 }
116
117 bool HTMLFormElement::isValidElement()
118 {
119 return checkValidity();
120 }
121
112 bool HTMLFormElement::rendererIsNeeded(const RenderStyle& style) 122 bool HTMLFormElement::rendererIsNeeded(const RenderStyle& style)
113 { 123 {
114 if (!m_wasDemoted) 124 if (!m_wasDemoted)
115 return HTMLElement::rendererIsNeeded(style); 125 return HTMLElement::rendererIsNeeded(style);
116 126
117 ContainerNode* node = parentNode(); 127 ContainerNode* node = parentNode();
118 if (!node || !node->renderer()) 128 if (!node || !node->renderer())
119 return HTMLElement::rendererIsNeeded(style); 129 return HTMLElement::rendererIsNeeded(style);
120 RenderObject* parentRenderer = node->renderer(); 130 RenderObject* parentRenderer = node->renderer();
121 // FIXME: Shouldn't we also check for table caption (see |formIsTablePart| b elow). 131 // FIXME: Shouldn't we also check for table caption (see |formIsTablePart| b elow).
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 if (!elements[i]->isFormControlElement()) 716 if (!elements[i]->isFormControlElement())
707 continue; 717 continue;
708 HTMLFormControlElement* control = toHTMLFormControlElement(elements[i]); 718 HTMLFormControlElement* control = toHTMLFormControlElement(elements[i]);
709 if (control->isSuccessfulSubmitButton()) 719 if (control->isSuccessfulSubmitButton())
710 return control; 720 return control;
711 } 721 }
712 722
713 return 0; 723 return 0;
714 } 724 }
715 725
726 void HTMLFormElement::setNeedsValidityCheck()
727 {
728 // For now unconditionally order style recalculation, which triggers
729 // validity recalculation. In the near future, implement validity cache and
730 // recalculate style only if it changed.
731 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::createW ithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Invalid));
732 }
733
716 bool HTMLFormElement::checkValidity() 734 bool HTMLFormElement::checkValidity()
717 { 735 {
718 return !checkInvalidControlsAndCollectUnhandled(0); 736 return !checkInvalidControlsAndCollectUnhandled(0);
719 } 737 }
720 738
721 bool HTMLFormElement::checkInvalidControlsAndCollectUnhandled(WillBeHeapVector<R efPtrWillBeMember<FormAssociatedElement> >* unhandledInvalidControls) 739 bool HTMLFormElement::checkInvalidControlsAndCollectUnhandled(WillBeHeapVector<R efPtrWillBeMember<FormAssociatedElement> >* unhandledInvalidControls)
722 { 740 {
723 RefPtrWillBeRawPtr<HTMLFormElement> protector(this); 741 RefPtrWillBeRawPtr<HTMLFormElement> protector(this);
724 // Copy associatedElements because event handlers called from 742 // Copy associatedElements because event handlers called from
725 // HTMLFormControlElement::checkValidity() might change associatedElements. 743 // HTMLFormControlElement::checkValidity() might change associatedElements.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 } 859 }
842 860
843 void HTMLFormElement::setDemoted(bool demoted) 861 void HTMLFormElement::setDemoted(bool demoted)
844 { 862 {
845 if (demoted) 863 if (demoted)
846 UseCounter::count(document(), UseCounter::DemotedFormElement); 864 UseCounter::count(document(), UseCounter::DemotedFormElement);
847 m_wasDemoted = demoted; 865 m_wasDemoted = demoted;
848 } 866 }
849 867
850 } // namespace 868 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/HTMLFormElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698