| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } | 236 } |
| 237 | 237 |
| 238 void HTMLLabelElement::accessKeyAction(bool sendMouseEvents) | 238 void HTMLLabelElement::accessKeyAction(bool sendMouseEvents) |
| 239 { | 239 { |
| 240 if (HTMLElement* element = control()) | 240 if (HTMLElement* element = control()) |
| 241 element->accessKeyAction(sendMouseEvents); | 241 element->accessKeyAction(sendMouseEvents); |
| 242 else | 242 else |
| 243 HTMLElement::accessKeyAction(sendMouseEvents); | 243 HTMLElement::accessKeyAction(sendMouseEvents); |
| 244 } | 244 } |
| 245 | 245 |
| 246 void HTMLLabelElement::updateLabel(TreeScope& scope, const AtomicString& oldForA
ttributeValue, const AtomicString& newForAttributeValue) | |
| 247 { | |
| 248 if (!inShadowIncludingDocument()) | |
| 249 return; | |
| 250 | |
| 251 if (oldForAttributeValue == newForAttributeValue) | |
| 252 return; | |
| 253 | |
| 254 if (!oldForAttributeValue.isEmpty()) | |
| 255 scope.removeLabel(oldForAttributeValue, this); | |
| 256 if (!newForAttributeValue.isEmpty()) | |
| 257 scope.addLabel(newForAttributeValue, this); | |
| 258 } | |
| 259 | |
| 260 Node::InsertionNotificationRequest HTMLLabelElement::insertedInto(ContainerNode*
insertionPoint) | 246 Node::InsertionNotificationRequest HTMLLabelElement::insertedInto(ContainerNode*
insertionPoint) |
| 261 { | 247 { |
| 262 InsertionNotificationRequest result = HTMLElement::insertedInto(insertionPoi
nt); | 248 InsertionNotificationRequest result = HTMLElement::insertedInto(insertionPoi
nt); |
| 263 FormAssociatedElement::insertedInto(insertionPoint); | 249 FormAssociatedElement::insertedInto(insertionPoint); |
| 264 if (insertionPoint->isInTreeScope()) { | |
| 265 TreeScope& scope = insertionPoint->treeScope(); | |
| 266 if (scope == treeScope() && scope.shouldCacheLabelsByForAttribute()) | |
| 267 updateLabel(scope, nullAtom, fastGetAttribute(forAttr)); | |
| 268 } | |
| 269 | 250 |
| 270 // Trigger for elements outside of forms. | 251 // Trigger for elements outside of forms. |
| 271 if (!formOwner() && insertionPoint->inShadowIncludingDocument()) | 252 if (!formOwner() && insertionPoint->inShadowIncludingDocument()) |
| 272 document().didAssociateFormControl(this); | 253 document().didAssociateFormControl(this); |
| 273 | 254 |
| 274 return result; | 255 return result; |
| 275 } | 256 } |
| 276 | 257 |
| 277 void HTMLLabelElement::removedFrom(ContainerNode* insertionPoint) | 258 void HTMLLabelElement::removedFrom(ContainerNode* insertionPoint) |
| 278 { | 259 { |
| 279 if (insertionPoint->isInTreeScope() && treeScope() == document()) { | |
| 280 TreeScope& treeScope = insertionPoint->treeScope(); | |
| 281 if (treeScope.shouldCacheLabelsByForAttribute()) | |
| 282 updateLabel(treeScope, fastGetAttribute(forAttr), nullAtom); | |
| 283 } | |
| 284 HTMLElement::removedFrom(insertionPoint); | 260 HTMLElement::removedFrom(insertionPoint); |
| 285 FormAssociatedElement::removedFrom(insertionPoint); | 261 FormAssociatedElement::removedFrom(insertionPoint); |
| 286 document().removeFormAssociation(this); | 262 document().removeFormAssociation(this); |
| 287 } | 263 } |
| 288 | 264 |
| 289 DEFINE_TRACE(HTMLLabelElement) | 265 DEFINE_TRACE(HTMLLabelElement) |
| 290 { | 266 { |
| 291 HTMLElement::trace(visitor); | 267 HTMLElement::trace(visitor); |
| 292 FormAssociatedElement::trace(visitor); | 268 FormAssociatedElement::trace(visitor); |
| 293 } | 269 } |
| 294 | 270 |
| 295 void HTMLLabelElement::parseAttribute(const QualifiedName& attributeName, const
AtomicString& oldValue, const AtomicString& attributeValue) | 271 void HTMLLabelElement::parseAttribute(const QualifiedName& attributeName, const
AtomicString& oldValue, const AtomicString& attributeValue) |
| 296 { | 272 { |
| 297 if (attributeName == formAttr) { | 273 if (attributeName == formAttr) { |
| 298 formAttributeChanged(); | 274 formAttributeChanged(); |
| 299 UseCounter::count(document(), UseCounter::HTMLLabelElementFormContentAtt
ribute); | 275 UseCounter::count(document(), UseCounter::HTMLLabelElementFormContentAtt
ribute); |
| 300 } else { | 276 } else { |
| 301 if (attributeName == forAttr) { | |
| 302 TreeScope& scope = treeScope(); | |
| 303 if (scope.shouldCacheLabelsByForAttribute()) | |
| 304 updateLabel(scope, oldValue, attributeValue); | |
| 305 } | |
| 306 HTMLElement::parseAttribute(attributeName, oldValue, attributeValue); | 277 HTMLElement::parseAttribute(attributeName, oldValue, attributeValue); |
| 307 } | 278 } |
| 308 } | 279 } |
| 309 | 280 |
| 310 } // namespace blink | 281 } // namespace blink |
| OLD | NEW |