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

Unified Diff: Source/core/html/HTMLLabelElement.cpp

Issue 569993002: <label> should support form association by parser (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLLabelElement.h ('k') | Source/core/html/HTMLObjectElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLLabelElement.cpp
diff --git a/Source/core/html/HTMLLabelElement.cpp b/Source/core/html/HTMLLabelElement.cpp
index 30c51e2ae048c74e96dce874f35072ac0f9f94ea..7c8ee1632883de633887bd18b8f2679664cde018 100644
--- a/Source/core/html/HTMLLabelElement.cpp
+++ b/Source/core/html/HTMLLabelElement.cpp
@@ -38,12 +38,17 @@ namespace blink {
using namespace HTMLNames;
-inline HTMLLabelElement::HTMLLabelElement(Document& document)
+inline HTMLLabelElement::HTMLLabelElement(Document& document, HTMLFormElement* form)
: HTMLElement(labelTag, document)
{
+ FormAssociatedElement::associateByParser(form);
}
-DEFINE_NODE_FACTORY(HTMLLabelElement)
+PassRefPtrWillBeRawPtr<HTMLLabelElement> HTMLLabelElement::create(Document& document, HTMLFormElement* form)
+{
+ RefPtrWillBeRawPtr<HTMLLabelElement> labelElement = adoptRefWillBeNoop(new HTMLLabelElement(document, form));
+ return labelElement.release();
+}
bool HTMLLabelElement::rendererIsFocusable() const
{
@@ -75,7 +80,7 @@ LabelableElement* HTMLLabelElement::control() const
HTMLFormElement* HTMLLabelElement::formOwner() const
{
- return FormAssociatedElement::findAssociatedForm(this);
+ return FormAssociatedElement::form();
}
void HTMLLabelElement::setActive(bool down)
@@ -226,9 +231,9 @@ void HTMLLabelElement::updateLabel(TreeScope& scope, const AtomicString& oldForA
return;
if (!oldForAttributeValue.isEmpty())
- scope.removeLabel(oldForAttributeValue, toHTMLLabelElement(this));
+ scope.removeLabel(oldForAttributeValue, this);
if (!newForAttributeValue.isEmpty())
- scope.addLabel(newForAttributeValue, toHTMLLabelElement(this));
+ scope.addLabel(newForAttributeValue, this);
}
void HTMLLabelElement::attributeWillChange(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue)
@@ -244,6 +249,7 @@ void HTMLLabelElement::attributeWillChange(const QualifiedName& name, const Atom
Node::InsertionNotificationRequest HTMLLabelElement::insertedInto(ContainerNode* insertionPoint)
{
InsertionNotificationRequest result = HTMLElement::insertedInto(insertionPoint);
+ FormAssociatedElement::insertedInto(insertionPoint);
if (insertionPoint->isInTreeScope()) {
TreeScope& scope = insertionPoint->treeScope();
if (scope == treeScope() && scope.shouldCacheLabelsByForAttribute())
@@ -260,6 +266,21 @@ void HTMLLabelElement::removedFrom(ContainerNode* insertionPoint)
updateLabel(treeScope, fastGetAttribute(forAttr), nullAtom);
}
HTMLElement::removedFrom(insertionPoint);
+ FormAssociatedElement::removedFrom(insertionPoint);
+}
+
+void HTMLLabelElement::trace(Visitor* visitor)
+{
+ HTMLElement::trace(visitor);
+ FormAssociatedElement::trace(visitor);
+}
+
+void HTMLLabelElement::parseAttribute(const QualifiedName& attributeName, const AtomicString& attributeValue)
+{
+ if (attributeName == formAttr)
+ formAttributeChanged();
+ else
+ HTMLElement::parseAttribute(attributeName, attributeValue);
}
} // namespace
« no previous file with comments | « Source/core/html/HTMLLabelElement.h ('k') | Source/core/html/HTMLObjectElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698