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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/HTMLFormElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLFormElement.cpp b/third_party/WebKit/Source/core/html/HTMLFormElement.cpp
index 515f3179af598d069e47faf41a10bde78c9eb49e..978394019ed30490d4b3ac1942c8f025ae5db17c 100644
--- a/third_party/WebKit/Source/core/html/HTMLFormElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLFormElement.cpp
@@ -31,7 +31,6 @@
#include "core/dom/Attribute.h"
#include "core/dom/Document.h"
#include "core/dom/ElementTraversal.h"
-#include "core/dom/IdTargetObserverRegistry.h"
#include "core/dom/NodeListsNodeData.h"
#include "core/events/AutocompleteErrorEvent.h"
#include "core/events/Event.h"
@@ -71,6 +70,7 @@ HTMLFormElement::HTMLFormElement(Document& document)
, m_associatedElementsAreDirty(false)
, m_imageElementsAreDirty(false)
, m_hasElementsAssociatedByParser(false)
+ , m_hasElementsAssociatedByFormAttribute(false)
, m_didFinishParsingChildren(false)
, m_wasUserSubmitted(false)
, m_isSubmittingOrInUserJSSubmitEvent(false)
@@ -529,6 +529,8 @@ void HTMLFormElement::associate(FormAssociatedElement& e)
{
m_associatedElementsAreDirty = true;
m_associatedElements.clear();
+ if (toHTMLElement(e).fastHasAttribute(formAttr))
+ m_hasElementsAssociatedByFormAttribute = true;
}
void HTMLFormElement::disassociate(FormAssociatedElement& e)
@@ -607,7 +609,7 @@ const FormAssociatedElement::List& HTMLFormElement::associatedElements() const
Node* scope = mutableThis;
if (m_hasElementsAssociatedByParser)
scope = &NodeTraversal::highestAncestorOrSelf(*mutableThis);
- if (inDocument() && treeScope().idTargetObserverRegistry().hasObservers(fastGetAttribute(idAttr)))
+ if (inDocument() && m_hasElementsAssociatedByFormAttribute)
scope = &treeScope().rootNode();
ASSERT(scope);
collectAssociatedElements(*scope, mutableThis->m_associatedElements);
@@ -837,4 +839,14 @@ void HTMLFormElement::setDemoted(bool demoted)
m_wasDemoted = demoted;
}
+void HTMLFormElement::invalidateDefaultButtonStyle() const
+{
+ for (const auto& control : associatedElements()) {
+ if (!control->isFormControlElement())
+ continue;
+ if (toHTMLFormControlElement(control)->canBeSuccessfulSubmitButton())
+ toHTMLFormControlElement(control)->pseudoStateChanged(CSSSelector::PseudoDefault);
+ }
+}
+
} // namespace blink
« 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