| OLD | NEW |
| 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, 2010 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved. |
| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 for (LabelableElement& element : Traversal<LabelableElement>::descendant
sOf(*this)) { | 65 for (LabelableElement& element : Traversal<LabelableElement>::descendant
sOf(*this)) { |
| 66 if (element.supportLabels()) { | 66 if (element.supportLabels()) { |
| 67 if (!element.isFormControlElement()) | 67 if (!element.isFormControlElement()) |
| 68 UseCounter::count(document(), UseCounter::HTMLLabelElementCo
ntrolForNonFormAssociatedElement); | 68 UseCounter::count(document(), UseCounter::HTMLLabelElementCo
ntrolForNonFormAssociatedElement); |
| 69 return &element; | 69 return &element; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 return nullptr; | 72 return nullptr; |
| 73 } | 73 } |
| 74 | 74 |
| 75 if (Element* element = treeScope().getElementById(controlId)) { | 75 if (Element* element = treeScopeOrDocument().getElementById(controlId)) { |
| 76 if (isLabelableElement(*element) && toLabelableElement(*element).support
Labels()) { | 76 if (isLabelableElement(*element) && toLabelableElement(*element).support
Labels()) { |
| 77 if (!element->isFormControlElement()) | 77 if (!element->isFormControlElement()) |
| 78 UseCounter::count(document(), UseCounter::HTMLLabelElementContro
lForNonFormAssociatedElement); | 78 UseCounter::count(document(), UseCounter::HTMLLabelElementContro
lForNonFormAssociatedElement); |
| 79 return toLabelableElement(element); | 79 return toLabelableElement(element); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 return nullptr; | 83 return nullptr; |
| 84 } | 84 } |
| 85 | 85 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 scope.removeLabel(oldForAttributeValue, this); | 255 scope.removeLabel(oldForAttributeValue, this); |
| 256 if (!newForAttributeValue.isEmpty()) | 256 if (!newForAttributeValue.isEmpty()) |
| 257 scope.addLabel(newForAttributeValue, this); | 257 scope.addLabel(newForAttributeValue, this); |
| 258 } | 258 } |
| 259 | 259 |
| 260 Node::InsertionNotificationRequest HTMLLabelElement::insertedInto(ContainerNode*
insertionPoint) | 260 Node::InsertionNotificationRequest HTMLLabelElement::insertedInto(ContainerNode*
insertionPoint) |
| 261 { | 261 { |
| 262 InsertionNotificationRequest result = HTMLElement::insertedInto(insertionPoi
nt); | 262 InsertionNotificationRequest result = HTMLElement::insertedInto(insertionPoi
nt); |
| 263 FormAssociatedElement::insertedInto(insertionPoint); | 263 FormAssociatedElement::insertedInto(insertionPoint); |
| 264 if (insertionPoint->isInTreeScope()) { | 264 if (insertionPoint->isInTreeScope()) { |
| 265 TreeScope& scope = insertionPoint->treeScope(); | 265 TreeScope& scope = insertionPoint->treeScopeOrDocument(); |
| 266 if (scope == treeScope() && scope.shouldCacheLabelsByForAttribute()) | 266 if (scope == treeScopeOrDocument() && scope.shouldCacheLabelsByForAttrib
ute()) |
| 267 updateLabel(scope, nullAtom, fastGetAttribute(forAttr)); | 267 updateLabel(scope, nullAtom, fastGetAttribute(forAttr)); |
| 268 } | 268 } |
| 269 | 269 |
| 270 // Trigger for elements outside of forms. | 270 // Trigger for elements outside of forms. |
| 271 if (!formOwner() && insertionPoint->inShadowIncludingDocument()) | 271 if (!formOwner() && insertionPoint->inShadowIncludingDocument()) |
| 272 document().didAssociateFormControl(this); | 272 document().didAssociateFormControl(this); |
| 273 | 273 |
| 274 return result; | 274 return result; |
| 275 } | 275 } |
| 276 | 276 |
| 277 void HTMLLabelElement::removedFrom(ContainerNode* insertionPoint) | 277 void HTMLLabelElement::removedFrom(ContainerNode* insertionPoint) |
| 278 { | 278 { |
| 279 if (insertionPoint->isInTreeScope() && treeScope() == document()) { | 279 if (insertionPoint->isInTreeScope() && treeScopeOrDocument() == document())
{ |
| 280 TreeScope& treeScope = insertionPoint->treeScope(); | 280 TreeScope& treeScope = insertionPoint->treeScopeOrDocument(); |
| 281 if (treeScope.shouldCacheLabelsByForAttribute()) | 281 if (treeScope.shouldCacheLabelsByForAttribute()) |
| 282 updateLabel(treeScope, fastGetAttribute(forAttr), nullAtom); | 282 updateLabel(treeScope, fastGetAttribute(forAttr), nullAtom); |
| 283 } | 283 } |
| 284 HTMLElement::removedFrom(insertionPoint); | 284 HTMLElement::removedFrom(insertionPoint); |
| 285 FormAssociatedElement::removedFrom(insertionPoint); | 285 FormAssociatedElement::removedFrom(insertionPoint); |
| 286 document().removeFormAssociation(this); | 286 document().removeFormAssociation(this); |
| 287 } | 287 } |
| 288 | 288 |
| 289 DEFINE_TRACE(HTMLLabelElement) | 289 DEFINE_TRACE(HTMLLabelElement) |
| 290 { | 290 { |
| 291 HTMLElement::trace(visitor); | 291 HTMLElement::trace(visitor); |
| 292 FormAssociatedElement::trace(visitor); | 292 FormAssociatedElement::trace(visitor); |
| 293 } | 293 } |
| 294 | 294 |
| 295 void HTMLLabelElement::parseAttribute(const QualifiedName& attributeName, const
AtomicString& oldValue, const AtomicString& attributeValue) | 295 void HTMLLabelElement::parseAttribute(const QualifiedName& attributeName, const
AtomicString& oldValue, const AtomicString& attributeValue) |
| 296 { | 296 { |
| 297 if (attributeName == formAttr) { | 297 if (attributeName == formAttr) { |
| 298 formAttributeChanged(); | 298 formAttributeChanged(); |
| 299 UseCounter::count(document(), UseCounter::HTMLLabelElementFormContentAtt
ribute); | 299 UseCounter::count(document(), UseCounter::HTMLLabelElementFormContentAtt
ribute); |
| 300 } else { | 300 } else { |
| 301 if (attributeName == forAttr) { | 301 if (attributeName == forAttr) { |
| 302 TreeScope& scope = treeScope(); | 302 TreeScope& scope = treeScopeOrDocument(); |
| 303 if (scope.shouldCacheLabelsByForAttribute()) | 303 if (scope.shouldCacheLabelsByForAttribute()) |
| 304 updateLabel(scope, oldValue, attributeValue); | 304 updateLabel(scope, oldValue, attributeValue); |
| 305 } | 305 } |
| 306 HTMLElement::parseAttribute(attributeName, oldValue, attributeValue); | 306 HTMLElement::parseAttribute(attributeName, oldValue, attributeValue); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 | 309 |
| 310 } // namespace blink | 310 } // namespace blink |
| OLD | NEW |