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

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

Issue 1763553002: Invalidate :default pseudo classes when a default button is added or removed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: return -> continue Created 4 years, 9 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, 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 13 matching lines...) Expand all
24 24
25 #include "core/html/HTMLFormElement.h" 25 #include "core/html/HTMLFormElement.h"
26 26
27 #include "bindings/core/v8/ScriptController.h" 27 #include "bindings/core/v8/ScriptController.h"
28 #include "bindings/core/v8/ScriptEventListener.h" 28 #include "bindings/core/v8/ScriptEventListener.h"
29 #include "bindings/core/v8/UnionTypesCore.h" 29 #include "bindings/core/v8/UnionTypesCore.h"
30 #include "core/HTMLNames.h" 30 #include "core/HTMLNames.h"
31 #include "core/dom/Attribute.h" 31 #include "core/dom/Attribute.h"
32 #include "core/dom/Document.h" 32 #include "core/dom/Document.h"
33 #include "core/dom/ElementTraversal.h" 33 #include "core/dom/ElementTraversal.h"
34 #include "core/dom/IdTargetObserverRegistry.h"
35 #include "core/dom/NodeListsNodeData.h" 34 #include "core/dom/NodeListsNodeData.h"
36 #include "core/events/AutocompleteErrorEvent.h" 35 #include "core/events/AutocompleteErrorEvent.h"
37 #include "core/events/Event.h" 36 #include "core/events/Event.h"
38 #include "core/events/GenericEventQueue.h" 37 #include "core/events/GenericEventQueue.h"
39 #include "core/events/ScopedEventQueue.h" 38 #include "core/events/ScopedEventQueue.h"
40 #include "core/frame/LocalDOMWindow.h" 39 #include "core/frame/LocalDOMWindow.h"
41 #include "core/frame/LocalFrame.h" 40 #include "core/frame/LocalFrame.h"
42 #include "core/frame/UseCounter.h" 41 #include "core/frame/UseCounter.h"
43 #include "core/frame/csp/ContentSecurityPolicy.h" 42 #include "core/frame/csp/ContentSecurityPolicy.h"
44 #include "core/html/HTMLCollection.h" 43 #include "core/html/HTMLCollection.h"
(...skipping 19 matching lines...) Expand all
64 using namespace HTMLNames; 63 using namespace HTMLNames;
65 64
66 HTMLFormElement::HTMLFormElement(Document& document) 65 HTMLFormElement::HTMLFormElement(Document& document)
67 : HTMLElement(formTag, document) 66 : HTMLElement(formTag, document)
68 #if !ENABLE(OILPAN) 67 #if !ENABLE(OILPAN)
69 , m_weakPtrFactory(this) 68 , m_weakPtrFactory(this)
70 #endif 69 #endif
71 , m_associatedElementsAreDirty(false) 70 , m_associatedElementsAreDirty(false)
72 , m_imageElementsAreDirty(false) 71 , m_imageElementsAreDirty(false)
73 , m_hasElementsAssociatedByParser(false) 72 , m_hasElementsAssociatedByParser(false)
73 , m_hasElementsAssociatedByFormAttribute(false)
74 , m_didFinishParsingChildren(false) 74 , m_didFinishParsingChildren(false)
75 , m_wasUserSubmitted(false) 75 , m_wasUserSubmitted(false)
76 , m_isSubmittingOrInUserJSSubmitEvent(false) 76 , m_isSubmittingOrInUserJSSubmitEvent(false)
77 , m_shouldSubmit(false) 77 , m_shouldSubmit(false)
78 , m_isInResetFunction(false) 78 , m_isInResetFunction(false)
79 , m_wasDemoted(false) 79 , m_wasDemoted(false)
80 , m_pendingAutocompleteEventsQueue(GenericEventQueue::create(this)) 80 , m_pendingAutocompleteEventsQueue(GenericEventQueue::create(this))
81 { 81 {
82 } 82 }
83 83
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 setAttributeEventListener(EventTypeNames::autocompleteerror, createAttri buteEventListener(this, name, value, eventParameterName())); 522 setAttributeEventListener(EventTypeNames::autocompleteerror, createAttri buteEventListener(this, name, value, eventParameterName()));
523 } else { 523 } else {
524 HTMLElement::parseAttribute(name, oldValue, value); 524 HTMLElement::parseAttribute(name, oldValue, value);
525 } 525 }
526 } 526 }
527 527
528 void HTMLFormElement::associate(FormAssociatedElement& e) 528 void HTMLFormElement::associate(FormAssociatedElement& e)
529 { 529 {
530 m_associatedElementsAreDirty = true; 530 m_associatedElementsAreDirty = true;
531 m_associatedElements.clear(); 531 m_associatedElements.clear();
532 if (toHTMLElement(e).fastHasAttribute(formAttr))
533 m_hasElementsAssociatedByFormAttribute = true;
532 } 534 }
533 535
534 void HTMLFormElement::disassociate(FormAssociatedElement& e) 536 void HTMLFormElement::disassociate(FormAssociatedElement& e)
535 { 537 {
536 m_associatedElementsAreDirty = true; 538 m_associatedElementsAreDirty = true;
537 m_associatedElements.clear(); 539 m_associatedElements.clear();
538 removeFromPastNamesMap(toHTMLElement(e)); 540 removeFromPastNamesMap(toHTMLElement(e));
539 } 541 }
540 542
541 bool HTMLFormElement::isURLAttribute(const Attribute& attribute) const 543 bool HTMLFormElement::isURLAttribute(const Attribute& attribute) const
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 // This function should be const conceptually. However we update some fields 602 // This function should be const conceptually. However we update some fields
601 // because of lazy evaluation. 603 // because of lazy evaluation.
602 const FormAssociatedElement::List& HTMLFormElement::associatedElements() const 604 const FormAssociatedElement::List& HTMLFormElement::associatedElements() const
603 { 605 {
604 if (!m_associatedElementsAreDirty) 606 if (!m_associatedElementsAreDirty)
605 return m_associatedElements; 607 return m_associatedElements;
606 HTMLFormElement* mutableThis = const_cast<HTMLFormElement*>(this); 608 HTMLFormElement* mutableThis = const_cast<HTMLFormElement*>(this);
607 Node* scope = mutableThis; 609 Node* scope = mutableThis;
608 if (m_hasElementsAssociatedByParser) 610 if (m_hasElementsAssociatedByParser)
609 scope = &NodeTraversal::highestAncestorOrSelf(*mutableThis); 611 scope = &NodeTraversal::highestAncestorOrSelf(*mutableThis);
610 if (inDocument() && treeScope().idTargetObserverRegistry().hasObservers(fast GetAttribute(idAttr))) 612 if (inDocument() && m_hasElementsAssociatedByFormAttribute)
611 scope = &treeScope().rootNode(); 613 scope = &treeScope().rootNode();
612 ASSERT(scope); 614 ASSERT(scope);
613 collectAssociatedElements(*scope, mutableThis->m_associatedElements); 615 collectAssociatedElements(*scope, mutableThis->m_associatedElements);
614 mutableThis->m_associatedElementsAreDirty = false; 616 mutableThis->m_associatedElementsAreDirty = false;
615 return m_associatedElements; 617 return m_associatedElements;
616 } 618 }
617 619
618 void HTMLFormElement::collectImageElements(Node& root, WillBeHeapVector<RawPtrWi llBeMember<HTMLImageElement>>& elements) 620 void HTMLFormElement::collectImageElements(Node& root, WillBeHeapVector<RawPtrWi llBeMember<HTMLImageElement>>& elements)
619 { 621 {
620 elements.clear(); 622 elements.clear();
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 returnValue.setRadioNodeList(radioNodeList(name, onlyMatchImg)); 832 returnValue.setRadioNodeList(radioNodeList(name, onlyMatchImg));
831 } 833 }
832 834
833 void HTMLFormElement::setDemoted(bool demoted) 835 void HTMLFormElement::setDemoted(bool demoted)
834 { 836 {
835 if (demoted) 837 if (demoted)
836 UseCounter::count(document(), UseCounter::DemotedFormElement); 838 UseCounter::count(document(), UseCounter::DemotedFormElement);
837 m_wasDemoted = demoted; 839 m_wasDemoted = demoted;
838 } 840 }
839 841
842 void HTMLFormElement::invalidateDefaultButtonStyle() const
843 {
844 for (const auto& control : associatedElements()) {
845 if (!control->isFormControlElement())
846 continue;
847 if (toHTMLFormControlElement(control)->canBeSuccessfulSubmitButton())
848 toHTMLFormControlElement(control)->pseudoStateChanged(CSSSelector::P seudoDefault);
849 }
850 }
851
840 } // namespace blink 852 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLFormElement.h ('k') | third_party/WebKit/Source/core/html/HTMLInputElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698