Index: Source/core/html/HTMLLabelElement.cpp |
diff --git a/Source/core/html/HTMLLabelElement.cpp b/Source/core/html/HTMLLabelElement.cpp |
index 354514026d3d51c1dd607049a2a51fe6a5a756e5..e9097f9dfee6b6043b0bba301fc28336f4cc08ec 100644 |
--- a/Source/core/html/HTMLLabelElement.cpp |
+++ b/Source/core/html/HTMLLabelElement.cpp |
@@ -37,12 +37,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 |
{ |
@@ -74,7 +79,7 @@ LabelableElement* HTMLLabelElement::control() const |
HTMLFormElement* HTMLLabelElement::formOwner() const |
{ |
- return FormAssociatedElement::findAssociatedForm(this); |
+ return !fastGetAttribute(formAttr).isNull() ? FormAssociatedElement::findAssociatedForm(this) : FormAssociatedElement::form(); |
keishi
2014/09/16 01:59:19
I think we shouldn't need to use findAssociatedFor
spartha
2014/09/17 11:02:18
Done.
|
} |
void HTMLLabelElement::setActive(bool down) |
@@ -197,10 +202,11 @@ void HTMLLabelElement::updateLabel(TreeScope& scope, const AtomicString& oldForA |
if (oldForAttributeValue == newForAttributeValue) |
return; |
+ HTMLElement* label = this; |
if (!oldForAttributeValue.isEmpty()) |
- scope.removeLabel(oldForAttributeValue, toHTMLLabelElement(this)); |
+ scope.removeLabel(oldForAttributeValue, toHTMLLabelElement(label)); |
keishi
2014/09/16 01:59:19
I think we don't need to use toHTMLLabelElement an
spartha
2014/09/17 11:02:18
Done.
|
if (!newForAttributeValue.isEmpty()) |
- scope.addLabel(newForAttributeValue, toHTMLLabelElement(this)); |
+ scope.addLabel(newForAttributeValue, toHTMLLabelElement(label)); |
} |
void HTMLLabelElement::attributeWillChange(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue) |
@@ -216,6 +222,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()) |
@@ -232,6 +239,13 @@ 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); |
} |
} // namespace |